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, ...@@ -1271,7 +1271,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> object_create = Handle<JSFunction> object_create =
SimpleInstallFunction(object_function, factory->create_string(), SimpleInstallFunction(object_function, factory->create_string(),
Builtins::kObjectCreate, 2, true); Builtins::kObjectCreate, 2, false);
native_context()->set_object_create(*object_create); native_context()->set_object_create(*object_create);
Handle<JSFunction> object_define_properties = SimpleInstallFunction( Handle<JSFunction> object_define_properties = SimpleInstallFunction(
......
...@@ -703,7 +703,7 @@ namespace internal { ...@@ -703,7 +703,7 @@ namespace internal {
/* Object */ \ /* Object */ \
CPP(ObjectAssign) \ CPP(ObjectAssign) \
/* ES #sec-object.create */ \ /* ES #sec-object.create */ \
TFJ(ObjectCreate, 2, kPrototype, kProperties) \ TFJ(ObjectCreate, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
CPP(ObjectDefineGetter) \ CPP(ObjectDefineGetter) \
CPP(ObjectDefineProperties) \ CPP(ObjectDefineProperties) \
CPP(ObjectDefineProperty) \ CPP(ObjectDefineProperty) \
......
...@@ -410,9 +410,16 @@ TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) { ...@@ -410,9 +410,16 @@ TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
// ES #sec-object.create // ES #sec-object.create
TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
Node* prototype = Parameter(Descriptor::kPrototype); int const kPrototypeArg = 0;
Node* properties = Parameter(Descriptor::kProperties); int const kPropertiesArg = 1;
Node* context = Parameter(Descriptor::kContext);
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), Label call_runtime(this, Label::kDeferred), prototype_valid(this),
no_properties(this); no_properties(this);
...@@ -483,13 +490,15 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { ...@@ -483,13 +490,15 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
BIND(&instantiate_map); BIND(&instantiate_map);
{ {
Node* instance = AllocateJSObjectFromMap(map.value(), properties.value()); Node* instance = AllocateJSObjectFromMap(map.value(), properties.value());
Return(instance); args.PopAndReturn(instance);
} }
} }
BIND(&call_runtime); 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