Commit 832eeef2 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Tnodify functions in CodeStubAssembler

Converts Node*s to TNode<>s in the following functions:
GotoIfNotNumber
GotoIfNumber
BitwiseOp
InitializePropertyArrayLength
LoadFixedDoubleArrayElement
GotoIfContextElementEqual
LoadJSFunctionPrototype
AllocateCellWithValue
AllocateSmiCell
LoadCellValue
StoreCellValue
AllocateOrderedHashTable
AllocateJSObjectFromMap
InitializeJSObjectFromMap

Bug: v8:9810
Change-Id: I323da8d72a0e164c70bd6026b32fa46010c7c256
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1910109Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65005}
parent 3f254fd2
......@@ -842,9 +842,11 @@ TNode<HeapObject> CollectionsBuiltinsAssembler::AllocateJSCollectionIterator(
TNode<HeapObject> CollectionsBuiltinsAssembler::AllocateTable(
Variant variant, TNode<IntPtrT> at_least_space_for) {
return CAST((variant == kMap || variant == kWeakMap)
? AllocateOrderedHashTable<OrderedHashMap>()
: AllocateOrderedHashTable<OrderedHashSet>());
if (variant == kMap || variant == kWeakMap) {
return AllocateOrderedHashTable<OrderedHashMap>();
} else {
return AllocateOrderedHashTable<OrderedHashSet>();
}
}
TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {
......
......@@ -214,7 +214,7 @@ TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
}
BIND(&instantiate_map);
return AllocateJSObjectFromMap(initial_map, properties.value(), nullptr,
return AllocateJSObjectFromMap(initial_map, properties.value(), base::nullopt,
kNone, kWithSlackTracking);
}
......
......@@ -1251,8 +1251,8 @@ TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) {
FillFixedArrayWithValue(HOLEY_ELEMENTS, parameters_and_registers,
IntPtrConstant(0), size, RootIndex::kUndefinedValue);
// TODO(cbruni): support start_offset to avoid double initialization.
TNode<JSObject> result =
AllocateJSObjectFromMap(map, nullptr, nullptr, kNone, kWithSlackTracking);
TNode<JSObject> result = AllocateJSObjectFromMap(
map, base::nullopt, base::nullopt, kNone, kWithSlackTracking);
StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kFunctionOffset,
closure);
StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kContextOffset,
......
......@@ -3127,7 +3127,7 @@ void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind,
if (IsSmiElementsKind(kind)) {
GotoIf(TaggedIsNotSmi(value), bailout);
} else if (IsDoubleElementsKind(kind)) {
GotoIfNotNumber(value, bailout);
GotoIfNotNumber(CAST(value), bailout);
}
if (IsDoubleElementsKind(kind)) {
value = ChangeNumberToFloat64(CAST(value));
......@@ -3159,22 +3159,21 @@ void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind,
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
}
Node* CodeStubAssembler::AllocateCellWithValue(Node* value,
WriteBarrierMode mode) {
TNode<Cell> CodeStubAssembler::AllocateCellWithValue(TNode<Object> value,
WriteBarrierMode mode) {
TNode<HeapObject> result = Allocate(Cell::kSize, kNone);
StoreMapNoWriteBarrier(result, RootIndex::kCellMap);
StoreCellValue(result, value, mode);
return result;
TNode<Cell> cell = CAST(result);
StoreCellValue(cell, value, mode);
return cell;
}
TNode<Object> CodeStubAssembler::LoadCellValue(Node* cell) {
CSA_SLOW_ASSERT(this, HasInstanceType(cell, CELL_TYPE));
TNode<Object> CodeStubAssembler::LoadCellValue(TNode<Cell> cell) {
return LoadObjectField(cell, Cell::kValueOffset);
}
void CodeStubAssembler::StoreCellValue(Node* cell, Node* value,
void CodeStubAssembler::StoreCellValue(TNode<Cell> cell, TNode<Object> value,
WriteBarrierMode mode) {
CSA_SLOW_ASSERT(this, HasInstanceType(cell, CELL_TYPE));
DCHECK(mode == SKIP_WRITE_BARRIER || mode == UPDATE_WRITE_BARRIER);
if (mode == UPDATE_WRITE_BARRIER) {
......@@ -3617,7 +3616,7 @@ TNode<NameDictionary> CodeStubAssembler::CopyNameDictionary(
}
template <typename CollectionType>
Node* CodeStubAssembler::AllocateOrderedHashTable() {
TNode<CollectionType> CodeStubAssembler::AllocateOrderedHashTable() {
static const int kCapacity = CollectionType::kMinCapacity;
static const int kBucketCount = kCapacity / CollectionType::kLoadFactor;
static const int kDataTableLength = kCapacity * CollectionType::kEntrySize;
......@@ -3634,7 +3633,7 @@ Node* CodeStubAssembler::AllocateOrderedHashTable() {
TNode<IntPtrT> length_intptr = IntPtrConstant(kFixedArrayLength);
TNode<Map> fixed_array_map =
CAST(LoadRoot(CollectionType::GetMapRootIndex()));
TNode<FixedArray> table =
TNode<CollectionType> table =
CAST(AllocateFixedArray(elements_kind, length_intptr,
kAllowLargeObjectAllocation, fixed_array_map));
......@@ -3668,8 +3667,10 @@ Node* CodeStubAssembler::AllocateOrderedHashTable() {
return table;
}
template Node* CodeStubAssembler::AllocateOrderedHashTable<OrderedHashMap>();
template Node* CodeStubAssembler::AllocateOrderedHashTable<OrderedHashSet>();
template TNode<OrderedHashMap>
CodeStubAssembler::AllocateOrderedHashTable<OrderedHashMap>();
template TNode<OrderedHashSet>
CodeStubAssembler::AllocateOrderedHashTable<OrderedHashSet>();
template <typename CollectionType>
TNode<CollectionType> CodeStubAssembler::AllocateSmallOrderedHashTable(
......@@ -3766,8 +3767,8 @@ CodeStubAssembler::AllocateSmallOrderedHashTable<SmallOrderedHashSet>(
TNode<IntPtrT> capacity);
TNode<JSObject> CodeStubAssembler::AllocateJSObjectFromMap(
SloppyTNode<Map> map, SloppyTNode<HeapObject> properties,
SloppyTNode<FixedArray> elements, AllocationFlags flags,
TNode<Map> map, base::Optional<TNode<HeapObject>> properties,
base::Optional<TNode<FixedArray>> elements, AllocationFlags flags,
SlackTrackingMode slack_tracking_mode) {
CSA_ASSERT(this, IsMap(map));
CSA_ASSERT(this, Word32BinaryNot(IsJSFunctionMap(map)));
......@@ -3783,29 +3784,30 @@ TNode<JSObject> CodeStubAssembler::AllocateJSObjectFromMap(
}
void CodeStubAssembler::InitializeJSObjectFromMap(
SloppyTNode<HeapObject> object, SloppyTNode<Map> map,
SloppyTNode<IntPtrT> instance_size, Node* properties, Node* elements,
TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size,
base::Optional<TNode<HeapObject>> properties,
base::Optional<TNode<FixedArray>> elements,
SlackTrackingMode slack_tracking_mode) {
CSA_SLOW_ASSERT(this, IsMap(map));
// This helper assumes that the object is in new-space, as guarded by the
// check in AllocatedJSObjectFromMap.
if (properties == nullptr) {
if (!properties) {
CSA_ASSERT(this, Word32BinaryNot(IsDictionaryMap((map))));
StoreObjectFieldRoot(object, JSObject::kPropertiesOrHashOffset,
RootIndex::kEmptyFixedArray);
} else {
CSA_ASSERT(this, Word32Or(Word32Or(IsPropertyArray(properties),
IsNameDictionary(properties)),
IsEmptyFixedArray(properties)));
CSA_ASSERT(this, Word32Or(Word32Or(IsPropertyArray(*properties),
IsNameDictionary(*properties)),
IsEmptyFixedArray(*properties)));
StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOrHashOffset,
properties);
*properties);
}
if (elements == nullptr) {
if (!elements) {
StoreObjectFieldRoot(object, JSObject::kElementsOffset,
RootIndex::kEmptyFixedArray);
} else {
CSA_ASSERT(this, IsFixedArray(elements));
StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements);
StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset,
*elements);
}
if (slack_tracking_mode == kNoSlackTracking) {
InitializeJSObjectBodyNoSlackTracking(object, map, instance_size);
......@@ -4091,7 +4093,7 @@ Node* CodeStubAssembler::ExtractFastJSArray(
TNode<Map> original_array_map = LoadMap(array);
TNode<Int32T> elements_kind = LoadMapElementsKind(original_array_map);
// Use the cannonical map for the Array's ElementsKind
// Use the canonical map for the Array's ElementsKind
TNode<NativeContext> native_context = LoadNativeContext(context);
TNode<Map> array_map = LoadJSArrayElementsMap(elements_kind, native_context);
......@@ -4602,10 +4604,8 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray(
return UncheckedCast<FixedArray>(var_result.value());
}
void CodeStubAssembler::InitializePropertyArrayLength(Node* property_array,
Node* length,
ParameterMode mode) {
CSA_SLOW_ASSERT(this, IsPropertyArray(property_array));
void CodeStubAssembler::InitializePropertyArrayLength(
TNode<PropertyArray> property_array, Node* length, ParameterMode mode) {
CSA_ASSERT(
this, IntPtrOrSmiGreaterThan(length, IntPtrOrSmiConstant(0, mode), mode));
CSA_ASSERT(
......@@ -4631,7 +4631,7 @@ Node* CodeStubAssembler::AllocatePropertyArray(Node* capacity_node,
RootIndex map_index = RootIndex::kPropertyArrayMap;
DCHECK(RootsTable::IsImmortalImmovable(map_index));
StoreMapNoWriteBarrier(array, map_index);
InitializePropertyArrayLength(array, capacity_node, mode);
InitializePropertyArrayLength(CAST(array), capacity_node, mode);
return array;
}
......@@ -12574,19 +12574,21 @@ TNode<Number> CodeStubAssembler::NumberSub(SloppyTNode<Number> a,
return var_result.value();
}
void CodeStubAssembler::GotoIfNotNumber(Node* input, Label* is_not_number) {
void CodeStubAssembler::GotoIfNotNumber(TNode<Object> input,
Label* is_not_number) {
Label is_number(this);
GotoIf(TaggedIsSmi(input), &is_number);
Branch(IsHeapNumber(input), &is_number, is_not_number);
Branch(IsHeapNumber(CAST(input)), &is_number, is_not_number);
BIND(&is_number);
}
void CodeStubAssembler::GotoIfNumber(Node* input, Label* is_number) {
void CodeStubAssembler::GotoIfNumber(TNode<Object> input, Label* is_number) {
GotoIf(TaggedIsSmi(input), is_number);
GotoIf(IsHeapNumber(input), is_number);
GotoIf(IsHeapNumber(CAST(input)), is_number);
}
TNode<Number> CodeStubAssembler::BitwiseOp(Node* left32, Node* right32,
TNode<Number> CodeStubAssembler::BitwiseOp(TNode<Word32T> left32,
TNode<Word32T> right32,
Operation bitwise_op) {
switch (bitwise_op) {
case Operation::kBitwiseAnd:
......
......@@ -790,11 +790,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Number> NumberDec(SloppyTNode<Number> value);
TNode<Number> NumberAdd(SloppyTNode<Number> a, SloppyTNode<Number> b);
TNode<Number> NumberSub(SloppyTNode<Number> a, SloppyTNode<Number> b);
void GotoIfNotNumber(Node* value, Label* is_not_number);
void GotoIfNumber(Node* value, Label* is_number);
void GotoIfNotNumber(TNode<Object> value, Label* is_not_number);
void GotoIfNumber(TNode<Object> value, Label* is_number);
TNode<Number> SmiToNumber(TNode<Smi> v) { return v; }
TNode<Number> BitwiseOp(Node* left32, Node* right32, Operation bitwise_op);
TNode<Number> BitwiseOp(TNode<Word32T> left32, TNode<Word32T> right32,
Operation bitwise_op);
// Allocate an object of the given size.
TNode<HeapObject> AllocateInNewSpace(TNode<IntPtrT> size,
......@@ -811,7 +812,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
using BranchGenerator = std::function<void(Label*, Label*)>;
using NodeGenerator = std::function<Node*()>;
using ExtraNode = std::pair<Node*, const char*>;
using ExtraNode = std::pair<TNode<Object>, const char*>;
void Assert(const BranchGenerator& branch, const char* message,
const char* file, int line,
......@@ -1198,8 +1199,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// This is only used on a newly allocated PropertyArray which
// doesn't have an existing hash.
void InitializePropertyArrayLength(Node* property_array, Node* length,
ParameterMode mode);
void InitializePropertyArrayLength(TNode<PropertyArray> property_array,
Node* length, ParameterMode mode);
// Check if the map is set for slow properties.
TNode<BoolT> IsDictionaryMap(SloppyTNode<Map> map);
......@@ -1385,9 +1386,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ParameterMode parameter_mode = INTPTR_PARAMETERS,
Label* if_hole = nullptr);
Node* LoadFixedDoubleArrayElement(TNode<FixedDoubleArray> object,
TNode<Smi> index,
Label* if_hole = nullptr) {
TNode<Float64T> LoadFixedDoubleArrayElement(TNode<FixedDoubleArray> object,
TNode<Smi> index,
Label* if_hole = nullptr) {
return LoadFixedDoubleArrayElement(object, index, MachineType::Float64(), 0,
SMI_PARAMETERS, if_hole);
}
......@@ -1476,8 +1477,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Context> LoadModuleContext(SloppyTNode<Context> context);
void GotoIfContextElementEqual(SloppyTNode<Object> value,
Node* native_context, int slot_index,
Label* if_equal) {
TNode<NativeContext> native_context,
int slot_index, Label* if_equal) {
GotoIf(TaggedEqual(value, LoadContextElement(native_context, slot_index)),
if_equal);
}
......@@ -1707,15 +1708,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<IntPtrT> end_address,
TNode<Object> value);
Node* AllocateCellWithValue(Node* value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
Node* AllocateSmiCell(int value = 0) {
TNode<Cell> AllocateCellWithValue(
TNode<Object> value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
TNode<Cell> AllocateSmiCell(int value = 0) {
return AllocateCellWithValue(SmiConstant(value), SKIP_WRITE_BARRIER);
}
TNode<Object> LoadCellValue(Node* cell);
TNode<Object> LoadCellValue(TNode<Cell> cell);
void StoreCellValue(Node* cell, Node* value,
void StoreCellValue(TNode<Cell> cell, TNode<Object> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// Allocate a HeapNumber without initializing its value.
......@@ -1778,20 +1779,22 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Label* large_object_fallback);
template <typename CollectionType>
Node* AllocateOrderedHashTable();
TNode<CollectionType> AllocateOrderedHashTable();
template <typename CollectionType>
TNode<CollectionType> AllocateSmallOrderedHashTable(TNode<IntPtrT> capacity);
TNode<JSObject> AllocateJSObjectFromMap(
SloppyTNode<Map> map, SloppyTNode<HeapObject> properties = nullptr,
SloppyTNode<FixedArray> elements = nullptr, AllocationFlags flags = kNone,
TNode<Map> map,
base::Optional<TNode<HeapObject>> properties = base::nullopt,
base::Optional<TNode<FixedArray>> elements = base::nullopt,
AllocationFlags flags = kNone,
SlackTrackingMode slack_tracking_mode = kNoSlackTracking);
void InitializeJSObjectFromMap(
SloppyTNode<HeapObject> object, SloppyTNode<Map> map,
SloppyTNode<IntPtrT> instance_size, Node* properties = nullptr,
Node* elements = nullptr,
TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size,
base::Optional<TNode<HeapObject>> properties = base::nullopt,
base::Optional<TNode<FixedArray>> elements = base::nullopt,
SlackTrackingMode slack_tracking_mode = kNoSlackTracking);
void InitializeJSObjectBodyWithSlackTracking(
......
......@@ -230,6 +230,9 @@
# BUG(5920): Flaky crash.
'test-serialize/PartialSerializerContext': [PASS, ['arch == x64 and mode == debug', SKIP]],
# Test is just big and quite slow.
'test-cpu-profiler/Inlining2': [PASS, SLOW],
}], # 'system == windows'
##############################################################################
......
......@@ -1847,9 +1847,9 @@ TEST(AllocateJSObjectFromMap) {
CodeStubAssembler m(asm_tester.state());
{
Node* map = m.Parameter(0);
Node* properties = m.Parameter(1);
Node* elements = m.Parameter(2);
TNode<Map> map = m.CAST(m.Parameter(0));
TNode<HeapObject> properties = m.CAST(m.Parameter(1));
TNode<FixedArray> elements = m.CAST(m.Parameter(2));
TNode<JSObject> result =
m.AllocateJSObjectFromMap(map, properties, elements);
......
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