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

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: fix extra natives 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 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 Handle<JSFunction> fun = 1540 Handle<JSFunction> fun =
1541 factory->NewFunctionFromSharedFunctionInfo(function_info, context); 1541 factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1542 1542
1543 // Call function using either the runtime object or the global 1543 // Call function using either the runtime object or the global
1544 // object as the receiver. Provide no parameters. 1544 // object as the receiver. Provide no parameters.
1545 Handle<Object> receiver = 1545 Handle<Object> receiver =
1546 Handle<Object>(use_runtime_context 1546 Handle<Object>(use_runtime_context
1547 ? top_context->builtins() 1547 ? top_context->builtins()
1548 : top_context->global_object(), 1548 : top_context->global_object(),
1549 isolate); 1549 isolate);
1550 return !Execution::Call( 1550 MaybeHandle<Object> result;
1551 isolate, fun, receiver, 0, NULL).is_null(); 1551 if (extension == NULL) {
1552 // For non-extension scripts, run script to get the function wrapper.
1553 Handle<Object> wrapper;
1554 if (!Execution::Call(isolate, fun, receiver, 0, NULL).ToHandle(&wrapper)) {
1555 return false;
1556 }
1557 // Then run the function wrapper.
1558 Handle<Object> global_obj(top_context->global_object(), isolate);
1559 Handle<Object> args[] = {global_obj};
1560 result = Execution::Call(isolate, Handle<JSFunction>::cast(wrapper),
1561 receiver, arraysize(args), args);
1562 } else {
1563 result = Execution::Call(isolate, fun, receiver, 0, NULL);
1564 }
1565 return !result.is_null();
1552 } 1566 }
1553 1567
1554 1568
1555 static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context, 1569 static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
1556 const char* holder_expr) { 1570 const char* holder_expr) {
1557 Isolate* isolate = native_context->GetIsolate(); 1571 Isolate* isolate = native_context->GetIsolate();
1558 Factory* factory = isolate->factory(); 1572 Factory* factory = isolate->factory();
1559 Handle<GlobalObject> global(native_context->global_object()); 1573 Handle<GlobalObject> global(native_context->global_object());
1560 const char* period_pos = strchr(holder_expr, '.'); 1574 const char* period_pos = strchr(holder_expr, '.');
1561 if (period_pos == NULL) { 1575 if (period_pos == NULL) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1896 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1883 1897
1884 // Allocate the builtins object. 1898 // Allocate the builtins object.
1885 Handle<JSBuiltinsObject> builtins = 1899 Handle<JSBuiltinsObject> builtins =
1886 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1900 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1887 builtins->set_builtins(*builtins); 1901 builtins->set_builtins(*builtins);
1888 builtins->set_native_context(*native_context()); 1902 builtins->set_native_context(*native_context());
1889 builtins->set_global_proxy(native_context()->global_proxy()); 1903 builtins->set_global_proxy(native_context()->global_proxy());
1890 1904
1891 1905
1892 // Set up the 'global' properties of the builtins object. The 1906 // Set up the 'builtin' property, which refers to the js builtins object.
1893 // 'global' property that refers to the global object is the only
1894 // way to get from code running in the builtins context to the
1895 // global object.
1896 static const PropertyAttributes attributes = 1907 static const PropertyAttributes attributes =
1897 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1908 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1898 Handle<String> global_string =
1899 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("global"));
1900 Handle<Object> global_obj(native_context()->global_object(), isolate());
1901 JSObject::AddProperty(builtins, global_string, global_obj, attributes);
1902 Handle<String> builtins_string = 1909 Handle<String> builtins_string =
1903 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins")); 1910 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
1904 JSObject::AddProperty(builtins, builtins_string, builtins, attributes); 1911 JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
1905 1912
1906 // Set up the reference from the global object to the builtins object. 1913 // Set up the reference from the global object to the builtins object.
1907 JSGlobalObject::cast(native_context()->global_object())-> 1914 JSGlobalObject::cast(native_context()->global_object())->
1908 set_builtins(*builtins); 1915 set_builtins(*builtins);
1909 1916
1910 // Create a bridge function that has context in the native context. 1917 // Create a bridge function that has context in the native context.
1911 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); 1918 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 return from + sizeof(NestingCounterType); 3019 return from + sizeof(NestingCounterType);
3013 } 3020 }
3014 3021
3015 3022
3016 // Called when the top-level V8 mutex is destroyed. 3023 // Called when the top-level V8 mutex is destroyed.
3017 void Bootstrapper::FreeThreadResources() { 3024 void Bootstrapper::FreeThreadResources() {
3018 DCHECK(!IsActive()); 3025 DCHECK(!IsActive());
3019 } 3026 }
3020 3027
3021 } } // namespace v8::internal 3028 } } // 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