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

Side by Side Diff: src/api.cc

Issue 2862483003: Do not enter contexts implicitly (Closed)
Patch Set: Use correct NewInstance() overload Created 3 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
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 public: 225 public:
226 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context) 226 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context)
227 : isolate_(isolate), context_(context), escaped_(false) { 227 : isolate_(isolate), context_(context), escaped_(false) {
228 // TODO(dcarney): remove this when blink stops crashing. 228 // TODO(dcarney): remove this when blink stops crashing.
229 DCHECK(!isolate_->external_caught_exception()); 229 DCHECK(!isolate_->external_caught_exception());
230 isolate_->handle_scope_implementer()->IncrementCallDepth(); 230 isolate_->handle_scope_implementer()->IncrementCallDepth();
231 if (!context.IsEmpty()) { 231 if (!context.IsEmpty()) {
232 i::Handle<i::Context> env = Utils::OpenHandle(*context); 232 i::Handle<i::Context> env = Utils::OpenHandle(*context);
233 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 233 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
234 if (isolate->context() != nullptr && 234 if (isolate->context() != nullptr &&
235 isolate->context()->native_context() == env->native_context() && 235 isolate->context()->native_context() == env->native_context()) {
236 impl->LastEnteredContextWas(env)) {
237 context_ = Local<Context>(); 236 context_ = Local<Context>();
238 } else { 237 } else {
239 context_->Enter(); 238 impl->SaveContext(isolate->context());
239 isolate->set_context(*env);
240 } 240 }
241 } 241 }
242 if (do_callback) isolate_->FireBeforeCallEnteredCallback(); 242 if (do_callback) isolate_->FireBeforeCallEnteredCallback();
243 } 243 }
244 ~CallDepthScope() { 244 ~CallDepthScope() {
245 if (!context_.IsEmpty()) context_->Exit(); 245 if (!context_.IsEmpty()) {
246 i::HandleScopeImplementer* impl = isolate_->handle_scope_implementer();
247 isolate_->set_context(impl->RestoreContext());
248 }
246 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); 249 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth();
247 if (do_callback) isolate_->FireCallCompletedCallback(); 250 if (do_callback) isolate_->FireCallCompletedCallback();
248 #ifdef DEBUG 251 #ifdef DEBUG
249 if (do_callback) CheckMicrotasksScopesConsistency(isolate_); 252 if (do_callback) CheckMicrotasksScopesConsistency(isolate_);
250 #endif 253 #endif
251 } 254 }
252 255
253 void Escape() { 256 void Escape() {
254 DCHECK(!escaped_); 257 DCHECK(!escaped_);
255 escaped_ = true; 258 escaped_ = true;
(...skipping 10217 matching lines...) Expand 10 before | Expand all | Expand 10 after
10473 Address callback_address = 10476 Address callback_address =
10474 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10477 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10475 VMState<EXTERNAL> state(isolate); 10478 VMState<EXTERNAL> state(isolate);
10476 ExternalCallbackScope call_scope(isolate, callback_address); 10479 ExternalCallbackScope call_scope(isolate, callback_address);
10477 callback(info); 10480 callback(info);
10478 } 10481 }
10479 10482
10480 10483
10481 } // namespace internal 10484 } // namespace internal
10482 } // namespace v8 10485 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698