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

Side by Side Diff: src/api.cc

Issue 128313002: Removed a few internal uses of Isolate::Current. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplified. Created 6 years, 11 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 | « src/api.h ('k') | src/bootstrapper.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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 i::Handle<i::Context> env = Utils::OpenHandle(this); 707 i::Handle<i::Context> env = Utils::OpenHandle(this);
708 i::Isolate* isolate = env->GetIsolate(); 708 i::Isolate* isolate = env->GetIsolate();
709 ENTER_V8(isolate); 709 ENTER_V8(isolate);
710 isolate->handle_scope_implementer()->EnterContext(env); 710 isolate->handle_scope_implementer()->EnterContext(env);
711 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 711 isolate->handle_scope_implementer()->SaveContext(isolate->context());
712 isolate->set_context(*env); 712 isolate->set_context(*env);
713 } 713 }
714 714
715 715
716 void Context::Exit() { 716 void Context::Exit() {
717 // TODO(dcarney): fix this once chrome is fixed. 717 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
718 i::Isolate* isolate = i::Isolate::Current();
719 i::Handle<i::Context> context = i::Handle<i::Context>::null(); 718 i::Handle<i::Context> context = i::Handle<i::Context>::null();
720 ENTER_V8(isolate); 719 ENTER_V8(isolate);
721 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context), 720 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context),
722 "v8::Context::Exit()", 721 "v8::Context::Exit()",
723 "Cannot exit non-entered context")) { 722 "Cannot exit non-entered context")) {
724 return; 723 return;
725 } 724 }
726 // Content of 'last_context' could be NULL. 725 // Content of 'last_context' could be NULL.
727 i::Context* last_context = 726 i::Context* last_context =
728 isolate->handle_scope_implementer()->RestoreContext(); 727 isolate->handle_scope_implementer()->RestoreContext();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 801
803 802
804 // --- N e a n d e r --- 803 // --- N e a n d e r ---
805 804
806 805
807 // A constructor cannot easily return an error value, therefore it is necessary 806 // A constructor cannot easily return an error value, therefore it is necessary
808 // to check for a dead VM with ON_BAILOUT before constructing any Neander 807 // to check for a dead VM with ON_BAILOUT before constructing any Neander
809 // objects. To remind you about this there is no HandleScope in the 808 // objects. To remind you about this there is no HandleScope in the
810 // NeanderObject constructor. When you add one to the site calling the 809 // NeanderObject constructor. When you add one to the site calling the
811 // constructor you should check that you ensured the VM was not dead first. 810 // constructor you should check that you ensured the VM was not dead first.
812 NeanderObject::NeanderObject(int size) { 811 NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) {
813 i::Isolate* isolate = i::Isolate::Current();
814 EnsureInitializedForIsolate(isolate, "v8::Nowhere"); 812 EnsureInitializedForIsolate(isolate, "v8::Nowhere");
815 ENTER_V8(isolate); 813 ENTER_V8(isolate);
816 value_ = isolate->factory()->NewNeanderObject(); 814 value_ = isolate->factory()->NewNeanderObject();
817 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size); 815 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
818 value_->set_elements(*elements); 816 value_->set_elements(*elements);
819 } 817 }
820 818
821 819
822 int NeanderObject::size() { 820 int NeanderObject::size() {
823 return i::FixedArray::cast(value_->elements())->length(); 821 return i::FixedArray::cast(value_->elements())->length();
824 } 822 }
825 823
826 824
827 NeanderArray::NeanderArray() : obj_(2) { 825 NeanderArray::NeanderArray(v8::internal::Isolate* isolate) : obj_(isolate, 2) {
828 obj_.set(0, i::Smi::FromInt(0)); 826 obj_.set(0, i::Smi::FromInt(0));
829 } 827 }
830 828
831 829
832 int NeanderArray::length() { 830 int NeanderArray::length() {
833 return i::Smi::cast(obj_.get(0))->value(); 831 return i::Smi::cast(obj_.get(0))->value();
834 } 832 }
835 833
836 834
837 i::Object* NeanderArray::get(int offset) { 835 i::Object* NeanderArray::get(int offset) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 that->set_tag(i::Smi::FromInt(type)); 872 that->set_tag(i::Smi::FromInt(type));
875 } 873 }
876 874
877 875
878 static void TemplateSet(i::Isolate* isolate, 876 static void TemplateSet(i::Isolate* isolate,
879 v8::Template* templ, 877 v8::Template* templ,
880 int length, 878 int length,
881 v8::Handle<v8::Data>* data) { 879 v8::Handle<v8::Data>* data) {
882 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate); 880 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate);
883 if (list->IsUndefined()) { 881 if (list->IsUndefined()) {
884 list = NeanderArray().value(); 882 list = NeanderArray(isolate).value();
885 Utils::OpenHandle(templ)->set_property_list(*list); 883 Utils::OpenHandle(templ)->set_property_list(*list);
886 } 884 }
887 NeanderArray array(list); 885 NeanderArray array(list);
888 array.add(isolate->factory()->NewNumberFromInt(length)); 886 array.add(isolate->factory()->NewNumberFromInt(length));
889 for (int i = 0; i < length; i++) { 887 for (int i = 0; i < length; i++) {
890 i::Handle<i::Object> value = data[i].IsEmpty() ? 888 i::Handle<i::Object> value = data[i].IsEmpty() ?
891 i::Handle<i::Object>(isolate->factory()->undefined_value()) : 889 i::Handle<i::Object>(isolate->factory()->undefined_value()) :
892 Utils::OpenHandle(*data[i]); 890 Utils::OpenHandle(*data[i]);
893 array.add(value); 891 array.add(value);
894 } 892 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); 1373 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
1376 constructor->set_instance_template(*Utils::OpenHandle(object_template)); 1374 constructor->set_instance_template(*Utils::OpenHandle(object_template));
1377 Utils::OpenHandle(object_template)->set_constructor(*constructor); 1375 Utils::OpenHandle(object_template)->set_constructor(*constructor);
1378 return constructor; 1376 return constructor;
1379 } 1377 }
1380 1378
1381 1379
1382 static inline void AddPropertyToTemplate( 1380 static inline void AddPropertyToTemplate(
1383 i::Handle<i::TemplateInfo> info, 1381 i::Handle<i::TemplateInfo> info,
1384 i::Handle<i::AccessorInfo> obj) { 1382 i::Handle<i::AccessorInfo> obj) {
1385 i::Handle<i::Object> list(info->property_accessors(), info->GetIsolate()); 1383 i::Isolate* isolate = info->GetIsolate();
1384 i::Handle<i::Object> list(info->property_accessors(), isolate);
1386 if (list->IsUndefined()) { 1385 if (list->IsUndefined()) {
1387 list = NeanderArray().value(); 1386 list = NeanderArray(isolate).value();
1388 info->set_property_accessors(*list); 1387 info->set_property_accessors(*list);
1389 } 1388 }
1390 NeanderArray array(list); 1389 NeanderArray array(list);
1391 array.add(obj); 1390 array.add(obj);
1392 } 1391 }
1393 1392
1394 1393
1395 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( 1394 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1396 i::Isolate* isolate, 1395 i::Isolate* isolate,
1397 Template* template_obj) { 1396 Template* template_obj) {
(...skipping 4771 matching lines...) Expand 10 before | Expand all | Expand 10 after
6169 } 6168 }
6170 6169
6171 6170
6172 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 6171 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
6173 i::Isolate* isolate = i::Isolate::Current(); 6172 i::Isolate* isolate = i::Isolate::Current();
6174 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); 6173 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
6175 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 6174 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
6176 ENTER_V8(isolate); 6175 ENTER_V8(isolate);
6177 i::HandleScope scope(isolate); 6176 i::HandleScope scope(isolate);
6178 NeanderArray listeners(isolate->factory()->message_listeners()); 6177 NeanderArray listeners(isolate->factory()->message_listeners());
6179 NeanderObject obj(2); 6178 NeanderObject obj(isolate, 2);
6180 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); 6179 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
6181 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() 6180 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
6182 : *Utils::OpenHandle(*data)); 6181 : *Utils::OpenHandle(*data));
6183 listeners.add(obj.value()); 6182 listeners.add(obj.value());
6184 return true; 6183 return true;
6185 } 6184 }
6186 6185
6187 6186
6188 void V8::RemoveMessageListeners(MessageCallback that) { 6187 void V8::RemoveMessageListeners(MessageCallback that) {
6189 i::Isolate* isolate = i::Isolate::Current(); 6188 i::Isolate* isolate = i::Isolate::Current();
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
7462 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7461 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7463 Address callback_address = 7462 Address callback_address =
7464 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7463 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7465 VMState<EXTERNAL> state(isolate); 7464 VMState<EXTERNAL> state(isolate);
7466 ExternalCallbackScope call_scope(isolate, callback_address); 7465 ExternalCallbackScope call_scope(isolate, callback_address);
7467 callback(info); 7466 callback(info);
7468 } 7467 }
7469 7468
7470 7469
7471 } } // namespace v8::internal 7470 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698