| OLD | NEW |
| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name, | 389 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name, |
| 390 InstanceType type, int instance_size, | 390 InstanceType type, int instance_size, |
| 391 MaybeHandle<JSObject> maybe_prototype, | 391 MaybeHandle<JSObject> maybe_prototype, |
| 392 Builtins::Name call, | 392 Builtins::Name call, |
| 393 PropertyAttributes attributes, | 393 PropertyAttributes attributes, |
| 394 bool strict_function_map = false) { | 394 bool strict_function_map = false) { |
| 395 Isolate* isolate = target->GetIsolate(); | 395 Isolate* isolate = target->GetIsolate(); |
| 396 Factory* factory = isolate->factory(); | 396 Factory* factory = isolate->factory(); |
| 397 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); | 397 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); |
| 398 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 398 Handle<Code> call_code(isolate->builtins()->builtin(call)); |
| 399 Handle<JSObject> prototype; | 399 Handle<JSObject> prototype; |
| 400 static const bool kReadOnlyPrototype = false; | 400 static const bool kReadOnlyPrototype = false; |
| 401 static const bool kInstallConstructor = false; | 401 static const bool kInstallConstructor = false; |
| 402 Handle<JSFunction> function = | 402 Handle<JSFunction> function = |
| 403 maybe_prototype.ToHandle(&prototype) | 403 maybe_prototype.ToHandle(&prototype) |
| 404 ? factory->NewFunction(name_string, call_code, prototype, type, | 404 ? factory->NewFunction(name_string, call_code, prototype, type, |
| 405 instance_size, kReadOnlyPrototype, | 405 instance_size, kReadOnlyPrototype, |
| 406 kInstallConstructor, strict_function_map) | 406 kInstallConstructor, strict_function_map) |
| 407 : factory->NewFunctionWithoutPrototype(name_string, call_code, | 407 : factory->NewFunctionWithoutPrototype(name_string, call_code, |
| 408 strict_function_map); | 408 strict_function_map); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 .Assert(); | 550 .Assert(); |
| 551 | 551 |
| 552 // Allocate initial strong object map. | 552 // Allocate initial strong object map. |
| 553 Handle<Map> strong_object_map = | 553 Handle<Map> strong_object_map = |
| 554 Map::Copy(Handle<Map>(object_fun->initial_map()), "EmptyStrongObject"); | 554 Map::Copy(Handle<Map>(object_fun->initial_map()), "EmptyStrongObject"); |
| 555 strong_object_map->set_is_strong(); | 555 strong_object_map->set_is_strong(); |
| 556 native_context()->set_js_object_strong_map(*strong_object_map); | 556 native_context()->set_js_object_strong_map(*strong_object_map); |
| 557 } | 557 } |
| 558 | 558 |
| 559 // Allocate the empty function as the prototype for function - ES6 19.2.3 | 559 // Allocate the empty function as the prototype for function - ES6 19.2.3 |
| 560 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); | 560 Handle<Code> code(isolate->builtins()->EmptyFunction()); |
| 561 Handle<JSFunction> empty_function = | 561 Handle<JSFunction> empty_function = |
| 562 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); | 562 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); |
| 563 | 563 |
| 564 // Allocate the function map first and then patch the prototype later | 564 // Allocate the function map first and then patch the prototype later |
| 565 Handle<Map> empty_function_map = | 565 Handle<Map> empty_function_map = |
| 566 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); | 566 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); |
| 567 DCHECK(!empty_function_map->is_dictionary_map()); | 567 DCHECK(!empty_function_map->is_dictionary_map()); |
| 568 Map::SetPrototype(empty_function_map, object_function_prototype); | 568 Map::SetPrototype(empty_function_map, object_function_prototype); |
| 569 empty_function_map->set_is_prototype_map(true); | 569 empty_function_map->set_is_prototype_map(true); |
| 570 | 570 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 Handle<Object> proto_template(global_constructor->prototype_template(), | 966 Handle<Object> proto_template(global_constructor->prototype_template(), |
| 967 isolate()); | 967 isolate()); |
| 968 if (!proto_template->IsUndefined()) { | 968 if (!proto_template->IsUndefined()) { |
| 969 js_global_object_template = | 969 js_global_object_template = |
| 970 Handle<ObjectTemplateInfo>::cast(proto_template); | 970 Handle<ObjectTemplateInfo>::cast(proto_template); |
| 971 } | 971 } |
| 972 } | 972 } |
| 973 | 973 |
| 974 if (js_global_object_template.is_null()) { | 974 if (js_global_object_template.is_null()) { |
| 975 Handle<String> name = Handle<String>(heap()->empty_string()); | 975 Handle<String> name = Handle<String>(heap()->empty_string()); |
| 976 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 976 Handle<Code> code = isolate()->builtins()->Illegal(); |
| 977 Builtins::kIllegal)); | |
| 978 Handle<JSObject> prototype = | 977 Handle<JSObject> prototype = |
| 979 factory()->NewFunctionPrototype(isolate()->object_function()); | 978 factory()->NewFunctionPrototype(isolate()->object_function()); |
| 980 js_global_object_function = factory()->NewFunction( | 979 js_global_object_function = factory()->NewFunction( |
| 981 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); | 980 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); |
| 982 #ifdef DEBUG | 981 #ifdef DEBUG |
| 983 LookupIterator it(prototype, factory()->constructor_string(), | 982 LookupIterator it(prototype, factory()->constructor_string(), |
| 984 LookupIterator::OWN_SKIP_INTERCEPTOR); | 983 LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 985 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); | 984 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); |
| 986 DCHECK(it.IsFound()); | 985 DCHECK(it.IsFound()); |
| 987 DCHECK_EQ(*isolate()->object_function(), *value); | 986 DCHECK_EQ(*isolate()->object_function(), *value); |
| 988 #endif | 987 #endif |
| 989 } else { | 988 } else { |
| 990 Handle<FunctionTemplateInfo> js_global_object_constructor( | 989 Handle<FunctionTemplateInfo> js_global_object_constructor( |
| 991 FunctionTemplateInfo::cast(js_global_object_template->constructor())); | 990 FunctionTemplateInfo::cast(js_global_object_template->constructor())); |
| 992 js_global_object_function = ApiNatives::CreateApiFunction( | 991 js_global_object_function = ApiNatives::CreateApiFunction( |
| 993 isolate(), js_global_object_constructor, factory()->the_hole_value(), | 992 isolate(), js_global_object_constructor, factory()->the_hole_value(), |
| 994 ApiNatives::GlobalObjectType); | 993 ApiNatives::GlobalObjectType); |
| 995 } | 994 } |
| 996 | 995 |
| 997 js_global_object_function->initial_map()->set_is_prototype_map(true); | 996 js_global_object_function->initial_map()->set_is_prototype_map(true); |
| 998 js_global_object_function->initial_map()->set_is_hidden_prototype(); | 997 js_global_object_function->initial_map()->set_is_hidden_prototype(); |
| 999 js_global_object_function->initial_map()->set_dictionary_map(true); | 998 js_global_object_function->initial_map()->set_dictionary_map(true); |
| 1000 Handle<JSGlobalObject> global_object = | 999 Handle<JSGlobalObject> global_object = |
| 1001 factory()->NewJSGlobalObject(js_global_object_function); | 1000 factory()->NewJSGlobalObject(js_global_object_function); |
| 1002 | 1001 |
| 1003 // Step 2: (re)initialize the global proxy object. | 1002 // Step 2: (re)initialize the global proxy object. |
| 1004 Handle<JSFunction> global_proxy_function; | 1003 Handle<JSFunction> global_proxy_function; |
| 1005 if (global_proxy_template.IsEmpty()) { | 1004 if (global_proxy_template.IsEmpty()) { |
| 1006 Handle<String> name = Handle<String>(heap()->empty_string()); | 1005 Handle<String> name = Handle<String>(heap()->empty_string()); |
| 1007 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 1006 Handle<Code> code = isolate()->builtins()->Illegal(); |
| 1008 Builtins::kIllegal)); | |
| 1009 global_proxy_function = factory()->NewFunction( | 1007 global_proxy_function = factory()->NewFunction( |
| 1010 name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); | 1008 name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); |
| 1011 } else { | 1009 } else { |
| 1012 Handle<ObjectTemplateInfo> data = | 1010 Handle<ObjectTemplateInfo> data = |
| 1013 v8::Utils::OpenHandle(*global_proxy_template); | 1011 v8::Utils::OpenHandle(*global_proxy_template); |
| 1014 Handle<FunctionTemplateInfo> global_constructor( | 1012 Handle<FunctionTemplateInfo> global_constructor( |
| 1015 FunctionTemplateInfo::cast(data->constructor())); | 1013 FunctionTemplateInfo::cast(data->constructor())); |
| 1016 global_proxy_function = ApiNatives::CreateApiFunction( | 1014 global_proxy_function = ApiNatives::CreateApiFunction( |
| 1017 isolate(), global_constructor, factory()->the_hole_value(), | 1015 isolate(), global_constructor, factory()->the_hole_value(), |
| 1018 ApiNatives::GlobalProxyType); | 1016 ApiNatives::GlobalProxyType); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 | 1094 |
| 1097 Handle<JSObject> global(native_context()->global_object()); | 1095 Handle<JSObject> global(native_context()->global_object()); |
| 1098 | 1096 |
| 1099 // Install global Function object | 1097 // Install global Function object |
| 1100 Handle<JSFunction> function_function = | 1098 Handle<JSFunction> function_function = |
| 1101 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 1099 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1102 empty_function, Builtins::kIllegal); | 1100 empty_function, Builtins::kIllegal); |
| 1103 function_function->initial_map()->set_is_callable(); | 1101 function_function->initial_map()->set_is_callable(); |
| 1104 function_function->initial_map()->set_is_constructor(true); | 1102 function_function->initial_map()->set_is_constructor(true); |
| 1105 function_function->shared()->set_construct_stub( | 1103 function_function->shared()->set_construct_stub( |
| 1106 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1104 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1107 | 1105 |
| 1108 { // --- A r r a y --- | 1106 { // --- A r r a y --- |
| 1109 Handle<JSFunction> array_function = | 1107 Handle<JSFunction> array_function = |
| 1110 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 1108 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 1111 isolate->initial_object_prototype(), | 1109 isolate->initial_object_prototype(), |
| 1112 Builtins::kArrayCode); | 1110 Builtins::kArrayCode); |
| 1113 array_function->shared()->DontAdaptArguments(); | 1111 array_function->shared()->DontAdaptArguments(); |
| 1114 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); | 1112 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
| 1115 | 1113 |
| 1116 // This seems a bit hackish, but we need to make sure Array.length | 1114 // This seems a bit hackish, but we need to make sure Array.length |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 CacheInitialJSArrayMaps(native_context(), initial_strong_map); | 1152 CacheInitialJSArrayMaps(native_context(), initial_strong_map); |
| 1155 } | 1153 } |
| 1156 | 1154 |
| 1157 { // --- N u m b e r --- | 1155 { // --- N u m b e r --- |
| 1158 Handle<JSFunction> number_fun = | 1156 Handle<JSFunction> number_fun = |
| 1159 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 1157 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
| 1160 isolate->initial_object_prototype(), | 1158 isolate->initial_object_prototype(), |
| 1161 Builtins::kIllegal); | 1159 Builtins::kIllegal); |
| 1162 native_context()->set_number_function(*number_fun); | 1160 native_context()->set_number_function(*number_fun); |
| 1163 number_fun->shared()->set_construct_stub( | 1161 number_fun->shared()->set_construct_stub( |
| 1164 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1162 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1165 } | 1163 } |
| 1166 | 1164 |
| 1167 { // --- B o o l e a n --- | 1165 { // --- B o o l e a n --- |
| 1168 Handle<JSFunction> boolean_fun = | 1166 Handle<JSFunction> boolean_fun = |
| 1169 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, | 1167 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, |
| 1170 isolate->initial_object_prototype(), | 1168 isolate->initial_object_prototype(), |
| 1171 Builtins::kIllegal); | 1169 Builtins::kIllegal); |
| 1172 native_context()->set_boolean_function(*boolean_fun); | 1170 native_context()->set_boolean_function(*boolean_fun); |
| 1173 } | 1171 } |
| 1174 | 1172 |
| 1175 { // --- S t r i n g --- | 1173 { // --- S t r i n g --- |
| 1176 Handle<JSFunction> string_fun = InstallFunction( | 1174 Handle<JSFunction> string_fun = InstallFunction( |
| 1177 global, "String", JS_VALUE_TYPE, JSValue::kSize, | 1175 global, "String", JS_VALUE_TYPE, JSValue::kSize, |
| 1178 isolate->initial_object_prototype(), Builtins::kStringConstructor); | 1176 isolate->initial_object_prototype(), Builtins::kStringConstructor); |
| 1179 string_fun->shared()->set_construct_stub(isolate->builtins()->builtin( | 1177 string_fun->shared()->set_construct_stub( |
| 1180 Builtins::kStringConstructor_ConstructStub)); | 1178 *isolate->builtins()->StringConstructor_ConstructStub()); |
| 1181 string_fun->shared()->DontAdaptArguments(); | 1179 string_fun->shared()->DontAdaptArguments(); |
| 1182 string_fun->shared()->set_length(1); | 1180 string_fun->shared()->set_length(1); |
| 1183 native_context()->set_string_function(*string_fun); | 1181 native_context()->set_string_function(*string_fun); |
| 1184 | 1182 |
| 1185 Handle<Map> string_map = | 1183 Handle<Map> string_map = |
| 1186 Handle<Map>(native_context()->string_function()->initial_map()); | 1184 Handle<Map>(native_context()->string_function()->initial_map()); |
| 1187 Map::EnsureDescriptorSlack(string_map, 1); | 1185 Map::EnsureDescriptorSlack(string_map, 1); |
| 1188 | 1186 |
| 1189 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 1187 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 1190 DONT_ENUM | DONT_DELETE | READ_ONLY); | 1188 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 1191 Handle<AccessorInfo> string_length( | 1189 Handle<AccessorInfo> string_length( |
| 1192 Accessors::StringLengthInfo(isolate, attribs)); | 1190 Accessors::StringLengthInfo(isolate, attribs)); |
| 1193 | 1191 |
| 1194 { // Add length. | 1192 { // Add length. |
| 1195 AccessorConstantDescriptor d(factory->length_string(), string_length, | 1193 AccessorConstantDescriptor d(factory->length_string(), string_length, |
| 1196 attribs); | 1194 attribs); |
| 1197 string_map->AppendDescriptor(&d); | 1195 string_map->AppendDescriptor(&d); |
| 1198 } | 1196 } |
| 1199 } | 1197 } |
| 1200 | 1198 |
| 1201 { | 1199 { |
| 1202 // --- S y m b o l --- | 1200 // --- S y m b o l --- |
| 1203 Handle<JSFunction> symbol_fun = InstallFunction( | 1201 Handle<JSFunction> symbol_fun = InstallFunction( |
| 1204 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1202 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
| 1205 isolate->initial_object_prototype(), Builtins::kSymbolConstructor); | 1203 isolate->initial_object_prototype(), Builtins::kSymbolConstructor); |
| 1206 symbol_fun->shared()->set_construct_stub(isolate->builtins()->builtin( | 1204 symbol_fun->shared()->set_construct_stub( |
| 1207 Builtins::kSymbolConstructor_ConstructStub)); | 1205 *isolate->builtins()->SymbolConstructor_ConstructStub()); |
| 1208 symbol_fun->shared()->set_internal_formal_parameter_count(1); | 1206 symbol_fun->shared()->set_internal_formal_parameter_count(1); |
| 1209 symbol_fun->shared()->set_length(1); | 1207 symbol_fun->shared()->set_length(1); |
| 1210 native_context()->set_symbol_function(*symbol_fun); | 1208 native_context()->set_symbol_function(*symbol_fun); |
| 1211 } | 1209 } |
| 1212 | 1210 |
| 1213 { // --- D a t e --- | 1211 { // --- D a t e --- |
| 1214 // Builtin functions for Date.prototype. | 1212 // Builtin functions for Date.prototype. |
| 1215 Handle<JSFunction> date_fun = InstallFunction( | 1213 Handle<JSFunction> date_fun = InstallFunction( |
| 1216 global, "Date", JS_DATE_TYPE, JSDate::kSize, | 1214 global, "Date", JS_DATE_TYPE, JSDate::kSize, |
| 1217 isolate->initial_object_prototype(), Builtins::kIllegal); | 1215 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1218 date_fun->shared()->set_construct_stub( | 1216 date_fun->shared()->set_construct_stub( |
| 1219 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1217 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1220 } | 1218 } |
| 1221 | 1219 |
| 1222 { // -- R e g E x p | 1220 { // -- R e g E x p |
| 1223 // Builtin functions for RegExp.prototype. | 1221 // Builtin functions for RegExp.prototype. |
| 1224 Handle<JSFunction> regexp_fun = | 1222 Handle<JSFunction> regexp_fun = |
| 1225 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 1223 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
| 1226 isolate->initial_object_prototype(), | 1224 isolate->initial_object_prototype(), |
| 1227 Builtins::kIllegal); | 1225 Builtins::kIllegal); |
| 1228 native_context()->set_regexp_function(*regexp_fun); | 1226 native_context()->set_regexp_function(*regexp_fun); |
| 1229 regexp_fun->shared()->set_construct_stub( | 1227 regexp_fun->shared()->set_construct_stub( |
| 1230 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1228 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1231 | 1229 |
| 1232 DCHECK(regexp_fun->has_initial_map()); | 1230 DCHECK(regexp_fun->has_initial_map()); |
| 1233 Handle<Map> initial_map(regexp_fun->initial_map()); | 1231 Handle<Map> initial_map(regexp_fun->initial_map()); |
| 1234 | 1232 |
| 1235 DCHECK_EQ(0, initial_map->GetInObjectProperties()); | 1233 DCHECK_EQ(0, initial_map->GetInObjectProperties()); |
| 1236 | 1234 |
| 1237 Map::EnsureDescriptorSlack(initial_map, 1); | 1235 Map::EnsureDescriptorSlack(initial_map, 1); |
| 1238 | 1236 |
| 1239 // ECMA-262, section 15.10.7.5. | 1237 // ECMA-262, section 15.10.7.5. |
| 1240 PropertyAttributes writable = | 1238 PropertyAttributes writable = |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 #undef INSTALL_TYPED_ARRAY | 1299 #undef INSTALL_TYPED_ARRAY |
| 1302 | 1300 |
| 1303 Handle<JSFunction> data_view_fun = | 1301 Handle<JSFunction> data_view_fun = |
| 1304 InstallFunction( | 1302 InstallFunction( |
| 1305 global, "DataView", JS_DATA_VIEW_TYPE, | 1303 global, "DataView", JS_DATA_VIEW_TYPE, |
| 1306 JSDataView::kSizeWithInternalFields, | 1304 JSDataView::kSizeWithInternalFields, |
| 1307 isolate->initial_object_prototype(), | 1305 isolate->initial_object_prototype(), |
| 1308 Builtins::kIllegal); | 1306 Builtins::kIllegal); |
| 1309 native_context()->set_data_view_fun(*data_view_fun); | 1307 native_context()->set_data_view_fun(*data_view_fun); |
| 1310 data_view_fun->shared()->set_construct_stub( | 1308 data_view_fun->shared()->set_construct_stub( |
| 1311 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1309 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1312 } | 1310 } |
| 1313 | 1311 |
| 1314 { // -- M a p | 1312 { // -- M a p |
| 1315 Handle<JSFunction> js_map_fun = InstallFunction( | 1313 Handle<JSFunction> js_map_fun = InstallFunction( |
| 1316 global, "Map", JS_MAP_TYPE, JSMap::kSize, | 1314 global, "Map", JS_MAP_TYPE, JSMap::kSize, |
| 1317 isolate->initial_object_prototype(), Builtins::kIllegal); | 1315 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1318 native_context()->set_js_map_fun(*js_map_fun); | 1316 native_context()->set_js_map_fun(*js_map_fun); |
| 1319 } | 1317 } |
| 1320 | 1318 |
| 1321 { // -- S e t | 1319 { // -- S e t |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1352 isolate->initial_object_prototype(), Builtins::kIllegal); | 1350 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1353 // -- W e a k S e t | 1351 // -- W e a k S e t |
| 1354 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, | 1352 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, |
| 1355 isolate->initial_object_prototype(), Builtins::kIllegal); | 1353 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1356 | 1354 |
| 1357 { // --- sloppy arguments map | 1355 { // --- sloppy arguments map |
| 1358 // Make sure we can recognize argument objects at runtime. | 1356 // Make sure we can recognize argument objects at runtime. |
| 1359 // This is done by introducing an anonymous function with | 1357 // This is done by introducing an anonymous function with |
| 1360 // class_name equals 'Arguments'. | 1358 // class_name equals 'Arguments'. |
| 1361 Handle<String> arguments_string = factory->Arguments_string(); | 1359 Handle<String> arguments_string = factory->Arguments_string(); |
| 1362 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1360 Handle<Code> code = isolate->builtins()->Illegal(); |
| 1363 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( | 1361 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( |
| 1364 arguments_string, code); | 1362 arguments_string, code); |
| 1365 function->shared()->set_instance_class_name(*arguments_string); | 1363 function->shared()->set_instance_class_name(*arguments_string); |
| 1366 | 1364 |
| 1367 Handle<Map> map = factory->NewMap( | 1365 Handle<Map> map = factory->NewMap( |
| 1368 JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize, FAST_ELEMENTS); | 1366 JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize, FAST_ELEMENTS); |
| 1369 // Create the descriptor array for the arguments object. | 1367 // Create the descriptor array for the arguments object. |
| 1370 Map::EnsureDescriptorSlack(map, 2); | 1368 Map::EnsureDescriptorSlack(map, 2); |
| 1371 | 1369 |
| 1372 { // length | 1370 { // length |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 | 1455 |
| 1458 native_context()->set_strict_arguments_map(*map); | 1456 native_context()->set_strict_arguments_map(*map); |
| 1459 | 1457 |
| 1460 DCHECK(map->GetInObjectProperties() > Heap::kArgumentsLengthIndex); | 1458 DCHECK(map->GetInObjectProperties() > Heap::kArgumentsLengthIndex); |
| 1461 DCHECK(!map->is_dictionary_map()); | 1459 DCHECK(!map->is_dictionary_map()); |
| 1462 DCHECK(IsFastObjectElementsKind(map->elements_kind())); | 1460 DCHECK(IsFastObjectElementsKind(map->elements_kind())); |
| 1463 } | 1461 } |
| 1464 | 1462 |
| 1465 { // --- context extension | 1463 { // --- context extension |
| 1466 // Create a function for the context extension objects. | 1464 // Create a function for the context extension objects. |
| 1467 Handle<Code> code = Handle<Code>( | 1465 Handle<Code> code = isolate->builtins()->Illegal(); |
| 1468 isolate->builtins()->builtin(Builtins::kIllegal)); | |
| 1469 Handle<JSFunction> context_extension_fun = factory->NewFunction( | 1466 Handle<JSFunction> context_extension_fun = factory->NewFunction( |
| 1470 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 1467 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
| 1471 JSObject::kHeaderSize); | 1468 JSObject::kHeaderSize); |
| 1472 | 1469 |
| 1473 Handle<String> name = factory->InternalizeOneByteString( | 1470 Handle<String> name = factory->InternalizeOneByteString( |
| 1474 STATIC_CHAR_VECTOR("context_extension")); | 1471 STATIC_CHAR_VECTOR("context_extension")); |
| 1475 context_extension_fun->shared()->set_instance_class_name(*name); | 1472 context_extension_fun->shared()->set_instance_class_name(*name); |
| 1476 native_context()->set_context_extension_function(*context_extension_fun); | 1473 native_context()->set_context_extension_function(*context_extension_fun); |
| 1477 } | 1474 } |
| 1478 | 1475 |
| 1479 | 1476 |
| 1480 { | 1477 { |
| 1481 // Set up the call-as-function delegate. | 1478 // Set up the call-as-function delegate. |
| 1482 Handle<Code> code = | 1479 Handle<Code> code = isolate->builtins()->HandleApiCallAsFunction(); |
| 1483 Handle<Code>(isolate->builtins()->builtin( | |
| 1484 Builtins::kHandleApiCallAsFunction)); | |
| 1485 Handle<JSFunction> delegate = factory->NewFunction( | 1480 Handle<JSFunction> delegate = factory->NewFunction( |
| 1486 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1481 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 1487 native_context()->set_call_as_function_delegate(*delegate); | 1482 native_context()->set_call_as_function_delegate(*delegate); |
| 1488 delegate->shared()->DontAdaptArguments(); | 1483 delegate->shared()->DontAdaptArguments(); |
| 1489 } | 1484 } |
| 1490 | 1485 |
| 1491 { | 1486 { |
| 1492 // Set up the call-as-constructor delegate. | 1487 // Set up the call-as-constructor delegate. |
| 1493 Handle<Code> code = | 1488 Handle<Code> code = isolate->builtins()->HandleApiCallAsConstructor(); |
| 1494 Handle<Code>(isolate->builtins()->builtin( | |
| 1495 Builtins::kHandleApiCallAsConstructor)); | |
| 1496 Handle<JSFunction> delegate = factory->NewFunction( | 1489 Handle<JSFunction> delegate = factory->NewFunction( |
| 1497 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1490 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 1498 native_context()->set_call_as_constructor_delegate(*delegate); | 1491 native_context()->set_call_as_constructor_delegate(*delegate); |
| 1499 delegate->shared()->DontAdaptArguments(); | 1492 delegate->shared()->DontAdaptArguments(); |
| 1500 } | 1493 } |
| 1501 } | 1494 } |
| 1502 | 1495 |
| 1503 | 1496 |
| 1504 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, | 1497 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 1505 Handle<JSFunction>* fun) { | 1498 Handle<JSFunction>* fun) { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 generator_function_prototype, NONE); | 1821 generator_function_prototype, NONE); |
| 1829 | 1822 |
| 1830 static const bool kUseStrictFunctionMap = true; | 1823 static const bool kUseStrictFunctionMap = true; |
| 1831 Handle<JSFunction> generator_function_function = | 1824 Handle<JSFunction> generator_function_function = |
| 1832 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE, | 1825 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE, |
| 1833 JSFunction::kSize, generator_function_prototype, | 1826 JSFunction::kSize, generator_function_prototype, |
| 1834 Builtins::kIllegal, kUseStrictFunctionMap); | 1827 Builtins::kIllegal, kUseStrictFunctionMap); |
| 1835 generator_function_function->initial_map()->set_is_callable(); | 1828 generator_function_function->initial_map()->set_is_callable(); |
| 1836 generator_function_function->initial_map()->set_is_constructor(true); | 1829 generator_function_function->initial_map()->set_is_constructor(true); |
| 1837 generator_function_function->shared()->set_construct_stub( | 1830 generator_function_function->shared()->set_construct_stub( |
| 1838 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 1831 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 1839 } | 1832 } |
| 1840 | 1833 |
| 1841 { // -- S e t I t e r a t o r | 1834 { // -- S e t I t e r a t o r |
| 1842 Handle<JSObject> set_iterator_prototype = | 1835 Handle<JSObject> set_iterator_prototype = |
| 1843 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); | 1836 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); |
| 1844 SetObjectPrototype(set_iterator_prototype, iterator_prototype); | 1837 SetObjectPrototype(set_iterator_prototype, iterator_prototype); |
| 1845 Handle<JSFunction> set_iterator_function = InstallFunction( | 1838 Handle<JSFunction> set_iterator_function = InstallFunction( |
| 1846 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, | 1839 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, |
| 1847 set_iterator_prototype, Builtins::kIllegal); | 1840 set_iterator_prototype, Builtins::kIllegal); |
| 1848 native_context->set_set_iterator_map(set_iterator_function->initial_map()); | 1841 native_context->set_set_iterator_map(set_iterator_function->initial_map()); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 if (!FLAG_harmony_proxies) return; | 2180 if (!FLAG_harmony_proxies) return; |
| 2188 Handle<JSGlobalObject> global( | 2181 Handle<JSGlobalObject> global( |
| 2189 JSGlobalObject::cast(native_context()->global_object())); | 2182 JSGlobalObject::cast(native_context()->global_object())); |
| 2190 Isolate* isolate = global->GetIsolate(); | 2183 Isolate* isolate = global->GetIsolate(); |
| 2191 Handle<JSFunction> proxy_fun = | 2184 Handle<JSFunction> proxy_fun = |
| 2192 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize, | 2185 InstallFunction(global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize, |
| 2193 isolate->initial_object_prototype(), Builtins::kIllegal); | 2186 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 2194 // TODO(verwaest): Set to null in InstallFunction. | 2187 // TODO(verwaest): Set to null in InstallFunction. |
| 2195 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value()); | 2188 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value()); |
| 2196 proxy_fun->shared()->set_construct_stub( | 2189 proxy_fun->shared()->set_construct_stub( |
| 2197 isolate->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 2190 *isolate->builtins()->JSBuiltinsConstructStub()); |
| 2198 native_context()->set_proxy_function(*proxy_fun); | 2191 native_context()->set_proxy_function(*proxy_fun); |
| 2199 } | 2192 } |
| 2200 | 2193 |
| 2201 | 2194 |
| 2202 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 2195 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 2203 const char* name, | 2196 const char* name, |
| 2204 ElementsKind elements_kind) { | 2197 ElementsKind elements_kind) { |
| 2205 // --- I n t e r n a l A r r a y --- | 2198 // --- I n t e r n a l A r r a y --- |
| 2206 // An array constructor on the builtins object that works like | 2199 // An array constructor on the builtins object that works like |
| 2207 // the public Array constructor, except that its prototype | 2200 // the public Array constructor, except that its prototype |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 | 2436 |
| 2444 // Set up the Promise constructor. | 2437 // Set up the Promise constructor. |
| 2445 { | 2438 { |
| 2446 Handle<String> key = factory()->Promise_string(); | 2439 Handle<String> key = factory()->Promise_string(); |
| 2447 Handle<JSFunction> function = Handle<JSFunction>::cast( | 2440 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 2448 Object::GetProperty(handle(native_context()->global_object()), key) | 2441 Object::GetProperty(handle(native_context()->global_object()), key) |
| 2449 .ToHandleChecked()); | 2442 .ToHandleChecked()); |
| 2450 JSFunction::EnsureHasInitialMap(function); | 2443 JSFunction::EnsureHasInitialMap(function); |
| 2451 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); | 2444 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); |
| 2452 function->shared()->set_construct_stub( | 2445 function->shared()->set_construct_stub( |
| 2453 isolate()->builtins()->builtin(Builtins::kJSBuiltinsConstructStub)); | 2446 *isolate()->builtins()->JSBuiltinsConstructStub()); |
| 2454 } | 2447 } |
| 2455 | 2448 |
| 2456 InstallBuiltinFunctionIds(); | 2449 InstallBuiltinFunctionIds(); |
| 2457 | 2450 |
| 2458 // Create a constructor for RegExp results (a variant of Array that | 2451 // Create a constructor for RegExp results (a variant of Array that |
| 2459 // predefines the two properties index and match). | 2452 // predefines the two properties index and match). |
| 2460 { | 2453 { |
| 2461 // RegExpResult initial map. | 2454 // RegExpResult initial map. |
| 2462 | 2455 |
| 2463 // Find global.Array.prototype to inherit from. | 2456 // Find global.Array.prototype to inherit from. |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 } | 3252 } |
| 3260 | 3253 |
| 3261 | 3254 |
| 3262 // Called when the top-level V8 mutex is destroyed. | 3255 // Called when the top-level V8 mutex is destroyed. |
| 3263 void Bootstrapper::FreeThreadResources() { | 3256 void Bootstrapper::FreeThreadResources() { |
| 3264 DCHECK(!IsActive()); | 3257 DCHECK(!IsActive()); |
| 3265 } | 3258 } |
| 3266 | 3259 |
| 3267 } // namespace internal | 3260 } // namespace internal |
| 3268 } // namespace v8 | 3261 } // namespace v8 |
| OLD | NEW |