Index: src/isolate.h |
diff --git a/src/isolate.h b/src/isolate.h |
index d93a862294aa13d7afde5b54b4332faaf752ff3f..a82b02c8403ba61c3e282f8478fcedf2cc95573c 100644 |
--- a/src/isolate.h |
+++ b/src/isolate.h |
@@ -207,6 +207,11 @@ class ThreadId { |
}; |
+#define FIELD_ACCESSOR(type, name) \ |
+ inline void set_##name(type v) { name##_ = v; } \ |
+ inline type name() const { return name##_; } |
+ |
+ |
class ThreadLocalTop BASE_EMBEDDED { |
public: |
// Does early low-level initialization that does not depend on the |
@@ -233,14 +238,7 @@ class ThreadLocalTop BASE_EMBEDDED { |
// stack, try_catch_handler_address returns a JS stack address that |
// corresponds to the place on the JS stack where the C++ handler |
// would have been if the stack were not separate. |
- inline Address try_catch_handler_address() { |
- return try_catch_handler_address_; |
- } |
- |
- // Set the address of the top C++ try catch handler. |
- inline void set_try_catch_handler_address(Address address) { |
- try_catch_handler_address_ = address; |
- } |
+ FIELD_ACCESSOR(Address, try_catch_handler_address) |
void Free() { |
ASSERT(!has_pending_message_); |
@@ -366,6 +364,11 @@ typedef List<HeapObject*> DebugObjectCache; |
V(CodeTracer*, code_tracer, NULL) \ |
ISOLATE_DEBUGGER_INIT_LIST(V) |
+#define THREAD_LOCAL_TOP_ACCESSOR(type, name) \ |
+ inline void set_##name(type v) { thread_local_top_.name##_ = v; } \ |
+ inline type name() const { return thread_local_top_.name##_; } |
+ |
+ |
class Isolate { |
// These forward declarations are required to make the friend declarations in |
// PerIsolateThreadData work on some older versions of gcc. |
@@ -392,17 +395,13 @@ class Isolate { |
prev_(NULL) { } |
Isolate* isolate() const { return isolate_; } |
ThreadId thread_id() const { return thread_id_; } |
- void set_stack_limit(uintptr_t value) { stack_limit_ = value; } |
- uintptr_t stack_limit() const { return stack_limit_; } |
- ThreadState* thread_state() const { return thread_state_; } |
- void set_thread_state(ThreadState* value) { thread_state_ = value; } |
+ |
+ FIELD_ACCESSOR(uintptr_t, stack_limit) |
+ FIELD_ACCESSOR(ThreadState*, thread_state) |
#if !defined(__arm__) && V8_TARGET_ARCH_ARM || \ |
!defined(__mips__) && V8_TARGET_ARCH_MIPS |
- Simulator* simulator() const { return simulator_; } |
- void set_simulator(Simulator* simulator) { |
- simulator_ = simulator; |
- } |
+ FIELD_ACCESSOR(Simulator*, simulator) |
#endif |
bool Matches(Isolate* isolate, ThreadId thread_id) const { |
@@ -541,38 +540,35 @@ class Isolate { |
} |
Context** context_address() { return &thread_local_top_.context_; } |
- SaveContext* save_context() { return thread_local_top_.save_context_; } |
- void set_save_context(SaveContext* save) { |
- thread_local_top_.save_context_ = save; |
- } |
+ THREAD_LOCAL_TOP_ACCESSOR(SaveContext*, save_context) |
// Access to current thread id. |
- ThreadId thread_id() { return thread_local_top_.thread_id_; } |
- void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; } |
+ THREAD_LOCAL_TOP_ACCESSOR(ThreadId, thread_id) |
// Interface to pending exception. |
MaybeObject* pending_exception() { |
ASSERT(has_pending_exception()); |
return thread_local_top_.pending_exception_; |
} |
- bool external_caught_exception() { |
- return thread_local_top_.external_caught_exception_; |
- } |
- void set_external_caught_exception(bool value) { |
- thread_local_top_.external_caught_exception_ = value; |
- } |
+ |
void set_pending_exception(MaybeObject* exception) { |
thread_local_top_.pending_exception_ = exception; |
} |
+ |
void clear_pending_exception() { |
thread_local_top_.pending_exception_ = heap_.the_hole_value(); |
} |
+ |
MaybeObject** pending_exception_address() { |
return &thread_local_top_.pending_exception_; |
} |
+ |
bool has_pending_exception() { |
return !thread_local_top_.pending_exception_->IsTheHole(); |
} |
+ |
+ THREAD_LOCAL_TOP_ACCESSOR(bool, external_caught_exception) |
+ |
void clear_pending_message() { |
thread_local_top_.has_pending_message_ = false; |
thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); |
@@ -587,12 +583,8 @@ class Isolate { |
bool* external_caught_exception_address() { |
return &thread_local_top_.external_caught_exception_; |
} |
- v8::TryCatch* catcher() { |
- return thread_local_top_.catcher_; |
- } |
- void set_catcher(v8::TryCatch* catcher) { |
- thread_local_top_.catcher_ = catcher; |
- } |
+ |
+ THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher) |
MaybeObject** scheduled_exception_address() { |
return &thread_local_top_.scheduled_exception_; |
@@ -708,12 +700,8 @@ class Isolate { |
// Tells whether the current context has experienced an out of memory |
// exception. |
bool is_out_of_memory(); |
- bool ignore_out_of_memory() { |
- return thread_local_top_.ignore_out_of_memory_; |
- } |
- void set_ignore_out_of_memory(bool value) { |
- thread_local_top_.ignore_out_of_memory_ = value; |
- } |
+ |
+ THREAD_LOCAL_TOP_ACCESSOR(bool, ignore_out_of_memory) |
void PrintCurrentStackTrace(FILE* out); |
void PrintStack(StringStream* accumulator); |
@@ -938,11 +926,7 @@ class Isolate { |
RuntimeState* runtime_state() { return &runtime_state_; } |
- void set_fp_stubs_generated(bool value) { |
- fp_stubs_generated_ = value; |
- } |
- |
- bool fp_stubs_generated() { return fp_stubs_generated_; } |
+ FIELD_ACCESSOR(bool, fp_stubs_generated); |
Builtins* builtins() { return &builtins_; } |
@@ -995,42 +979,18 @@ class Isolate { |
#if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ |
V8_TARGET_ARCH_MIPS && !defined(__mips__) |
- bool simulator_initialized() { return simulator_initialized_; } |
- void set_simulator_initialized(bool initialized) { |
- simulator_initialized_ = initialized; |
- } |
- |
- HashMap* simulator_i_cache() { return simulator_i_cache_; } |
- void set_simulator_i_cache(HashMap* hash_map) { |
- simulator_i_cache_ = hash_map; |
- } |
- |
- Redirection* simulator_redirection() { |
- return simulator_redirection_; |
- } |
- void set_simulator_redirection(Redirection* redirection) { |
- simulator_redirection_ = redirection; |
- } |
+ FIELD_ACCESSOR(bool, simulator_initialized) |
+ FIELD_ACCESSOR(HashMap*, simulator_i_cache) |
+ FIELD_ACCESSOR(Redirection*, simulator_redirection) |
#endif |
Factory* factory() { return reinterpret_cast<Factory*>(this); } |
static const int kJSRegexpStaticOffsetsVectorSize = 128; |
- ExternalCallbackScope* external_callback_scope() { |
- return thread_local_top_.external_callback_scope_; |
- } |
- void set_external_callback_scope(ExternalCallbackScope* scope) { |
- thread_local_top_.external_callback_scope_ = scope; |
- } |
- |
- StateTag current_vm_state() { |
- return thread_local_top_.current_vm_state_; |
- } |
+ THREAD_LOCAL_TOP_ACCESSOR(ExternalCallbackScope*, external_callback_scope) |
- void set_current_vm_state(StateTag state) { |
- thread_local_top_.current_vm_state_ = state; |
- } |
+ THREAD_LOCAL_TOP_ACCESSOR(StateTag, current_vm_state) |
void SetData(uint32_t slot, void* data) { |
ASSERT(slot < Internals::kNumIsolateDataSlots); |
@@ -1041,12 +1001,7 @@ class Isolate { |
return embedder_data_[slot]; |
} |
- LookupResult* top_lookup_result() { |
- return thread_local_top_.top_lookup_result_; |
- } |
- void SetTopLookupResult(LookupResult* top) { |
- thread_local_top_.top_lookup_result_ = top; |
- } |
+ THREAD_LOCAL_TOP_ACCESSOR(LookupResult*, top_lookup_result) |
bool IsDead() { return has_fatal_error_; } |
void SignalFatalError() { has_fatal_error_ = true; } |
@@ -1096,13 +1051,7 @@ class Isolate { |
bool IsDeferredHandle(Object** location); |
#endif // DEBUG |
- int max_available_threads() const { |
- return max_available_threads_; |
- } |
- |
- void set_max_available_threads(int value) { |
- max_available_threads_ = value; |
- } |
+ FIELD_ACCESSOR(int, max_available_threads); |
bool concurrent_recompilation_enabled() { |
// Thread is only available with flag enabled. |
@@ -1403,6 +1352,10 @@ class Isolate { |
}; |
+#undef FIELD_ACCESSOR |
+#undef THREAD_LOCAL_TOP_ACCESSOR |
+ |
+ |
// If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
// class as a work around for a bug in the generated code found with these |
// versions of GCC. See V8 issue 122 for details. |