Commit a374cc97 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[cleanup][CSA] TNodify StoreObjectField methods

TNodified:
 * StoreObjectField
 * StoreObjectFieldNoWriteBarrier

Bug: v8:10021
Change-Id: I74b34af410c560a1b005c0b93c71468ef57087fe
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1993296
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65733}
parent 304e97d3
......@@ -73,15 +73,18 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
IntPtrEqual(LoadMapInstanceSizeInWords(promise_map),
IntPtrConstant(JSPromise::kSizeWithEmbedderFields /
kTaggedSize)));
TNode<HeapObject> wrapped_value = InnerAllocate(base, kWrappedPromiseOffset);
TNode<JSPromise> promise;
{
// Initialize Promise
TNode<HeapObject> wrapped_value =
InnerAllocate(base, kWrappedPromiseOffset);
StoreMapNoWriteBarrier(wrapped_value, promise_map);
StoreObjectFieldRoot(wrapped_value, JSPromise::kPropertiesOrHashOffset,
RootIndex::kEmptyFixedArray);
StoreObjectFieldRoot(wrapped_value, JSPromise::kElementsOffset,
RootIndex::kEmptyFixedArray);
PromiseInit(wrapped_value);
promise = CAST(wrapped_value);
PromiseInit(promise);
}
// Initialize resolve handler
......@@ -103,16 +106,16 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
Branch(IsPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(),
&if_debugging, &do_resolve_promise);
BIND(&if_debugging);
var_throwaway = CAST(CallRuntime(Runtime::kAwaitPromisesInitOld, context,
value, wrapped_value, outer_promise,
on_reject, is_predicted_as_caught));
var_throwaway =
CAST(CallRuntime(Runtime::kAwaitPromisesInitOld, context, value, promise,
outer_promise, on_reject, is_predicted_as_caught));
Goto(&do_resolve_promise);
BIND(&do_resolve_promise);
// Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »).
CallBuiltin(Builtins::kResolvePromise, context, wrapped_value, value);
CallBuiltin(Builtins::kResolvePromise, context, promise, value);
return CallBuiltin(Builtins::kPerformPromiseThen, context, wrapped_value,
return CallBuiltin(Builtins::kPerformPromiseThen, context, promise,
on_resolve, on_reject, var_throwaway.value());
}
......
......@@ -42,7 +42,7 @@ TNode<JSPromise> PromiseBuiltinsAssembler::AllocateJSPromise(
return CAST(promise);
}
void PromiseBuiltinsAssembler::PromiseInit(Node* promise) {
void PromiseBuiltinsAssembler::PromiseInit(TNode<JSPromise> promise) {
STATIC_ASSERT(v8::Promise::kPending == 0);
StoreObjectFieldNoWriteBarrier(promise, JSPromise::kReactionsOrResultOffset,
SmiConstant(Smi::zero()));
......
......@@ -69,7 +69,7 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
SloppyTNode<Context> native_context,
TNode<Object> promise_constructor,
TNode<Object> executor, Label* if_noaccess);
void PromiseInit(Node* promise);
void PromiseInit(TNode<JSPromise> promise);
// We can shortcut the SpeciesConstructor on {promise_map} if it's
// [[Prototype]] is the (initial) Promise.prototype and the @@species
......
......@@ -336,11 +336,9 @@ TNode<String> StringBuiltinsAssembler::AllocateConsString(TNode<Uint32T> length,
[=] { return ConsStringMapConstant(); }));
TNode<HeapObject> result = AllocateInNewSpace(ConsString::kSize);
StoreMapNoWriteBarrier(result, result_map);
StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length,
MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length);
StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldOffset,
Int32Constant(String::kEmptyHashField),
MachineRepresentation::kWord32);
Int32Constant(String::kEmptyHashField));
StoreObjectFieldNoWriteBarrier(result, ConsString::kFirstOffset, left);
StoreObjectFieldNoWriteBarrier(result, ConsString::kSecondOffset, right);
return CAST(result);
......
......@@ -56,25 +56,20 @@ TNode<JSArrayBuffer> TypedArrayBuiltinsAssembler::AllocateEmptyOnHeapBuffer(
if (FIELD_SIZE(JSArrayBuffer::kOptionalPaddingOffset) != 0) {
DCHECK_EQ(4, FIELD_SIZE(JSArrayBuffer::kOptionalPaddingOffset));
StoreObjectFieldNoWriteBarrier(
buffer, JSArrayBuffer::kOptionalPaddingOffset, Int32Constant(0),
MachineRepresentation::kWord32);
buffer, JSArrayBuffer::kOptionalPaddingOffset, Int32Constant(0));
}
int32_t bitfield_value = (1 << JSArrayBuffer::IsExternalBit::kShift) |
(1 << JSArrayBuffer::IsDetachableBit::kShift);
StoreObjectFieldNoWriteBarrier(buffer, JSArrayBuffer::kBitFieldOffset,
Int32Constant(bitfield_value),
MachineRepresentation::kWord32);
Int32Constant(bitfield_value));
StoreObjectFieldNoWriteBarrier(buffer, JSArrayBuffer::kByteLengthOffset,
byte_length,
MachineType::PointerRepresentation());
byte_length);
StoreObjectFieldNoWriteBarrier(buffer, JSArrayBuffer::kBackingStoreOffset,
IntPtrConstant(0),
MachineType::PointerRepresentation());
IntPtrConstant(0));
if (V8_ARRAY_BUFFER_EXTENSION_BOOL) {
StoreObjectFieldNoWriteBarrier(buffer, JSArrayBuffer::kExtensionOffset,
IntPtrConstant(0),
MachineType::PointerRepresentation());
IntPtrConstant(0));
}
for (int offset = JSArrayBuffer::kHeaderSize;
offset < JSArrayBuffer::kSizeWithEmbedderFields; offset += kTaggedSize) {
......
......@@ -44,7 +44,7 @@ namespace promise {
extern macro ConstructorBuiltinsAssembler::EmitFastNewObject(
Context, JSFunction, JSReceiver): JSObject;
extern macro PromiseBuiltinsAssembler::PromiseInit(Object): void;
extern macro PromiseBuiltinsAssembler::PromiseInit(JSPromise): void;
extern macro
PromiseBuiltinsAssembler::IsPromiseHookEnabledOrHasAsyncEventDelegate(): bool;
......@@ -78,10 +78,9 @@ namespace promise {
if (promiseFun == newTarget) {
result = AllocateAndInitJSPromise(context);
} else {
const resultObject = EmitFastNewObject(
context, promiseFun, UnsafeCast<JSReceiver>(newTarget));
PromiseInit(resultObject);
result = UnsafeCast<JSPromise>(resultObject);
result = UnsafeCast<JSPromise>(EmitFastNewObject(
context, promiseFun, UnsafeCast<JSReceiver>(newTarget)));
PromiseInit(result);
if (IsPromiseHookEnabledOrHasAsyncEventDelegate()) {
runtime::PromiseHookInit(result, Undefined);
}
......
......@@ -2801,8 +2801,7 @@ void CodeStubAssembler::StoreObjectByteNoWriteBarrier(TNode<HeapObject> object,
void CodeStubAssembler::StoreHeapNumberValue(SloppyTNode<HeapNumber> object,
SloppyTNode<Float64T> value) {
StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value,
MachineRepresentation::kFloat64);
StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value);
}
void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, int offset,
......@@ -2813,7 +2812,8 @@ void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, int offset,
UncheckedCast<HeapObject>(object), offset, value);
}
void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, Node* offset,
void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object,
TNode<IntPtrT> offset,
TNode<Object> value) {
int const_offset;
if (ToInt32Constant(offset, &const_offset)) {
......@@ -2823,34 +2823,12 @@ void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, Node* offset,
}
}
void CodeStubAssembler::StoreObjectFieldNoWriteBarrier(
Node* object, int offset, Node* value, MachineRepresentation rep) {
if (CanBeTaggedPointer(rep)) {
OptimizedStoreFieldAssertNoWriteBarrier(
rep, UncheckedCast<HeapObject>(object), offset, value);
} else {
OptimizedStoreFieldUnsafeNoWriteBarrier(
rep, UncheckedCast<HeapObject>(object), offset, value);
}
}
void CodeStubAssembler::UnsafeStoreObjectFieldNoWriteBarrier(
TNode<HeapObject> object, int offset, TNode<Object> value) {
OptimizedStoreFieldUnsafeNoWriteBarrier(MachineRepresentation::kTagged,
object, offset, value);
}
void CodeStubAssembler::StoreObjectFieldNoWriteBarrier(
Node* object, SloppyTNode<IntPtrT> offset, Node* value,
MachineRepresentation rep) {
int const_offset;
if (ToInt32Constant(offset, &const_offset)) {
return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep);
}
StoreNoWriteBarrier(rep, object,
IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value);
}
void CodeStubAssembler::StoreMap(TNode<HeapObject> object, TNode<Map> map) {
OptimizedStoreMap(object, map);
}
......@@ -3170,16 +3148,14 @@ TNode<BigInt> CodeStubAssembler::AllocateRawBigInt(TNode<IntPtrT> length) {
if (FIELD_SIZE(BigInt::kOptionalPaddingOffset) != 0) {
DCHECK_EQ(4, FIELD_SIZE(BigInt::kOptionalPaddingOffset));
StoreObjectFieldNoWriteBarrier(raw_result, BigInt::kOptionalPaddingOffset,
Int32Constant(0),
MachineRepresentation::kWord32);
Int32Constant(0));
}
return UncheckedCast<BigInt>(raw_result);
}
void CodeStubAssembler::StoreBigIntBitfield(TNode<BigInt> bigint,
TNode<Word32T> bitfield) {
StoreObjectFieldNoWriteBarrier(bigint, BigInt::kBitfieldOffset, bitfield,
MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(bigint, BigInt::kBitfieldOffset, bitfield);
}
void CodeStubAssembler::StoreBigIntDigit(TNode<BigInt> bigint,
......@@ -3191,7 +3167,7 @@ void CodeStubAssembler::StoreBigIntDigit(TNode<BigInt> bigint,
bigint,
BigInt::kDigitsOffset +
static_cast<int>(digit_index) * kSystemPointerSize,
digit, UintPtrT::kMachineRepresentation);
digit);
}
void CodeStubAssembler::StoreBigIntDigit(TNode<BigInt> bigint,
......@@ -3200,8 +3176,7 @@ void CodeStubAssembler::StoreBigIntDigit(TNode<BigInt> bigint,
TNode<IntPtrT> offset =
IntPtrAdd(IntPtrConstant(BigInt::kDigitsOffset),
IntPtrMul(digit_index, IntPtrConstant(kSystemPointerSize)));
StoreObjectFieldNoWriteBarrier(bigint, offset, digit,
UintPtrT::kMachineRepresentation);
StoreObjectFieldNoWriteBarrier(bigint, offset, digit);
}
TNode<Word32T> CodeStubAssembler::LoadBigIntBitfield(TNode<BigInt> bigint) {
......@@ -3290,11 +3265,9 @@ TNode<String> CodeStubAssembler::AllocateSeqOneByteString(
DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kOneByteStringMap));
StoreMapNoWriteBarrier(result, RootIndex::kOneByteStringMap);
StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset,
Uint32Constant(length),
MachineRepresentation::kWord32);
Uint32Constant(length));
StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset,
Int32Constant(String::kEmptyHashField),
MachineRepresentation::kWord32);
Int32Constant(String::kEmptyHashField));
return CAST(result);
}
......@@ -3314,11 +3287,9 @@ TNode<String> CodeStubAssembler::AllocateSeqTwoByteString(
DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kStringMap));
StoreMapNoWriteBarrier(result, RootIndex::kStringMap);
StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset,
Uint32Constant(length),
MachineRepresentation::kWord32);
Uint32Constant(length));
StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset,
Int32Constant(String::kEmptyHashField),
MachineRepresentation::kWord32);
Int32Constant(String::kEmptyHashField));
return CAST(result);
}
......@@ -3332,14 +3303,10 @@ TNode<String> CodeStubAssembler::AllocateSlicedString(RootIndex map_root_index,
DCHECK(RootsTable::IsImmortalImmovable(map_root_index));
StoreMapNoWriteBarrier(result, map_root_index);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset,
Int32Constant(String::kEmptyHashField),
MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length,
MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent,
MachineRepresentation::kTagged);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset,
MachineRepresentation::kTagged);
Int32Constant(String::kEmptyHashField));
StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent);
StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset);
return CAST(result);
}
......@@ -3586,8 +3553,7 @@ void CodeStubAssembler::InitializeJSObjectBodyWithSlackTracking(
TNode<Word32T> new_bit_field3 = Int32Sub(
bit_field3,
Int32Constant(1 << Map::Bits3::ConstructionCounterBits::kShift));
StoreObjectFieldNoWriteBarrier(map, Map::kBitField3Offset, new_bit_field3,
MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(map, Map::kBitField3Offset, new_bit_field3);
STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
// The object still has in-object slack therefore the |unsed_or_unused|
......@@ -4347,9 +4313,9 @@ void CodeStubAssembler::InitializePropertyArrayLength(
IntPtrOrSmiLessThanOrEqual(
length, IntPtrOrSmiConstant(PropertyArray::LengthField::kMax, mode),
mode));
StoreObjectFieldNoWriteBarrier(
property_array, PropertyArray::kLengthAndHashOffset,
ParameterToTagged(length, mode), MachineRepresentation::kTaggedSigned);
StoreObjectFieldNoWriteBarrier(property_array,
PropertyArray::kLengthAndHashOffset,
ParameterToTagged(length, mode));
}
Node* CodeStubAssembler::AllocatePropertyArray(Node* capacity_node,
......@@ -5028,9 +4994,9 @@ void CodeStubAssembler::InitializeAllocationMemento(
allocation_site, AllocationSite::kPretenureCreateCountOffset);
TNode<Int32T> incremented_count = Int32Add(count, Int32Constant(1));
StoreObjectFieldNoWriteBarrier(
allocation_site, AllocationSite::kPretenureCreateCountOffset,
incremented_count, MachineRepresentation::kWord32);
StoreObjectFieldNoWriteBarrier(allocation_site,
AllocationSite::kPretenureCreateCountOffset,
incremented_count);
}
Comment("]");
}
......@@ -9446,8 +9412,7 @@ void CodeStubAssembler::ReportFeedbackUpdate(
const char* reason) {
// Reset profiler ticks.
StoreObjectFieldNoWriteBarrier(
feedback_vector, FeedbackVector::kProfilerTicksOffset, Int32Constant(0),
MachineRepresentation::kWord32);
feedback_vector, FeedbackVector::kProfilerTicksOffset, Int32Constant(0));
#ifdef V8_TRACE_FEEDBACK_UPDATES
// Trace the update.
......@@ -10025,7 +9990,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements,
GotoIfNot(IsJSArray(object), &done);
TNode<WordT> new_length = IntPtrAdd(key, IntPtrOrSmiConstant(1, mode));
StoreObjectFieldNoWriteBarrier(object, JSArray::kLengthOffset,
StoreObjectFieldNoWriteBarrier(CAST(object), JSArray::kLengthOffset,
ParameterToTagged(new_length, mode));
Goto(&done);
}
......@@ -10191,13 +10156,11 @@ TNode<AllocationSite> CodeStubAssembler::CreateAllocationSiteInFeedbackVector(
// Pretenuring calculation field.
StoreObjectFieldNoWriteBarrier(site, AllocationSite::kPretenureDataOffset,
Int32Constant(0),
MachineRepresentation::kWord32);
Int32Constant(0));
// Pretenuring memento creation count field.
StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kPretenureCreateCountOffset, Int32Constant(0),
MachineRepresentation::kWord32);
site, AllocationSite::kPretenureCreateCountOffset, Int32Constant(0));
// Store an empty fixed array for the code dependency.
StoreObjectFieldRoot(site, AllocationSite::kDependentCodeOffset,
......
......@@ -1546,30 +1546,35 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Store a field to an object on the heap.
void StoreObjectField(TNode<HeapObject> object, int offset,
TNode<Object> value);
void StoreObjectField(TNode<HeapObject> object, Node* offset,
void StoreObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset,
TNode<Object> value);
void StoreObjectFieldNoWriteBarrier(
Node* object, int offset, Node* value,
MachineRepresentation rep = MachineRepresentation::kTagged);
void UnsafeStoreObjectFieldNoWriteBarrier(TNode<HeapObject> object,
int offset, TNode<Object> value);
void StoreObjectFieldNoWriteBarrier(
Node* object, SloppyTNode<IntPtrT> offset, Node* value,
MachineRepresentation rep = MachineRepresentation::kTagged);
template <class T = Object>
void StoreObjectFieldNoWriteBarrier(Node* object, SloppyTNode<IntPtrT> offset,
template <class T>
void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object,
SloppyTNode<IntPtrT> offset,
TNode<T> value) {
StoreObjectFieldNoWriteBarrier(object, offset, value,
MachineRepresentationOf<T>::value);
int const_offset;
if (ToInt32Constant(offset, &const_offset)) {
return StoreObjectFieldNoWriteBarrier<T>(object, const_offset, value);
}
StoreNoWriteBarrier(MachineRepresentationOf<T>::value, object,
IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)),
value);
}
template <class T = Object>
void StoreObjectFieldNoWriteBarrier(Node* object, int offset,
template <class T>
void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object, int offset,
TNode<T> value) {
StoreObjectFieldNoWriteBarrier(object, offset, value,
MachineRepresentationOf<T>::value);
if (CanBeTaggedPointer(MachineRepresentationOf<T>::value)) {
OptimizedStoreFieldAssertNoWriteBarrier(MachineRepresentationOf<T>::value,
object, offset, value);
} else {
OptimizedStoreFieldUnsafeNoWriteBarrier(MachineRepresentationOf<T>::value,
object, offset, value);
}
}
void UnsafeStoreObjectFieldNoWriteBarrier(TNode<HeapObject> object,
int offset, TNode<Object> value);
// Store the Map of an HeapObject.
void StoreMap(TNode<HeapObject> object, TNode<Map> map);
void StoreMapNoWriteBarrier(TNode<HeapObject> object,
......
......@@ -1342,8 +1342,7 @@ void AccessorAssembler::OverwriteExistingFastDataProperty(
BranchIfSameNumberValue(current_value, double_value, &done, slow);
BIND(&if_mutable);
}
StoreObjectFieldNoWriteBarrier(object, field_offset, double_value,
MachineRepresentation::kFloat64);
StoreObjectFieldNoWriteBarrier(object, field_offset, double_value);
} else {
if (do_transitioning_store) {
TNode<HeapNumber> heap_number =
......@@ -1911,8 +1910,7 @@ void AccessorAssembler::HandleStoreFieldAndReturn(
BIND(&do_store);
// Do the store.
if (store_value_as_double) {
StoreObjectFieldNoWriteBarrier(property_storage, offset, *double_value,
MachineRepresentation::kFloat64);
StoreObjectFieldNoWriteBarrier(property_storage, offset, *double_value);
} else if (representation.IsSmi()) {
TNode<Smi> value_smi = CAST(value);
StoreObjectFieldNoWriteBarrier(property_storage, offset, value_smi);
......
......@@ -304,8 +304,8 @@ void KeyedStoreGenericAssembler::MaybeUpdateLengthAndReturn(
UpdateLength update_length) {
if (update_length != kDontChangeLength) {
TNode<Smi> new_length = SmiTag(Signed(IntPtrAdd(index, IntPtrConstant(1))));
StoreObjectFieldNoWriteBarrier(receiver, JSArray::kLengthOffset, new_length,
MachineRepresentation::kTagged);
StoreObjectFieldNoWriteBarrier(receiver, JSArray::kLengthOffset,
new_length);
}
Return(value);
}
......
......@@ -1186,8 +1186,7 @@ void InterpreterAssembler::UpdateInterruptBudget(TNode<Int32T> weight,
// Update budget.
StoreObjectFieldNoWriteBarrier(
feedback_cell, FeedbackCell::kInterruptBudgetOffset, new_budget.value(),
MachineRepresentation::kWord32);
feedback_cell, FeedbackCell::kInterruptBudgetOffset, new_budget.value());
Goto(&done);
BIND(&done);
Comment("] UpdateInterruptBudget");
......
......@@ -215,11 +215,11 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate,
param =
tester.raw_assembler_for_testing()->ChangeFloat32ToFloat64(param);
V8_FALLTHROUGH;
case MachineRepresentation::kFloat64:
case MachineRepresentation::kFloat64: {
__ StoreObjectFieldNoWriteBarrier(
__ LoadFixedArrayElement(result_array, i), HeapNumber::kValueOffset,
param, MachineRepresentation::kFloat64);
break;
__ Cast(__ LoadFixedArrayElement(result_array, i)),
HeapNumber::kValueOffset, __ UncheckedCast<Float64T>(param));
} break;
case MachineRepresentation::kSimd128: {
TNode<FixedArray> vector =
__ Cast(__ LoadFixedArrayElement(result_array, i));
......
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