Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: src/execution.h

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/disassembler.cc ('k') | src/execution.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/execution.h
===================================================================
--- src/execution.h (revision 3427)
+++ src/execution.h (working copy)
@@ -139,8 +139,52 @@
class ExecutionAccess;
+class StackGuardPrivateData;
+class StackGuardData {
+ class ThreadLocal {
+ public:
+ explicit ThreadLocal(int dummy) { } // static data initialization only
+ ThreadLocal() { Clear(); }
+ // You should hold the ExecutionAccess lock when you call Initialize or
+ // Clear.
+ void Initialize();
+ void Clear();
+ // The stack limit is split into a JavaScript and a C++ stack limit. These
+ // two are the same except when running on a simulator where the C++ and
+ // JavaScript stacks are separate. Each of the two stack limits have two
+ // values. The one eith the real_ prefix is the actual stack limit
+ // set for the VM. The one without the real_ prefix has the same value as
+ // the actual stack limit except when there is an interruption (e.g. debug
+ // break or preemption) in which case it is lowered to make stack checks
+ // fail. Both the generated code and the runtime system check against the
+ // one without the real_ prefix.
+ uintptr_t real_jslimit_; // Actual JavaScript stack limit set for the VM.
+ uintptr_t jslimit_;
+ uintptr_t real_climit_; // Actual C++ stack limit set for the VM.
+ uintptr_t climit_;
+
+ int nesting_;
+ int postpone_interrupts_nesting_;
+ int interrupt_flags_;
+ private:
+ ThreadLocal(const ThreadLocal& another);
+ };
+
+ // Static state for stack guards.
+ ThreadLocal thread_local_;
+
+ StackGuardPrivateData* stack_guard_private_data_;
+
+ friend class V8Context;
+ friend class StackGuard;
+ friend class PostponeInterruptsScope;
+
+ StackGuardData();
+ DISALLOW_COPY_AND_ASSIGN(StackGuardData);
+};
+
// StackGuard contains the handling of the limits that are used to limit the
// number of nested invocations of JavaScript and the stack size used in each
// invocation.
@@ -181,19 +225,21 @@
// thread. There are no locks protecting this, but it is assumed that you
// have the global V8 lock if you are using multiple V8 threads.
static uintptr_t climit() {
- return thread_local_.climit_;
+ return v8_context()->stack_guard_data_.thread_local_.climit_;
}
static uintptr_t jslimit() {
- return thread_local_.jslimit_;
+ return v8_context()->stack_guard_data_.thread_local_.jslimit_;
}
static uintptr_t real_jslimit() {
- return thread_local_.real_jslimit_;
+ return v8_context()->stack_guard_data_.thread_local_.real_jslimit_;
}
static Address address_of_jslimit() {
- return reinterpret_cast<Address>(&thread_local_.jslimit_);
+ return reinterpret_cast<Address>(
+ &v8_context()->stack_guard_data_.thread_local_.jslimit_);
}
static Address address_of_real_jslimit() {
- return reinterpret_cast<Address>(&thread_local_.real_jslimit_);
+ return reinterpret_cast<Address>(
+ &v8_context()->stack_guard_data_.thread_local_.real_jslimit_);
}
private:
@@ -202,16 +248,20 @@
// You should hold the ExecutionAccess lock when calling this method.
static void set_limits(uintptr_t value, const ExecutionAccess& lock) {
- thread_local_.jslimit_ = value;
- thread_local_.climit_ = value;
+ StackGuardData::ThreadLocal& thread_local =
+ v8_context()->stack_guard_data_.thread_local_;
+ thread_local.jslimit_ = value;
+ thread_local.climit_ = value;
Heap::SetStackLimits();
}
// Reset limits to actual values. For example after handling interrupt.
// You should hold the ExecutionAccess lock when calling this method.
static void reset_limits(const ExecutionAccess& lock) {
- thread_local_.jslimit_ = thread_local_.real_jslimit_;
- thread_local_.climit_ = thread_local_.real_climit_;
+ StackGuardData::ThreadLocal& thread_local = v8_context()->
+ stack_guard_data_.thread_local_;
+ thread_local.jslimit_ = thread_local.real_jslimit_;
+ thread_local.climit_ = thread_local.real_climit_;
Heap::SetStackLimits();
}
@@ -229,37 +279,13 @@
static const uintptr_t kIllegalLimit = 0xfffffff8;
#endif
- class ThreadLocal {
- public:
- ThreadLocal() { Clear(); }
- // You should hold the ExecutionAccess lock when you call Initialize or
- // Clear.
- void Initialize();
- void Clear();
+ static void PostConstruct();
+ static void PreDestroy();
+ friend class V8Context;
- // The stack limit is split into a JavaScript and a C++ stack limit. These
- // two are the same except when running on a simulator where the C++ and
- // JavaScript stacks are separate. Each of the two stack limits have two
- // values. The one eith the real_ prefix is the actual stack limit
- // set for the VM. The one without the real_ prefix has the same value as
- // the actual stack limit except when there is an interruption (e.g. debug
- // break or preemption) in which case it is lowered to make stack checks
- // fail. Both the generated code and the runtime system check against the
- // one without the real_ prefix.
- uintptr_t real_jslimit_; // Actual JavaScript stack limit set for the VM.
- uintptr_t jslimit_;
- uintptr_t real_climit_; // Actual C++ stack limit set for the VM.
- uintptr_t climit_;
-
- int nesting_;
- int postpone_interrupts_nesting_;
- int interrupt_flags_;
- };
-
- static ThreadLocal thread_local_;
-
friend class StackLimitCheck;
friend class PostponeInterruptsScope;
+ friend class StackGuardData::ThreadLocal;
};
@@ -284,12 +310,14 @@
class PostponeInterruptsScope BASE_EMBEDDED {
public:
PostponeInterruptsScope() {
- StackGuard::thread_local_.postpone_interrupts_nesting_++;
+ v8_context()->
+ stack_guard_data_.thread_local_.postpone_interrupts_nesting_++;
StackGuard::DisableInterrupts();
}
~PostponeInterruptsScope() {
- if (--StackGuard::thread_local_.postpone_interrupts_nesting_ == 0) {
+ if (--v8_context()->
+ stack_guard_data_.thread_local_.postpone_interrupts_nesting_ == 0) {
StackGuard::EnableInterrupts();
}
}
« no previous file with comments | « src/disassembler.cc ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698