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

Side by Side Diff: src/api.cc

Issue 352173006: Clean up the global object naming madness. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 5 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/accessors.cc ('k') | src/arm/builtins-arm.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 // 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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 if (obj.is_null()) return Local<Value>(); 1640 if (obj.is_null()) return Local<Value>();
1641 i::Isolate* isolate = i::Handle<i::HeapObject>::cast(obj)->GetIsolate(); 1641 i::Isolate* isolate = i::Handle<i::HeapObject>::cast(obj)->GetIsolate();
1642 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1642 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1643 LOG_API(isolate, "Script::Run"); 1643 LOG_API(isolate, "Script::Run");
1644 ENTER_V8(isolate); 1644 ENTER_V8(isolate);
1645 i::Logger::TimerEventScope timer_scope( 1645 i::Logger::TimerEventScope timer_scope(
1646 isolate, i::Logger::TimerEventScope::v8_execute); 1646 isolate, i::Logger::TimerEventScope::v8_execute);
1647 i::HandleScope scope(isolate); 1647 i::HandleScope scope(isolate);
1648 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); 1648 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
1649 EXCEPTION_PREAMBLE(isolate); 1649 EXCEPTION_PREAMBLE(isolate);
1650 i::Handle<i::Object> receiver( 1650 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate);
1651 isolate->context()->global_proxy(), isolate);
1652 i::Handle<i::Object> result; 1651 i::Handle<i::Object> result;
1653 has_pending_exception = !i::Execution::Call( 1652 has_pending_exception = !i::Execution::Call(
1654 isolate, fun, receiver, 0, NULL).ToHandle(&result); 1653 isolate, fun, receiver, 0, NULL).ToHandle(&result);
1655 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); 1654 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
1656 return Utils::ToLocal(scope.CloseAndEscape(result)); 1655 return Utils::ToLocal(scope.CloseAndEscape(result));
1657 } 1656 }
1658 1657
1659 1658
1660 Local<UnboundScript> Script::GetUnboundScript() { 1659 Local<UnboundScript> Script::GetUnboundScript() {
1661 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1660 i::Handle<i::Object> obj = Utils::OpenHandle(this);
(...skipping 3436 matching lines...) Expand 10 before | Expand all | Expand 10 after
5098 5097
5099 const char* v8::V8::GetVersion() { 5098 const char* v8::V8::GetVersion() {
5100 return i::Version::GetVersion(); 5099 return i::Version::GetVersion();
5101 } 5100 }
5102 5101
5103 5102
5104 static i::Handle<i::Context> CreateEnvironment( 5103 static i::Handle<i::Context> CreateEnvironment(
5105 i::Isolate* isolate, 5104 i::Isolate* isolate,
5106 v8::ExtensionConfiguration* extensions, 5105 v8::ExtensionConfiguration* extensions,
5107 v8::Handle<ObjectTemplate> global_template, 5106 v8::Handle<ObjectTemplate> global_template,
5108 v8::Handle<Value> global_object) { 5107 v8::Handle<Value> maybe_global_proxy) {
5109 i::Handle<i::Context> env; 5108 i::Handle<i::Context> env;
5110 5109
5111 // Enter V8 via an ENTER_V8 scope. 5110 // Enter V8 via an ENTER_V8 scope.
5112 { 5111 {
5113 ENTER_V8(isolate); 5112 ENTER_V8(isolate);
5114 v8::Handle<ObjectTemplate> proxy_template = global_template; 5113 v8::Handle<ObjectTemplate> proxy_template = global_template;
5115 i::Handle<i::FunctionTemplateInfo> proxy_constructor; 5114 i::Handle<i::FunctionTemplateInfo> proxy_constructor;
5116 i::Handle<i::FunctionTemplateInfo> global_constructor; 5115 i::Handle<i::FunctionTemplateInfo> global_constructor;
5117 5116
5118 if (!global_template.IsEmpty()) { 5117 if (!global_template.IsEmpty()) {
(...skipping 17 matching lines...) Expand all
5136 proxy_constructor->set_access_check_info( 5135 proxy_constructor->set_access_check_info(
5137 global_constructor->access_check_info()); 5136 global_constructor->access_check_info());
5138 proxy_constructor->set_needs_access_check( 5137 proxy_constructor->set_needs_access_check(
5139 global_constructor->needs_access_check()); 5138 global_constructor->needs_access_check());
5140 global_constructor->set_needs_access_check(false); 5139 global_constructor->set_needs_access_check(false);
5141 global_constructor->set_access_check_info( 5140 global_constructor->set_access_check_info(
5142 isolate->heap()->undefined_value()); 5141 isolate->heap()->undefined_value());
5143 } 5142 }
5144 } 5143 }
5145 5144
5145 i::Handle<i::Object> proxy = Utils::OpenHandle(*maybe_global_proxy, true);
5146 i::MaybeHandle<i::JSGlobalProxy> maybe_proxy;
5147 if (!proxy.is_null()) {
5148 maybe_proxy = i::Handle<i::JSGlobalProxy>::cast(proxy);
5149 }
5146 // Create the environment. 5150 // Create the environment.
5147 env = isolate->bootstrapper()->CreateEnvironment( 5151 env = isolate->bootstrapper()->CreateEnvironment(
5148 Utils::OpenHandle(*global_object, true), 5152 maybe_proxy, proxy_template, extensions);
5149 proxy_template,
5150 extensions);
5151 5153
5152 // Restore the access check info on the global template. 5154 // Restore the access check info on the global template.
5153 if (!global_template.IsEmpty()) { 5155 if (!global_template.IsEmpty()) {
5154 ASSERT(!global_constructor.is_null()); 5156 ASSERT(!global_constructor.is_null());
5155 ASSERT(!proxy_constructor.is_null()); 5157 ASSERT(!proxy_constructor.is_null());
5156 global_constructor->set_access_check_info( 5158 global_constructor->set_access_check_info(
5157 proxy_constructor->access_check_info()); 5159 proxy_constructor->access_check_info());
5158 global_constructor->set_needs_access_check( 5160 global_constructor->set_needs_access_check(
5159 proxy_constructor->needs_access_check()); 5161 proxy_constructor->needs_access_check());
5160 } 5162 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
5819 if (!val->IsJSObject()) return false; 5821 if (!val->IsJSObject()) return false;
5820 i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(val); 5822 i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(val);
5821 i::Isolate* isolate = obj->GetIsolate(); 5823 i::Isolate* isolate = obj->GetIsolate();
5822 LOG_API(isolate, "IsPromise"); 5824 LOG_API(isolate, "IsPromise");
5823 ENTER_V8(isolate); 5825 ENTER_V8(isolate);
5824 EXCEPTION_PREAMBLE(isolate); 5826 EXCEPTION_PREAMBLE(isolate);
5825 i::Handle<i::Object> argv[] = { obj }; 5827 i::Handle<i::Object> argv[] = { obj };
5826 i::Handle<i::Object> b; 5828 i::Handle<i::Object> b;
5827 has_pending_exception = !i::Execution::Call( 5829 has_pending_exception = !i::Execution::Call(
5828 isolate, 5830 isolate,
5829 handle( 5831 isolate->is_promise(),
5830 isolate->context()->global_object()->native_context()->is_promise()),
5831 isolate->factory()->undefined_value(), 5832 isolate->factory()->undefined_value(),
5832 ARRAY_SIZE(argv), argv, 5833 ARRAY_SIZE(argv), argv,
5833 false).ToHandle(&b); 5834 false).ToHandle(&b);
5834 EXCEPTION_BAILOUT_CHECK(isolate, false); 5835 EXCEPTION_BAILOUT_CHECK(isolate, false);
5835 return b->BooleanValue(); 5836 return b->BooleanValue();
5836 } 5837 }
5837 5838
5838 5839
5839 Local<Promise::Resolver> Promise::Resolver::New(Isolate* v8_isolate) { 5840 Local<Promise::Resolver> Promise::Resolver::New(Isolate* v8_isolate) {
5840 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 5841 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
5841 LOG_API(isolate, "Promise::Resolver::New"); 5842 LOG_API(isolate, "Promise::Resolver::New");
5842 ENTER_V8(isolate); 5843 ENTER_V8(isolate);
5843 EXCEPTION_PREAMBLE(isolate); 5844 EXCEPTION_PREAMBLE(isolate);
5844 i::Handle<i::Object> result; 5845 i::Handle<i::Object> result;
5845 has_pending_exception = !i::Execution::Call( 5846 has_pending_exception = !i::Execution::Call(
5846 isolate, 5847 isolate,
5847 handle(isolate->context()->global_object()->native_context()-> 5848 isolate->promise_create(),
5848 promise_create()),
5849 isolate->factory()->undefined_value(), 5849 isolate->factory()->undefined_value(),
5850 0, NULL, 5850 0, NULL,
5851 false).ToHandle(&result); 5851 false).ToHandle(&result);
5852 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise::Resolver>()); 5852 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise::Resolver>());
5853 return Local<Promise::Resolver>::Cast(Utils::ToLocal(result)); 5853 return Local<Promise::Resolver>::Cast(Utils::ToLocal(result));
5854 } 5854 }
5855 5855
5856 5856
5857 Local<Promise> Promise::Resolver::GetPromise() { 5857 Local<Promise> Promise::Resolver::GetPromise() {
5858 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5858 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5859 return Local<Promise>::Cast(Utils::ToLocal(promise)); 5859 return Local<Promise>::Cast(Utils::ToLocal(promise));
5860 } 5860 }
5861 5861
5862 5862
5863 void Promise::Resolver::Resolve(Handle<Value> value) { 5863 void Promise::Resolver::Resolve(Handle<Value> value) {
5864 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5864 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5865 i::Isolate* isolate = promise->GetIsolate(); 5865 i::Isolate* isolate = promise->GetIsolate();
5866 LOG_API(isolate, "Promise::Resolver::Resolve"); 5866 LOG_API(isolate, "Promise::Resolver::Resolve");
5867 ENTER_V8(isolate); 5867 ENTER_V8(isolate);
5868 EXCEPTION_PREAMBLE(isolate); 5868 EXCEPTION_PREAMBLE(isolate);
5869 i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) }; 5869 i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5870 has_pending_exception = i::Execution::Call( 5870 has_pending_exception = i::Execution::Call(
5871 isolate, 5871 isolate,
5872 handle(isolate->context()->global_object()->native_context()-> 5872 isolate->promise_resolve(),
5873 promise_resolve()),
5874 isolate->factory()->undefined_value(), 5873 isolate->factory()->undefined_value(),
5875 ARRAY_SIZE(argv), argv, 5874 ARRAY_SIZE(argv), argv,
5876 false).is_null(); 5875 false).is_null();
5877 EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;); 5876 EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5878 } 5877 }
5879 5878
5880 5879
5881 void Promise::Resolver::Reject(Handle<Value> value) { 5880 void Promise::Resolver::Reject(Handle<Value> value) {
5882 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5881 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5883 i::Isolate* isolate = promise->GetIsolate(); 5882 i::Isolate* isolate = promise->GetIsolate();
5884 LOG_API(isolate, "Promise::Resolver::Reject"); 5883 LOG_API(isolate, "Promise::Resolver::Reject");
5885 ENTER_V8(isolate); 5884 ENTER_V8(isolate);
5886 EXCEPTION_PREAMBLE(isolate); 5885 EXCEPTION_PREAMBLE(isolate);
5887 i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) }; 5886 i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5888 has_pending_exception = i::Execution::Call( 5887 has_pending_exception = i::Execution::Call(
5889 isolate, 5888 isolate,
5890 handle(isolate->context()->global_object()->native_context()-> 5889 isolate->promise_reject(),
5891 promise_reject()),
5892 isolate->factory()->undefined_value(), 5890 isolate->factory()->undefined_value(),
5893 ARRAY_SIZE(argv), argv, 5891 ARRAY_SIZE(argv), argv,
5894 false).is_null(); 5892 false).is_null();
5895 EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;); 5893 EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5896 } 5894 }
5897 5895
5898 5896
5899 Local<Promise> Promise::Chain(Handle<Function> handler) { 5897 Local<Promise> Promise::Chain(Handle<Function> handler) {
5900 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5898 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5901 i::Isolate* isolate = promise->GetIsolate(); 5899 i::Isolate* isolate = promise->GetIsolate();
5902 LOG_API(isolate, "Promise::Chain"); 5900 LOG_API(isolate, "Promise::Chain");
5903 ENTER_V8(isolate); 5901 ENTER_V8(isolate);
5904 EXCEPTION_PREAMBLE(isolate); 5902 EXCEPTION_PREAMBLE(isolate);
5905 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; 5903 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5906 i::Handle<i::Object> result; 5904 i::Handle<i::Object> result;
5907 has_pending_exception = !i::Execution::Call( 5905 has_pending_exception = !i::Execution::Call(
5908 isolate, 5906 isolate,
5909 handle(isolate->context()->global_object()->native_context()-> 5907 isolate->promise_chain(),
5910 promise_chain()),
5911 promise, 5908 promise,
5912 ARRAY_SIZE(argv), argv, 5909 ARRAY_SIZE(argv), argv,
5913 false).ToHandle(&result); 5910 false).ToHandle(&result);
5914 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); 5911 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
5915 return Local<Promise>::Cast(Utils::ToLocal(result)); 5912 return Local<Promise>::Cast(Utils::ToLocal(result));
5916 } 5913 }
5917 5914
5918 5915
5919 Local<Promise> Promise::Catch(Handle<Function> handler) { 5916 Local<Promise> Promise::Catch(Handle<Function> handler) {
5920 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5917 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5921 i::Isolate* isolate = promise->GetIsolate(); 5918 i::Isolate* isolate = promise->GetIsolate();
5922 LOG_API(isolate, "Promise::Catch"); 5919 LOG_API(isolate, "Promise::Catch");
5923 ENTER_V8(isolate); 5920 ENTER_V8(isolate);
5924 EXCEPTION_PREAMBLE(isolate); 5921 EXCEPTION_PREAMBLE(isolate);
5925 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; 5922 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5926 i::Handle<i::Object> result; 5923 i::Handle<i::Object> result;
5927 has_pending_exception = !i::Execution::Call( 5924 has_pending_exception = !i::Execution::Call(
5928 isolate, 5925 isolate,
5929 handle(isolate->context()->global_object()->native_context()-> 5926 isolate->promise_catch(),
5930 promise_catch()),
5931 promise, 5927 promise,
5932 ARRAY_SIZE(argv), argv, 5928 ARRAY_SIZE(argv), argv,
5933 false).ToHandle(&result); 5929 false).ToHandle(&result);
5934 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); 5930 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
5935 return Local<Promise>::Cast(Utils::ToLocal(result)); 5931 return Local<Promise>::Cast(Utils::ToLocal(result));
5936 } 5932 }
5937 5933
5938 5934
5939 Local<Promise> Promise::Then(Handle<Function> handler) { 5935 Local<Promise> Promise::Then(Handle<Function> handler) {
5940 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 5936 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5941 i::Isolate* isolate = promise->GetIsolate(); 5937 i::Isolate* isolate = promise->GetIsolate();
5942 LOG_API(isolate, "Promise::Then"); 5938 LOG_API(isolate, "Promise::Then");
5943 ENTER_V8(isolate); 5939 ENTER_V8(isolate);
5944 EXCEPTION_PREAMBLE(isolate); 5940 EXCEPTION_PREAMBLE(isolate);
5945 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; 5941 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5946 i::Handle<i::Object> result; 5942 i::Handle<i::Object> result;
5947 has_pending_exception = !i::Execution::Call( 5943 has_pending_exception = !i::Execution::Call(
5948 isolate, 5944 isolate,
5949 handle(isolate->context()->global_object()->native_context()-> 5945 isolate->promise_then(),
5950 promise_then()),
5951 promise, 5946 promise,
5952 ARRAY_SIZE(argv), argv, 5947 ARRAY_SIZE(argv), argv,
5953 false).ToHandle(&result); 5948 false).ToHandle(&result);
5954 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); 5949 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
5955 return Local<Promise>::Cast(Utils::ToLocal(result)); 5950 return Local<Promise>::Cast(Utils::ToLocal(result));
5956 } 5951 }
5957 5952
5958 5953
5959 bool v8::ArrayBuffer::IsExternal() const { 5954 bool v8::ArrayBuffer::IsExternal() const {
5960 return Utils::OpenHandle(this)->is_external(); 5955 return Utils::OpenHandle(this)->is_external();
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
6375 bool Isolate::InContext() { 6370 bool Isolate::InContext() {
6376 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6371 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6377 return isolate->context() != NULL; 6372 return isolate->context() != NULL;
6378 } 6373 }
6379 6374
6380 6375
6381 v8::Local<v8::Context> Isolate::GetCurrentContext() { 6376 v8::Local<v8::Context> Isolate::GetCurrentContext() {
6382 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6377 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6383 i::Context* context = isolate->context(); 6378 i::Context* context = isolate->context();
6384 if (context == NULL) return Local<Context>(); 6379 if (context == NULL) return Local<Context>();
6385 i::Context* native_context = context->global_object()->native_context(); 6380 i::Context* native_context = context->native_context();
6386 if (native_context == NULL) return Local<Context>(); 6381 if (native_context == NULL) return Local<Context>();
6387 return Utils::ToLocal(i::Handle<i::Context>(native_context)); 6382 return Utils::ToLocal(i::Handle<i::Context>(native_context));
6388 } 6383 }
6389 6384
6390 6385
6391 v8::Local<v8::Context> Isolate::GetCallingContext() { 6386 v8::Local<v8::Context> Isolate::GetCallingContext() {
6392 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6387 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6393 i::Handle<i::Object> calling = isolate->GetCallingNativeContext(); 6388 i::Handle<i::Object> calling = isolate->GetCallingNativeContext();
6394 if (calling.is_null()) return Local<Context>(); 6389 if (calling.is_null()) return Local<Context>();
6395 return Utils::ToLocal(i::Handle<i::Context>::cast(calling)); 6390 return Utils::ToLocal(i::Handle<i::Context>::cast(calling));
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
7630 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7625 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7631 Address callback_address = 7626 Address callback_address =
7632 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7627 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7633 VMState<EXTERNAL> state(isolate); 7628 VMState<EXTERNAL> state(isolate);
7634 ExternalCallbackScope call_scope(isolate, callback_address); 7629 ExternalCallbackScope call_scope(isolate, callback_address);
7635 callback(info); 7630 callback(info);
7636 } 7631 }
7637 7632
7638 7633
7639 } } // namespace v8::internal 7634 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698