Commit 50f58ea6 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[cleanup] Unifying instance type checks in CSA

Bug: v8:6921
Change-Id: I7602cd68aec6e91e6e59ed78a5e27196e2d28835
Reviewed-on: https://chromium-review.googlesource.com/718101Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48542}
parent ab0266e2
......@@ -1686,12 +1686,11 @@ TF_BUILTIN(ArrayIsArray, CodeStubAssembler) {
GotoIf(TaggedIsSmi(object), &return_false);
TNode<Word32T> instance_type = LoadInstanceType(CAST(object));
GotoIf(Word32Equal(instance_type, Int32Constant(JS_ARRAY_TYPE)),
&return_true);
GotoIf(InstanceTypeEqual(instance_type, JS_ARRAY_TYPE), &return_true);
// TODO(verwaest): Handle proxies in-place.
Branch(Word32Equal(instance_type, Int32Constant(JS_PROXY_TYPE)),
&call_runtime, &return_false);
Branch(InstanceTypeEqual(instance_type, JS_PROXY_TYPE), &call_runtime,
&return_false);
BIND(&return_true);
Return(BooleanConstant(true));
......@@ -2291,8 +2290,8 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
GotoIf(WordEqual(array, UndefinedConstant()), &allocate_iterator_result);
Node* array_type = LoadInstanceType(array);
Branch(Word32Equal(array_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
&if_istypedarray, &if_isgeneric);
Branch(InstanceTypeEqual(array_type, JS_TYPED_ARRAY_TYPE), &if_istypedarray,
&if_isgeneric);
BIND(&if_isgeneric);
{
......@@ -2302,8 +2301,8 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
{
VARIABLE(var_length, MachineRepresentation::kTagged);
Label if_isarray(this), if_isnotarray(this), done(this);
Branch(Word32Equal(array_type, Int32Constant(JS_ARRAY_TYPE)),
&if_isarray, &if_isnotarray);
Branch(InstanceTypeEqual(array_type, JS_ARRAY_TYPE), &if_isarray,
&if_isnotarray);
BIND(&if_isarray);
{
......
......@@ -29,8 +29,8 @@ void DateBuiltinsAssembler::Generate_DatePrototype_GetField(Node* context,
GotoIf(TaggedIsSmi(receiver), &receiver_not_date);
Node* receiver_instance_type = LoadInstanceType(receiver);
GotoIf(Word32NotEqual(receiver_instance_type, Int32Constant(JS_DATE_TYPE)),
&receiver_not_date);
GotoIfNot(InstanceTypeEqual(receiver_instance_type, JS_DATE_TYPE),
&receiver_not_date);
// Load the specified date field, falling back to the runtime as necessary.
if (field_index == JSDate::kDateValue) {
......
......@@ -31,8 +31,7 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
Label if_receiverisincompatible(this, Label::kDeferred);
GotoIf(TaggedIsSmi(receiver), &if_receiverisincompatible);
Node* receiver_instance_type = LoadInstanceType(receiver);
GotoIfNot(Word32Equal(receiver_instance_type,
Int32Constant(JS_GENERATOR_OBJECT_TYPE)),
GotoIfNot(InstanceTypeEqual(receiver_instance_type, JS_GENERATOR_OBJECT_TYPE),
&if_receiverisincompatible);
// Check if the {receiver} is running or already closed.
......
......@@ -46,9 +46,8 @@ void SharedArrayBufferBuiltinsAssembler::ValidateSharedTypedArray(
GotoIf(TaggedIsSmi(tagged), &invalid);
// Fail if the array's instance type is not JSTypedArray.
GotoIf(Word32NotEqual(LoadInstanceType(tagged),
Int32Constant(JS_TYPED_ARRAY_TYPE)),
&invalid);
GotoIfNot(InstanceTypeEqual(LoadInstanceType(tagged), JS_TYPED_ARRAY_TYPE),
&invalid);
// Fail if the array's JSArrayBuffer is not shared.
Node* array_buffer = LoadObjectField(tagged, JSTypedArray::kBufferOffset);
......
......@@ -2206,9 +2206,9 @@ TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
Node* iterator = Parameter(Descriptor::kReceiver);
GotoIf(TaggedIsSmi(iterator), &throw_bad_receiver);
GotoIfNot(Word32Equal(LoadInstanceType(iterator),
Int32Constant(JS_STRING_ITERATOR_TYPE)),
&throw_bad_receiver);
GotoIfNot(
InstanceTypeEqual(LoadInstanceType(iterator), JS_STRING_ITERATOR_TYPE),
&throw_bad_receiver);
Node* string = LoadObjectField(iterator, JSStringIterator::kStringOffset);
Node* position =
......
......@@ -1204,7 +1204,7 @@ TNode<Int32T> CodeStubAssembler::LoadInstanceType(
Node* CodeStubAssembler::HasInstanceType(Node* object,
InstanceType instance_type) {
return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type));
return InstanceTypeEqual(LoadInstanceType(object), instance_type);
}
Node* CodeStubAssembler::DoesntHaveInstanceType(Node* object,
......@@ -1235,10 +1235,8 @@ TNode<Int32T> CodeStubAssembler::LoadHashForJSObject(
Node* type = LoadInstanceType(properties_or_hash);
Label if_property_array(this), if_property_dictionary(this), done(this);
GotoIf(Word32Equal(type, Int32Constant(PROPERTY_ARRAY_TYPE)),
&if_property_array);
GotoIf(Word32Equal(type, Int32Constant(HASH_TABLE_TYPE)),
&if_property_dictionary);
GotoIf(InstanceTypeEqual(type, PROPERTY_ARRAY_TYPE), &if_property_array);
GotoIf(InstanceTypeEqual(type, HASH_TABLE_TYPE), &if_property_dictionary);
var_hash.Bind(Int32Constant(PropertyArray::kNoHashSentinel));
Goto(&done);
......@@ -1417,7 +1415,7 @@ TNode<Object> CodeStubAssembler::LoadMapConstructor(SloppyTNode<Map> map) {
{
GotoIf(TaggedIsSmi(result), &done);
Node* is_map_type =
Word32Equal(LoadInstanceType(CAST(result)), Int32Constant(MAP_TYPE));
InstanceTypeEqual(LoadInstanceType(CAST(result)), MAP_TYPE);
GotoIfNot(is_map_type, &done);
result =
LoadObjectField(CAST(result), Map::kConstructorOrBackPointerOffset);
......@@ -3452,7 +3450,7 @@ Node* CodeStubAssembler::ToThisValue(Node* context, Node* value,
// Check if {value} is a JSValue.
Label if_valueisvalue(this, Label::kDeferred), if_valueisnotvalue(this);
Branch(Word32Equal(value_instance_type, Int32Constant(JS_VALUE_TYPE)),
Branch(InstanceTypeEqual(value_instance_type, JS_VALUE_TYPE),
&if_valueisvalue, &if_valueisnotvalue);
BIND(&if_valueisvalue);
......@@ -3728,7 +3726,7 @@ Node* CodeStubAssembler::IsNullOrJSReceiver(Node* object) {
}
Node* CodeStubAssembler::IsJSGlobalProxyInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(JS_GLOBAL_PROXY_TYPE));
return InstanceTypeEqual(instance_type, JS_GLOBAL_PROXY_TYPE);
}
Node* CodeStubAssembler::IsJSObjectInstanceType(Node* instance_type) {
......@@ -3747,21 +3745,17 @@ Node* CodeStubAssembler::IsJSObject(Node* object) {
}
Node* CodeStubAssembler::IsJSProxy(Node* object) {
Node* object_map = LoadMap(object);
Node* object_instance_type = LoadMapInstanceType(object_map);
return InstanceTypeEqual(object_instance_type, JS_PROXY_TYPE);
return HasInstanceType(object, JS_PROXY_TYPE);
}
Node* CodeStubAssembler::IsJSGlobalProxy(Node* object) {
return Word32Equal(LoadInstanceType(object),
Int32Constant(JS_GLOBAL_PROXY_TYPE));
return HasInstanceType(object, JS_GLOBAL_PROXY_TYPE);
}
Node* CodeStubAssembler::IsMap(Node* map) { return IsMetaMap(LoadMap(map)); }
Node* CodeStubAssembler::IsJSValueInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(JS_VALUE_TYPE));
return InstanceTypeEqual(instance_type, JS_VALUE_TYPE);
}
Node* CodeStubAssembler::IsJSValue(Node* object) {
......@@ -3773,7 +3767,7 @@ Node* CodeStubAssembler::IsJSValueMap(Node* map) {
}
Node* CodeStubAssembler::IsJSArrayInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(JS_ARRAY_TYPE));
return InstanceTypeEqual(instance_type, JS_ARRAY_TYPE);
}
Node* CodeStubAssembler::IsJSArray(Node* object) {
......@@ -3877,7 +3871,7 @@ Node* CodeStubAssembler::IsString(Node* object) {
}
Node* CodeStubAssembler::IsSymbolInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(SYMBOL_TYPE));
return InstanceTypeEqual(instance_type, SYMBOL_TYPE);
}
Node* CodeStubAssembler::IsSymbol(Node* object) {
......@@ -3885,7 +3879,7 @@ Node* CodeStubAssembler::IsSymbol(Node* object) {
}
Node* CodeStubAssembler::IsBigIntInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(BIGINT_TYPE));
return InstanceTypeEqual(instance_type, BIGINT_TYPE);
}
Node* CodeStubAssembler::IsBigInt(Node* object) {
......@@ -3931,7 +3925,7 @@ Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) {
}
Node* CodeStubAssembler::IsJSFunctionInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(JS_FUNCTION_TYPE));
return InstanceTypeEqual(instance_type, JS_FUNCTION_TYPE);
}
Node* CodeStubAssembler::IsJSFunction(Node* object) {
......@@ -4861,12 +4855,12 @@ Node* CodeStubAssembler::ToName(Node* context, Node* value) {
BIND(&not_name);
{
GotoIf(Word32Equal(value_instance_type, Int32Constant(HEAP_NUMBER_TYPE)),
GotoIf(InstanceTypeEqual(value_instance_type, HEAP_NUMBER_TYPE),
&is_number);
Label not_oddball(this);
GotoIf(Word32NotEqual(value_instance_type, Int32Constant(ODDBALL_TYPE)),
&not_oddball);
GotoIfNot(InstanceTypeEqual(value_instance_type, ODDBALL_TYPE),
&not_oddball);
var_result.Bind(LoadObjectField(value, Oddball::kToStringOffset));
Goto(&end);
......@@ -4906,7 +4900,7 @@ Node* CodeStubAssembler::NonNumberToNumberOrNumeric(Node* context, Node* input,
if_inputisother(this, Label::kDeferred);
GotoIf(IsStringInstanceType(input_instance_type), &if_inputisstring);
GotoIf(IsBigIntInstanceType(input_instance_type), &if_inputisbigint);
GotoIf(Word32Equal(input_instance_type, Int32Constant(ODDBALL_TYPE)),
GotoIf(InstanceTypeEqual(input_instance_type, ODDBALL_TYPE),
&if_inputisoddball);
Branch(IsJSReceiverInstanceType(input_instance_type), &if_inputisreceiver,
&if_inputisother);
......@@ -5155,8 +5149,7 @@ TNode<String> CodeStubAssembler::ToString(SloppyTNode<Context> context,
BIND(&not_heap_number);
{
GotoIf(Word32NotEqual(input_instance_type, Int32Constant(ODDBALL_TYPE)),
&runtime);
GotoIfNot(InstanceTypeEqual(input_instance_type, ODDBALL_TYPE), &runtime);
result.Bind(LoadObjectField(CAST(input), Oddball::kToStringOffset));
Goto(&done);
}
......@@ -5432,11 +5425,10 @@ void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex,
// then it must be an uncacheable index. Handle this case in the runtime.
GotoIf(IsClearWord32(hash, Name::kIsNotArrayIndexMask), if_bailout);
// Check if we have a ThinString.
GotoIf(Word32Equal(key_instance_type, Int32Constant(THIN_STRING_TYPE)),
GotoIf(InstanceTypeEqual(key_instance_type, THIN_STRING_TYPE),
&if_thinstring);
GotoIf(InstanceTypeEqual(key_instance_type, THIN_ONE_BYTE_STRING_TYPE),
&if_thinstring);
GotoIf(
Word32Equal(key_instance_type, Int32Constant(THIN_ONE_BYTE_STRING_TYPE)),
&if_thinstring);
// Finally, check if |key| is internalized.
STATIC_ASSERT(kNotInternalizedTag != 0);
GotoIf(IsSetWord32(key_instance_type, kIsNotInternalizedMask),
......@@ -6014,7 +6006,7 @@ void CodeStubAssembler::TryLookupProperty(
BIND(&if_objectisspecial);
{
// Handle global object here and bailout for other special objects.
GotoIfNot(Word32Equal(instance_type, Int32Constant(JS_GLOBAL_OBJECT_TYPE)),
GotoIfNot(InstanceTypeEqual(instance_type, JS_GLOBAL_OBJECT_TYPE),
if_bailout);
// Handle interceptors and access checks in runtime.
......@@ -6230,8 +6222,7 @@ Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details,
Node* getter_map = LoadMap(getter);
Node* instance_type = LoadMapInstanceType(getter_map);
// FunctionTemplateInfo getters are not supported yet.
GotoIf(Word32Equal(instance_type,
Int32Constant(FUNCTION_TEMPLATE_INFO_TYPE)),
GotoIf(InstanceTypeEqual(instance_type, FUNCTION_TEMPLATE_INFO_TYPE),
if_bailout);
// Return undefined if the {getter} is not callable.
......@@ -6545,8 +6536,7 @@ void CodeStubAssembler::TryPrototypeChainLookup(
BIND(&if_objectisreceiver);
if (if_proxy) {
GotoIf(Word32Equal(instance_type, Int32Constant(JS_PROXY_TYPE)),
if_proxy);
GotoIf(InstanceTypeEqual(instance_type, JS_PROXY_TYPE), if_proxy);
}
}
......@@ -6580,9 +6570,8 @@ void CodeStubAssembler::TryPrototypeChainLookup(
BIND(&next_proto);
// Bailout if it can be an integer indexed exotic case.
GotoIf(
Word32Equal(holder_instance_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
if_bailout);
GotoIf(InstanceTypeEqual(holder_instance_type, JS_TYPED_ARRAY_TYPE),
if_bailout);
Node* proto = LoadMapPrototype(holder_map);
......@@ -6716,9 +6705,8 @@ Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable,
// Goto runtime if {callable} is not a JSFunction.
Node* callable_instance_type = LoadMapInstanceType(callable_map);
GotoIfNot(
Word32Equal(callable_instance_type, Int32Constant(JS_FUNCTION_TYPE)),
&return_runtime);
GotoIfNot(InstanceTypeEqual(callable_instance_type, JS_FUNCTION_TYPE),
&return_runtime);
// Goto runtime if {callable} is not a constructor or has
// a non-instance "prototype".
......@@ -6744,9 +6732,8 @@ Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable,
// created so far and hence we should return false.
Node* callable_prototype_instance_type =
LoadInstanceType(callable_prototype);
GotoIfNot(
Word32Equal(callable_prototype_instance_type, Int32Constant(MAP_TYPE)),
&callable_prototype_valid);
GotoIfNot(InstanceTypeEqual(callable_prototype_instance_type, MAP_TYPE),
&callable_prototype_valid);
var_callable_prototype.Bind(
LoadObjectField(callable_prototype, Map::kPrototypeOffset));
Goto(&callable_prototype_valid);
......@@ -8071,17 +8058,14 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
// and {rhs} is either a HeapNumber or Oddball.
Label collect_any_feedback(this), collect_oddball_feedback(this),
collect_feedback_done(this);
GotoIfNot(
Word32Equal(lhs_instance_type, Int32Constant(ODDBALL_TYPE)),
&collect_any_feedback);
GotoIfNot(InstanceTypeEqual(lhs_instance_type, ODDBALL_TYPE),
&collect_any_feedback);
Node* rhs_instance_type = LoadMapInstanceType(rhs_map);
GotoIf(Word32Equal(rhs_instance_type,
Int32Constant(HEAP_NUMBER_TYPE)),
GotoIf(InstanceTypeEqual(rhs_instance_type, HEAP_NUMBER_TYPE),
&collect_oddball_feedback);
Branch(
Word32Equal(rhs_instance_type, Int32Constant(ODDBALL_TYPE)),
&collect_oddball_feedback, &collect_any_feedback);
Branch(InstanceTypeEqual(rhs_instance_type, ODDBALL_TYPE),
&collect_oddball_feedback, &collect_any_feedback);
BIND(&collect_oddball_feedback);
{
......@@ -9379,7 +9363,7 @@ Node* CodeStubAssembler::Typeof(Node* value) {
Node* instance_type = LoadMapInstanceType(map);
GotoIf(Word32Equal(instance_type, Int32Constant(ODDBALL_TYPE)), &if_oddball);
GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &if_oddball);
Node* callable_or_undetectable_mask = Word32And(
LoadMapBitField(map),
......@@ -9398,7 +9382,7 @@ Node* CodeStubAssembler::Typeof(Node* value) {
GotoIf(IsBigIntInstanceType(instance_type), &return_bigint);
CSA_ASSERT(this, Word32Equal(instance_type, Int32Constant(SYMBOL_TYPE)));
CSA_ASSERT(this, InstanceTypeEqual(instance_type, SYMBOL_TYPE));
result_var.Bind(HeapConstant(isolate()->factory()->symbol_string()));
Goto(&return_result);
......@@ -9792,8 +9776,8 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
Label if_istypedarray(this), if_isgeneric(this);
Branch(Word32Equal(array_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
&if_istypedarray, &if_isgeneric);
Branch(InstanceTypeEqual(array_type, JS_TYPED_ARRAY_TYPE), &if_istypedarray,
&if_isgeneric);
BIND(&if_isgeneric);
{
......@@ -9826,8 +9810,8 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
}
} else {
Label if_istypedarray(this), if_isgeneric(this);
Branch(Word32Equal(array_type, Int32Constant(JS_TYPED_ARRAY_TYPE)),
&if_istypedarray, &if_isgeneric);
Branch(InstanceTypeEqual(array_type, JS_TYPED_ARRAY_TYPE), &if_istypedarray,
&if_isgeneric);
BIND(&if_isgeneric);
{
......
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