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

Side by Side Diff: src/api.cc

Issue 1079713002: api: introduce SealHandleScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix typo in a test Created 5 years, 8 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 "Escape value set twice"); 667 "Escape value set twice");
668 if (escape_value == NULL) { 668 if (escape_value == NULL) {
669 *escape_slot_ = heap->undefined_value(); 669 *escape_slot_ = heap->undefined_value();
670 return NULL; 670 return NULL;
671 } 671 }
672 *escape_slot_ = *escape_value; 672 *escape_slot_ = *escape_value;
673 return escape_slot_; 673 return escape_slot_;
674 } 674 }
675 675
676 676
677 SealHandleScope::SealHandleScope(Isolate* isolate) {
678 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
679
680 isolate_ = internal_isolate;
681 i::HandleScopeData* current = internal_isolate->handle_scope_data();
682 prev_limit_ = current->limit;
683 current->limit = current->next;
684 prev_level_ = current->level;
685 current->level = 0;
686 }
687
688
689 SealHandleScope::~SealHandleScope() {
690 i::HandleScopeData* current = isolate_->handle_scope_data();
691 DCHECK_EQ(0, current->level);
692 current->level = prev_level_;
693 DCHECK_EQ(current->next, current->limit);
694 current->limit = prev_limit_;
695 }
696
697
677 void Context::Enter() { 698 void Context::Enter() {
678 i::Handle<i::Context> env = Utils::OpenHandle(this); 699 i::Handle<i::Context> env = Utils::OpenHandle(this);
679 i::Isolate* isolate = env->GetIsolate(); 700 i::Isolate* isolate = env->GetIsolate();
680 ENTER_V8(isolate); 701 ENTER_V8(isolate);
681 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 702 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
682 impl->EnterContext(env); 703 impl->EnterContext(env);
683 impl->SaveContext(isolate->context()); 704 impl->SaveContext(isolate->context());
684 isolate->set_context(*env); 705 isolate->set_context(*env);
685 } 706 }
686 707
(...skipping 7392 matching lines...) Expand 10 before | Expand all | Expand 10 after
8079 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8100 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8080 Address callback_address = 8101 Address callback_address =
8081 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8102 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8082 VMState<EXTERNAL> state(isolate); 8103 VMState<EXTERNAL> state(isolate);
8083 ExternalCallbackScope call_scope(isolate, callback_address); 8104 ExternalCallbackScope call_scope(isolate, callback_address);
8084 callback(info); 8105 callback(info);
8085 } 8106 }
8086 8107
8087 8108
8088 } } // namespace v8::internal 8109 } } // 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