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 "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 1805 matching lines...) Loading... |
1816 | 1816 |
1817 | 1817 |
1818 v8::TryCatch::TryCatch() | 1818 v8::TryCatch::TryCatch() |
1819 : isolate_(i::Isolate::Current()), | 1819 : isolate_(i::Isolate::Current()), |
1820 next_(isolate_->try_catch_handler()), | 1820 next_(isolate_->try_catch_handler()), |
1821 is_verbose_(false), | 1821 is_verbose_(false), |
1822 can_continue_(true), | 1822 can_continue_(true), |
1823 capture_message_(true), | 1823 capture_message_(true), |
1824 rethrow_(false), | 1824 rethrow_(false), |
1825 has_terminated_(false) { | 1825 has_terminated_(false) { |
1826 Reset(); | 1826 ResetInternal(); |
1827 // Special handling for simulators which have a separate JS stack. | 1827 // Special handling for simulators which have a separate JS stack. |
1828 js_stack_comparable_address_ = | 1828 js_stack_comparable_address_ = |
1829 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch( | 1829 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch( |
1830 GetCurrentStackPosition())); | 1830 GetCurrentStackPosition())); |
1831 isolate_->RegisterTryCatchHandler(this); | 1831 isolate_->RegisterTryCatchHandler(this); |
1832 } | 1832 } |
1833 | 1833 |
1834 | 1834 |
1835 v8::TryCatch::~TryCatch() { | 1835 v8::TryCatch::~TryCatch() { |
1836 DCHECK(isolate_ == i::Isolate::Current()); | 1836 DCHECK(isolate_ == i::Isolate::Current()); |
(...skipping 91 matching lines...) Loading... |
1928 if (HasCaught() && !message->IsTheHole()) { | 1928 if (HasCaught() && !message->IsTheHole()) { |
1929 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); | 1929 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); |
1930 } else { | 1930 } else { |
1931 return v8::Local<v8::Message>(); | 1931 return v8::Local<v8::Message>(); |
1932 } | 1932 } |
1933 } | 1933 } |
1934 | 1934 |
1935 | 1935 |
1936 void v8::TryCatch::Reset() { | 1936 void v8::TryCatch::Reset() { |
1937 DCHECK(isolate_ == i::Isolate::Current()); | 1937 DCHECK(isolate_ == i::Isolate::Current()); |
| 1938 if (!rethrow_ && HasCaught() && isolate_->has_scheduled_exception()) { |
| 1939 // If an exception was caught but is still scheduled because no API call |
| 1940 // promoted it, then it is canceled to prevent it from being propagated. |
| 1941 // Note that this will not cancel termination exceptions. |
| 1942 isolate_->CancelScheduledExceptionFromTryCatch(this); |
| 1943 } |
| 1944 ResetInternal(); |
| 1945 } |
| 1946 |
| 1947 |
| 1948 void v8::TryCatch::ResetInternal() { |
1938 i::Object* the_hole = isolate_->heap()->the_hole_value(); | 1949 i::Object* the_hole = isolate_->heap()->the_hole_value(); |
1939 exception_ = the_hole; | 1950 exception_ = the_hole; |
1940 message_obj_ = the_hole; | 1951 message_obj_ = the_hole; |
1941 message_script_ = the_hole; | 1952 message_script_ = the_hole; |
1942 message_start_pos_ = 0; | 1953 message_start_pos_ = 0; |
1943 message_end_pos_ = 0; | 1954 message_end_pos_ = 0; |
1944 } | 1955 } |
1945 | 1956 |
1946 | 1957 |
1947 void v8::TryCatch::SetVerbose(bool value) { | 1958 void v8::TryCatch::SetVerbose(bool value) { |
(...skipping 5675 matching lines...) Loading... |
7623 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7634 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7624 Address callback_address = | 7635 Address callback_address = |
7625 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7636 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7626 VMState<EXTERNAL> state(isolate); | 7637 VMState<EXTERNAL> state(isolate); |
7627 ExternalCallbackScope call_scope(isolate, callback_address); | 7638 ExternalCallbackScope call_scope(isolate, callback_address); |
7628 callback(info); | 7639 callback(info); |
7629 } | 7640 } |
7630 | 7641 |
7631 | 7642 |
7632 } } // namespace v8::internal | 7643 } } // namespace v8::internal |
OLD | NEW |