| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ->GetCurrentContext(); | 150 ->GetCurrentContext(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 class InternalEscapableScope : public v8::EscapableHandleScope { | 153 class InternalEscapableScope : public v8::EscapableHandleScope { |
| 154 public: | 154 public: |
| 155 explicit inline InternalEscapableScope(i::Isolate* isolate) | 155 explicit inline InternalEscapableScope(i::Isolate* isolate) |
| 156 : v8::EscapableHandleScope(reinterpret_cast<v8::Isolate*>(isolate)) {} | 156 : v8::EscapableHandleScope(reinterpret_cast<v8::Isolate*>(isolate)) {} |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 | 159 |
| 160 #ifdef V8_ENABLE_CHECKS | 160 #ifdef DEBUG |
| 161 void CheckMicrotasksScopesConsistency(i::Isolate* isolate) { | 161 void CheckMicrotasksScopesConsistency(i::Isolate* isolate) { |
| 162 auto handle_scope_implementer = isolate->handle_scope_implementer(); | 162 auto handle_scope_implementer = isolate->handle_scope_implementer(); |
| 163 if (handle_scope_implementer->microtasks_policy() == | 163 if (handle_scope_implementer->microtasks_policy() == |
| 164 v8::MicrotasksPolicy::kScoped) { | 164 v8::MicrotasksPolicy::kScoped) { |
| 165 DCHECK(handle_scope_implementer->GetMicrotasksScopeDepth() || | 165 DCHECK(handle_scope_implementer->GetMicrotasksScopeDepth() || |
| 166 !handle_scope_implementer->DebugMicrotasksScopeDepthIsZero()); | 166 !handle_scope_implementer->DebugMicrotasksScopeDepthIsZero()); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 #endif | 169 #endif |
| 170 | 170 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 181 DCHECK(!isolate_->external_caught_exception()); | 181 DCHECK(!isolate_->external_caught_exception()); |
| 182 isolate_->IncrementJsCallsFromApiCounter(); | 182 isolate_->IncrementJsCallsFromApiCounter(); |
| 183 isolate_->handle_scope_implementer()->IncrementCallDepth(); | 183 isolate_->handle_scope_implementer()->IncrementCallDepth(); |
| 184 if (!context_.IsEmpty()) context_->Enter(); | 184 if (!context_.IsEmpty()) context_->Enter(); |
| 185 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); | 185 if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); |
| 186 } | 186 } |
| 187 ~CallDepthScope() { | 187 ~CallDepthScope() { |
| 188 if (!context_.IsEmpty()) context_->Exit(); | 188 if (!context_.IsEmpty()) context_->Exit(); |
| 189 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); | 189 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); |
| 190 if (do_callback_) isolate_->FireCallCompletedCallback(); | 190 if (do_callback_) isolate_->FireCallCompletedCallback(); |
| 191 #ifdef V8_ENABLE_CHECKS | 191 #ifdef DEBUG |
| 192 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); | 192 if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); |
| 193 #endif | 193 #endif |
| 194 } | 194 } |
| 195 | 195 |
| 196 void Escape() { | 196 void Escape() { |
| 197 DCHECK(!escaped_); | 197 DCHECK(!escaped_); |
| 198 escaped_ = true; | 198 escaped_ = true; |
| 199 auto handle_scope_implementer = isolate_->handle_scope_implementer(); | 199 auto handle_scope_implementer = isolate_->handle_scope_implementer(); |
| 200 handle_scope_implementer->DecrementCallDepth(); | 200 handle_scope_implementer->DecrementCallDepth(); |
| 201 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); | 201 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); |
| (...skipping 7535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7737 isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds( | 7737 isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds( |
| 7738 &visitor_adapter); | 7738 &visitor_adapter); |
| 7739 } | 7739 } |
| 7740 | 7740 |
| 7741 | 7741 |
| 7742 MicrotasksScope::MicrotasksScope(Isolate* isolate, MicrotasksScope::Type type) | 7742 MicrotasksScope::MicrotasksScope(Isolate* isolate, MicrotasksScope::Type type) |
| 7743 : isolate_(reinterpret_cast<i::Isolate*>(isolate)), | 7743 : isolate_(reinterpret_cast<i::Isolate*>(isolate)), |
| 7744 run_(type == MicrotasksScope::kRunMicrotasks) { | 7744 run_(type == MicrotasksScope::kRunMicrotasks) { |
| 7745 auto handle_scope_implementer = isolate_->handle_scope_implementer(); | 7745 auto handle_scope_implementer = isolate_->handle_scope_implementer(); |
| 7746 if (run_) handle_scope_implementer->IncrementMicrotasksScopeDepth(); | 7746 if (run_) handle_scope_implementer->IncrementMicrotasksScopeDepth(); |
| 7747 #ifdef V8_ENABLE_CHECKS | 7747 #ifdef DEBUG |
| 7748 if (!run_) handle_scope_implementer->IncrementDebugMicrotasksScopeDepth(); | 7748 if (!run_) handle_scope_implementer->IncrementDebugMicrotasksScopeDepth(); |
| 7749 #endif | 7749 #endif |
| 7750 } | 7750 } |
| 7751 | 7751 |
| 7752 | 7752 |
| 7753 MicrotasksScope::~MicrotasksScope() { | 7753 MicrotasksScope::~MicrotasksScope() { |
| 7754 auto handle_scope_implementer = isolate_->handle_scope_implementer(); | 7754 auto handle_scope_implementer = isolate_->handle_scope_implementer(); |
| 7755 if (run_) { | 7755 if (run_) { |
| 7756 handle_scope_implementer->DecrementMicrotasksScopeDepth(); | 7756 handle_scope_implementer->DecrementMicrotasksScopeDepth(); |
| 7757 if (MicrotasksPolicy::kScoped == | 7757 if (MicrotasksPolicy::kScoped == |
| 7758 handle_scope_implementer->microtasks_policy()) { | 7758 handle_scope_implementer->microtasks_policy()) { |
| 7759 PerformCheckpoint(reinterpret_cast<Isolate*>(isolate_)); | 7759 PerformCheckpoint(reinterpret_cast<Isolate*>(isolate_)); |
| 7760 } | 7760 } |
| 7761 } | 7761 } |
| 7762 #ifdef V8_ENABLE_CHECKS | 7762 #ifdef DEBUG |
| 7763 if (!run_) handle_scope_implementer->DecrementDebugMicrotasksScopeDepth(); | 7763 if (!run_) handle_scope_implementer->DecrementDebugMicrotasksScopeDepth(); |
| 7764 #endif | 7764 #endif |
| 7765 } | 7765 } |
| 7766 | 7766 |
| 7767 | 7767 |
| 7768 void MicrotasksScope::PerformCheckpoint(Isolate* v8Isolate) { | 7768 void MicrotasksScope::PerformCheckpoint(Isolate* v8Isolate) { |
| 7769 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8Isolate); | 7769 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8Isolate); |
| 7770 if (IsExecutionTerminatingCheck(isolate)) return; | 7770 if (IsExecutionTerminatingCheck(isolate)) return; |
| 7771 auto handle_scope_implementer = isolate->handle_scope_implementer(); | 7771 auto handle_scope_implementer = isolate->handle_scope_implementer(); |
| 7772 if (!handle_scope_implementer->GetMicrotasksScopeDepth() && | 7772 if (!handle_scope_implementer->GetMicrotasksScopeDepth() && |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8693 Address callback_address = | 8693 Address callback_address = |
| 8694 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8694 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8695 VMState<EXTERNAL> state(isolate); | 8695 VMState<EXTERNAL> state(isolate); |
| 8696 ExternalCallbackScope call_scope(isolate, callback_address); | 8696 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8697 callback(info); | 8697 callback(info); |
| 8698 } | 8698 } |
| 8699 | 8699 |
| 8700 | 8700 |
| 8701 } // namespace internal | 8701 } // namespace internal |
| 8702 } // namespace v8 | 8702 } // namespace v8 |
| OLD | NEW |