Commit d968ed29 authored by bmeurer's avatar bmeurer Committed by Commit Bot

[builtins] Don't adapt arguments for Object.create.

Object.create is most often called with a single parameter, the
prototype, and the properties are usually omitted. So optimizing
for the common case, we remove the argument adaption.

R=jgruber@chromium.org
BUG=v8:5989

Review-Url: https://codereview.chromium.org/2953913002
Cr-Commit-Position: refs/heads/master@{#46153}
parent a8273f7e
......@@ -1271,7 +1271,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> object_create =
SimpleInstallFunction(object_function, factory->create_string(),
Builtins::kObjectCreate, 2, true);
Builtins::kObjectCreate, 2, false);
native_context()->set_object_create(*object_create);
Handle<JSFunction> object_define_properties = SimpleInstallFunction(
......
......@@ -703,7 +703,7 @@ namespace internal {
/* Object */ \
CPP(ObjectAssign) \
/* ES #sec-object.create */ \
TFJ(ObjectCreate, 2, kPrototype, kProperties) \
TFJ(ObjectCreate, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
CPP(ObjectDefineGetter) \
CPP(ObjectDefineProperties) \
CPP(ObjectDefineProperty) \
......
......@@ -410,9 +410,16 @@ TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
// ES #sec-object.create
TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
Node* prototype = Parameter(Descriptor::kPrototype);
Node* properties = Parameter(Descriptor::kProperties);
Node* context = Parameter(Descriptor::kContext);
int const kPrototypeArg = 0;
int const kPropertiesArg = 1;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* prototype = args.GetOptionalArgumentValue(kPrototypeArg);
Node* properties = args.GetOptionalArgumentValue(kPropertiesArg);
Node* context = Parameter(BuiltinDescriptor::kContext);
Label call_runtime(this, Label::kDeferred), prototype_valid(this),
no_properties(this);
......@@ -483,13 +490,15 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
BIND(&instantiate_map);
{
Node* instance = AllocateJSObjectFromMap(map.value(), properties.value());
Return(instance);
args.PopAndReturn(instance);
}
}
BIND(&call_runtime);
{
Return(CallRuntime(Runtime::kObjectCreate, context, prototype, properties));
Node* result =
CallRuntime(Runtime::kObjectCreate, context, prototype, properties);
args.PopAndReturn(result);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment