Commit 3f675bbd authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] TNodify CSA::Store methods

Converts StoreObjectField, StoreMapNoWriteBarrier and
StoreObjectFieldRoot to use TNode parameters and convert all of their
uses.

Bug: v8:10021
Change-Id: Ic0511e43677f6aaaeac20df58a69be74156d390f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1980581Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65605}
parent 6951b5c6
......@@ -498,8 +498,8 @@ TF_BUILTIN(AsyncGeneratorResolve, AsyncGeneratorBuiltinsAssembler) {
// Let iteratorResult be CreateIterResultObject(value, done).
const TNode<HeapObject> iter_result = Allocate(JSIteratorResult::kSize);
{
TNode<Object> map = LoadContextElement(LoadNativeContext(context),
Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> map = CAST(LoadContextElement(
LoadNativeContext(context), Context::ITERATOR_RESULT_MAP_INDEX));
StoreMapNoWriteBarrier(iter_result, map);
StoreObjectFieldRoot(iter_result, JSIteratorResult::kPropertiesOrHashOffset,
RootIndex::kEmptyFixedArray);
......
......@@ -45,7 +45,7 @@ class BaseCollectionsAssembler : public CodeStubAssembler {
// possible.
void AddConstructorEntries(Variant variant, TNode<Context> context,
TNode<Context> native_context,
TNode<Object> collection,
TNode<HeapObject> collection,
TNode<Object> initial_entries);
// Fast path for adding constructor entries. Assumes the entries are a fast
......@@ -172,7 +172,7 @@ void BaseCollectionsAssembler::AddConstructorEntry(
void BaseCollectionsAssembler::AddConstructorEntries(
Variant variant, TNode<Context> context, TNode<Context> native_context,
TNode<Object> collection, TNode<Object> initial_entries) {
TNode<HeapObject> collection, TNode<Object> initial_entries) {
TVARIABLE(BoolT, use_fast_loop,
IsFastJSArrayWithNoCustomIteration(context, initial_entries));
TNode<IntPtrT> at_least_space_for =
......@@ -185,8 +185,8 @@ void BaseCollectionsAssembler::AddConstructorEntries(
TNode<HeapObject> table = AllocateTable(variant, at_least_space_for);
StoreObjectField(collection, GetTableOffset(variant), table);
GotoIf(IsNullOrUndefined(initial_entries), &exit);
GotoIfInitialAddFunctionModified(variant, CAST(native_context),
CAST(collection), &slow_loop);
GotoIfInitialAddFunctionModified(variant, CAST(native_context), collection,
&slow_loop);
Branch(use_fast_loop.value(), &fast_loop, &slow_loop);
}
BIND(&fast_loop);
......@@ -212,7 +212,7 @@ void BaseCollectionsAssembler::AddConstructorEntries(
// Check that add/set function has not been modified.
Label if_not_modified(this), if_modified(this);
GotoIfInitialAddFunctionModified(variant, CAST(native_context),
CAST(collection), &if_modified);
collection, &if_modified);
Goto(&if_not_modified);
BIND(&if_modified);
Unreachable();
......@@ -728,7 +728,7 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
// |iterable| is an iterator, it will update the state of the iterator to
// 'exhausted'.
TNode<JSArray> SetOrSetIteratorToList(TNode<Context> context,
TNode<Object> iterable);
TNode<HeapObject> iterable);
void BranchIfMapIteratorProtectorValid(Label* if_true, Label* if_false);
void BranchIfSetIteratorProtectorValid(Label* if_true, Label* if_false);
......@@ -826,8 +826,8 @@ TNode<HeapObject> CollectionsBuiltinsAssembler::AllocateJSCollectionIterator(
const TNode<Object> table =
LoadObjectField(collection, JSCollection::kTableOffset);
const TNode<NativeContext> native_context = LoadNativeContext(context);
const TNode<Object> iterator_map =
LoadContextElement(native_context, map_index);
const TNode<Map> iterator_map =
CAST(LoadContextElement(native_context, map_index));
const TNode<HeapObject> iterator =
AllocateInNewSpace(IteratorType::kHeaderSize);
StoreMapNoWriteBarrier(iterator, iterator_map);
......@@ -1167,17 +1167,17 @@ TF_BUILTIN(MapIteratorToList, CollectionsBuiltinsAssembler) {
}
TNode<JSArray> CollectionsBuiltinsAssembler::SetOrSetIteratorToList(
TNode<Context> context, TNode<Object> iterable) {
TNode<Context> context, TNode<HeapObject> iterable) {
TVARIABLE(OrderedHashSet, var_table);
Label if_set(this), if_iterator(this), copy(this);
const TNode<Uint16T> instance_type = LoadInstanceType(CAST(iterable));
const TNode<Uint16T> instance_type = LoadInstanceType(iterable);
Branch(InstanceTypeEqual(instance_type, JS_SET_TYPE), &if_set, &if_iterator);
BIND(&if_set);
{
// {iterable} is a JSSet.
var_table = CAST(LoadObjectField(CAST(iterable), JSSet::kTableOffset));
var_table = CAST(LoadObjectField(iterable, JSSet::kTableOffset));
Goto(&copy);
}
......@@ -1249,7 +1249,7 @@ TNode<JSArray> CollectionsBuiltinsAssembler::SetOrSetIteratorToList(
TF_BUILTIN(SetOrSetIteratorToList, CollectionsBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> object = CAST(Parameter(Descriptor::kSource));
TNode<HeapObject> object = CAST(Parameter(Descriptor::kSource));
Return(SetOrSetIteratorToList(context, object));
}
......@@ -2057,14 +2057,14 @@ TF_BUILTIN(MapPrototypeValues, CollectionsBuiltinsAssembler) {
TF_BUILTIN(MapIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
const char* const kMethodName = "Map Iterator.prototype.next";
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
const TNode<Object> maybe_receiver = CAST(Parameter(Descriptor::kReceiver));
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
// Ensure that the {receiver} is actually a JSMapIterator.
// Ensure that {maybe_receiver} is actually a JSMapIterator.
Label if_receiver_valid(this), if_receiver_invalid(this, Label::kDeferred);
GotoIf(TaggedIsSmi(receiver), &if_receiver_invalid);
GotoIf(TaggedIsSmi(maybe_receiver), &if_receiver_invalid);
const TNode<Uint16T> receiver_instance_type =
LoadInstanceType(CAST(receiver));
LoadInstanceType(CAST(maybe_receiver));
GotoIf(
InstanceTypeEqual(receiver_instance_type, JS_MAP_KEY_VALUE_ITERATOR_TYPE),
&if_receiver_valid);
......@@ -2074,8 +2074,9 @@ TF_BUILTIN(MapIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
&if_receiver_valid, &if_receiver_invalid);
BIND(&if_receiver_invalid);
ThrowTypeError(context, MessageTemplate::kIncompatibleMethodReceiver,
StringConstant(kMethodName), receiver);
StringConstant(kMethodName), maybe_receiver);
BIND(&if_receiver_valid);
TNode<JSMapIterator> receiver = CAST(maybe_receiver);
// Check if the {receiver} is exhausted.
TVARIABLE(Oddball, var_done, TrueConstant());
......@@ -2087,7 +2088,7 @@ TF_BUILTIN(MapIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
TNode<OrderedHashMap> table;
TNode<IntPtrT> index;
std::tie(table, index) =
TransitionAndUpdate<JSMapIterator, OrderedHashMap>(CAST(receiver));
TransitionAndUpdate<JSMapIterator, OrderedHashMap>(receiver);
// Read the next entry from the {table}, skipping holes.
TNode<Object> entry_key;
......@@ -2279,14 +2280,14 @@ TF_BUILTIN(SetPrototypeValues, CollectionsBuiltinsAssembler) {
TF_BUILTIN(SetIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
const char* const kMethodName = "Set Iterator.prototype.next";
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
const TNode<Object> maybe_receiver = CAST(Parameter(Descriptor::kReceiver));
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
// Ensure that the {receiver} is actually a JSSetIterator.
// Ensure that {maybe_receiver} is actually a JSSetIterator.
Label if_receiver_valid(this), if_receiver_invalid(this, Label::kDeferred);
GotoIf(TaggedIsSmi(receiver), &if_receiver_invalid);
GotoIf(TaggedIsSmi(maybe_receiver), &if_receiver_invalid);
const TNode<Uint16T> receiver_instance_type =
LoadInstanceType(CAST(receiver));
LoadInstanceType(CAST(maybe_receiver));
GotoIf(InstanceTypeEqual(receiver_instance_type, JS_SET_VALUE_ITERATOR_TYPE),
&if_receiver_valid);
Branch(
......@@ -2294,9 +2295,11 @@ TF_BUILTIN(SetIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
&if_receiver_valid, &if_receiver_invalid);
BIND(&if_receiver_invalid);
ThrowTypeError(context, MessageTemplate::kIncompatibleMethodReceiver,
StringConstant(kMethodName), receiver);
StringConstant(kMethodName), maybe_receiver);
BIND(&if_receiver_valid);
TNode<JSSetIterator> receiver = CAST(maybe_receiver);
// Check if the {receiver} is exhausted.
TVARIABLE(Oddball, var_done, TrueConstant());
TVARIABLE(Object, var_value, UndefinedConstant());
......@@ -2307,7 +2310,7 @@ TF_BUILTIN(SetIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
TNode<OrderedHashSet> table;
TNode<IntPtrT> index;
std::tie(table, index) =
TransitionAndUpdate<JSSetIterator, OrderedHashSet>(CAST(receiver));
TransitionAndUpdate<JSSetIterator, OrderedHashSet>(receiver);
// Read the next entry from the {table}, skipping holes.
TNode<Object> entry_key;
......
......@@ -733,8 +733,8 @@ TF_BUILTIN(NumberConstructor, ConstructorBuiltinsAssembler) {
// from the current frame here in order to reduce register pressure on the
// fast path.
TNode<JSFunction> target = LoadTargetFromFrame();
TNode<Object> result =
CallBuiltin(Builtins::kFastNewObject, context, target, new_target);
TNode<HeapObject> result = CAST(
CallBuiltin(Builtins::kFastNewObject, context, target, new_target));
StoreObjectField(result, JSPrimitiveWrapper::kValueOffset, n_value);
args.PopAndReturn(result);
}
......
......@@ -429,8 +429,8 @@ TF_BUILTIN(ToObject, CodeStubAssembler) {
TNode<NativeContext> native_context = LoadNativeContext(context);
TNode<JSFunction> constructor = CAST(LoadContextElement(
native_context, constructor_function_index_var.value()));
TNode<Object> initial_map =
LoadObjectField(constructor, JSFunction::kPrototypeOrInitialMapOffset);
TNode<Map> initial_map = LoadObjectField<Map>(
constructor, JSFunction::kPrototypeOrInitialMapOffset);
TNode<HeapObject> js_primitive_wrapper =
Allocate(JSPrimitiveWrapper::kHeaderSize);
StoreMapNoWriteBarrier(js_primitive_wrapper, initial_map);
......
......@@ -30,8 +30,8 @@ TNode<JSPromise> PromiseBuiltinsAssembler::AllocateJSPromise(
const TNode<JSFunction> promise_fun =
CAST(LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX));
CSA_ASSERT(this, IsFunctionWithPrototypeSlotMap(LoadMap(promise_fun)));
const TNode<Object> promise_map =
LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
const TNode<Map> promise_map = LoadObjectField<Map>(
promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
const TNode<HeapObject> promise =
Allocate(JSPromise::kSizeWithEmbedderFields);
StoreMapNoWriteBarrier(promise, promise_map);
......
......@@ -2822,16 +2822,16 @@ void CodeStubAssembler::StoreHeapNumberValue(SloppyTNode<HeapNumber> object,
MachineRepresentation::kFloat64);
}
void CodeStubAssembler::StoreObjectField(Node* object, int offset,
Node* value) {
void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, int offset,
TNode<Object> value) {
DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead.
OptimizedStoreField(MachineRepresentation::kTagged,
UncheckedCast<HeapObject>(object), offset, value);
}
void CodeStubAssembler::StoreObjectField(Node* object, Node* offset,
Node* value) {
void CodeStubAssembler::StoreObjectField(TNode<HeapObject> object, Node* offset,
TNode<Object> value) {
int const_offset;
if (ToInt32Constant(offset, &const_offset)) {
StoreObjectField(object, const_offset, value);
......@@ -2872,24 +2872,23 @@ void CodeStubAssembler::StoreMap(TNode<HeapObject> object, TNode<Map> map) {
OptimizedStoreMap(object, map);
}
void CodeStubAssembler::StoreMapNoWriteBarrier(Node* object,
void CodeStubAssembler::StoreMapNoWriteBarrier(TNode<HeapObject> object,
RootIndex map_root_index) {
StoreMapNoWriteBarrier(object, LoadRoot(map_root_index));
StoreMapNoWriteBarrier(object, CAST(LoadRoot(map_root_index)));
}
void CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) {
CSA_SLOW_ASSERT(this, IsMap(map));
void CodeStubAssembler::StoreMapNoWriteBarrier(TNode<HeapObject> object,
TNode<Map> map) {
OptimizedStoreFieldAssertNoWriteBarrier(MachineRepresentation::kTaggedPointer,
UncheckedCast<HeapObject>(object),
HeapObject::kMapOffset, map);
object, HeapObject::kMapOffset, map);
}
void CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset,
RootIndex root_index) {
void CodeStubAssembler::StoreObjectFieldRoot(TNode<HeapObject> object,
int offset, RootIndex root_index) {
if (RootsTable::IsImmortalImmovable(root_index)) {
return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index));
StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index));
} else {
return StoreObjectField(object, offset, LoadRoot(root_index));
StoreObjectField(object, offset, LoadRoot(root_index));
}
}
......@@ -5028,7 +5027,7 @@ TNode<FixedArrayBase> CodeStubAssembler::GrowElementsCapacity(
CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity,
new_capacity, SKIP_WRITE_BARRIER, mode);
StoreObjectField(object, JSObject::kElementsOffset, new_elements);
StoreObjectField(CAST(object), JSObject::kElementsOffset, new_elements);
Comment("] GrowElementsCapacity");
return new_elements;
}
......@@ -12441,8 +12440,8 @@ TNode<JSObject> CodeStubAssembler::AllocateJSIteratorResult(
SloppyTNode<Oddball> done) {
CSA_ASSERT(this, IsBoolean(done));
TNode<NativeContext> native_context = LoadNativeContext(context);
TNode<Object> map =
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> map = CAST(
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
TNode<HeapObject> result = Allocate(JSIteratorResult::kSize);
StoreMapNoWriteBarrier(result, map);
StoreObjectFieldRoot(result, JSIteratorResult::kPropertiesOrHashOffset,
......@@ -12466,16 +12465,16 @@ TNode<JSObject> CodeStubAssembler::AllocateJSIteratorResultForEntry(
StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, length);
StoreFixedArrayElement(elements, 0, key);
StoreFixedArrayElement(elements, 1, value);
TNode<Object> array_map = LoadContextElement(
native_context, Context::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX);
TNode<Map> array_map = CAST(LoadContextElement(
native_context, Context::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX));
TNode<HeapObject> array = InnerAllocate(elements, elements_size);
StoreMapNoWriteBarrier(array, array_map);
StoreObjectFieldRoot(array, JSArray::kPropertiesOrHashOffset,
RootIndex::kEmptyFixedArray);
StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements);
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
TNode<Object> iterator_map =
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> iterator_map = CAST(
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
TNode<HeapObject> result = InnerAllocate(array, JSArray::kHeaderSize);
StoreMapNoWriteBarrier(result, iterator_map);
StoreObjectFieldRoot(result, JSIteratorResult::kPropertiesOrHashOffset,
......
......@@ -1536,8 +1536,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
void StoreHeapNumberValue(SloppyTNode<HeapNumber> object,
SloppyTNode<Float64T> value);
// Store a field to an object on the heap.
void StoreObjectField(Node* object, int offset, Node* value);
void StoreObjectField(Node* object, Node* offset, Node* value);
void StoreObjectField(TNode<HeapObject> object, int offset,
TNode<Object> value);
void StoreObjectField(TNode<HeapObject> object, Node* offset,
TNode<Object> value);
void StoreObjectFieldNoWriteBarrier(
Node* object, int offset, Node* value,
MachineRepresentation rep = MachineRepresentation::kTagged);
......@@ -1562,9 +1564,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Store the Map of an HeapObject.
void StoreMap(TNode<HeapObject> object, TNode<Map> map);
void StoreMapNoWriteBarrier(Node* object, RootIndex map_root_index);
void StoreMapNoWriteBarrier(Node* object, Node* map);
void StoreObjectFieldRoot(Node* object, int offset, RootIndex root);
void StoreMapNoWriteBarrier(TNode<HeapObject> object,
RootIndex map_root_index);
void StoreMapNoWriteBarrier(TNode<HeapObject> object, TNode<Map> map);
void StoreObjectFieldRoot(TNode<HeapObject> object, int offset,
RootIndex root);
// Store an array element to a FixedArray.
void StoreFixedArrayElement(
TNode<FixedArray> object, int index, SloppyTNode<Object> value,
......
......@@ -795,7 +795,8 @@ IGNITION_HANDLER(StaModuleVariable, InterpreterAssembler) {
module, SourceTextModule::kRegularExportsOffset);
// The actual array index is (cell_index - 1).
TNode<IntPtrT> export_index = IntPtrSub(cell_index, IntPtrConstant(1));
TNode<Object> cell = LoadFixedArrayElement(regular_exports, export_index);
TNode<HeapObject> cell =
CAST(LoadFixedArrayElement(regular_exports, export_index));
StoreObjectField(cell, Cell::kValueOffset, value);
Goto(&end);
}
......
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