Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: src/api.cc

Issue 282783004: Reland of "v8::TryCatch now works correctly with ASAN's UseAfterReturn mode enabled." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remake Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/arm/simulator-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "api.h" 5 #include "api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #include <cmath> // For isnan. 8 #include <cmath> // For isnan.
9 #ifdef V8_USE_ADDRESS_SANITIZER
10 #include <sanitizer/asan_interface.h>
11 #endif // V8_USE_ADDRESS_SANITIZER
9 #include "../include/v8-debug.h" 12 #include "../include/v8-debug.h"
10 #include "../include/v8-profiler.h" 13 #include "../include/v8-profiler.h"
11 #include "../include/v8-testing.h" 14 #include "../include/v8-testing.h"
12 #include "assert-scope.h" 15 #include "assert-scope.h"
13 #include "bootstrapper.h" 16 #include "bootstrapper.h"
14 #include "code-stubs.h" 17 #include "code-stubs.h"
15 #include "compiler.h" 18 #include "compiler.h"
16 #include "conversions-inl.h" 19 #include "conversions-inl.h"
17 #include "counters.h" 20 #include "counters.h"
18 #include "cpu-profiler.h" 21 #include "cpu-profiler.h"
(...skipping 11 matching lines...) Expand all
30 #endif 33 #endif
31 #include "parser.h" 34 #include "parser.h"
32 #include "platform.h" 35 #include "platform.h"
33 #include "platform/time.h" 36 #include "platform/time.h"
34 #include "profile-generator-inl.h" 37 #include "profile-generator-inl.h"
35 #include "property-details.h" 38 #include "property-details.h"
36 #include "property.h" 39 #include "property.h"
37 #include "runtime.h" 40 #include "runtime.h"
38 #include "runtime-profiler.h" 41 #include "runtime-profiler.h"
39 #include "scanner-character-streams.h" 42 #include "scanner-character-streams.h"
43 #include "simulator.h"
40 #include "snapshot.h" 44 #include "snapshot.h"
41 #include "unicode-inl.h" 45 #include "unicode-inl.h"
42 #include "utils/random-number-generator.h" 46 #include "utils/random-number-generator.h"
43 #include "v8threads.h" 47 #include "v8threads.h"
44 #include "version.h" 48 #include "version.h"
45 #include "vm-state-inl.h" 49 #include "vm-state-inl.h"
46 50
47 51
48 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 52 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
49 53
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 ScriptOrigin origin(file_name); 1782 ScriptOrigin origin(file_name);
1779 return Compile(source, &origin); 1783 return Compile(source, &origin);
1780 } 1784 }
1781 1785
1782 1786
1783 // --- E x c e p t i o n s --- 1787 // --- E x c e p t i o n s ---
1784 1788
1785 1789
1786 v8::TryCatch::TryCatch() 1790 v8::TryCatch::TryCatch()
1787 : isolate_(i::Isolate::Current()), 1791 : isolate_(i::Isolate::Current()),
1788 next_(isolate_->try_catch_handler_address()), 1792 next_(isolate_->try_catch_handler()),
1789 is_verbose_(false), 1793 is_verbose_(false),
1790 can_continue_(true), 1794 can_continue_(true),
1791 capture_message_(true), 1795 capture_message_(true),
1792 rethrow_(false), 1796 rethrow_(false),
1793 has_terminated_(false) { 1797 has_terminated_(false) {
1794 Reset(); 1798 Reset();
1799 js_stack_comparable_address_ = this;
1800 #ifdef V8_USE_ADDRESS_SANITIZER
1801 void* asan_fake_stack_handle = __asan_get_current_fake_stack();
1802 if (asan_fake_stack_handle != NULL) {
1803 js_stack_comparable_address_ = __asan_addr_is_in_fake_stack(
1804 asan_fake_stack_handle, js_stack_comparable_address_, NULL, NULL);
1805 CHECK(js_stack_comparable_address_ != NULL);
1806 }
1807 #endif
1808 // Special handling for simulators which have a separate JS stack.
1809 js_stack_comparable_address_ = reinterpret_cast<void*>(
1810 v8::internal::SimulatorStack::RegisterCTryCatch(
1811 reinterpret_cast<uintptr_t>(js_stack_comparable_address_)));
1795 isolate_->RegisterTryCatchHandler(this); 1812 isolate_->RegisterTryCatchHandler(this);
1796 } 1813 }
1797 1814
1798 1815
1799 v8::TryCatch::~TryCatch() { 1816 v8::TryCatch::~TryCatch() {
1800 ASSERT(isolate_ == i::Isolate::Current()); 1817 ASSERT(isolate_ == i::Isolate::Current());
1801 if (rethrow_) { 1818 if (rethrow_) {
1802 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_); 1819 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
1803 v8::HandleScope scope(isolate); 1820 v8::HandleScope scope(isolate);
1804 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception()); 1821 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception());
1805 if (HasCaught() && capture_message_) { 1822 if (HasCaught() && capture_message_) {
1806 // If an exception was caught and rethrow_ is indicated, the saved 1823 // If an exception was caught and rethrow_ is indicated, the saved
1807 // message, script, and location need to be restored to Isolate TLS 1824 // message, script, and location need to be restored to Isolate TLS
1808 // for reuse. capture_message_ needs to be disabled so that DoThrow() 1825 // for reuse. capture_message_ needs to be disabled so that DoThrow()
1809 // does not create a new message. 1826 // does not create a new message.
1810 isolate_->thread_local_top()->rethrowing_message_ = true; 1827 isolate_->thread_local_top()->rethrowing_message_ = true;
1811 isolate_->RestorePendingMessageFromTryCatch(this); 1828 isolate_->RestorePendingMessageFromTryCatch(this);
1812 } 1829 }
1813 isolate_->UnregisterTryCatchHandler(this); 1830 isolate_->UnregisterTryCatchHandler(this);
1831 v8::internal::SimulatorStack::UnregisterCTryCatch();
1814 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc); 1832 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
1815 ASSERT(!isolate_->thread_local_top()->rethrowing_message_); 1833 ASSERT(!isolate_->thread_local_top()->rethrowing_message_);
1816 } else { 1834 } else {
1817 isolate_->UnregisterTryCatchHandler(this); 1835 isolate_->UnregisterTryCatchHandler(this);
1836 v8::internal::SimulatorStack::UnregisterCTryCatch();
1818 } 1837 }
1819 } 1838 }
1820 1839
1821 1840
1822 bool v8::TryCatch::HasCaught() const { 1841 bool v8::TryCatch::HasCaught() const {
1823 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); 1842 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1824 } 1843 }
1825 1844
1826 1845
1827 bool v8::TryCatch::CanContinue() const { 1846 bool v8::TryCatch::CanContinue() const {
(...skipping 5735 matching lines...) Expand 10 before | Expand all | Expand 10 after
7563 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7582 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7564 Address callback_address = 7583 Address callback_address =
7565 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7584 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7566 VMState<EXTERNAL> state(isolate); 7585 VMState<EXTERNAL> state(isolate);
7567 ExternalCallbackScope call_scope(isolate, callback_address); 7586 ExternalCallbackScope call_scope(isolate, callback_address);
7568 callback(info); 7587 callback(info);
7569 } 7588 }
7570 7589
7571 7590
7572 } } // namespace v8::internal 7591 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/arm/simulator-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698