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;
class SaveContext; // Forward declaration.
class ThreadVisitor; // Defined in v8threads.h
+class VMState; // Defined in vm-state.h
class ThreadLocalTop BASE_EMBEDDED {
public:
// 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_;
}
#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_; }
#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) {
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) {
+++ /dev/null
-// 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
#ifndef V8_VM_STATE_H_
#define V8_VM_STATE_H_
+#include "top.h"
+
namespace v8 {
namespace internal {
// 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;
}
VMState* previous_;
Address external_callback_;
- // A stack of VM states.
- static AtomicWord current_state_;
#else
public:
explicit VMState(StateTag state) {}