| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context, | 175 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context, |
| 176 bool do_callback) | 176 bool do_callback) |
| 177 : isolate_(isolate), | 177 : isolate_(isolate), |
| 178 context_(context), | 178 context_(context), |
| 179 escaped_(false), | 179 escaped_(false), |
| 180 do_callback_(do_callback) { | 180 do_callback_(do_callback) { |
| 181 // TODO(dcarney): remove this when blink stops crashing. | 181 // TODO(dcarney): remove this when blink stops crashing. |
| 182 DCHECK(!isolate_->external_caught_exception()); | 182 DCHECK(!isolate_->external_caught_exception()); |
| 183 isolate_->IncrementJsCallsFromApiCounter(); | 183 isolate_->IncrementJsCallsFromApiCounter(); |
| 184 isolate_->handle_scope_implementer()->IncrementCallDepth(); | 184 isolate_->handle_scope_implementer()->IncrementCallDepth(); |
| 185 if (!context.IsEmpty()) { | 185 if (!context_.IsEmpty()) context_->Enter(); |
| 186 i::Handle<i::Context> env = Utils::OpenHandle(*context); | |
| 187 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); | |
| 188 if (isolate->context() != nullptr && | |
| 189 isolate->context()->native_context() == env->native_context() && | |
| 190 impl->LastEnteredContextWas(env)) { | |
| 191 context_ = Local<Context>(); | |
| 192 } else { | |
| 193 context_->Enter(); | |
| 194 } | |
| 195 } | |
| 196 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); | 186 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); |
| 197 } | 187 } |
| 198 ~CallDepthScope() { | 188 ~CallDepthScope() { |
| 199 if (!context_.IsEmpty()) context_->Exit(); | 189 if (!context_.IsEmpty()) context_->Exit(); |
| 200 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); | 190 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); |
| 201 if (do_callback_) isolate_->FireCallCompletedCallback(); | 191 if (do_callback_) isolate_->FireCallCompletedCallback(); |
| 202 #ifdef DEBUG | 192 #ifdef DEBUG |
| 203 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); | 193 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); |
| 204 #endif | 194 #endif |
| 205 } | 195 } |
| (...skipping 8743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8949 Address callback_address = | 8939 Address callback_address = |
| 8950 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8940 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8951 VMState<EXTERNAL> state(isolate); | 8941 VMState<EXTERNAL> state(isolate); |
| 8952 ExternalCallbackScope call_scope(isolate, callback_address); | 8942 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8953 callback(info); | 8943 callback(info); |
| 8954 } | 8944 } |
| 8955 | 8945 |
| 8956 | 8946 |
| 8957 } // namespace internal | 8947 } // namespace internal |
| 8958 } // namespace v8 | 8948 } // namespace v8 |
| OLD | NEW |