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 #ifndef V8_ISOLATE_H_ | 5 #ifndef V8_ISOLATE_H_ |
6 #define V8_ISOLATE_H_ | 6 #define V8_ISOLATE_H_ |
7 | 7 |
8 #include "include/v8-debug.h" | 8 #include "include/v8-debug.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 template <StateTag Tag> class VMState; | 71 template <StateTag Tag> class VMState; |
72 | 72 |
73 // 'void function pointer', used to roundtrip the | 73 // 'void function pointer', used to roundtrip the |
74 // ExternalReference::ExternalReferenceRedirector since we can not include | 74 // ExternalReference::ExternalReferenceRedirector since we can not include |
75 // assembler.h, where it is defined, here. | 75 // assembler.h, where it is defined, here. |
76 typedef void* ExternalReferenceRedirectorPointer(); | 76 typedef void* ExternalReferenceRedirectorPointer(); |
77 | 77 |
78 | 78 |
79 class Debug; | 79 class Debug; |
80 class Debugger; | 80 class Debugger; |
| 81 class PromiseOnStack; |
81 | 82 |
82 #if !defined(__arm__) && V8_TARGET_ARCH_ARM || \ | 83 #if !defined(__arm__) && V8_TARGET_ARCH_ARM || \ |
83 !defined(__aarch64__) && V8_TARGET_ARCH_ARM64 || \ | 84 !defined(__aarch64__) && V8_TARGET_ARCH_ARM64 || \ |
84 !defined(__mips__) && V8_TARGET_ARCH_MIPS || \ | 85 !defined(__mips__) && V8_TARGET_ARCH_MIPS || \ |
85 !defined(__mips__) && V8_TARGET_ARCH_MIPS64 | 86 !defined(__mips__) && V8_TARGET_ARCH_MIPS64 |
86 class Redirection; | 87 class Redirection; |
87 class Simulator; | 88 class Simulator; |
88 #endif | 89 #endif |
89 | 90 |
90 | 91 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // hardware, try_catch_handler_address and TryCatchHandler return | 234 // hardware, try_catch_handler_address and TryCatchHandler return |
234 // the same pointer. When running on a simulator with a separate JS | 235 // the same pointer. When running on a simulator with a separate JS |
235 // stack, try_catch_handler_address returns a JS stack address that | 236 // stack, try_catch_handler_address returns a JS stack address that |
236 // corresponds to the place on the JS stack where the C++ handler | 237 // corresponds to the place on the JS stack where the C++ handler |
237 // would have been if the stack were not separate. | 238 // would have been if the stack were not separate. |
238 Address try_catch_handler_address() { | 239 Address try_catch_handler_address() { |
239 return reinterpret_cast<Address>( | 240 return reinterpret_cast<Address>( |
240 v8::TryCatch::JSStackComparableAddress(try_catch_handler())); | 241 v8::TryCatch::JSStackComparableAddress(try_catch_handler())); |
241 } | 242 } |
242 | 243 |
243 void Free() { | 244 void Free(); |
244 DCHECK(!has_pending_message_); | |
245 DCHECK(!external_caught_exception_); | |
246 DCHECK(try_catch_handler_ == NULL); | |
247 } | |
248 | 245 |
249 Isolate* isolate_; | 246 Isolate* isolate_; |
250 // The context where the current execution method is created and for variable | 247 // The context where the current execution method is created and for variable |
251 // lookups. | 248 // lookups. |
252 Context* context_; | 249 Context* context_; |
253 ThreadId thread_id_; | 250 ThreadId thread_id_; |
254 Object* pending_exception_; | 251 Object* pending_exception_; |
255 bool has_pending_message_; | 252 bool has_pending_message_; |
256 bool rethrowing_message_; | 253 bool rethrowing_message_; |
257 Object* pending_message_obj_; | 254 Object* pending_message_obj_; |
258 Object* pending_message_script_; | 255 Object* pending_message_script_; |
259 int pending_message_start_pos_; | 256 int pending_message_start_pos_; |
260 int pending_message_end_pos_; | 257 int pending_message_end_pos_; |
261 // Use a separate value for scheduled exceptions to preserve the | 258 // Use a separate value for scheduled exceptions to preserve the |
262 // invariants that hold about pending_exception. We may want to | 259 // invariants that hold about pending_exception. We may want to |
263 // unify them later. | 260 // unify them later. |
264 Object* scheduled_exception_; | 261 Object* scheduled_exception_; |
265 bool external_caught_exception_; | 262 bool external_caught_exception_; |
266 SaveContext* save_context_; | 263 SaveContext* save_context_; |
267 v8::TryCatch* catcher_; | 264 v8::TryCatch* catcher_; |
268 | 265 |
269 // Stack. | 266 // Stack. |
270 Address c_entry_fp_; // the frame pointer of the top c entry frame | 267 Address c_entry_fp_; // the frame pointer of the top c entry frame |
271 Address handler_; // try-blocks are chained through the stack | 268 Address handler_; // try-blocks are chained through the stack |
272 | 269 |
| 270 // Throwing an exception may cause a Promise rejection. For this purpose |
| 271 // we keep track of a stack of nested promises and the corresponding |
| 272 // try-catch handlers. |
| 273 PromiseOnStack* promise_on_stack_; |
| 274 |
273 #ifdef USE_SIMULATOR | 275 #ifdef USE_SIMULATOR |
274 Simulator* simulator_; | 276 Simulator* simulator_; |
275 #endif | 277 #endif |
276 | 278 |
277 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame | 279 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame |
278 // the external callback we're currently in | 280 // the external callback we're currently in |
279 ExternalCallbackScope* external_callback_scope_; | 281 ExternalCallbackScope* external_callback_scope_; |
280 StateTag current_vm_state_; | 282 StateTag current_vm_state_; |
281 | 283 |
282 // Generated code scratch locations. | 284 // Generated code scratch locations. |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 671 |
670 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); } | 672 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); } |
671 void FreeThreadResources() { thread_local_top_.Free(); } | 673 void FreeThreadResources() { thread_local_top_.Free(); } |
672 | 674 |
673 // This method is called by the api after operations that may throw | 675 // This method is called by the api after operations that may throw |
674 // exceptions. If an exception was thrown and not handled by an external | 676 // exceptions. If an exception was thrown and not handled by an external |
675 // handler the exception is scheduled to be rethrown when we return to running | 677 // handler the exception is scheduled to be rethrown when we return to running |
676 // JavaScript code. If an exception is scheduled true is returned. | 678 // JavaScript code. If an exception is scheduled true is returned. |
677 bool OptionalRescheduleException(bool is_bottom_call); | 679 bool OptionalRescheduleException(bool is_bottom_call); |
678 | 680 |
| 681 // Push and pop a promise and the current try-catch handler. |
| 682 void PushPromise(Handle<JSObject> promise); |
| 683 void PopPromise(); |
| 684 Handle<Object> GetPromiseOnStackOnThrow(); |
| 685 |
679 class ExceptionScope { | 686 class ExceptionScope { |
680 public: | 687 public: |
681 explicit ExceptionScope(Isolate* isolate) : | 688 explicit ExceptionScope(Isolate* isolate) : |
682 // Scope currently can only be used for regular exceptions, | 689 // Scope currently can only be used for regular exceptions, |
683 // not termination exception. | 690 // not termination exception. |
684 isolate_(isolate), | 691 isolate_(isolate), |
685 pending_exception_(isolate_->pending_exception(), isolate_), | 692 pending_exception_(isolate_->pending_exception(), isolate_), |
686 catcher_(isolate_->catcher()) | 693 catcher_(isolate_->catcher()) |
687 { } | 694 { } |
688 | 695 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 friend class v8::Unlocker; | 1349 friend class v8::Unlocker; |
1343 | 1350 |
1344 DISALLOW_COPY_AND_ASSIGN(Isolate); | 1351 DISALLOW_COPY_AND_ASSIGN(Isolate); |
1345 }; | 1352 }; |
1346 | 1353 |
1347 | 1354 |
1348 #undef FIELD_ACCESSOR | 1355 #undef FIELD_ACCESSOR |
1349 #undef THREAD_LOCAL_TOP_ACCESSOR | 1356 #undef THREAD_LOCAL_TOP_ACCESSOR |
1350 | 1357 |
1351 | 1358 |
| 1359 class PromiseOnStack { |
| 1360 public: |
| 1361 PromiseOnStack(StackHandler* handler, Handle<JSObject> promise, |
| 1362 PromiseOnStack* prev) |
| 1363 : handler_(handler), promise_(promise), prev_(prev) {} |
| 1364 StackHandler* handler() { return handler_; } |
| 1365 Handle<JSObject> promise() { return promise_; } |
| 1366 PromiseOnStack* prev() { return prev_; } |
| 1367 |
| 1368 private: |
| 1369 StackHandler* handler_; |
| 1370 Handle<JSObject> promise_; |
| 1371 PromiseOnStack* prev_; |
| 1372 }; |
| 1373 |
| 1374 |
1352 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1375 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
1353 // class as a work around for a bug in the generated code found with these | 1376 // class as a work around for a bug in the generated code found with these |
1354 // versions of GCC. See V8 issue 122 for details. | 1377 // versions of GCC. See V8 issue 122 for details. |
1355 class SaveContext BASE_EMBEDDED { | 1378 class SaveContext BASE_EMBEDDED { |
1356 public: | 1379 public: |
1357 inline explicit SaveContext(Isolate* isolate); | 1380 inline explicit SaveContext(Isolate* isolate); |
1358 | 1381 |
1359 ~SaveContext() { | 1382 ~SaveContext() { |
1360 isolate_->set_context(context_.is_null() ? NULL : *context_); | 1383 isolate_->set_context(context_.is_null() ? NULL : *context_); |
1361 isolate_->set_save_context(prev_); | 1384 isolate_->set_save_context(prev_); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 } | 1554 } |
1532 | 1555 |
1533 EmbeddedVector<char, 128> filename_; | 1556 EmbeddedVector<char, 128> filename_; |
1534 FILE* file_; | 1557 FILE* file_; |
1535 int scope_depth_; | 1558 int scope_depth_; |
1536 }; | 1559 }; |
1537 | 1560 |
1538 } } // namespace v8::internal | 1561 } } // namespace v8::internal |
1539 | 1562 |
1540 #endif // V8_ISOLATE_H_ | 1563 #endif // V8_ISOLATE_H_ |
OLD | NEW |