Chromium Code Reviews| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 class CallDepthScope { | 157 class CallDepthScope { |
| 158 public: | 158 public: |
| 159 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context, | 159 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context, |
| 160 bool do_callback) | 160 bool do_callback) |
| 161 : isolate_(isolate), | 161 : isolate_(isolate), |
| 162 context_(context), | 162 context_(context), |
| 163 escaped_(false), | 163 escaped_(false), |
| 164 do_callback_(do_callback) { | 164 do_callback_(do_callback) { |
| 165 // TODO(dcarney): remove this when blink stops crashing. | 165 // TODO(dcarney): remove this when blink stops crashing. |
| 166 DCHECK(!isolate_->external_caught_exception()); | 166 DCHECK(!isolate_->external_caught_exception()); |
| 167 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); | |
|
dgozman
2016/02/11 02:08:49
I think I'd move this call after context->Enter()
| |
| 167 isolate_->IncrementJsCallsFromApiCounter(); | 168 isolate_->IncrementJsCallsFromApiCounter(); |
| 168 isolate_->handle_scope_implementer()->IncrementCallDepth(); | 169 isolate_->handle_scope_implementer()->IncrementCallDepth(); |
| 169 if (!context_.IsEmpty()) context_->Enter(); | 170 if (!context_.IsEmpty()) context_->Enter(); |
| 170 } | 171 } |
| 171 ~CallDepthScope() { | 172 ~CallDepthScope() { |
| 172 if (!context_.IsEmpty()) context_->Exit(); | 173 if (!context_.IsEmpty()) context_->Exit(); |
| 173 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); | 174 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); |
| 174 if (do_callback_) isolate_->FireCallCompletedCallback(); | 175 if (do_callback_) isolate_->FireCallCompletedCallback(); |
| 175 } | 176 } |
| 176 | 177 |
| (...skipping 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7364 | 7365 |
| 7365 | 7366 |
| 7366 void Isolate::SetEventLogger(LogEventCallback that) { | 7367 void Isolate::SetEventLogger(LogEventCallback that) { |
| 7367 // Do not overwrite the event logger if we want to log explicitly. | 7368 // Do not overwrite the event logger if we want to log explicitly. |
| 7368 if (i::FLAG_log_internal_timer_events) return; | 7369 if (i::FLAG_log_internal_timer_events) return; |
| 7369 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7370 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7370 isolate->set_event_logger(that); | 7371 isolate->set_event_logger(that); |
| 7371 } | 7372 } |
| 7372 | 7373 |
| 7373 | 7374 |
| 7375 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { | |
| 7376 if (callback == NULL) return; | |
| 7377 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | |
| 7378 isolate->AddBeforeCallEnteredCallback(callback); | |
| 7379 } | |
| 7380 | |
| 7381 | |
| 7382 void Isolate::RemoveBeforeCallEnteredCallback( | |
| 7383 BeforeCallEnteredCallback callback) { | |
| 7384 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | |
| 7385 isolate->RemoveBeforeCallEnteredCallback(callback); | |
| 7386 } | |
| 7387 | |
| 7388 | |
| 7374 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { | 7389 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 7375 if (callback == NULL) return; | 7390 if (callback == NULL) return; |
| 7376 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7391 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7377 isolate->AddCallCompletedCallback(callback); | 7392 isolate->AddCallCompletedCallback(callback); |
| 7378 } | 7393 } |
| 7379 | 7394 |
| 7380 | 7395 |
| 7381 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 7396 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
| 7382 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7397 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7383 isolate->RemoveCallCompletedCallback(callback); | 7398 isolate->RemoveCallCompletedCallback(callback); |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8554 Address callback_address = | 8569 Address callback_address = |
| 8555 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8570 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8556 VMState<EXTERNAL> state(isolate); | 8571 VMState<EXTERNAL> state(isolate); |
| 8557 ExternalCallbackScope call_scope(isolate, callback_address); | 8572 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8558 callback(info); | 8573 callback(info); |
| 8559 } | 8574 } |
| 8560 | 8575 |
| 8561 | 8576 |
| 8562 } // namespace internal | 8577 } // namespace internal |
| 8563 } // namespace v8 | 8578 } // namespace v8 |
| OLD | NEW |