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

Side by Side Diff: src/bootstrapper.cc

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | src/builtins.h » ('j') | src/runtime/runtime-classes.cc » ('J')
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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 global_object, object_name, isolate->object_function(), DONT_ENUM); 1095 global_object, object_name, isolate->object_function(), DONT_ENUM);
1096 1096
1097 Handle<JSObject> global(native_context()->global_object()); 1097 Handle<JSObject> global(native_context()->global_object());
1098 1098
1099 // Install global Function object 1099 // Install global Function object
1100 Handle<JSFunction> function_function = 1100 Handle<JSFunction> function_function =
1101 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 1101 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
1102 empty_function, Builtins::kIllegal); 1102 empty_function, Builtins::kIllegal);
1103 function_function->initial_map()->set_is_callable(); 1103 function_function->initial_map()->set_is_callable();
1104 function_function->initial_map()->set_is_constructor(true); 1104 function_function->initial_map()->set_is_constructor(true);
1105 function_function->shared()->set_construct_stub(
1106 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1105 1107
1106 { // --- A r r a y --- 1108 { // --- A r r a y ---
1107 Handle<JSFunction> array_function = 1109 Handle<JSFunction> array_function =
1108 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 1110 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
1109 isolate->initial_object_prototype(), 1111 isolate->initial_object_prototype(),
1110 Builtins::kArrayCode); 1112 Builtins::kArrayCode);
1111 array_function->shared()->DontAdaptArguments(); 1113 array_function->shared()->DontAdaptArguments();
1112 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); 1114 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode));
1113 1115
1114 // This seems a bit hackish, but we need to make sure Array.length 1116 // This seems a bit hackish, but we need to make sure Array.length
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 initial_strong_map->set_is_strong(); 1153 initial_strong_map->set_is_strong();
1152 CacheInitialJSArrayMaps(native_context(), initial_strong_map); 1154 CacheInitialJSArrayMaps(native_context(), initial_strong_map);
1153 } 1155 }
1154 1156
1155 { // --- N u m b e r --- 1157 { // --- N u m b e r ---
1156 Handle<JSFunction> number_fun = 1158 Handle<JSFunction> number_fun =
1157 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, 1159 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
1158 isolate->initial_object_prototype(), 1160 isolate->initial_object_prototype(),
1159 Builtins::kIllegal); 1161 Builtins::kIllegal);
1160 native_context()->set_number_function(*number_fun); 1162 native_context()->set_number_function(*number_fun);
1163 number_fun->shared()->set_construct_stub(
1164 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1161 } 1165 }
1162 1166
1163 { // --- B o o l e a n --- 1167 { // --- B o o l e a n ---
1164 Handle<JSFunction> boolean_fun = 1168 Handle<JSFunction> boolean_fun =
1165 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, 1169 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
1166 isolate->initial_object_prototype(), 1170 isolate->initial_object_prototype(),
1167 Builtins::kIllegal); 1171 Builtins::kIllegal);
1168 native_context()->set_boolean_function(*boolean_fun); 1172 native_context()->set_boolean_function(*boolean_fun);
1169 } 1173 }
1170 1174
(...skipping 30 matching lines...) Expand all
1201 isolate->initial_object_prototype(), Builtins::kSymbolConstructor); 1205 isolate->initial_object_prototype(), Builtins::kSymbolConstructor);
1202 symbol_fun->shared()->set_construct_stub(isolate->builtins()->builtin( 1206 symbol_fun->shared()->set_construct_stub(isolate->builtins()->builtin(
1203 Builtins::kSymbolConstructor_ConstructStub)); 1207 Builtins::kSymbolConstructor_ConstructStub));
1204 symbol_fun->shared()->set_internal_formal_parameter_count(1); 1208 symbol_fun->shared()->set_internal_formal_parameter_count(1);
1205 symbol_fun->shared()->set_length(1); 1209 symbol_fun->shared()->set_length(1);
1206 native_context()->set_symbol_function(*symbol_fun); 1210 native_context()->set_symbol_function(*symbol_fun);
1207 } 1211 }
1208 1212
1209 { // --- D a t e --- 1213 { // --- D a t e ---
1210 // Builtin functions for Date.prototype. 1214 // Builtin functions for Date.prototype.
1211 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, 1215 Handle<JSFunction> date_fun = InstallFunction(
1212 isolate->initial_object_prototype(), Builtins::kIllegal); 1216 global, "Date", JS_DATE_TYPE, JSDate::kSize,
1217 isolate->initial_object_prototype(), Builtins::kIllegal);
1218 date_fun->shared()->set_construct_stub(
1219 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1213 } 1220 }
1214 1221
1215 { // -- R e g E x p 1222 { // -- R e g E x p
1216 // Builtin functions for RegExp.prototype. 1223 // Builtin functions for RegExp.prototype.
1217 Handle<JSFunction> regexp_fun = 1224 Handle<JSFunction> regexp_fun =
1218 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 1225 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
1219 isolate->initial_object_prototype(), 1226 isolate->initial_object_prototype(),
1220 Builtins::kIllegal); 1227 Builtins::kIllegal);
1221 native_context()->set_regexp_function(*regexp_fun); 1228 native_context()->set_regexp_function(*regexp_fun);
1222 1229
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 1841 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
1835 generator_function_prototype, NONE); 1842 generator_function_prototype, NONE);
1836 1843
1837 static const bool kUseStrictFunctionMap = true; 1844 static const bool kUseStrictFunctionMap = true;
1838 Handle<JSFunction> generator_function_function = 1845 Handle<JSFunction> generator_function_function =
1839 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE, 1846 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE,
1840 JSFunction::kSize, generator_function_prototype, 1847 JSFunction::kSize, generator_function_prototype,
1841 Builtins::kIllegal, kUseStrictFunctionMap); 1848 Builtins::kIllegal, kUseStrictFunctionMap);
1842 generator_function_function->initial_map()->set_is_callable(); 1849 generator_function_function->initial_map()->set_is_callable();
1843 generator_function_function->initial_map()->set_is_constructor(true); 1850 generator_function_function->initial_map()->set_is_constructor(true);
1851 generator_function_function->shared()->set_construct_stub(
1852 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1844 } 1853 }
1845 1854
1846 { // -- S e t I t e r a t o r 1855 { // -- S e t I t e r a t o r
1847 Handle<JSObject> set_iterator_prototype = 1856 Handle<JSObject> set_iterator_prototype =
1848 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 1857 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
1849 SetObjectPrototype(set_iterator_prototype, iterator_prototype); 1858 SetObjectPrototype(set_iterator_prototype, iterator_prototype);
1850 Handle<JSFunction> set_iterator_function = InstallFunction( 1859 Handle<JSFunction> set_iterator_function = InstallFunction(
1851 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 1860 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
1852 set_iterator_prototype, Builtins::kIllegal); 1861 set_iterator_prototype, Builtins::kIllegal);
1853 native_context->set_set_iterator_map(set_iterator_function->initial_map()); 1862 native_context->set_set_iterator_map(set_iterator_function->initial_map());
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION) 2193 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION)
2185 #undef SIMD128_INSTALL_FUNCTION 2194 #undef SIMD128_INSTALL_FUNCTION
2186 } 2195 }
2187 2196
2188 2197
2189 void Genesis::InitializeGlobal_harmony_proxies() { 2198 void Genesis::InitializeGlobal_harmony_proxies() {
2190 if (!FLAG_harmony_proxies) return; 2199 if (!FLAG_harmony_proxies) return;
2191 Handle<JSGlobalObject> global( 2200 Handle<JSGlobalObject> global(
2192 JSGlobalObject::cast(native_context()->global_object())); 2201 JSGlobalObject::cast(native_context()->global_object()));
2193 Isolate* isolate = global->GetIsolate(); 2202 Isolate* isolate = global->GetIsolate();
2194 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize, 2203 Handle<JSFunction> proxy_fun =
2195 isolate->initial_object_prototype(), Builtins::kIllegal); 2204 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize,
2205 isolate->initial_object_prototype(), Builtins::kIllegal);
2206 // TODO(verwaest): Set to null in InstallFunction.
2207 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value());
2208 proxy_fun->shared()->set_construct_stub(
2209 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
2210 native_context()->set_proxy_function(*proxy_fun);
2196 } 2211 }
2197 2212
2198 2213
2199 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, 2214 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
2200 const char* name, 2215 const char* name,
2201 ElementsKind elements_kind) { 2216 ElementsKind elements_kind) {
2202 // --- I n t e r n a l A r r a y --- 2217 // --- I n t e r n a l A r r a y ---
2203 // An array constructor on the builtins object that works like 2218 // An array constructor on the builtins object that works like
2204 // the public Array constructor, except that its prototype 2219 // the public Array constructor, except that its prototype
2205 // doesn't inherit from Object.prototype. 2220 // doesn't inherit from Object.prototype.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 DCHECK(call->is_compiled()); 2446 DCHECK(call->is_compiled());
2432 2447
2433 // Set the expected parameters for apply to 2; required by builtin. 2448 // Set the expected parameters for apply to 2; required by builtin.
2434 apply->shared()->set_internal_formal_parameter_count(2); 2449 apply->shared()->set_internal_formal_parameter_count(2);
2435 2450
2436 // Set the lengths for the functions to satisfy ECMA-262. 2451 // Set the lengths for the functions to satisfy ECMA-262.
2437 call->shared()->set_length(1); 2452 call->shared()->set_length(1);
2438 apply->shared()->set_length(2); 2453 apply->shared()->set_length(2);
2439 } 2454 }
2440 2455
2456 // Set up the Promise constructor.
2457 {
2458 Handle<String> key = factory()->Promise_string();
2459 Handle<JSFunction> function = Handle<JSFunction>::cast(
2460 Object::GetProperty(handle(native_context()->global_object()), key)
2461 .ToHandleChecked());
2462 JSFunction::EnsureHasInitialMap(function);
2463 function->initial_map()->set_instance_type(JS_PROMISE_TYPE);
2464 function->shared()->set_construct_stub(
2465 isolate()->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
2466 }
2467
2441 InstallBuiltinFunctionIds(); 2468 InstallBuiltinFunctionIds();
2442 2469
2443 // Create a constructor for RegExp results (a variant of Array that 2470 // Create a constructor for RegExp results (a variant of Array that
2444 // predefines the two properties index and match). 2471 // predefines the two properties index and match).
2445 { 2472 {
2446 // RegExpResult initial map. 2473 // RegExpResult initial map.
2447 2474
2448 // Find global.Array.prototype to inherit from. 2475 // Find global.Array.prototype to inherit from.
2449 Handle<JSFunction> array_constructor(native_context()->array_function()); 2476 Handle<JSFunction> array_constructor(native_context()->array_function());
2450 Handle<JSObject> array_prototype( 2477 Handle<JSObject> array_prototype(
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 } 3271 }
3245 3272
3246 3273
3247 // Called when the top-level V8 mutex is destroyed. 3274 // Called when the top-level V8 mutex is destroyed.
3248 void Bootstrapper::FreeThreadResources() { 3275 void Bootstrapper::FreeThreadResources() {
3249 DCHECK(!IsActive()); 3276 DCHECK(!IsActive());
3250 } 3277 }
3251 3278
3252 } // namespace internal 3279 } // namespace internal
3253 } // namespace v8 3280 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins.h » ('j') | src/runtime/runtime-classes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698