Commit 1f7d80cd authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Add CSA types to SpeciesConstructor and GetSuperConstructor

Also changed the order of params so that context comes first to be more
consistent with other CSA helpers.

Change-Id: Ibf602dc7f3a148bed7fc0f93cc3dbc714febd786
Reviewed-on: https://chromium-review.googlesource.com/999513Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52441}
parent 223e0088
...@@ -1053,7 +1053,7 @@ TF_BUILTIN(GetSuperConstructor, ObjectBuiltinsAssembler) { ...@@ -1053,7 +1053,7 @@ TF_BUILTIN(GetSuperConstructor, ObjectBuiltinsAssembler) {
Node* object = Parameter(Descriptor::kObject); Node* object = Parameter(Descriptor::kObject);
Node* context = Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
Return(GetSuperConstructor(object, context)); Return(GetSuperConstructor(context, object));
} }
TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) { TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) {
......
...@@ -1995,7 +1995,7 @@ TNode<Object> RegExpBuiltinsAssembler::MatchAllIterator( ...@@ -1995,7 +1995,7 @@ TNode<Object> RegExpBuiltinsAssembler::MatchAllIterator(
TNode<Object> regexp_fun = TNode<Object> regexp_fun =
LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX); LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX);
TNode<Object> species_constructor = TNode<Object> species_constructor =
CAST(SpeciesConstructor(native_context, maybe_regexp, regexp_fun)); SpeciesConstructor(native_context, maybe_regexp, regexp_fun);
// b. Let flags be ? ToString(? Get(R, "flags")). // b. Let flags be ? ToString(? Get(R, "flags")).
// TODO(pwong): Add fast path to avoid property lookup. // TODO(pwong): Add fast path to avoid property lookup.
......
...@@ -866,8 +866,7 @@ TNode<Object> TypedArrayBuiltinsAssembler::TypedArraySpeciesConstructor( ...@@ -866,8 +866,7 @@ TNode<Object> TypedArrayBuiltinsAssembler::TypedArraySpeciesConstructor(
Branch(IsSpeciesProtectorCellInvalid(), &slow, &done); Branch(IsSpeciesProtectorCellInvalid(), &slow, &done);
BIND(&slow); BIND(&slow);
var_constructor = var_constructor = SpeciesConstructor(context, exemplar, default_constructor);
CAST(SpeciesConstructor(context, exemplar, default_constructor));
Goto(&done); Goto(&done);
BIND(&done); BIND(&done);
......
...@@ -10307,19 +10307,17 @@ Node* CodeStubAssembler::Typeof(Node* value) { ...@@ -10307,19 +10307,17 @@ Node* CodeStubAssembler::Typeof(Node* value) {
return result_var.value(); return result_var.value();
} }
Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, TNode<Object> CodeStubAssembler::GetSuperConstructor(
Node* context) { SloppyTNode<Context> context, SloppyTNode<JSFunction> active_function) {
CSA_ASSERT(this, IsJSFunction(active_function));
Label is_not_constructor(this, Label::kDeferred), out(this); Label is_not_constructor(this, Label::kDeferred), out(this);
VARIABLE(result, MachineRepresentation::kTagged); TVARIABLE(Object, result);
Node* map = LoadMap(active_function); TNode<Map> map = LoadMap(active_function);
Node* prototype = LoadMapPrototype(map); TNode<Object> prototype = LoadMapPrototype(map);
Node* prototype_map = LoadMap(prototype); TNode<Map> prototype_map = LoadMap(CAST(prototype));
GotoIfNot(IsConstructorMap(prototype_map), &is_not_constructor); GotoIfNot(IsConstructorMap(prototype_map), &is_not_constructor);
result.Bind(prototype); result = prototype;
Goto(&out); Goto(&out);
BIND(&is_not_constructor); BIND(&is_not_constructor);
...@@ -10333,14 +10331,14 @@ Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, ...@@ -10333,14 +10331,14 @@ Node* CodeStubAssembler::GetSuperConstructor(Node* active_function,
return result.value(); return result.value();
} }
Node* CodeStubAssembler::SpeciesConstructor(Node* context, Node* object, TNode<Object> CodeStubAssembler::SpeciesConstructor(
Node* default_constructor) { SloppyTNode<Context> context, SloppyTNode<Object> object,
SloppyTNode<Object> default_constructor) {
Isolate* isolate = this->isolate(); Isolate* isolate = this->isolate();
VARIABLE(var_result, MachineRepresentation::kTagged); TVARIABLE(Object, var_result, default_constructor);
var_result.Bind(default_constructor);
// 2. Let C be ? Get(O, "constructor"). // 2. Let C be ? Get(O, "constructor").
Node* const constructor = TNode<Object> constructor =
GetProperty(context, object, isolate->factory()->constructor_string()); GetProperty(context, object, isolate->factory()->constructor_string());
// 3. If C is undefined, return defaultConstructor. // 3. If C is undefined, return defaultConstructor.
...@@ -10352,7 +10350,7 @@ Node* CodeStubAssembler::SpeciesConstructor(Node* context, Node* object, ...@@ -10352,7 +10350,7 @@ Node* CodeStubAssembler::SpeciesConstructor(Node* context, Node* object,
MessageTemplate::kConstructorNotReceiver); MessageTemplate::kConstructorNotReceiver);
// 5. Let S be ? Get(C, @@species). // 5. Let S be ? Get(C, @@species).
Node* const species = TNode<Object> species =
GetProperty(context, constructor, isolate->factory()->species_symbol()); GetProperty(context, constructor, isolate->factory()->species_symbol());
// 6. If S is either undefined or null, return defaultConstructor. // 6. If S is either undefined or null, return defaultConstructor.
...@@ -10361,8 +10359,8 @@ Node* CodeStubAssembler::SpeciesConstructor(Node* context, Node* object, ...@@ -10361,8 +10359,8 @@ Node* CodeStubAssembler::SpeciesConstructor(Node* context, Node* object,
// 7. If IsConstructor(S) is true, return S. // 7. If IsConstructor(S) is true, return S.
Label throw_error(this); Label throw_error(this);
GotoIf(TaggedIsSmi(species), &throw_error); GotoIf(TaggedIsSmi(species), &throw_error);
GotoIfNot(IsConstructorMap(LoadMap(species)), &throw_error); GotoIfNot(IsConstructorMap(LoadMap(CAST(species))), &throw_error);
var_result.Bind(species); var_result = species;
Goto(&out); Goto(&out);
// 8. Throw a TypeError exception. // 8. Throw a TypeError exception.
......
...@@ -1960,10 +1960,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1960,10 +1960,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* Typeof(Node* value); Node* Typeof(Node* value);
Node* GetSuperConstructor(Node* value, Node* context); TNode<Object> GetSuperConstructor(SloppyTNode<Context> context,
SloppyTNode<JSFunction> active_function);
Node* SpeciesConstructor(Node* context, Node* object, TNode<Object> SpeciesConstructor(SloppyTNode<Context> context,
Node* default_constructor); SloppyTNode<Object> object,
SloppyTNode<Object> default_constructor);
Node* InstanceOf(Node* object, Node* callable, Node* context); Node* InstanceOf(Node* object, Node* callable, Node* context);
......
...@@ -1478,7 +1478,7 @@ IGNITION_HANDLER(DeletePropertySloppy, InterpreterAssembler) { ...@@ -1478,7 +1478,7 @@ IGNITION_HANDLER(DeletePropertySloppy, InterpreterAssembler) {
IGNITION_HANDLER(GetSuperConstructor, InterpreterAssembler) { IGNITION_HANDLER(GetSuperConstructor, InterpreterAssembler) {
Node* active_function = GetAccumulator(); Node* active_function = GetAccumulator();
Node* context = GetContext(); Node* context = GetContext();
Node* result = GetSuperConstructor(active_function, context); Node* result = GetSuperConstructor(context, active_function);
StoreRegisterAtOperandIndex(result, 0); StoreRegisterAtOperandIndex(result, 0);
Dispatch(); Dispatch();
} }
......
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