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

Side by Side Diff: src/api.cc

Issue 1457223005: Remove a bunch of Isolate::Current() callsites from simulators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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
« no previous file with comments | « no previous file | 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 "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 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 next_(isolate_->try_catch_handler()), 2123 next_(isolate_->try_catch_handler()),
2124 is_verbose_(false), 2124 is_verbose_(false),
2125 can_continue_(true), 2125 can_continue_(true),
2126 capture_message_(true), 2126 capture_message_(true),
2127 rethrow_(false), 2127 rethrow_(false),
2128 has_terminated_(false) { 2128 has_terminated_(false) {
2129 ResetInternal(); 2129 ResetInternal();
2130 // Special handling for simulators which have a separate JS stack. 2130 // Special handling for simulators which have a separate JS stack.
2131 js_stack_comparable_address_ = 2131 js_stack_comparable_address_ =
2132 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch( 2132 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch(
2133 v8::internal::GetCurrentStackPosition())); 2133 isolate_, v8::internal::GetCurrentStackPosition()));
2134 isolate_->RegisterTryCatchHandler(this); 2134 isolate_->RegisterTryCatchHandler(this);
2135 } 2135 }
2136 2136
2137 2137
2138 v8::TryCatch::TryCatch(v8::Isolate* isolate) 2138 v8::TryCatch::TryCatch(v8::Isolate* isolate)
2139 : isolate_(reinterpret_cast<i::Isolate*>(isolate)), 2139 : isolate_(reinterpret_cast<i::Isolate*>(isolate)),
2140 next_(isolate_->try_catch_handler()), 2140 next_(isolate_->try_catch_handler()),
2141 is_verbose_(false), 2141 is_verbose_(false),
2142 can_continue_(true), 2142 can_continue_(true),
2143 capture_message_(true), 2143 capture_message_(true),
2144 rethrow_(false), 2144 rethrow_(false),
2145 has_terminated_(false) { 2145 has_terminated_(false) {
2146 ResetInternal(); 2146 ResetInternal();
2147 // Special handling for simulators which have a separate JS stack. 2147 // Special handling for simulators which have a separate JS stack.
2148 js_stack_comparable_address_ = 2148 js_stack_comparable_address_ =
2149 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch( 2149 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch(
2150 v8::internal::GetCurrentStackPosition())); 2150 isolate_, v8::internal::GetCurrentStackPosition()));
2151 isolate_->RegisterTryCatchHandler(this); 2151 isolate_->RegisterTryCatchHandler(this);
2152 } 2152 }
2153 2153
2154 2154
2155 v8::TryCatch::~TryCatch() { 2155 v8::TryCatch::~TryCatch() {
2156 if (rethrow_) { 2156 if (rethrow_) {
2157 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_); 2157 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
2158 v8::HandleScope scope(isolate); 2158 v8::HandleScope scope(isolate);
2159 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception()); 2159 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception());
2160 if (HasCaught() && capture_message_) { 2160 if (HasCaught() && capture_message_) {
2161 // If an exception was caught and rethrow_ is indicated, the saved 2161 // If an exception was caught and rethrow_ is indicated, the saved
2162 // message, script, and location need to be restored to Isolate TLS 2162 // message, script, and location need to be restored to Isolate TLS
2163 // for reuse. capture_message_ needs to be disabled so that Throw() 2163 // for reuse. capture_message_ needs to be disabled so that Throw()
2164 // does not create a new message. 2164 // does not create a new message.
2165 isolate_->thread_local_top()->rethrowing_message_ = true; 2165 isolate_->thread_local_top()->rethrowing_message_ = true;
2166 isolate_->RestorePendingMessageFromTryCatch(this); 2166 isolate_->RestorePendingMessageFromTryCatch(this);
2167 } 2167 }
2168 isolate_->UnregisterTryCatchHandler(this); 2168 isolate_->UnregisterTryCatchHandler(this);
2169 v8::internal::SimulatorStack::UnregisterCTryCatch(); 2169 v8::internal::SimulatorStack::UnregisterCTryCatch(isolate_);
2170 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc); 2170 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
2171 DCHECK(!isolate_->thread_local_top()->rethrowing_message_); 2171 DCHECK(!isolate_->thread_local_top()->rethrowing_message_);
2172 } else { 2172 } else {
2173 if (HasCaught() && isolate_->has_scheduled_exception()) { 2173 if (HasCaught() && isolate_->has_scheduled_exception()) {
2174 // If an exception was caught but is still scheduled because no API call 2174 // If an exception was caught but is still scheduled because no API call
2175 // promoted it, then it is canceled to prevent it from being propagated. 2175 // promoted it, then it is canceled to prevent it from being propagated.
2176 // Note that this will not cancel termination exceptions. 2176 // Note that this will not cancel termination exceptions.
2177 isolate_->CancelScheduledExceptionFromTryCatch(this); 2177 isolate_->CancelScheduledExceptionFromTryCatch(this);
2178 } 2178 }
2179 isolate_->UnregisterTryCatchHandler(this); 2179 isolate_->UnregisterTryCatchHandler(this);
2180 v8::internal::SimulatorStack::UnregisterCTryCatch(); 2180 v8::internal::SimulatorStack::UnregisterCTryCatch(isolate_);
2181 } 2181 }
2182 } 2182 }
2183 2183
2184 2184
2185 bool v8::TryCatch::HasCaught() const { 2185 bool v8::TryCatch::HasCaught() const {
2186 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); 2186 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
2187 } 2187 }
2188 2188
2189 2189
2190 bool v8::TryCatch::CanContinue() const { 2190 bool v8::TryCatch::CanContinue() const {
(...skipping 6319 matching lines...) Expand 10 before | Expand all | Expand 10 after
8510 Address callback_address = 8510 Address callback_address =
8511 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8511 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8512 VMState<EXTERNAL> state(isolate); 8512 VMState<EXTERNAL> state(isolate);
8513 ExternalCallbackScope call_scope(isolate, callback_address); 8513 ExternalCallbackScope call_scope(isolate, callback_address);
8514 callback(info); 8514 callback(info);
8515 } 8515 }
8516 8516
8517 8517
8518 } // namespace internal 8518 } // namespace internal
8519 } // namespace v8 8519 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/arm/simulator-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698