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

Side by Side Diff: src/api.cc

Issue 24245005: Add EscapableHandleScope to api to fix problems with HandleScope::Close (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 694 }
695 695
696 696
697 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { 697 i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
698 ASSERT(value->IsHeapObject()); 698 ASSERT(value->IsHeapObject());
699 return reinterpret_cast<i::Object**>( 699 return reinterpret_cast<i::Object**>(
700 i::HandleScope::CreateHandle(value->GetIsolate(), value)); 700 i::HandleScope::CreateHandle(value->GetIsolate(), value));
701 } 701 }
702 702
703 703
704 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) {
705 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
706 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value());
707 Initialize(v8_isolate);
708 }
709
710
711 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
712 ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(),
713 "EscapeableHandleScope::Escape",
714 "Escape value set twice");
715 if (escape_value == NULL) {
716 *escape_slot_ = isolate_->heap()->undefined_value();
717 return NULL;
718 }
719 *escape_slot_ = *escape_value;
720 return escape_slot_;
721 }
722
723
704 void Context::Enter() { 724 void Context::Enter() {
705 i::Handle<i::Context> env = Utils::OpenHandle(this); 725 i::Handle<i::Context> env = Utils::OpenHandle(this);
706 i::Isolate* isolate = env->GetIsolate(); 726 i::Isolate* isolate = env->GetIsolate();
707 ENTER_V8(isolate); 727 ENTER_V8(isolate);
708 isolate->handle_scope_implementer()->EnterContext(env); 728 isolate->handle_scope_implementer()->EnterContext(env);
709 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 729 isolate->handle_scope_implementer()->SaveContext(isolate->context());
710 isolate->set_context(*env); 730 isolate->set_context(*env);
711 } 731 }
712 732
713 733
(...skipping 6846 matching lines...) Expand 10 before | Expand all | Expand 10 after
7560 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7580 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7561 Address callback_address = 7581 Address callback_address =
7562 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7582 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7563 VMState<EXTERNAL> state(isolate); 7583 VMState<EXTERNAL> state(isolate);
7564 ExternalCallbackScope call_scope(isolate, callback_address); 7584 ExternalCallbackScope call_scope(isolate, callback_address);
7565 callback(info); 7585 callback(info);
7566 } 7586 }
7567 7587
7568 7588
7569 } } // namespace v8::internal 7589 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698