+ // Install Date.prototype[@@toPrimitive].
+ {
+ Handle<String> key = factory()->Date_string();
+ Handle<JSFunction> date = Handle<JSFunction>::cast(
+ Object::GetProperty(handle(native_context()->global_object()), key)
+ .ToHandleChecked());
+ Handle<JSObject> proto =
+ Handle<JSObject>(JSObject::cast(date->instance_prototype()));
+
+ // 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));
+
+ // Set the expected parameters for @@toPrimitive to 1; required by builtin.
+ to_primitive->shared()->set_internal_formal_parameter_count(1);
+
+ // Set the length for the function to satisfy ECMA-262.
+ to_primitive->shared()->set_length(1);
+ }
+