| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 bool do_callback) | 161 bool do_callback) |
| 162 : isolate_(isolate), | 162 : isolate_(isolate), |
| 163 context_(context), | 163 context_(context), |
| 164 escaped_(false), | 164 escaped_(false), |
| 165 do_callback_(do_callback) { | 165 do_callback_(do_callback) { |
| 166 // TODO(dcarney): remove this when blink stops crashing. | 166 // TODO(dcarney): remove this when blink stops crashing. |
| 167 DCHECK(!isolate_->external_caught_exception()); | 167 DCHECK(!isolate_->external_caught_exception()); |
| 168 isolate_->IncrementJsCallsFromApiCounter(); | 168 isolate_->IncrementJsCallsFromApiCounter(); |
| 169 isolate_->handle_scope_implementer()->IncrementCallDepth(); | 169 isolate_->handle_scope_implementer()->IncrementCallDepth(); |
| 170 if (!context_.IsEmpty()) context_->Enter(); | 170 if (!context_.IsEmpty()) context_->Enter(); |
| 171 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); |
| 171 } | 172 } |
| 172 ~CallDepthScope() { | 173 ~CallDepthScope() { |
| 173 if (!context_.IsEmpty()) context_->Exit(); | 174 if (!context_.IsEmpty()) context_->Exit(); |
| 174 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); | 175 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); |
| 175 if (do_callback_) isolate_->FireCallCompletedCallback(); | 176 if (do_callback_) isolate_->FireCallCompletedCallback(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void Escape() { | 179 void Escape() { |
| 179 DCHECK(!escaped_); | 180 DCHECK(!escaped_); |
| 180 escaped_ = true; | 181 escaped_ = true; |
| (...skipping 7184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7365 | 7366 |
| 7366 | 7367 |
| 7367 void Isolate::SetEventLogger(LogEventCallback that) { | 7368 void Isolate::SetEventLogger(LogEventCallback that) { |
| 7368 // Do not overwrite the event logger if we want to log explicitly. | 7369 // Do not overwrite the event logger if we want to log explicitly. |
| 7369 if (i::FLAG_log_internal_timer_events) return; | 7370 if (i::FLAG_log_internal_timer_events) return; |
| 7370 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7371 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7371 isolate->set_event_logger(that); | 7372 isolate->set_event_logger(that); |
| 7372 } | 7373 } |
| 7373 | 7374 |
| 7374 | 7375 |
| 7376 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { |
| 7377 if (callback == NULL) return; |
| 7378 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7379 isolate->AddBeforeCallEnteredCallback(callback); |
| 7380 } |
| 7381 |
| 7382 |
| 7383 void Isolate::RemoveBeforeCallEnteredCallback( |
| 7384 BeforeCallEnteredCallback callback) { |
| 7385 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7386 isolate->RemoveBeforeCallEnteredCallback(callback); |
| 7387 } |
| 7388 |
| 7389 |
| 7375 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { | 7390 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 7376 if (callback == NULL) return; | 7391 if (callback == NULL) return; |
| 7377 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7392 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7378 isolate->AddCallCompletedCallback(callback); | 7393 isolate->AddCallCompletedCallback(callback); |
| 7379 } | 7394 } |
| 7380 | 7395 |
| 7381 | 7396 |
| 7382 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 7397 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
| 7383 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7398 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7384 isolate->RemoveCallCompletedCallback(callback); | 7399 isolate->RemoveCallCompletedCallback(callback); |
| 7385 } | 7400 } |
| 7386 | 7401 |
| 7387 | 7402 |
| 7403 void Isolate::AddCallCompletedCallback( |
| 7404 DeprecatedCallCompletedCallback callback) { |
| 7405 AddCallCompletedCallback(reinterpret_cast<CallCompletedCallback>(callback)); |
| 7406 } |
| 7407 |
| 7408 |
| 7409 void Isolate::RemoveCallCompletedCallback( |
| 7410 DeprecatedCallCompletedCallback callback) { |
| 7411 RemoveCallCompletedCallback( |
| 7412 reinterpret_cast<CallCompletedCallback>(callback)); |
| 7413 } |
| 7414 |
| 7415 |
| 7388 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { | 7416 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { |
| 7389 if (callback == NULL) return; | 7417 if (callback == NULL) return; |
| 7390 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7418 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7391 isolate->SetPromiseRejectCallback(callback); | 7419 isolate->SetPromiseRejectCallback(callback); |
| 7392 } | 7420 } |
| 7393 | 7421 |
| 7394 | 7422 |
| 7395 void Isolate::RunMicrotasks() { | 7423 void Isolate::RunMicrotasks() { |
| 7396 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks(); | 7424 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks(); |
| 7397 } | 7425 } |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8556 Address callback_address = | 8584 Address callback_address = |
| 8557 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8585 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8558 VMState<EXTERNAL> state(isolate); | 8586 VMState<EXTERNAL> state(isolate); |
| 8559 ExternalCallbackScope call_scope(isolate, callback_address); | 8587 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8560 callback(info); | 8588 callback(info); |
| 8561 } | 8589 } |
| 8562 | 8590 |
| 8563 | 8591 |
| 8564 } // namespace internal | 8592 } // namespace internal |
| 8565 } // namespace v8 | 8593 } // namespace v8 |
| OLD | NEW |