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

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 | « src/arm64/builtins-arm64.cc ('k') | src/builtins.h » ('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/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);
1229 regexp_fun->shared()->set_construct_stub(
1230 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1222 1231
1223 DCHECK(regexp_fun->has_initial_map()); 1232 DCHECK(regexp_fun->has_initial_map());
1224 Handle<Map> initial_map(regexp_fun->initial_map()); 1233 Handle<Map> initial_map(regexp_fun->initial_map());
1225 1234
1226 DCHECK_EQ(0, initial_map->GetInObjectProperties()); 1235 DCHECK_EQ(0, initial_map->GetInObjectProperties());
1227 1236
1228 Map::EnsureDescriptorSlack(initial_map, 1); 1237 Map::EnsureDescriptorSlack(initial_map, 1);
1229 1238
1230 // ECMA-262, section 15.10.7.5. 1239 // ECMA-262, section 15.10.7.5.
1231 PropertyAttributes writable = 1240 PropertyAttributes writable =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) 1300 TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
1292 #undef INSTALL_TYPED_ARRAY 1301 #undef INSTALL_TYPED_ARRAY
1293 1302
1294 Handle<JSFunction> data_view_fun = 1303 Handle<JSFunction> data_view_fun =
1295 InstallFunction( 1304 InstallFunction(
1296 global, "DataView", JS_DATA_VIEW_TYPE, 1305 global, "DataView", JS_DATA_VIEW_TYPE,
1297 JSDataView::kSizeWithInternalFields, 1306 JSDataView::kSizeWithInternalFields,
1298 isolate->initial_object_prototype(), 1307 isolate->initial_object_prototype(),
1299 Builtins::kIllegal); 1308 Builtins::kIllegal);
1300 native_context()->set_data_view_fun(*data_view_fun); 1309 native_context()->set_data_view_fun(*data_view_fun);
1310 data_view_fun->shared()->set_construct_stub(
1311 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1301 } 1312 }
1302 1313
1303 { // -- M a p 1314 { // -- M a p
1304 Handle<JSFunction> js_map_fun = InstallFunction( 1315 Handle<JSFunction> js_map_fun = InstallFunction(
1305 global, "Map", JS_MAP_TYPE, JSMap::kSize, 1316 global, "Map", JS_MAP_TYPE, JSMap::kSize,
1306 isolate->initial_object_prototype(), Builtins::kIllegal); 1317 isolate->initial_object_prototype(), Builtins::kIllegal);
1307 native_context()->set_js_map_fun(*js_map_fun); 1318 native_context()->set_js_map_fun(*js_map_fun);
1308 } 1319 }
1309 1320
1310 { // -- S e t 1321 { // -- S e t
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 1845 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
1835 generator_function_prototype, NONE); 1846 generator_function_prototype, NONE);
1836 1847
1837 static const bool kUseStrictFunctionMap = true; 1848 static const bool kUseStrictFunctionMap = true;
1838 Handle<JSFunction> generator_function_function = 1849 Handle<JSFunction> generator_function_function =
1839 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE, 1850 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE,
1840 JSFunction::kSize, generator_function_prototype, 1851 JSFunction::kSize, generator_function_prototype,
1841 Builtins::kIllegal, kUseStrictFunctionMap); 1852 Builtins::kIllegal, kUseStrictFunctionMap);
1842 generator_function_function->initial_map()->set_is_callable(); 1853 generator_function_function->initial_map()->set_is_callable();
1843 generator_function_function->initial_map()->set_is_constructor(true); 1854 generator_function_function->initial_map()->set_is_constructor(true);
1855 generator_function_function->shared()->set_construct_stub(
1856 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
1844 } 1857 }
1845 1858
1846 { // -- S e t I t e r a t o r 1859 { // -- S e t I t e r a t o r
1847 Handle<JSObject> set_iterator_prototype = 1860 Handle<JSObject> set_iterator_prototype =
1848 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 1861 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
1849 SetObjectPrototype(set_iterator_prototype, iterator_prototype); 1862 SetObjectPrototype(set_iterator_prototype, iterator_prototype);
1850 Handle<JSFunction> set_iterator_function = InstallFunction( 1863 Handle<JSFunction> set_iterator_function = InstallFunction(
1851 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 1864 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
1852 set_iterator_prototype, Builtins::kIllegal); 1865 set_iterator_prototype, Builtins::kIllegal);
1853 native_context->set_set_iterator_map(set_iterator_function->initial_map()); 1866 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) 2197 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION)
2185 #undef SIMD128_INSTALL_FUNCTION 2198 #undef SIMD128_INSTALL_FUNCTION
2186 } 2199 }
2187 2200
2188 2201
2189 void Genesis::InitializeGlobal_harmony_proxies() { 2202 void Genesis::InitializeGlobal_harmony_proxies() {
2190 if (!FLAG_harmony_proxies) return; 2203 if (!FLAG_harmony_proxies) return;
2191 Handle<JSGlobalObject> global( 2204 Handle<JSGlobalObject> global(
2192 JSGlobalObject::cast(native_context()->global_object())); 2205 JSGlobalObject::cast(native_context()->global_object()));
2193 Isolate* isolate = global->GetIsolate(); 2206 Isolate* isolate = global->GetIsolate();
2194 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize, 2207 Handle<JSFunction> proxy_fun =
2195 isolate->initial_object_prototype(), Builtins::kIllegal); 2208 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize,
2209 isolate->initial_object_prototype(), Builtins::kIllegal);
2210 // TODO(verwaest): Set to null in InstallFunction.
2211 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value());
2212 proxy_fun->shared()->set_construct_stub(
2213 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
2214 native_context()->set_proxy_function(*proxy_fun);
2196 } 2215 }
2197 2216
2198 2217
2199 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, 2218 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
2200 const char* name, 2219 const char* name,
2201 ElementsKind elements_kind) { 2220 ElementsKind elements_kind) {
2202 // --- I n t e r n a l A r r a y --- 2221 // --- I n t e r n a l A r r a y ---
2203 // An array constructor on the builtins object that works like 2222 // An array constructor on the builtins object that works like
2204 // the public Array constructor, except that its prototype 2223 // the public Array constructor, except that its prototype
2205 // doesn't inherit from Object.prototype. 2224 // doesn't inherit from Object.prototype.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 DCHECK(call->is_compiled()); 2450 DCHECK(call->is_compiled());
2432 2451
2433 // Set the expected parameters for apply to 2; required by builtin. 2452 // Set the expected parameters for apply to 2; required by builtin.
2434 apply->shared()->set_internal_formal_parameter_count(2); 2453 apply->shared()->set_internal_formal_parameter_count(2);
2435 2454
2436 // Set the lengths for the functions to satisfy ECMA-262. 2455 // Set the lengths for the functions to satisfy ECMA-262.
2437 call->shared()->set_length(1); 2456 call->shared()->set_length(1);
2438 apply->shared()->set_length(2); 2457 apply->shared()->set_length(2);
2439 } 2458 }
2440 2459
2460 // Set up the Promise constructor.
2461 {
2462 Handle<String> key = factory()->Promise_string();
2463 Handle<JSFunction> function = Handle<JSFunction>::cast(
2464 Object::GetProperty(handle(native_context()->global_object()), key)
2465 .ToHandleChecked());
2466 JSFunction::EnsureHasInitialMap(function);
2467 function->initial_map()->set_instance_type(JS_PROMISE_TYPE);
2468 function->shared()->set_construct_stub(
2469 isolate()->builtins()->builtin(Builtins::kJSBuiltinsConstructStub));
2470 }
2471
2441 InstallBuiltinFunctionIds(); 2472 InstallBuiltinFunctionIds();
2442 2473
2443 // Create a constructor for RegExp results (a variant of Array that 2474 // Create a constructor for RegExp results (a variant of Array that
2444 // predefines the two properties index and match). 2475 // predefines the two properties index and match).
2445 { 2476 {
2446 // RegExpResult initial map. 2477 // RegExpResult initial map.
2447 2478
2448 // Find global.Array.prototype to inherit from. 2479 // Find global.Array.prototype to inherit from.
2449 Handle<JSFunction> array_constructor(native_context()->array_function()); 2480 Handle<JSFunction> array_constructor(native_context()->array_function());
2450 Handle<JSObject> array_prototype( 2481 Handle<JSObject> array_prototype(
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 } 3275 }
3245 3276
3246 3277
3247 // Called when the top-level V8 mutex is destroyed. 3278 // Called when the top-level V8 mutex is destroyed.
3248 void Bootstrapper::FreeThreadResources() { 3279 void Bootstrapper::FreeThreadResources() {
3249 DCHECK(!IsActive()); 3280 DCHECK(!IsActive());
3250 } 3281 }
3251 3282
3252 } // namespace internal 3283 } // namespace internal
3253 } // namespace v8 3284 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698