Commit 4a44cf83 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup][csa] Introduce Times[SystemPointer|Tagged]Size instead of TimesPointerSize

Bug: v8:8477, v8:8562
Change-Id: I54b857cdacf9360b95d64147a486a0d5fa1ffe10
Reviewed-on: https://chromium-review.googlesource.com/c/1388526
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58473}
parent a233a350
......@@ -386,7 +386,7 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
CSA_ASSERT(this, Word32BinaryNot(IsFixedDoubleArray(array)));
TNode<IntPtrT> length = SmiToIntPtr(smi_length);
TNode<WordT> byte_length = TimesPointerSize(length);
TNode<WordT> byte_length = TimesTaggedSize(length);
CSA_ASSERT(this, UintPtrLessThan(length, byte_length));
static const int32_t fa_base_data_offset =
......
......@@ -109,7 +109,7 @@ TF_BUILTIN(FastNewClosure, ConstructorBuiltinsAssembler) {
// Create a new closure from the given function info in new space
TNode<IntPtrT> instance_size_in_bytes =
TimesPointerSize(LoadMapInstanceSizeInWords(function_map));
TimesTaggedSize(LoadMapInstanceSizeInWords(function_map));
TNode<Object> result = Allocate(instance_size_in_bytes);
StoreMapNoWriteBarrier(result, function_map);
InitializeJSObjectBodyNoSlackTracking(result, function_map,
......@@ -492,7 +492,7 @@ Node* ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
// barriers when copying all object fields.
STATIC_ASSERT(JSObject::kMaxInstanceSize < kMaxRegularHeapObjectSize);
TNode<IntPtrT> instance_size =
TimesPointerSize(LoadMapInstanceSizeInWords(boilerplate_map));
TimesTaggedSize(LoadMapInstanceSizeInWords(boilerplate_map));
TNode<IntPtrT> allocation_size = instance_size;
bool needs_allocation_memento = FLAG_allocation_site_pretenuring;
if (needs_allocation_memento) {
......
......@@ -145,9 +145,9 @@ TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) {
GotoIf(WordEqual(index, length), &done_loop2);
// Load the parameter at the given {index}.
TNode<Object> value =
CAST(Load(MachineType::AnyTagged(), frame,
TimesPointerSize(IntPtrSub(offset, index))));
TNode<Object> value = BitcastWordToTagged(
Load(MachineType::Pointer(), frame,
TimesSystemPointerSize(IntPtrSub(offset, index))));
// Store the {value} into the {result}.
StoreFixedArrayElement(result, index, value, SKIP_WRITE_BARRIER);
......
......@@ -103,7 +103,7 @@ void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueStart(
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::CalculateRingBufferOffset(
TNode<IntPtrT> capacity, TNode<IntPtrT> start, TNode<IntPtrT> index) {
return TimesPointerSize(
return TimesSystemPointerSize(
WordAnd(IntPtrAdd(start, index), IntPtrSub(capacity, IntPtrConstant(1))));
}
......@@ -373,7 +373,7 @@ void MicrotaskQueueBuiltinsAssembler::EnterMicrotaskContext(
ContextStack::kDataOffset);
Node* data = Load(MachineType::Pointer(), hsi, data_offset);
StoreNoWriteBarrier(MachineType::Pointer().representation(), data,
TimesPointerSize(size),
TimesSystemPointerSize(size),
BitcastTaggedToWord(native_context));
TNode<IntPtrT> new_size = IntPtrAdd(size, IntPtrConstant(1));
......
......@@ -2498,7 +2498,7 @@ void CodeStubAssembler::StoreContextElement(SloppyTNode<Context> context,
void CodeStubAssembler::StoreContextElement(SloppyTNode<Context> context,
SloppyTNode<IntPtrT> slot_index,
SloppyTNode<Object> value) {
Node* offset = IntPtrAdd(TimesPointerSize(slot_index),
Node* offset = IntPtrAdd(TimesTaggedSize(slot_index),
IntPtrConstant(Context::SlotOffset(0)));
Store(context, offset, value);
}
......@@ -3388,7 +3388,7 @@ TNode<NameDictionary> CodeStubAssembler::AllocateNameDictionaryWithCapacity(
CSA_ASSERT(this, IntPtrGreaterThan(capacity, IntPtrConstant(0)));
TNode<IntPtrT> length = EntryToIndex<NameDictionary>(capacity);
TNode<IntPtrT> store_size = IntPtrAdd(
TimesPointerSize(length), IntPtrConstant(NameDictionary::kHeaderSize));
TimesTaggedSize(length), IntPtrConstant(NameDictionary::kHeaderSize));
TNode<NameDictionary> result =
UncheckedCast<NameDictionary>(AllocateInNewSpace(store_size));
......@@ -3530,7 +3530,7 @@ TNode<CollectionType> CodeStubAssembler::AllocateSmallOrderedHashTable(
Int32Div(TruncateIntPtrToInt32(total_size_word_aligned),
Int32Constant(kTaggedSize)));
total_size_word_aligned =
UncheckedCast<IntPtrT>(TimesPointerSize(total_size_word_aligned));
UncheckedCast<IntPtrT>(TimesTaggedSize(total_size_word_aligned));
// Allocate the table and add the proper map.
TNode<Map> small_ordered_hash_map =
......@@ -3660,7 +3660,7 @@ template void CodeStubAssembler::FindOrderedHashTableEntry<OrderedHashSet>(
Node* CodeStubAssembler::AllocateStruct(Node* map, AllocationFlags flags) {
Comment("AllocateStruct");
CSA_ASSERT(this, IsMap(map));
TNode<IntPtrT> size = TimesPointerSize(LoadMapInstanceSizeInWords(map));
TNode<IntPtrT> size = TimesTaggedSize(LoadMapInstanceSizeInWords(map));
TNode<Object> object = Allocate(size, flags);
StoreMapNoWriteBarrier(object, map);
InitializeStructBody(object, map, size, Struct::kHeaderSize);
......@@ -3689,7 +3689,7 @@ Node* CodeStubAssembler::AllocateJSObjectFromMap(
CSA_ASSERT(this, Word32BinaryNot(InstanceTypeEqual(LoadMapInstanceType(map),
JS_GLOBAL_OBJECT_TYPE)));
TNode<IntPtrT> instance_size =
TimesPointerSize(LoadMapInstanceSizeInWords(map));
TimesTaggedSize(LoadMapInstanceSizeInWords(map));
TNode<Object> object = AllocateInNewSpace(instance_size, flags);
StoreMapNoWriteBarrier(object, map);
InitializeJSObjectFromMap(object, map, instance_size, properties, elements,
......@@ -3768,7 +3768,7 @@ void CodeStubAssembler::InitializeJSObjectBodyWithSlackTracking(
// The object still has in-object slack therefore the |unsed_or_unused|
// field contain the "used" value.
Node* used_size = TimesPointerSize(ChangeUint32ToWord(
Node* used_size = TimesTaggedSize(ChangeUint32ToWord(
LoadObjectField(map, Map::kUsedOrUnusedInstanceSizeInWordsOffset,
MachineType::Uint8())));
......@@ -4589,7 +4589,7 @@ void CodeStubAssembler::FillFixedArrayWithSmiZero(TNode<FixedArray> array,
TNode<IntPtrT> length) {
CSA_ASSERT(this, WordEqual(length, LoadAndUntagFixedArrayBaseLength(array)));
TNode<IntPtrT> byte_length = TimesPointerSize(length);
TNode<IntPtrT> byte_length = TimesTaggedSize(length);
CSA_ASSERT(this, UintPtrLessThan(length, byte_length));
static const int32_t fa_base_data_offset =
......@@ -5658,7 +5658,12 @@ TNode<UintPtrT> CodeStubAssembler::ChangeNonnegativeNumberToUintPtr(
return result.value();
}
TNode<WordT> CodeStubAssembler::TimesPointerSize(SloppyTNode<WordT> value) {
TNode<WordT> CodeStubAssembler::TimesSystemPointerSize(
SloppyTNode<WordT> value) {
return WordShl(value, kSystemPointerSizeLog2);
}
TNode<WordT> CodeStubAssembler::TimesTaggedSize(SloppyTNode<WordT> value) {
return WordShl(value, kTaggedSizeLog2);
}
......@@ -9151,7 +9156,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
BIND(&if_inobject);
{
Comment("if_inobject");
Node* field_offset = TimesPointerSize(field_index);
Node* field_offset = TimesTaggedSize(field_index);
Label if_double(this), if_tagged(this);
Branch(Word32NotEqual(representation,
......@@ -13154,13 +13159,12 @@ void CodeStubArguments::ForEach(
DCHECK_EQ(mode, argc_mode_);
last = argc_;
}
// TODO(ishell): INTPTR_ELEMENTS
Node* start = assembler_->IntPtrSub(
assembler_->UncheckedCast<IntPtrT>(arguments_),
assembler_->ElementOffsetFromIndex(first, PACKED_ELEMENTS, mode));
assembler_->ElementOffsetFromIndex(first, SYSTEM_POINTER_ELEMENTS, mode));
Node* end = assembler_->IntPtrSub(
assembler_->UncheckedCast<IntPtrT>(arguments_),
assembler_->ElementOffsetFromIndex(last, PACKED_ELEMENTS, mode));
assembler_->ElementOffsetFromIndex(last, SYSTEM_POINTER_ELEMENTS, mode));
assembler_->BuildFastLoop(
vars, start, end,
[this, &body](Node* current) {
......
......@@ -1890,13 +1890,34 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Variable* var_numeric,
Variable* var_feedback);
TNode<WordT> TimesPointerSize(SloppyTNode<WordT> value);
// TODO(ishell): drop this version once all usages are fixed.
TNode<WordT> TimesPointerSize(SloppyTNode<WordT> value) {
STATIC_ASSERT(kTaggedSize == kSystemPointerSize);
return TimesSystemPointerSize(value);
}
TNode<IntPtrT> TimesPointerSize(TNode<IntPtrT> value) {
return Signed(TimesPointerSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<UintPtrT> TimesPointerSize(TNode<UintPtrT> value) {
return Unsigned(TimesPointerSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<WordT> TimesSystemPointerSize(SloppyTNode<WordT> value);
TNode<IntPtrT> TimesSystemPointerSize(TNode<IntPtrT> value) {
return Signed(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<UintPtrT> TimesSystemPointerSize(TNode<UintPtrT> value) {
return Unsigned(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<WordT> TimesTaggedSize(SloppyTNode<WordT> value);
TNode<IntPtrT> TimesTaggedSize(TNode<IntPtrT> value) {
return Signed(TimesTaggedSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<UintPtrT> TimesTaggedSize(TNode<UintPtrT> value) {
return Unsigned(TimesTaggedSize(implicit_cast<TNode<WordT>>(value)));
}
TNode<WordT> TimesDoubleSize(SloppyTNode<WordT> value);
TNode<UintPtrT> TimesDoubleSize(TNode<UintPtrT> value) {
return Unsigned(TimesDoubleSize(implicit_cast<TNode<WordT>>(value)));
......
......@@ -68,7 +68,14 @@ enum ElementsKind : uint8_t {
LAST_FAST_ELEMENTS_KIND = HOLEY_DOUBLE_ELEMENTS,
FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS,
LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = BIGINT64_ELEMENTS,
TERMINAL_FAST_ELEMENTS_KIND = HOLEY_ELEMENTS
TERMINAL_FAST_ELEMENTS_KIND = HOLEY_ELEMENTS,
// Alias for kSystemPointerSize-sized elements
#ifdef V8_COMPRESS_POINTERS
SYSTEM_POINTER_ELEMENTS = PACKED_DOUBLE_ELEMENTS,
#else
SYSTEM_POINTER_ELEMENTS = PACKED_ELEMENTS,
#endif
};
constexpr int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
......
......@@ -1130,7 +1130,7 @@ void AccessorAssembler::OverwriteExistingFastDataProperty(
BIND(&inobject);
{
Node* field_offset = TimesPointerSize(field_index);
Node* field_offset = TimesTaggedSize(field_index);
Label tagged_rep(this), double_rep(this);
Branch(
Word32Equal(representation, Int32Constant(Representation::kDouble)),
......@@ -3640,7 +3640,7 @@ void AccessorAssembler::GenerateCloneObjectIC() {
TNode<IntPtrT> result_start =
LoadMapInobjectPropertiesStartInWords(result_map);
TNode<IntPtrT> field_offset_difference =
TimesPointerSize(IntPtrSub(result_start, source_start));
TimesTaggedSize(IntPtrSub(result_start, source_start));
// If MutableHeapNumbers may be present in-object, allocations may occur
// within this loop, thus the write barrier is required.
......@@ -3653,7 +3653,7 @@ void AccessorAssembler::GenerateCloneObjectIC() {
source_start, source_size,
[=](Node* field_index) {
TNode<IntPtrT> field_offset =
TimesPointerSize(UncheckedCast<IntPtrT>(field_index));
TimesTaggedSize(UncheckedCast<IntPtrT>(field_index));
if (may_use_mutable_heap_numbers) {
TNode<Object> field = LoadObjectField(source, field_offset);
......
......@@ -65,6 +65,12 @@ bool EQUALS(Isolate* isolate, T left, Handle<M> right) {
// Tests
//
TEST(SystemPointerElementsKind) {
CHECK_EQ(ElementsKindToShiftSize(SYSTEM_POINTER_ELEMENTS),
kSystemPointerSizeLog2);
CHECK_EQ(ElementsKindToByteSize(SYSTEM_POINTER_ELEMENTS), kSystemPointerSize);
}
TEST(JSObjectAddingProperties) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
......
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