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

Side by Side Diff: src/bootstrapper.cc

Issue 1579613002: [builtins] Refactor the remaining Date builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months 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/builtins.h » ('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 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 2542
2543 // Install the Date.now, Date.parse and Date.UTC functions. 2543 // Install the Date.now, Date.parse and Date.UTC functions.
2544 SimpleInstallFunction(date_fun, "now", Builtins::kDateNow, 0, false); 2544 SimpleInstallFunction(date_fun, "now", Builtins::kDateNow, 0, false);
2545 SimpleInstallFunction(date_fun, "parse", Builtins::kDateParse, 1, false); 2545 SimpleInstallFunction(date_fun, "parse", Builtins::kDateParse, 1, false);
2546 SimpleInstallFunction(date_fun, "UTC", Builtins::kDateUTC, 7, false); 2546 SimpleInstallFunction(date_fun, "UTC", Builtins::kDateUTC, 7, false);
2547 2547
2548 // Install the "constructor" property on the {prototype}. 2548 // Install the "constructor" property on the {prototype}.
2549 JSObject::AddProperty(prototype, factory()->constructor_string(), date_fun, 2549 JSObject::AddProperty(prototype, factory()->constructor_string(), date_fun,
2550 DONT_ENUM); 2550 DONT_ENUM);
2551 2551
2552 // Install the toISOString and valueOf functions. 2552 // Install the Date.prototype methods.
2553 SimpleInstallFunction(prototype, "toString",
2554 Builtins::kDatePrototypeToString, 0, false);
2555 SimpleInstallFunction(prototype, "toDateString",
2556 Builtins::kDatePrototypeToDateString, 0, false);
2557 SimpleInstallFunction(prototype, "toTimeString",
2558 Builtins::kDatePrototypeToTimeString, 0, false);
2559 SimpleInstallFunction(prototype, "toGMTString",
2560 Builtins::kDatePrototypeToUTCString, 0, false);
2553 SimpleInstallFunction(prototype, "toISOString", 2561 SimpleInstallFunction(prototype, "toISOString",
2554 Builtins::kDatePrototypeToISOString, 0, false); 2562 Builtins::kDatePrototypeToISOString, 0, false);
2563 SimpleInstallFunction(prototype, "toUTCString",
2564 Builtins::kDatePrototypeToUTCString, 0, false);
2555 SimpleInstallFunction(prototype, "getDate", Builtins::kDatePrototypeGetDate, 2565 SimpleInstallFunction(prototype, "getDate", Builtins::kDatePrototypeGetDate,
2556 0, true); 2566 0, true);
2567 SimpleInstallFunction(prototype, "setDate", Builtins::kDatePrototypeSetDate,
2568 1, false);
2557 SimpleInstallFunction(prototype, "getDay", Builtins::kDatePrototypeGetDay, 2569 SimpleInstallFunction(prototype, "getDay", Builtins::kDatePrototypeGetDay,
2558 0, true); 2570 0, true);
2559 SimpleInstallFunction(prototype, "getFullYear", 2571 SimpleInstallFunction(prototype, "getFullYear",
2560 Builtins::kDatePrototypeGetFullYear, 0, true); 2572 Builtins::kDatePrototypeGetFullYear, 0, true);
2573 SimpleInstallFunction(prototype, "setFullYear",
2574 Builtins::kDatePrototypeSetFullYear, 3, false);
2561 SimpleInstallFunction(prototype, "getHours", 2575 SimpleInstallFunction(prototype, "getHours",
2562 Builtins::kDatePrototypeGetHours, 0, true); 2576 Builtins::kDatePrototypeGetHours, 0, true);
2577 SimpleInstallFunction(prototype, "setHours",
2578 Builtins::kDatePrototypeSetHours, 4, false);
2563 SimpleInstallFunction(prototype, "getMilliseconds", 2579 SimpleInstallFunction(prototype, "getMilliseconds",
2564 Builtins::kDatePrototypeGetMilliseconds, 0, true); 2580 Builtins::kDatePrototypeGetMilliseconds, 0, true);
2581 SimpleInstallFunction(prototype, "setMilliseconds",
2582 Builtins::kDatePrototypeSetMilliseconds, 1, false);
2565 SimpleInstallFunction(prototype, "getMinutes", 2583 SimpleInstallFunction(prototype, "getMinutes",
2566 Builtins::kDatePrototypeGetMinutes, 0, true); 2584 Builtins::kDatePrototypeGetMinutes, 0, true);
2585 SimpleInstallFunction(prototype, "setMinutes",
2586 Builtins::kDatePrototypeSetMinutes, 3, false);
2567 SimpleInstallFunction(prototype, "getMonth", 2587 SimpleInstallFunction(prototype, "getMonth",
2568 Builtins::kDatePrototypeGetMonth, 0, true); 2588 Builtins::kDatePrototypeGetMonth, 0, true);
2589 SimpleInstallFunction(prototype, "setMonth",
2590 Builtins::kDatePrototypeSetMonth, 2, false);
2569 SimpleInstallFunction(prototype, "getSeconds", 2591 SimpleInstallFunction(prototype, "getSeconds",
2570 Builtins::kDatePrototypeGetSeconds, 0, true); 2592 Builtins::kDatePrototypeGetSeconds, 0, true);
2593 SimpleInstallFunction(prototype, "setSeconds",
2594 Builtins::kDatePrototypeSetSeconds, 2, false);
2571 SimpleInstallFunction(prototype, "getTime", Builtins::kDatePrototypeGetTime, 2595 SimpleInstallFunction(prototype, "getTime", Builtins::kDatePrototypeGetTime,
2572 0, true); 2596 0, true);
2597 SimpleInstallFunction(prototype, "setTime", Builtins::kDatePrototypeSetTime,
2598 1, false);
2573 SimpleInstallFunction(prototype, "getTimezoneOffset", 2599 SimpleInstallFunction(prototype, "getTimezoneOffset",
2574 Builtins::kDatePrototypeGetTimezoneOffset, 0, true); 2600 Builtins::kDatePrototypeGetTimezoneOffset, 0, true);
2575 SimpleInstallFunction(prototype, "getUTCDate", 2601 SimpleInstallFunction(prototype, "getUTCDate",
2576 Builtins::kDatePrototypeGetUTCDate, 0, true); 2602 Builtins::kDatePrototypeGetUTCDate, 0, true);
2603 SimpleInstallFunction(prototype, "setUTCDate",
2604 Builtins::kDatePrototypeSetUTCDate, 1, false);
2577 SimpleInstallFunction(prototype, "getUTCDay", 2605 SimpleInstallFunction(prototype, "getUTCDay",
2578 Builtins::kDatePrototypeGetUTCDay, 0, true); 2606 Builtins::kDatePrototypeGetUTCDay, 0, true);
2579 SimpleInstallFunction(prototype, "getUTCFullYear", 2607 SimpleInstallFunction(prototype, "getUTCFullYear",
2580 Builtins::kDatePrototypeGetUTCFullYear, 0, true); 2608 Builtins::kDatePrototypeGetUTCFullYear, 0, true);
2609 SimpleInstallFunction(prototype, "setUTCFullYear",
2610 Builtins::kDatePrototypeSetUTCFullYear, 3, false);
2581 SimpleInstallFunction(prototype, "getUTCHours", 2611 SimpleInstallFunction(prototype, "getUTCHours",
2582 Builtins::kDatePrototypeGetUTCHours, 0, true); 2612 Builtins::kDatePrototypeGetUTCHours, 0, true);
2613 SimpleInstallFunction(prototype, "setUTCHours",
2614 Builtins::kDatePrototypeSetUTCHours, 4, false);
2583 SimpleInstallFunction(prototype, "getUTCMilliseconds", 2615 SimpleInstallFunction(prototype, "getUTCMilliseconds",
2584 Builtins::kDatePrototypeGetUTCMilliseconds, 0, true); 2616 Builtins::kDatePrototypeGetUTCMilliseconds, 0, true);
2617 SimpleInstallFunction(prototype, "setUTCMilliseconds",
2618 Builtins::kDatePrototypeSetUTCMilliseconds, 1, false);
2585 SimpleInstallFunction(prototype, "getUTCMinutes", 2619 SimpleInstallFunction(prototype, "getUTCMinutes",
2586 Builtins::kDatePrototypeGetUTCMinutes, 0, true); 2620 Builtins::kDatePrototypeGetUTCMinutes, 0, true);
2621 SimpleInstallFunction(prototype, "setUTCMinutes",
2622 Builtins::kDatePrototypeSetUTCMinutes, 3, false);
2587 SimpleInstallFunction(prototype, "getUTCMonth", 2623 SimpleInstallFunction(prototype, "getUTCMonth",
2588 Builtins::kDatePrototypeGetUTCMonth, 0, true); 2624 Builtins::kDatePrototypeGetUTCMonth, 0, true);
2625 SimpleInstallFunction(prototype, "setUTCMonth",
2626 Builtins::kDatePrototypeSetUTCMonth, 2, false);
2589 SimpleInstallFunction(prototype, "getUTCSeconds", 2627 SimpleInstallFunction(prototype, "getUTCSeconds",
2590 Builtins::kDatePrototypeGetUTCSeconds, 0, true); 2628 Builtins::kDatePrototypeGetUTCSeconds, 0, true);
2629 SimpleInstallFunction(prototype, "setUTCSeconds",
2630 Builtins::kDatePrototypeSetUTCSeconds, 2, false);
2591 SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf, 2631 SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf,
2592 0, false); 2632 0, false);
2633 SimpleInstallFunction(prototype, "getYear", Builtins::kDatePrototypeGetYear,
2634 0, true);
2635 SimpleInstallFunction(prototype, "setYear", Builtins::kDatePrototypeSetYear,
2636 1, false);
2637
2638 #ifndef V8_I18N_SUPPORT
2639 // Install i18n fallback functions.
2640 SimpleInstallFunction(prototype, "toLocaleString",
2641 Builtins::kDatePrototypeToString, 0, false);
2642 SimpleInstallFunction(prototype, "toLocaleDateString",
2643 Builtins::kDatePrototypeToDateString, 0, false);
2644 SimpleInstallFunction(prototype, "toLocaleTimeString",
2645 Builtins::kDatePrototypeToTimeString, 0, false);
2646 #endif // V8_I18N_SUPPORT
2593 2647
2594 // Install the @@toPrimitive function. 2648 // Install the @@toPrimitive function.
2595 Handle<JSFunction> to_primitive = InstallFunction( 2649 Handle<JSFunction> to_primitive = InstallFunction(
2596 prototype, factory()->to_primitive_symbol(), JS_OBJECT_TYPE, 2650 prototype, factory()->to_primitive_symbol(), JS_OBJECT_TYPE,
2597 JSObject::kHeaderSize, MaybeHandle<JSObject>(), 2651 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
2598 Builtins::kDatePrototypeToPrimitive, 2652 Builtins::kDatePrototypeToPrimitive,
2599 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 2653 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2600 2654
2601 // Set the expected parameters for @@toPrimitive to 1; required by builtin. 2655 // Set the expected parameters for @@toPrimitive to 1; required by builtin.
2602 to_primitive->shared()->set_internal_formal_parameter_count(1); 2656 to_primitive->shared()->set_internal_formal_parameter_count(1);
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 } 3525 }
3472 3526
3473 3527
3474 // Called when the top-level V8 mutex is destroyed. 3528 // Called when the top-level V8 mutex is destroyed.
3475 void Bootstrapper::FreeThreadResources() { 3529 void Bootstrapper::FreeThreadResources() {
3476 DCHECK(!IsActive()); 3530 DCHECK(!IsActive());
3477 } 3531 }
3478 3532
3479 } // namespace internal 3533 } // namespace internal
3480 } // namespace v8 3534 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins.h » ('j') | src/builtins.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698