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

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: fixes 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 | « src/api.h ('k') | test/cctest/cctest.status » ('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
692 isolate_ = internal_isolate;
693 i::HandleScopeData* current = internal_isolate->handle_scope_data();
694 prev_limit_ = current->limit;
695 current->limit = current->next;
696 prev_level_ = current->level;
697 current->level = 0;
698 }
699
700
701 SealHandleScope::~SealHandleScope() {
702 i::HandleScopeData* current = isolate_->handle_scope_data();
703 DCHECK_EQ(0, current->level);
704 current->level = prev_level_;
705 DCHECK_EQ(current->next, current->limit);
706 current->limit = prev_limit_;
707 }
708
709
689 void Context::Enter() { 710 void Context::Enter() {
690 i::Handle<i::Context> env = Utils::OpenHandle(this); 711 i::Handle<i::Context> env = Utils::OpenHandle(this);
691 i::Isolate* isolate = env->GetIsolate(); 712 i::Isolate* isolate = env->GetIsolate();
692 ENTER_V8(isolate); 713 ENTER_V8(isolate);
693 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 714 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
694 impl->EnterContext(env); 715 impl->EnterContext(env);
695 impl->SaveContext(isolate->context()); 716 impl->SaveContext(isolate->context());
696 isolate->set_context(*env); 717 isolate->set_context(*env);
697 } 718 }
698 719
(...skipping 7299 matching lines...) Expand 10 before | Expand all | Expand 10 after
7998 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8019 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7999 Address callback_address = 8020 Address callback_address =
8000 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8021 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8001 VMState<EXTERNAL> state(isolate); 8022 VMState<EXTERNAL> state(isolate);
8002 ExternalCallbackScope call_scope(isolate, callback_address); 8023 ExternalCallbackScope call_scope(isolate, callback_address);
8003 callback(info); 8024 callback(info);
8004 } 8025 }
8005 8026
8006 8027
8007 } } // namespace v8::internal 8028 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698