Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/api.cc

Issue 985873002: api: introduce SealHandleScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/handles-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 "HandleScope::HandleScope",
Yang 2015/03/10 12:52:32 Please update this line to SealHandleScope.
701 "Entering the V8 API without proper locking in place");
702
703 isolate_ = internal_isolate;
704 i::HandleScopeData* current = internal_isolate->handle_scope_data();
705 level_ = current->level;
706 current->level = 0;
707 }
708
709
710 SealHandleScope::~SealHandleScope() {
711 i::HandleScopeData* current = isolate_->handle_scope_data();
712 DCHECK_EQ(0, current->level);
713 current->level = level_;
714 }
715
716
689 void Context::Enter() { 717 void Context::Enter() {
690 i::Handle<i::Context> env = Utils::OpenHandle(this); 718 i::Handle<i::Context> env = Utils::OpenHandle(this);
691 i::Isolate* isolate = env->GetIsolate(); 719 i::Isolate* isolate = env->GetIsolate();
692 ENTER_V8(isolate); 720 ENTER_V8(isolate);
693 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 721 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
694 impl->EnterContext(env); 722 impl->EnterContext(env);
695 impl->SaveContext(isolate->context()); 723 impl->SaveContext(isolate->context());
696 isolate->set_context(*env); 724 isolate->set_context(*env);
697 } 725 }
698 726
(...skipping 7299 matching lines...) Expand 10 before | Expand all | Expand 10 after
7998 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8026 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7999 Address callback_address = 8027 Address callback_address =
8000 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8028 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8001 VMState<EXTERNAL> state(isolate); 8029 VMState<EXTERNAL> state(isolate);
8002 ExternalCallbackScope call_scope(isolate, callback_address); 8030 ExternalCallbackScope call_scope(isolate, callback_address);
8003 callback(info); 8031 callback(info);
8004 } 8032 }
8005 8033
8006 8034
8007 } } // namespace v8::internal 8035 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/handles-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698