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