| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "ast.h" | 9 #include "ast.h" |
| 10 #include "bootstrapper.h" | 10 #include "bootstrapper.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 void ThreadLocalTop::InitializeInternal() { | 63 void ThreadLocalTop::InitializeInternal() { |
| 64 c_entry_fp_ = 0; | 64 c_entry_fp_ = 0; |
| 65 handler_ = 0; | 65 handler_ = 0; |
| 66 #ifdef USE_SIMULATOR | 66 #ifdef USE_SIMULATOR |
| 67 simulator_ = NULL; | 67 simulator_ = NULL; |
| 68 #endif | 68 #endif |
| 69 js_entry_sp_ = NULL; | 69 js_entry_sp_ = NULL; |
| 70 external_callback_scope_ = NULL; | 70 external_callback_scope_ = NULL; |
| 71 current_vm_state_ = EXTERNAL; | 71 current_vm_state_ = EXTERNAL; |
| 72 try_catch_handler_address_ = NULL; | 72 try_catch_handler_ = NULL; |
| 73 context_ = NULL; | 73 context_ = NULL; |
| 74 thread_id_ = ThreadId::Invalid(); | 74 thread_id_ = ThreadId::Invalid(); |
| 75 external_caught_exception_ = false; | 75 external_caught_exception_ = false; |
| 76 failed_access_check_callback_ = NULL; | 76 failed_access_check_callback_ = NULL; |
| 77 save_context_ = NULL; | 77 save_context_ = NULL; |
| 78 catcher_ = NULL; | 78 catcher_ = NULL; |
| 79 top_lookup_result_ = NULL; | 79 top_lookup_result_ = NULL; |
| 80 | 80 |
| 81 // These members are re-initialized later after deserialization | 81 // These members are re-initialized later after deserialization |
| 82 // is complete. | 82 // is complete. |
| 83 pending_exception_ = NULL; | 83 pending_exception_ = NULL; |
| 84 has_pending_message_ = false; | 84 has_pending_message_ = false; |
| 85 rethrowing_message_ = false; | 85 rethrowing_message_ = false; |
| 86 pending_message_obj_ = NULL; | 86 pending_message_obj_ = NULL; |
| 87 pending_message_script_ = NULL; | 87 pending_message_script_ = NULL; |
| 88 scheduled_exception_ = NULL; | 88 scheduled_exception_ = NULL; |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 void ThreadLocalTop::Initialize() { | 92 void ThreadLocalTop::Initialize() { |
| 93 InitializeInternal(); | 93 InitializeInternal(); |
| 94 #ifdef USE_SIMULATOR | 94 #ifdef USE_SIMULATOR |
| 95 simulator_ = Simulator::current(isolate_); | 95 simulator_ = Simulator::current(isolate_); |
| 96 #endif | 96 #endif |
| 97 thread_id_ = ThreadId::Current(); | 97 thread_id_ = ThreadId::Current(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { | |
| 102 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); | |
| 103 } | |
| 104 | |
| 105 | |
| 106 Thread::LocalStorageKey Isolate::isolate_key_; | 101 Thread::LocalStorageKey Isolate::isolate_key_; |
| 107 Thread::LocalStorageKey Isolate::thread_id_key_; | 102 Thread::LocalStorageKey Isolate::thread_id_key_; |
| 108 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 103 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 109 #ifdef DEBUG | 104 #ifdef DEBUG |
| 110 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 105 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
| 111 #endif // DEBUG | 106 #endif // DEBUG |
| 112 Mutex Isolate::process_wide_mutex_; | 107 Mutex Isolate::process_wide_mutex_; |
| 113 // TODO(dcarney): Remove with default isolate. | 108 // TODO(dcarney): Remove with default isolate. |
| 114 enum DefaultIsolateStatus { | 109 enum DefaultIsolateStatus { |
| 115 kDefaultIsolateUninitialized, | 110 kDefaultIsolateUninitialized, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 197 |
| 203 | 198 |
| 204 void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { | 199 void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { |
| 205 // Visit the roots from the top for a given thread. | 200 // Visit the roots from the top for a given thread. |
| 206 v->VisitPointer(&thread->pending_exception_); | 201 v->VisitPointer(&thread->pending_exception_); |
| 207 v->VisitPointer(&(thread->pending_message_obj_)); | 202 v->VisitPointer(&(thread->pending_message_obj_)); |
| 208 v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_))); | 203 v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_))); |
| 209 v->VisitPointer(BitCast<Object**>(&(thread->context_))); | 204 v->VisitPointer(BitCast<Object**>(&(thread->context_))); |
| 210 v->VisitPointer(&thread->scheduled_exception_); | 205 v->VisitPointer(&thread->scheduled_exception_); |
| 211 | 206 |
| 212 for (v8::TryCatch* block = thread->TryCatchHandler(); | 207 for (v8::TryCatch* block = thread->try_catch_handler(); |
| 213 block != NULL; | 208 block != NULL; |
| 214 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { | 209 block = block->next_) { |
| 215 v->VisitPointer(BitCast<Object**>(&(block->exception_))); | 210 v->VisitPointer(BitCast<Object**>(&(block->exception_))); |
| 216 v->VisitPointer(BitCast<Object**>(&(block->message_obj_))); | 211 v->VisitPointer(BitCast<Object**>(&(block->message_obj_))); |
| 217 v->VisitPointer(BitCast<Object**>(&(block->message_script_))); | 212 v->VisitPointer(BitCast<Object**>(&(block->message_script_))); |
| 218 } | 213 } |
| 219 | 214 |
| 220 // Iterate over pointers on native execution stack. | 215 // Iterate over pointers on native execution stack. |
| 221 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { | 216 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { |
| 222 it.frame()->Iterate(v); | 217 it.frame()->Iterate(v); |
| 223 } | 218 } |
| 224 | 219 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 : blocks->at(i) + kHandleBlockSize; | 254 : blocks->at(i) + kHandleBlockSize; |
| 260 if (blocks->at(i) <= handle && handle < block_limit) return true; | 255 if (blocks->at(i) <= handle && handle < block_limit) return true; |
| 261 } | 256 } |
| 262 } | 257 } |
| 263 return false; | 258 return false; |
| 264 } | 259 } |
| 265 #endif // DEBUG | 260 #endif // DEBUG |
| 266 | 261 |
| 267 | 262 |
| 268 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) { | 263 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) { |
| 269 // The ARM simulator has a separate JS stack. We therefore register | 264 thread_local_top()->set_try_catch_handler(that); |
| 270 // the C++ try catch handler with the simulator and get back an | |
| 271 // address that can be used for comparisons with addresses into the | |
| 272 // JS stack. When running without the simulator, the address | |
| 273 // returned will be the address of the C++ try catch handler itself. | |
| 274 Address address = reinterpret_cast<Address>( | |
| 275 SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that))); | |
| 276 thread_local_top()->set_try_catch_handler_address(address); | |
| 277 } | 265 } |
| 278 | 266 |
| 279 | 267 |
| 280 void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) { | 268 void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) { |
| 281 ASSERT(thread_local_top()->TryCatchHandler() == that); | 269 ASSERT(thread_local_top()->try_catch_handler() == that); |
| 282 thread_local_top()->set_try_catch_handler_address( | 270 thread_local_top()->set_try_catch_handler(that->next_); |
| 283 reinterpret_cast<Address>(that->next_)); | |
| 284 thread_local_top()->catcher_ = NULL; | 271 thread_local_top()->catcher_ = NULL; |
| 285 SimulatorStack::UnregisterCTryCatch(); | |
| 286 } | 272 } |
| 287 | 273 |
| 288 | 274 |
| 289 Handle<String> Isolate::StackTraceString() { | 275 Handle<String> Isolate::StackTraceString() { |
| 290 if (stack_trace_nesting_level_ == 0) { | 276 if (stack_trace_nesting_level_ == 0) { |
| 291 stack_trace_nesting_level_++; | 277 stack_trace_nesting_level_++; |
| 292 HeapStringAllocator allocator; | 278 HeapStringAllocator allocator; |
| 293 StringStream::ClearMentionedObjectCache(this); | 279 StringStream::ClearMentionedObjectCache(this); |
| 294 StringStream accumulator(&allocator); | 280 StringStream accumulator(&allocator); |
| 295 incomplete_message_ = &accumulator; | 281 incomplete_message_ = &accumulator; |
| (...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 ASSERT(handle_scope_implementer()->CallDepthIsZero()); | 2239 ASSERT(handle_scope_implementer()->CallDepthIsZero()); |
| 2254 | 2240 |
| 2255 // Increase call depth to prevent recursive callbacks. | 2241 // Increase call depth to prevent recursive callbacks. |
| 2256 handle_scope_implementer()->IncrementCallDepth(); | 2242 handle_scope_implementer()->IncrementCallDepth(); |
| 2257 Execution::RunMicrotasks(this); | 2243 Execution::RunMicrotasks(this); |
| 2258 handle_scope_implementer()->DecrementCallDepth(); | 2244 handle_scope_implementer()->DecrementCallDepth(); |
| 2259 } | 2245 } |
| 2260 | 2246 |
| 2261 | 2247 |
| 2262 } } // namespace v8::internal | 2248 } } // namespace v8::internal |
| OLD | NEW |