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

Unified Diff: src/bootstrapper.cc

Issue 1556333002: [runtime] Migrate several Date builtins to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | src/builtins.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index eba1be88717ef0a490e668a50dff762d537c3f4d..9608bbd053a331b8fb2832c06e50311aad78c68d 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1249,11 +1249,13 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// Builtin functions for Date.prototype.
Handle<JSFunction> date_fun = InstallFunction(
global, "Date", JS_DATE_TYPE, JSDate::kSize,
- isolate->initial_object_prototype(), Builtins::kIllegal);
+ isolate->initial_object_prototype(), Builtins::kDateConstructor);
InstallWithIntrinsicDefaultProto(isolate, date_fun,
Context::DATE_FUNCTION_INDEX);
date_fun->shared()->set_construct_stub(
- *isolate->builtins()->JSBuiltinsConstructStub());
+ *isolate->builtins()->DateConstructor_ConstructStub());
+ date_fun->shared()->set_length(7);
+ date_fun->shared()->DontAdaptArguments();
}
{ // -- R e g E x p
@@ -2530,21 +2532,36 @@ bool Genesis::InstallNatives(ContextType context_type) {
native_context()->set_global_eval_fun(*eval);
}
- // Install Date.prototype[@@toPrimitive].
+ // Setup the Date constructor.
{
Handle<String> key = factory()->Date_string();
- Handle<JSFunction> date = Handle<JSFunction>::cast(
+ Handle<JSFunction> date_fun = Handle<JSFunction>::cast(
Object::GetProperty(handle(native_context()->global_object()), key)
.ToHandleChecked());
- Handle<JSObject> proto =
- Handle<JSObject>(JSObject::cast(date->instance_prototype()));
+ Handle<JSObject> prototype =
+ Handle<JSObject>(JSObject::cast(date_fun->instance_prototype()));
+
+ // Install the Date.now, Date.parse and Date.UTC functions.
+ SimpleInstallFunction(date_fun, "now", Builtins::kDateNow, 0, false);
+ SimpleInstallFunction(date_fun, "parse", Builtins::kDateParse, 1, false);
+ SimpleInstallFunction(date_fun, "UTC", Builtins::kDateUTC, 7, false);
+
+ // Install the "constructor" property on the {prototype}.
+ JSObject::AddProperty(prototype, factory()->constructor_string(), date_fun,
+ DONT_ENUM);
+
+ // Install the toISOString and valueOf functions.
+ SimpleInstallFunction(prototype, "toISOString",
+ Builtins::kDatePrototypeToISOString, 0, false);
+ SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf,
+ 0, false);
// Install the @@toPrimitive function.
- Handle<JSFunction> to_primitive =
- InstallFunction(proto, factory()->to_primitive_symbol(), JS_OBJECT_TYPE,
- JSObject::kHeaderSize, MaybeHandle<JSObject>(),
- Builtins::kDateToPrimitive,
- static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
+ Handle<JSFunction> to_primitive = InstallFunction(
+ prototype, factory()->to_primitive_symbol(), JS_OBJECT_TYPE,
+ JSObject::kHeaderSize, MaybeHandle<JSObject>(),
+ Builtins::kDatePrototypeToPrimitive,
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
// Set the expected parameters for @@toPrimitive to 1; required by builtin.
to_primitive->shared()->set_internal_formal_parameter_count(1);
« no previous file with comments | « src/api.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698