[Collections] Dont adapt args for constructors

Bug: v8:5717
Change-Id: I03579764656aa743bbc9bbf08e6affecd626d73d
Reviewed-on: https://chromium-review.googlesource.com/527338
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45787}
This commit is contained in:
Sathya Gunasekaran 2017-06-07 12:36:36 -07:00 committed by Commit Bot
parent 2c296b7eb3
commit 8c9ea5eda6
3 changed files with 26 additions and 14 deletions

View File

@ -2933,7 +2933,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<SharedFunctionInfo> shared(js_map_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->Map_string());
shared->set_internal_formal_parameter_count(1);
shared->DontAdaptArguments();
shared->set_length(0);
// Install the "constructor" property on the {prototype}.
@ -2970,7 +2970,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<SharedFunctionInfo> shared(js_set_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->Set_string());
shared->set_internal_formal_parameter_count(1);
shared->DontAdaptArguments();
shared->set_length(0);
// Install the "constructor" property on the {prototype}.

View File

@ -38,10 +38,16 @@ Node* CollectionsBuiltinsAssembler::AllocateJSCollection(
}
TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {
// TODO(gsathya): Don't use arguments adaptor
Node* const iterable = Parameter(Descriptor::kIterable);
Node* const new_target = Parameter(Descriptor::kNewTarget);
Node* const context = Parameter(Descriptor::kContext);
const int kIterableArg = 0;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* const iterable =
args.GetOptionalArgumentValue(kIterableArg, UndefinedConstant());
Node* const new_target = Parameter(BuiltinDescriptor::kNewTarget);
Node* const context = Parameter(BuiltinDescriptor::kContext);
Label if_target_is_undefined(this, Label::kDeferred);
GotoIf(IsUndefined(new_target), &if_target_is_undefined);
@ -155,14 +161,20 @@ TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {
}
BIND(&exit);
Return(var_result.value());
args.PopAndReturn(var_result.value());
}
TF_BUILTIN(SetConstructor, CollectionsBuiltinsAssembler) {
// TODO(gsathya): Don't use arguments adaptor
Node* const iterable = Parameter(Descriptor::kIterable);
Node* const new_target = Parameter(Descriptor::kNewTarget);
Node* const context = Parameter(Descriptor::kContext);
const int kIterableArg = 0;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* const iterable =
args.GetOptionalArgumentValue(kIterableArg, UndefinedConstant());
Node* const new_target = Parameter(BuiltinDescriptor::kNewTarget);
Node* const context = Parameter(BuiltinDescriptor::kContext);
Label if_target_is_undefined(this, Label::kDeferred);
GotoIf(IsUndefined(new_target), &if_target_is_undefined);
@ -258,7 +270,7 @@ TF_BUILTIN(SetConstructor, CollectionsBuiltinsAssembler) {
}
BIND(&exit);
Return(var_result.value());
args.PopAndReturn(var_result.value());
}
Node* CollectionsBuiltinsAssembler::CallGetRaw(Node* const table,

View File

@ -572,7 +572,7 @@ namespace internal {
LoadGlobal) \
\
/* Map */ \
TFJ(MapConstructor, 1, kIterable) \
TFJ(MapConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
TFJ(MapGet, 1, kKey) \
TFJ(MapHas, 1, kKey) \
\
@ -849,7 +849,7 @@ namespace internal {
TFJ(RegExpPrototypeSplit, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
\
/* Set */ \
TFJ(SetConstructor, 1, kIterable) \
TFJ(SetConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
TFJ(SetHas, 1, kKey) \
\
/* SharedArrayBuffer */ \