Commit f4893bbe authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Tnodify misc CodeStubAssembler functions

This tnodifies:
TaggedToNumeric
TaggedToNumericWithFeedback
ThrowIfNotInstanceType (also made void since its return value was never
used).
IsSharedFunctionInfo
ComputeUnseededHash (and moves it to builtins-collections-gen.cc)
ComputeSeededHash
TrapAllocationMemento
BranchIfAccessorPair
GotoIfNumberGreaterThanOrEqual
CodeStubArguments::PopAndReturn

Also removes CodeStubArguments::GetArguments which was never called.

Bug: v8:10021
Change-Id: Iaa434f933f0d37ff999ba41601e982b62cfab048
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1989828
Auto-Submit: Dan Elphick <delphick@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65661}
parent a4e162f7
......@@ -748,6 +748,8 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
const std::function<void(TNode<Object>, Label*, Label*)>& key_compare,
TVariable<IntPtrT>* entry_start_position, Label* entry_found,
Label* not_found);
TNode<Word32T> ComputeUnseededHash(TNode<IntPtrT> key);
};
template <typename CollectionType>
......@@ -1253,6 +1255,20 @@ TF_BUILTIN(SetOrSetIteratorToList, CollectionsBuiltinsAssembler) {
Return(SetOrSetIteratorToList(context, object));
}
TNode<Word32T> CollectionsBuiltinsAssembler::ComputeUnseededHash(
TNode<IntPtrT> key) {
// See v8::internal::ComputeUnseededHash()
TNode<Word32T> hash = TruncateIntPtrToInt32(key);
hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)),
Word32Shl(hash, Int32Constant(15)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12)));
hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4)));
hash = Int32Mul(hash, Int32Constant(2057));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16)));
return Word32And(hash, Int32Constant(0x3FFFFFFF));
}
template <typename CollectionType>
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey(
TNode<CollectionType> table, TNode<Smi> smi_key, TVariable<IntPtrT>* result,
......
......@@ -5507,18 +5507,17 @@ TNode<Object> CodeStubAssembler::ToThisValue(TNode<Context> context,
return var_value.value();
}
Node* CodeStubAssembler::ThrowIfNotInstanceType(Node* context, Node* value,
InstanceType instance_type,
char const* method_name) {
void CodeStubAssembler::ThrowIfNotInstanceType(TNode<Context> context,
TNode<Object> value,
InstanceType instance_type,
char const* method_name) {
Label out(this), throw_exception(this, Label::kDeferred);
VARIABLE(var_value_map, MachineRepresentation::kTagged);
GotoIf(TaggedIsSmi(value), &throw_exception);
// Load the instance type of the {value}.
var_value_map.Bind(LoadMap(value));
const TNode<Uint16T> value_instance_type =
LoadMapInstanceType(var_value_map.value());
TNode<Map> map = LoadMap(CAST(value));
const TNode<Uint16T> value_instance_type = LoadMapInstanceType(map);
Branch(Word32Equal(value_instance_type, Int32Constant(instance_type)), &out,
&throw_exception);
......@@ -5529,7 +5528,6 @@ Node* CodeStubAssembler::ThrowIfNotInstanceType(Node* context, Node* value,
StringConstant(method_name), value);
BIND(&out);
return var_value_map.value();
}
void CodeStubAssembler::ThrowIfNotJSReceiver(TNode<Context> context,
......@@ -7012,12 +7010,14 @@ TNode<BigInt> CodeStubAssembler::ToBigInt(TNode<Context> context,
return var_result.value();
}
void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
void CodeStubAssembler::TaggedToNumeric(TNode<Context> context,
TNode<Object> value, Label* done,
Variable* var_numeric) {
TaggedToNumeric(context, value, done, var_numeric, nullptr);
}
void CodeStubAssembler::TaggedToNumericWithFeedback(Node* context, Node* value,
void CodeStubAssembler::TaggedToNumericWithFeedback(TNode<Context> context,
TNode<Object> value,
Label* done,
Variable* var_numeric,
Variable* var_feedback) {
......@@ -7025,20 +7025,23 @@ void CodeStubAssembler::TaggedToNumericWithFeedback(Node* context, Node* value,
TaggedToNumeric(context, value, done, var_numeric, var_feedback);
}
void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
void CodeStubAssembler::TaggedToNumeric(TNode<Context> context,
TNode<Object> value, Label* done,
Variable* var_numeric,
Variable* var_feedback) {
var_numeric->Bind(value);
Label if_smi(this), if_heapnumber(this), if_bigint(this), if_oddball(this);
GotoIf(TaggedIsSmi(value), &if_smi);
TNode<Map> map = LoadMap(value);
TNode<HeapObject> heap_object_value = CAST(value);
TNode<Map> map = LoadMap(heap_object_value);
GotoIf(IsHeapNumberMap(map), &if_heapnumber);
TNode<Uint16T> instance_type = LoadMapInstanceType(map);
GotoIf(IsBigIntInstanceType(instance_type), &if_bigint);
// {value} is not a Numeric yet.
// {heap_object_value} is not a Numeric yet.
GotoIf(Word32Equal(instance_type, Int32Constant(ODDBALL_TYPE)), &if_oddball);
var_numeric->Bind(CallBuiltin(Builtins::kNonNumberToNumeric, context, value));
var_numeric->Bind(
CallBuiltin(Builtins::kNonNumberToNumeric, context, heap_object_value));
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny);
Goto(done);
......@@ -7056,7 +7059,8 @@ void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
BIND(&if_oddball);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNumberOrOddball);
var_numeric->Bind(LoadObjectField(value, Oddball::kToNumberOffset));
var_numeric->Bind(
LoadObjectField(heap_object_value, Oddball::kToNumberOffset));
Goto(done);
}
......@@ -7725,20 +7729,7 @@ template V8_EXPORT_PRIVATE void CodeStubAssembler::NameDictionaryLookup<
GlobalDictionary>(TNode<GlobalDictionary>, TNode<Name>, Label*,
TVariable<IntPtrT>*, Label*, LookupMode);
Node* CodeStubAssembler::ComputeUnseededHash(Node* key) {
// See v8::internal::ComputeUnseededHash()
TNode<Word32T> hash = TruncateIntPtrToInt32(key);
hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)),
Word32Shl(hash, Int32Constant(15)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12)));
hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4)));
hash = Int32Mul(hash, Int32Constant(2057));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16)));
return Word32And(hash, Int32Constant(0x3FFFFFFF));
}
Node* CodeStubAssembler::ComputeSeededHash(Node* key) {
TNode<Word32T> CodeStubAssembler::ComputeSeededHash(TNode<IntPtrT> key) {
const TNode<ExternalReference> function_addr =
ExternalConstant(ExternalReference::compute_integer_hash());
const TNode<ExternalReference> isolate_ptr =
......@@ -7748,10 +7739,9 @@ Node* CodeStubAssembler::ComputeSeededHash(Node* key) {
MachineType type_uint32 = MachineType::Uint32();
MachineType type_int32 = MachineType::Int32();
Node* const result = CallCFunction(
return UncheckedCast<Word32T>(CallCFunction(
function_addr, type_uint32, std::make_pair(type_ptr, isolate_ptr),
std::make_pair(type_int32, TruncateIntPtrToInt32(key)));
return result;
std::make_pair(type_int32, TruncateIntPtrToInt32(key))));
}
void CodeStubAssembler::NumberDictionaryLookup(
......@@ -10115,7 +10105,7 @@ void CodeStubAssembler::TransitionElementsKind(TNode<JSObject> object,
StoreMap(object, map);
}
void CodeStubAssembler::TrapAllocationMemento(Node* object,
void CodeStubAssembler::TrapAllocationMemento(TNode<JSObject> object,
Label* memento_found) {
Comment("[ TrapAllocationMemento");
Label no_memento_found(this);
......@@ -10499,8 +10489,8 @@ void CodeStubAssembler::BranchIfNumberRelationalComparison(
}
}
void CodeStubAssembler::GotoIfNumberGreaterThanOrEqual(Node* left, Node* right,
Label* if_true) {
void CodeStubAssembler::GotoIfNumberGreaterThanOrEqual(
SloppyTNode<Number> left, SloppyTNode<Number> right, Label* if_true) {
Label if_false(this);
BranchIfNumberRelationalComparison(Operation::kGreaterThanOrEqual, left,
right, if_true, &if_false);
......@@ -12638,7 +12628,7 @@ void CodeStubArguments::ForEach(
-kSystemPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
}
void CodeStubArguments::PopAndReturn(Node* value) {
void CodeStubArguments::PopAndReturn(TNode<Object> value) {
TNode<IntPtrT> pop_count;
if (receiver_mode_ == ReceiverMode::kHasReceiver) {
pop_count = assembler_->IntPtrAdd(argc_, assembler_->IntPtrConstant(1));
......
......@@ -2366,10 +2366,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Uint32T> ChangeNumberToUint32(TNode<Number> value);
TNode<Float64T> ChangeNumberToFloat64(TNode<Number> value);
void TaggedToNumeric(Node* context, Node* value, Label* done,
void TaggedToNumeric(TNode<Context> context, TNode<Object> value, Label* done,
Variable* var_numeric);
void TaggedToNumericWithFeedback(Node* context, Node* value, Label* done,
Variable* var_numeric,
void TaggedToNumericWithFeedback(TNode<Context> context, TNode<Object> value,
Label* done, Variable* var_numeric,
Variable* var_feedback);
TNode<WordT> TimesSystemPointerSize(SloppyTNode<WordT> value);
......@@ -2414,10 +2414,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
char const* method_name);
// Throws a TypeError for {method_name} if {value} is not of the given
// instance type. Returns {value}'s map.
Node* ThrowIfNotInstanceType(Node* context, Node* value,
InstanceType instance_type,
char const* method_name);
// instance type.
void ThrowIfNotInstanceType(TNode<Context> context, TNode<Object> value,
InstanceType instance_type,
char const* method_name);
// Throws a TypeError for {method_name} if {value} is not a JSReceiver.
void ThrowIfNotJSReceiver(TNode<Context> context, TNode<Object> value,
MessageTemplate msg_template,
......@@ -2565,7 +2565,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> IsNotWeakFixedArraySubclass(SloppyTNode<HeapObject> object);
TNode<BoolT> IsZeroOrContext(SloppyTNode<Object> object);
inline TNode<BoolT> IsSharedFunctionInfo(Node* object) {
inline TNode<BoolT> IsSharedFunctionInfo(TNode<HeapObject> object) {
return IsSharedFunctionInfoMap(LoadMap(object));
}
......@@ -3043,8 +3043,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Label* if_not_found,
LookupMode mode = kFindExisting);
Node* ComputeUnseededHash(Node* key);
Node* ComputeSeededHash(Node* key);
TNode<Word32T> ComputeSeededHash(TNode<IntPtrT> key);
void NumberDictionaryLookup(TNode<NumberDictionary> dictionary,
TNode<IntPtrT> intptr_index, Label* if_found,
......@@ -3329,7 +3328,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ElementsKind from_kind, ElementsKind to_kind,
Label* bailout);
void TrapAllocationMemento(Node* object, Label* memento_found);
void TrapAllocationMemento(TNode<JSObject> object, Label* memento_found);
TNode<IntPtrT> PageFromAddress(TNode<IntPtrT> address);
......@@ -3466,13 +3465,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
right, if_true, if_false);
}
void BranchIfAccessorPair(Node* value, Label* if_accessor_pair,
void BranchIfAccessorPair(TNode<Object> value, Label* if_accessor_pair,
Label* if_not_accessor_pair) {
GotoIf(TaggedIsSmi(value), if_not_accessor_pair);
Branch(IsAccessorPair(value), if_accessor_pair, if_not_accessor_pair);
Branch(IsAccessorPair(CAST(value)), if_accessor_pair, if_not_accessor_pair);
}
void GotoIfNumberGreaterThanOrEqual(Node* left, Node* right, Label* if_false);
void GotoIfNumberGreaterThanOrEqual(SloppyTNode<Number> left,
SloppyTNode<Number> right,
Label* if_false);
TNode<Oddball> Equal(SloppyTNode<Object> lhs, SloppyTNode<Object> rhs,
SloppyTNode<Context> context,
......@@ -3829,7 +3830,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Node* context, Node* input, Object::Conversion mode,
BigIntHandling bigint_handling = BigIntHandling::kThrow);
void TaggedToNumeric(Node* context, Node* value, Label* done,
void TaggedToNumeric(TNode<Context> context, TNode<Object> value, Label* done,
Variable* var_numeric, Variable* var_feedback);
template <Object::Conversion conversion>
......@@ -3972,11 +3973,9 @@ class V8_EXPORT_PRIVATE CodeStubArguments {
return ForEach(vars, body, first_intptr, last_intptr);
}
void PopAndReturn(Node* value);
void PopAndReturn(TNode<Object> value);
private:
Node* GetArguments();
CodeStubAssembler* assembler_;
ReceiverMode receiver_mode_;
TNode<IntPtrT> argc_;
......
......@@ -500,7 +500,8 @@ TEST(ComputeIntegerHash) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state());
m.Return(m.SmiFromInt32(m.ComputeSeededHash(m.SmiUntag(m.Parameter(0)))));
m.Return(m.SmiFromInt32(m.UncheckedCast<Int32T>(
m.ComputeSeededHash(m.SmiUntag(m.Parameter(0))))));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......
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