| 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 <queue> | 8 #include <queue> |
| 9 #include "include/v8-debug.h" | 9 #include "include/v8-debug.h" |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); } | 680 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); } |
| 681 void FreeThreadResources() { thread_local_top_.Free(); } | 681 void FreeThreadResources() { thread_local_top_.Free(); } |
| 682 | 682 |
| 683 // This method is called by the api after operations that may throw | 683 // This method is called by the api after operations that may throw |
| 684 // exceptions. If an exception was thrown and not handled by an external | 684 // exceptions. If an exception was thrown and not handled by an external |
| 685 // handler the exception is scheduled to be rethrown when we return to running | 685 // handler the exception is scheduled to be rethrown when we return to running |
| 686 // JavaScript code. If an exception is scheduled true is returned. | 686 // JavaScript code. If an exception is scheduled true is returned. |
| 687 bool OptionalRescheduleException(bool is_bottom_call); | 687 bool OptionalRescheduleException(bool is_bottom_call); |
| 688 | 688 |
| 689 // Push and pop a promise and the current try-catch handler. | 689 // Push and pop a promise and the current try-catch handler. |
| 690 void PushPromise(Handle<JSObject> promise); | 690 void PushPromise(Handle<JSObject> promise, Handle<JSFunction> function); |
| 691 void PopPromise(); | 691 void PopPromise(); |
| 692 Handle<Object> GetPromiseOnStackOnThrow(); | 692 Handle<Object> GetPromiseOnStackOnThrow(); |
| 693 | 693 |
| 694 class ExceptionScope { | 694 class ExceptionScope { |
| 695 public: | 695 public: |
| 696 // Scope currently can only be used for regular exceptions, | 696 // Scope currently can only be used for regular exceptions, |
| 697 // not termination exception. | 697 // not termination exception. |
| 698 explicit ExceptionScope(Isolate* isolate) | 698 explicit ExceptionScope(Isolate* isolate) |
| 699 : isolate_(isolate), | 699 : isolate_(isolate), |
| 700 pending_exception_(isolate_->pending_exception(), isolate_) {} | 700 pending_exception_(isolate_->pending_exception(), isolate_) {} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 } | 757 } |
| 758 | 758 |
| 759 // Re-throw an exception. This involves no error reporting since error | 759 // Re-throw an exception. This involves no error reporting since error |
| 760 // reporting was handled when the exception was thrown originally. | 760 // reporting was handled when the exception was thrown originally. |
| 761 Object* ReThrow(Object* exception); | 761 Object* ReThrow(Object* exception); |
| 762 | 762 |
| 763 // Find the correct handler for the current pending exception. This also | 763 // Find the correct handler for the current pending exception. This also |
| 764 // clears and returns the current pending exception. | 764 // clears and returns the current pending exception. |
| 765 Object* FindHandler(); | 765 Object* FindHandler(); |
| 766 | 766 |
| 767 // Tries to predict whether the exception will be caught. Note that this can | 767 // Tries to predict whether an exception will be caught. Note that this can |
| 768 // only produce an estimate, because it is undecidable whether a finally | 768 // only produce an estimate, because it is undecidable whether a finally |
| 769 // clause will consume or re-throw an exception. We conservatively assume any | 769 // clause will consume or re-throw an exception. We conservatively assume any |
| 770 // finally clause will behave as if the exception were consumed. | 770 // finally clause will behave as if the exception were consumed. |
| 771 bool PredictWhetherExceptionIsCaught(Object* exception); | 771 enum CatchType { NOT_CAUGHT, CAUGHT_BY_JAVASCRIPT, CAUGHT_BY_EXTERNAL }; |
| 772 CatchType PredictExceptionCatcher(); |
| 772 | 773 |
| 773 void ScheduleThrow(Object* exception); | 774 void ScheduleThrow(Object* exception); |
| 774 // Re-set pending message, script and positions reported to the TryCatch | 775 // Re-set pending message, script and positions reported to the TryCatch |
| 775 // back to the TLS for re-use when rethrowing. | 776 // back to the TLS for re-use when rethrowing. |
| 776 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); | 777 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); |
| 777 // Un-schedule an exception that was caught by a TryCatch handler. | 778 // Un-schedule an exception that was caught by a TryCatch handler. |
| 778 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); | 779 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); |
| 779 void ReportPendingMessages(); | 780 void ReportPendingMessages(); |
| 780 // Return pending location if any or unfilled structure. | 781 // Return pending location if any or unfilled structure. |
| 781 MessageLocation GetMessageLocation(); | 782 MessageLocation GetMessageLocation(); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 DISALLOW_COPY_AND_ASSIGN(Isolate); | 1364 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 1364 }; | 1365 }; |
| 1365 | 1366 |
| 1366 | 1367 |
| 1367 #undef FIELD_ACCESSOR | 1368 #undef FIELD_ACCESSOR |
| 1368 #undef THREAD_LOCAL_TOP_ACCESSOR | 1369 #undef THREAD_LOCAL_TOP_ACCESSOR |
| 1369 | 1370 |
| 1370 | 1371 |
| 1371 class PromiseOnStack { | 1372 class PromiseOnStack { |
| 1372 public: | 1373 public: |
| 1373 PromiseOnStack(StackHandler* handler, Handle<JSObject> promise, | 1374 PromiseOnStack(Handle<JSFunction> function, Handle<JSObject> promise, |
| 1374 PromiseOnStack* prev) | 1375 PromiseOnStack* prev) |
| 1375 : handler_(handler), promise_(promise), prev_(prev) {} | 1376 : function_(function), promise_(promise), prev_(prev) {} |
| 1376 StackHandler* handler() { return handler_; } | 1377 Handle<JSFunction> function() { return function_; } |
| 1377 Handle<JSObject> promise() { return promise_; } | 1378 Handle<JSObject> promise() { return promise_; } |
| 1378 PromiseOnStack* prev() { return prev_; } | 1379 PromiseOnStack* prev() { return prev_; } |
| 1379 | 1380 |
| 1380 private: | 1381 private: |
| 1381 StackHandler* handler_; | 1382 Handle<JSFunction> function_; |
| 1382 Handle<JSObject> promise_; | 1383 Handle<JSObject> promise_; |
| 1383 PromiseOnStack* prev_; | 1384 PromiseOnStack* prev_; |
| 1384 }; | 1385 }; |
| 1385 | 1386 |
| 1386 | 1387 |
| 1387 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1388 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
| 1388 // class as a work around for a bug in the generated code found with these | 1389 // class as a work around for a bug in the generated code found with these |
| 1389 // versions of GCC. See V8 issue 122 for details. | 1390 // versions of GCC. See V8 issue 122 for details. |
| 1390 class SaveContext BASE_EMBEDDED { | 1391 class SaveContext BASE_EMBEDDED { |
| 1391 public: | 1392 public: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 } | 1567 } |
| 1567 | 1568 |
| 1568 EmbeddedVector<char, 128> filename_; | 1569 EmbeddedVector<char, 128> filename_; |
| 1569 FILE* file_; | 1570 FILE* file_; |
| 1570 int scope_depth_; | 1571 int scope_depth_; |
| 1571 }; | 1572 }; |
| 1572 | 1573 |
| 1573 } } // namespace v8::internal | 1574 } } // namespace v8::internal |
| 1574 | 1575 |
| 1575 #endif // V8_ISOLATE_H_ | 1576 #endif // V8_ISOLATE_H_ |
| OLD | NEW |