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 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 *isolate->builtins()->SymbolConstructor_ConstructStub()); | 1242 *isolate->builtins()->SymbolConstructor_ConstructStub()); |
1243 symbol_fun->shared()->set_length(1); | 1243 symbol_fun->shared()->set_length(1); |
1244 symbol_fun->shared()->DontAdaptArguments(); | 1244 symbol_fun->shared()->DontAdaptArguments(); |
1245 native_context()->set_symbol_function(*symbol_fun); | 1245 native_context()->set_symbol_function(*symbol_fun); |
1246 } | 1246 } |
1247 | 1247 |
1248 { // --- D a t e --- | 1248 { // --- D a t e --- |
1249 // Builtin functions for Date.prototype. | 1249 // Builtin functions for Date.prototype. |
1250 Handle<JSFunction> date_fun = InstallFunction( | 1250 Handle<JSFunction> date_fun = InstallFunction( |
1251 global, "Date", JS_DATE_TYPE, JSDate::kSize, | 1251 global, "Date", JS_DATE_TYPE, JSDate::kSize, |
1252 isolate->initial_object_prototype(), Builtins::kIllegal); | 1252 isolate->initial_object_prototype(), Builtins::kDateConstructor); |
1253 InstallWithIntrinsicDefaultProto(isolate, date_fun, | 1253 InstallWithIntrinsicDefaultProto(isolate, date_fun, |
1254 Context::DATE_FUNCTION_INDEX); | 1254 Context::DATE_FUNCTION_INDEX); |
1255 date_fun->shared()->set_construct_stub( | 1255 date_fun->shared()->set_construct_stub( |
1256 *isolate->builtins()->JSBuiltinsConstructStub()); | 1256 *isolate->builtins()->DateConstructor_ConstructStub()); |
| 1257 date_fun->shared()->set_length(7); |
| 1258 date_fun->shared()->DontAdaptArguments(); |
1257 } | 1259 } |
1258 | 1260 |
1259 { // -- R e g E x p | 1261 { // -- R e g E x p |
1260 // Builtin functions for RegExp.prototype. | 1262 // Builtin functions for RegExp.prototype. |
1261 Handle<JSFunction> regexp_fun = | 1263 Handle<JSFunction> regexp_fun = |
1262 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 1264 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
1263 isolate->initial_object_prototype(), | 1265 isolate->initial_object_prototype(), |
1264 Builtins::kIllegal); | 1266 Builtins::kIllegal); |
1265 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, | 1267 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, |
1266 Context::REGEXP_FUNCTION_INDEX); | 1268 Context::REGEXP_FUNCTION_INDEX); |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 2525 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
2524 | 2526 |
2525 // Install Global.eval. | 2527 // Install Global.eval. |
2526 { | 2528 { |
2527 Handle<JSFunction> eval = SimpleInstallFunction( | 2529 Handle<JSFunction> eval = SimpleInstallFunction( |
2528 handle(native_context()->global_object()), factory()->eval_string(), | 2530 handle(native_context()->global_object()), factory()->eval_string(), |
2529 Builtins::kGlobalEval, 1, false); | 2531 Builtins::kGlobalEval, 1, false); |
2530 native_context()->set_global_eval_fun(*eval); | 2532 native_context()->set_global_eval_fun(*eval); |
2531 } | 2533 } |
2532 | 2534 |
2533 // Install Date.prototype[@@toPrimitive]. | 2535 // Setup the Date constructor. |
2534 { | 2536 { |
2535 Handle<String> key = factory()->Date_string(); | 2537 Handle<String> key = factory()->Date_string(); |
2536 Handle<JSFunction> date = Handle<JSFunction>::cast( | 2538 Handle<JSFunction> date_fun = Handle<JSFunction>::cast( |
2537 Object::GetProperty(handle(native_context()->global_object()), key) | 2539 Object::GetProperty(handle(native_context()->global_object()), key) |
2538 .ToHandleChecked()); | 2540 .ToHandleChecked()); |
2539 Handle<JSObject> proto = | 2541 Handle<JSObject> prototype = |
2540 Handle<JSObject>(JSObject::cast(date->instance_prototype())); | 2542 Handle<JSObject>(JSObject::cast(date_fun->instance_prototype())); |
| 2543 |
| 2544 // Install the Date.now, Date.parse and Date.UTC functions. |
| 2545 SimpleInstallFunction(date_fun, "now", Builtins::kDateNow, 0, false); |
| 2546 SimpleInstallFunction(date_fun, "parse", Builtins::kDateParse, 1, false); |
| 2547 SimpleInstallFunction(date_fun, "UTC", Builtins::kDateUTC, 7, false); |
| 2548 |
| 2549 // Install the "constructor" property on the {prototype}. |
| 2550 JSObject::AddProperty(prototype, factory()->constructor_string(), date_fun, |
| 2551 DONT_ENUM); |
| 2552 |
| 2553 // Install the toISOString and valueOf functions. |
| 2554 SimpleInstallFunction(prototype, "toISOString", |
| 2555 Builtins::kDatePrototypeToISOString, 0, false); |
| 2556 SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf, |
| 2557 0, false); |
2541 | 2558 |
2542 // Install the @@toPrimitive function. | 2559 // Install the @@toPrimitive function. |
2543 Handle<JSFunction> to_primitive = | 2560 Handle<JSFunction> to_primitive = InstallFunction( |
2544 InstallFunction(proto, factory()->to_primitive_symbol(), JS_OBJECT_TYPE, | 2561 prototype, factory()->to_primitive_symbol(), JS_OBJECT_TYPE, |
2545 JSObject::kHeaderSize, MaybeHandle<JSObject>(), | 2562 JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
2546 Builtins::kDateToPrimitive, | 2563 Builtins::kDatePrototypeToPrimitive, |
2547 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 2564 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
2548 | 2565 |
2549 // Set the expected parameters for @@toPrimitive to 1; required by builtin. | 2566 // Set the expected parameters for @@toPrimitive to 1; required by builtin. |
2550 to_primitive->shared()->set_internal_formal_parameter_count(1); | 2567 to_primitive->shared()->set_internal_formal_parameter_count(1); |
2551 | 2568 |
2552 // Set the length for the function to satisfy ECMA-262. | 2569 // Set the length for the function to satisfy ECMA-262. |
2553 to_primitive->shared()->set_length(1); | 2570 to_primitive->shared()->set_length(1); |
2554 } | 2571 } |
2555 | 2572 |
2556 // Install Array.prototype.concat | 2573 // Install Array.prototype.concat |
2557 { | 2574 { |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 } | 3438 } |
3422 | 3439 |
3423 | 3440 |
3424 // Called when the top-level V8 mutex is destroyed. | 3441 // Called when the top-level V8 mutex is destroyed. |
3425 void Bootstrapper::FreeThreadResources() { | 3442 void Bootstrapper::FreeThreadResources() { |
3426 DCHECK(!IsActive()); | 3443 DCHECK(!IsActive()); |
3427 } | 3444 } |
3428 | 3445 |
3429 } // namespace internal | 3446 } // namespace internal |
3430 } // namespace v8 | 3447 } // namespace v8 |
OLD | NEW |