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);
}
......
This diff is collapsed.
......@@ -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