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()) context_->Enter(); | 185 if (!context.IsEmpty()) { |
| 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 } |
186 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); | 196 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); |
187 } | 197 } |
188 ~CallDepthScope() { | 198 ~CallDepthScope() { |
189 if (!context_.IsEmpty()) context_->Exit(); | 199 if (!context_.IsEmpty()) context_->Exit(); |
190 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); | 200 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); |
191 if (do_callback_) isolate_->FireCallCompletedCallback(); | 201 if (do_callback_) isolate_->FireCallCompletedCallback(); |
192 #ifdef DEBUG | 202 #ifdef DEBUG |
193 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); | 203 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); |
194 #endif | 204 #endif |
195 } | 205 } |
(...skipping 8743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8939 Address callback_address = | 8949 Address callback_address = |
8940 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8950 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8941 VMState<EXTERNAL> state(isolate); | 8951 VMState<EXTERNAL> state(isolate); |
8942 ExternalCallbackScope call_scope(isolate, callback_address); | 8952 ExternalCallbackScope call_scope(isolate, callback_address); |
8943 callback(info); | 8953 callback(info); |
8944 } | 8954 } |
8945 | 8955 |
8946 | 8956 |
8947 } // namespace internal | 8957 } // namespace internal |
8948 } // namespace v8 | 8958 } // namespace v8 |
OLD | NEW |