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/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 array_function, isolate->factory()->InternalizeUtf8String("isArray"), | 1299 array_function, isolate->factory()->InternalizeUtf8String("isArray"), |
1300 Builtins::kArrayIsArray, 1, true); | 1300 Builtins::kArrayIsArray, 1, true); |
1301 native_context()->set_is_arraylike(*is_arraylike); | 1301 native_context()->set_is_arraylike(*is_arraylike); |
1302 } | 1302 } |
1303 | 1303 |
1304 { // --- N u m b e r --- | 1304 { // --- N u m b e r --- |
1305 Handle<JSFunction> number_fun = InstallFunction( | 1305 Handle<JSFunction> number_fun = InstallFunction( |
1306 global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 1306 global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
1307 isolate->initial_object_prototype(), Builtins::kNumberConstructor); | 1307 isolate->initial_object_prototype(), Builtins::kNumberConstructor); |
1308 number_fun->shared()->DontAdaptArguments(); | 1308 number_fun->shared()->DontAdaptArguments(); |
1309 number_fun->shared()->set_construct_stub( | 1309 Handle<Code> code = isolate->builtins()->NumberConstructor_ConstructStub(); |
1310 *isolate->builtins()->NumberConstructor_ConstructStub()); | 1310 code->set_is_construct_stub(true); // Mark as hand-written construct stub. |
1311 number_fun->shared()->set_construct_stub(*code); | |
1311 number_fun->shared()->set_length(1); | 1312 number_fun->shared()->set_length(1); |
1312 InstallWithIntrinsicDefaultProto(isolate, number_fun, | 1313 InstallWithIntrinsicDefaultProto(isolate, number_fun, |
1313 Context::NUMBER_FUNCTION_INDEX); | 1314 Context::NUMBER_FUNCTION_INDEX); |
1314 | 1315 |
1315 // Create the %NumberPrototype% | 1316 // Create the %NumberPrototype% |
1316 Handle<JSValue> prototype = | 1317 Handle<JSValue> prototype = |
1317 Handle<JSValue>::cast(factory->NewJSObject(number_fun, TENURED)); | 1318 Handle<JSValue>::cast(factory->NewJSObject(number_fun, TENURED)); |
1318 prototype->set_value(Smi::FromInt(0)); | 1319 prototype->set_value(Smi::FromInt(0)); |
1319 Accessors::FunctionSetPrototype(number_fun, prototype).Assert(); | 1320 Accessors::FunctionSetPrototype(number_fun, prototype).Assert(); |
1320 | 1321 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 SimpleInstallFunction(prototype, "toString", | 1366 SimpleInstallFunction(prototype, "toString", |
1366 Builtins::kBooleanPrototypeToString, 0, true); | 1367 Builtins::kBooleanPrototypeToString, 0, true); |
1367 SimpleInstallFunction(prototype, "valueOf", | 1368 SimpleInstallFunction(prototype, "valueOf", |
1368 Builtins::kBooleanPrototypeValueOf, 0, true); | 1369 Builtins::kBooleanPrototypeValueOf, 0, true); |
1369 } | 1370 } |
1370 | 1371 |
1371 { // --- S t r i n g --- | 1372 { // --- S t r i n g --- |
1372 Handle<JSFunction> string_fun = InstallFunction( | 1373 Handle<JSFunction> string_fun = InstallFunction( |
1373 global, "String", JS_VALUE_TYPE, JSValue::kSize, | 1374 global, "String", JS_VALUE_TYPE, JSValue::kSize, |
1374 isolate->initial_object_prototype(), Builtins::kStringConstructor); | 1375 isolate->initial_object_prototype(), Builtins::kStringConstructor); |
1375 string_fun->shared()->set_construct_stub( | 1376 Handle<Code> code = isolate->builtins()->StringConstructor_ConstructStub(); |
1376 *isolate->builtins()->StringConstructor_ConstructStub()); | 1377 code->set_is_construct_stub(true); |
1378 string_fun->shared()->set_construct_stub(*code); | |
Yang
2016/07/08 07:08:04
Would it make sense to introduce a SharedFunctionI
jgruber
2016/07/08 10:02:41
set_construct_stub is also called on non-builtin s
jgruber
2016/07/08 10:11:59
Disregard my previous comment, I did add SetConstr
| |
1377 string_fun->shared()->DontAdaptArguments(); | 1379 string_fun->shared()->DontAdaptArguments(); |
1378 string_fun->shared()->set_length(1); | 1380 string_fun->shared()->set_length(1); |
1379 InstallWithIntrinsicDefaultProto(isolate, string_fun, | 1381 InstallWithIntrinsicDefaultProto(isolate, string_fun, |
1380 Context::STRING_FUNCTION_INDEX); | 1382 Context::STRING_FUNCTION_INDEX); |
1381 | 1383 |
1382 Handle<Map> string_map = | 1384 Handle<Map> string_map = |
1383 Handle<Map>(native_context()->string_function()->initial_map()); | 1385 Handle<Map>(native_context()->string_function()->initial_map()); |
1384 string_map->set_elements_kind(FAST_STRING_WRAPPER_ELEMENTS); | 1386 string_map->set_elements_kind(FAST_STRING_WRAPPER_ELEMENTS); |
1385 Map::EnsureDescriptorSlack(string_map, 1); | 1387 Map::EnsureDescriptorSlack(string_map, 1); |
1386 | 1388 |
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4016 } | 4018 } |
4017 | 4019 |
4018 | 4020 |
4019 // Called when the top-level V8 mutex is destroyed. | 4021 // Called when the top-level V8 mutex is destroyed. |
4020 void Bootstrapper::FreeThreadResources() { | 4022 void Bootstrapper::FreeThreadResources() { |
4021 DCHECK(!IsActive()); | 4023 DCHECK(!IsActive()); |
4022 } | 4024 } |
4023 | 4025 |
4024 } // namespace internal | 4026 } // namespace internal |
4025 } // namespace v8 | 4027 } // namespace v8 |
OLD | NEW |