Make state stack thread local. When using Lockers the state stacks of
multiple threads got mixed up so that the current state could be an already deallocated state from another thread. Review URL: http://codereview.chromium.org/3828016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5665 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
051f156bdd
commit
5616c8bf21
@ -68,6 +68,9 @@ void ThreadLocalTop::Initialize() {
|
||||
handler_ = 0;
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
js_entry_sp_ = 0;
|
||||
#endif
|
||||
#ifdef ENABLE_VMSTATE_TRACKING
|
||||
current_vm_state_ = NULL;
|
||||
#endif
|
||||
try_catch_handler_address_ = NULL;
|
||||
context_ = NULL;
|
||||
|
16
src/top.h
16
src/top.h
@ -41,6 +41,7 @@ namespace internal {
|
||||
|
||||
class SaveContext; // Forward declaration.
|
||||
class ThreadVisitor; // Defined in v8threads.h
|
||||
class VMState; // Defined in vm-state.h
|
||||
|
||||
class ThreadLocalTop BASE_EMBEDDED {
|
||||
public:
|
||||
@ -101,10 +102,15 @@ class ThreadLocalTop BASE_EMBEDDED {
|
||||
// Stack.
|
||||
Address c_entry_fp_; // the frame pointer of the top c entry frame
|
||||
Address handler_; // try-blocks are chained through the stack
|
||||
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
Address js_entry_sp_; // the stack pointer of the bottom js entry frame
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VMSTATE_TRACKING
|
||||
VMState* current_vm_state_;
|
||||
#endif
|
||||
|
||||
// Generated code scratch locations.
|
||||
int32_t formal_count_;
|
||||
|
||||
@ -254,6 +260,16 @@ class Top {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VMSTATE_TRACKING
|
||||
static VMState* current_vm_state() {
|
||||
return thread_local_.current_vm_state_;
|
||||
}
|
||||
|
||||
static void set_current_vm_state(VMState* state) {
|
||||
thread_local_.current_vm_state_ = state;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generated code scratch locations.
|
||||
static void* formal_count_address() { return &thread_local_.formal_count_; }
|
||||
|
||||
|
@ -75,9 +75,9 @@ VMState::VMState(StateTag state)
|
||||
#endif
|
||||
state_ = state;
|
||||
// Save the previous state.
|
||||
previous_ = reinterpret_cast<VMState*>(current_state_);
|
||||
previous_ = Top::current_vm_state();
|
||||
// Install the new state.
|
||||
OS::ReleaseStore(¤t_state_, reinterpret_cast<AtomicWord>(this));
|
||||
Top::set_current_vm_state(this);
|
||||
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
if (FLAG_log_state_changes) {
|
||||
@ -106,7 +106,7 @@ VMState::VMState(StateTag state)
|
||||
VMState::~VMState() {
|
||||
if (disabled_) return;
|
||||
// Return to the previous state.
|
||||
OS::ReleaseStore(¤t_state_, reinterpret_cast<AtomicWord>(previous_));
|
||||
Top::set_current_vm_state(previous_);
|
||||
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
if (FLAG_log_state_changes) {
|
||||
|
@ -1,39 +0,0 @@
|
||||
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "v8.h"
|
||||
|
||||
#include "vm-state.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
#ifdef ENABLE_VMSTATE_TRACKING
|
||||
AtomicWord VMState::current_state_ = 0;
|
||||
#endif
|
||||
|
||||
} } // namespace v8::internal
|
@ -28,6 +28,8 @@
|
||||
#ifndef V8_VM_STATE_H_
|
||||
#define V8_VM_STATE_H_
|
||||
|
||||
#include "top.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
@ -44,16 +46,16 @@ class VMState BASE_EMBEDDED {
|
||||
|
||||
// Used for debug asserts.
|
||||
static bool is_outermost_external() {
|
||||
return current_state_ == 0;
|
||||
return Top::current_vm_state() == 0;
|
||||
}
|
||||
|
||||
static StateTag current_state() {
|
||||
VMState* state = reinterpret_cast<VMState*>(current_state_);
|
||||
VMState* state = Top::current_vm_state();
|
||||
return state ? state->state() : EXTERNAL;
|
||||
}
|
||||
|
||||
static Address external_callback() {
|
||||
VMState* state = reinterpret_cast<VMState*>(current_state_);
|
||||
VMState* state = Top::current_vm_state();
|
||||
return state ? state->external_callback_ : NULL;
|
||||
}
|
||||
|
||||
@ -63,8 +65,6 @@ class VMState BASE_EMBEDDED {
|
||||
VMState* previous_;
|
||||
Address external_callback_;
|
||||
|
||||
// A stack of VM states.
|
||||
static AtomicWord current_state_;
|
||||
#else
|
||||
public:
|
||||
explicit VMState(StateTag state) {}
|
||||
|
Loading…
Reference in New Issue
Block a user