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

Side by Side Diff: src/bootstrapper.cc

Issue 1132513003: Call builtin code wrapped in functions from the bootstrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/arraybuffer.js ('k') | src/collection.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 Handle<JSFunction> fun = 1507 Handle<JSFunction> fun =
1508 factory->NewFunctionFromSharedFunctionInfo(function_info, context); 1508 factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1509 1509
1510 // Call function using either the runtime object or the global 1510 // Call function using either the runtime object or the global
1511 // object as the receiver. Provide no parameters. 1511 // object as the receiver. Provide no parameters.
1512 Handle<Object> receiver = 1512 Handle<Object> receiver =
1513 Handle<Object>(use_runtime_context 1513 Handle<Object>(use_runtime_context
1514 ? top_context->builtins() 1514 ? top_context->builtins()
1515 : top_context->global_object(), 1515 : top_context->global_object(),
1516 isolate); 1516 isolate);
1517 return !Execution::Call( 1517 MaybeHandle<Object> result;
1518 isolate, fun, receiver, 0, NULL).is_null(); 1518 if (extension == NULL) {
1519 // For non-extension scripts, run script to get the function wrapper.
1520 Handle<Object> wrapper;
1521 if (!Execution::Call(isolate, fun, receiver, 0, NULL).ToHandle(&wrapper)) {
1522 return false;
1523 }
1524 // Then run the function wrapper.
1525 Handle<Object> global_obj(top_context->global_object(), isolate);
1526 Handle<Object> args[] = {global_obj};
1527 result = Execution::Call(isolate, Handle<JSFunction>::cast(wrapper),
1528 receiver, arraysize(args), args);
1529 } else {
1530 result = Execution::Call(isolate, fun, receiver, 0, NULL);
1531 }
1532 return !result.is_null();
1519 } 1533 }
1520 1534
1521 1535
1522 static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context, 1536 static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
1523 const char* holder_expr) { 1537 const char* holder_expr) {
1524 Isolate* isolate = native_context->GetIsolate(); 1538 Isolate* isolate = native_context->GetIsolate();
1525 Factory* factory = isolate->factory(); 1539 Factory* factory = isolate->factory();
1526 Handle<GlobalObject> global(native_context->global_object()); 1540 Handle<GlobalObject> global(native_context->global_object());
1527 const char* period_pos = strchr(holder_expr, '.'); 1541 const char* period_pos = strchr(holder_expr, '.');
1528 if (period_pos == NULL) { 1542 if (period_pos == NULL) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1863 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1850 1864
1851 // Allocate the builtins object. 1865 // Allocate the builtins object.
1852 Handle<JSBuiltinsObject> builtins = 1866 Handle<JSBuiltinsObject> builtins =
1853 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1867 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1854 builtins->set_builtins(*builtins); 1868 builtins->set_builtins(*builtins);
1855 builtins->set_native_context(*native_context()); 1869 builtins->set_native_context(*native_context());
1856 builtins->set_global_proxy(native_context()->global_proxy()); 1870 builtins->set_global_proxy(native_context()->global_proxy());
1857 1871
1858 1872
1859 // Set up the 'global' properties of the builtins object. The 1873 // Set up the 'global' properties of the builtins object. The
Jakob Kummerow 2015/05/07 13:49:51 This comment feels slightly outdated.
1860 // 'global' property that refers to the global object is the only 1874 // 'global' property that refers to the global object is the only
1861 // way to get from code running in the builtins context to the 1875 // way to get from code running in the builtins context to the
1862 // global object. 1876 // global object.
1863 static const PropertyAttributes attributes = 1877 static const PropertyAttributes attributes =
1864 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1878 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1865 Handle<String> global_string =
1866 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("global"));
1867 Handle<Object> global_obj(native_context()->global_object(), isolate());
1868 JSObject::AddProperty(builtins, global_string, global_obj, attributes);
1869 Handle<String> builtins_string = 1879 Handle<String> builtins_string =
1870 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins")); 1880 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
1871 JSObject::AddProperty(builtins, builtins_string, builtins, attributes); 1881 JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
1872 1882
1873 // Set up the reference from the global object to the builtins object. 1883 // Set up the reference from the global object to the builtins object.
1874 JSGlobalObject::cast(native_context()->global_object())-> 1884 JSGlobalObject::cast(native_context()->global_object())->
1875 set_builtins(*builtins); 1885 set_builtins(*builtins);
1876 1886
1877 // Create a bridge function that has context in the native context. 1887 // Create a bridge function that has context in the native context.
1878 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); 1888 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 return from + sizeof(NestingCounterType); 2977 return from + sizeof(NestingCounterType);
2968 } 2978 }
2969 2979
2970 2980
2971 // Called when the top-level V8 mutex is destroyed. 2981 // Called when the top-level V8 mutex is destroyed.
2972 void Bootstrapper::FreeThreadResources() { 2982 void Bootstrapper::FreeThreadResources() {
2973 DCHECK(!IsActive()); 2983 DCHECK(!IsActive());
2974 } 2984 }
2975 2985
2976 } } // namespace v8::internal 2986 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arraybuffer.js ('k') | src/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698