Chromium Code Reviews| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 "Escape value set twice"); | 679 "Escape value set twice"); |
| 680 if (escape_value == NULL) { | 680 if (escape_value == NULL) { |
| 681 *escape_slot_ = heap->undefined_value(); | 681 *escape_slot_ = heap->undefined_value(); |
| 682 return NULL; | 682 return NULL; |
| 683 } | 683 } |
| 684 *escape_slot_ = *escape_value; | 684 *escape_slot_ = *escape_value; |
| 685 return escape_slot_; | 685 return escape_slot_; |
| 686 } | 686 } |
| 687 | 687 |
| 688 | 688 |
| 689 SealHandleScope::SealHandleScope(Isolate* isolate) { | |
| 690 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
| 691 // We do not want to check the correct usage of the Locker class all over the | |
| 692 // place, so we do it only here: Without a HandleScope, an embedder can do | |
| 693 // almost nothing, so it is enough to check in this central place. | |
| 694 // We make an exception if the serializer is enabled, which means that the | |
| 695 // Isolate is exclusively used to create a snapshot. | |
| 696 Utils::ApiCheck( | |
| 697 !v8::Locker::IsActive() || | |
| 698 internal_isolate->thread_manager()->IsLockedByCurrentThread() || | |
| 699 internal_isolate->serializer_enabled(), | |
| 700 "SealHandleScope::SealHandleScope", | |
| 701 "Entering the V8 API without proper locking in place"); | |
|
Yang
2015/03/13 07:18:20
Do we actually need this check here? If you want t
| |
| 702 | |
| 703 isolate_ = internal_isolate; | |
| 704 i::HandleScopeData* current = internal_isolate->handle_scope_data(); | |
| 705 prev_limit_ = current->limit; | |
| 706 current->limit = current->next; | |
| 707 prev_level_ = current->level; | |
| 708 current->level = 0; | |
| 709 } | |
| 710 | |
| 711 | |
| 712 SealHandleScope::~SealHandleScope() { | |
| 713 i::HandleScopeData* current = isolate_->handle_scope_data(); | |
| 714 DCHECK_EQ(0, current->level); | |
| 715 current->level = prev_level_; | |
| 716 DCHECK_EQ(current->next, current->limit); | |
| 717 current->limit = prev_limit_; | |
| 718 } | |
| 719 | |
| 720 | |
| 689 void Context::Enter() { | 721 void Context::Enter() { |
| 690 i::Handle<i::Context> env = Utils::OpenHandle(this); | 722 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 691 i::Isolate* isolate = env->GetIsolate(); | 723 i::Isolate* isolate = env->GetIsolate(); |
| 692 ENTER_V8(isolate); | 724 ENTER_V8(isolate); |
| 693 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); | 725 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); |
| 694 impl->EnterContext(env); | 726 impl->EnterContext(env); |
| 695 impl->SaveContext(isolate->context()); | 727 impl->SaveContext(isolate->context()); |
| 696 isolate->set_context(*env); | 728 isolate->set_context(*env); |
| 697 } | 729 } |
| 698 | 730 |
| (...skipping 7299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7998 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8030 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7999 Address callback_address = | 8031 Address callback_address = |
| 8000 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8032 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8001 VMState<EXTERNAL> state(isolate); | 8033 VMState<EXTERNAL> state(isolate); |
| 8002 ExternalCallbackScope call_scope(isolate, callback_address); | 8034 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8003 callback(info); | 8035 callback(info); |
| 8004 } | 8036 } |
| 8005 | 8037 |
| 8006 | 8038 |
| 8007 } } // namespace v8::internal | 8039 } } // namespace v8::internal |
| OLD | NEW |