diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 5e90ba9784..64f5f26d0e 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2933,7 +2933,7 @@ void Genesis::InitializeGlobal(Handle global_object, Handle 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 global_object, Handle 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}. diff --git a/src/builtins/builtins-collections-gen.cc b/src/builtins/builtins-collections-gen.cc index 3a782f5fe2..2b78974437 100644 --- a/src/builtins/builtins-collections-gen.cc +++ b/src/builtins/builtins-collections-gen.cc @@ -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, diff --git a/src/builtins/builtins-definitions.h b/src/builtins/builtins-definitions.h index d0527b216e..bd0f9223ea 100644 --- a/src/builtins/builtins-definitions.h +++ b/src/builtins/builtins-definitions.h @@ -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 */ \