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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 HandleScope::HandleScope(Isolate* isolate) { | 583 HandleScope::HandleScope(Isolate* isolate) { |
584 Initialize(isolate); | 584 Initialize(isolate); |
585 } | 585 } |
586 | 586 |
587 | 587 |
588 void HandleScope::Initialize(Isolate* isolate) { | 588 void HandleScope::Initialize(Isolate* isolate) { |
589 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 589 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
590 // We do not want to check the correct usage of the Locker class all over the | 590 // We do not want to check the correct usage of the Locker class all over the |
591 // place, so we do it only here: Without a HandleScope, an embedder can do | 591 // place, so we do it only here: Without a HandleScope, an embedder can do |
592 // almost nothing, so it is enough to check in this central place. | 592 // almost nothing, so it is enough to check in this central place. |
593 Utils::ApiCheck(!v8::Locker::IsActive() || | 593 // We make an exception if the serializer is enabled, which means that the |
594 internal_isolate->thread_manager()->IsLockedByCurrentThread(), | 594 // Isolate is exclusively used to create a snapshot. |
595 "HandleScope::HandleScope", | 595 Utils::ApiCheck( |
596 "Entering the V8 API without proper locking in place"); | 596 !v8::Locker::IsActive() || |
| 597 internal_isolate->thread_manager()->IsLockedByCurrentThread() || |
| 598 internal_isolate->serializer_enabled(), |
| 599 "HandleScope::HandleScope", |
| 600 "Entering the V8 API without proper locking in place"); |
597 i::HandleScopeData* current = internal_isolate->handle_scope_data(); | 601 i::HandleScopeData* current = internal_isolate->handle_scope_data(); |
598 isolate_ = internal_isolate; | 602 isolate_ = internal_isolate; |
599 prev_next_ = current->next; | 603 prev_next_ = current->next; |
600 prev_limit_ = current->limit; | 604 prev_limit_ = current->limit; |
601 current->level++; | 605 current->level++; |
602 } | 606 } |
603 | 607 |
604 | 608 |
605 HandleScope::~HandleScope() { | 609 HandleScope::~HandleScope() { |
606 i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); | 610 i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); |
(...skipping 7395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8002 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8006 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8003 Address callback_address = | 8007 Address callback_address = |
8004 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8008 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8005 VMState<EXTERNAL> state(isolate); | 8009 VMState<EXTERNAL> state(isolate); |
8006 ExternalCallbackScope call_scope(isolate, callback_address); | 8010 ExternalCallbackScope call_scope(isolate, callback_address); |
8007 callback(info); | 8011 callback(info); |
8008 } | 8012 } |
8009 | 8013 |
8010 | 8014 |
8011 } } // namespace v8::internal | 8015 } } // namespace v8::internal |
OLD | NEW |