Commit 6951b5c6 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Tnodify all uses of LoadBufferObject/LoadObjectField

Makes the Node* versions private so they can still be called from the
inlined TNode versions.

Also changes to LoadFromParentFrame to return TNode<Object> since its
uses don't require anything looser.

Bug: v8:10021
Change-Id: I84e3831d444a7787e0b03ff2f9e665181a9caa06
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1980578
Commit-Queue: Dan Elphick <delphick@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65604}
parent c2c58856
...@@ -84,13 +84,13 @@ TF_BUILTIN(AsyncFunctionEnter, AsyncFunctionBuiltinsAssembler) { ...@@ -84,13 +84,13 @@ TF_BUILTIN(AsyncFunctionEnter, AsyncFunctionBuiltinsAssembler) {
// Compute the number of registers and parameters. // Compute the number of registers and parameters.
TNode<SharedFunctionInfo> shared = LoadObjectField<SharedFunctionInfo>( TNode<SharedFunctionInfo> shared = LoadObjectField<SharedFunctionInfo>(
closure, JSFunction::kSharedFunctionInfoOffset); closure, JSFunction::kSharedFunctionInfoOffset);
TNode<IntPtrT> formal_parameter_count = ChangeInt32ToIntPtr( TNode<IntPtrT> formal_parameter_count =
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset, ChangeInt32ToIntPtr(LoadObjectField<Uint16T>(
MachineType::Uint16())); shared, SharedFunctionInfo::kFormalParameterCountOffset));
TNode<BytecodeArray> bytecode_array = TNode<BytecodeArray> bytecode_array =
LoadSharedFunctionInfoBytecodeArray(shared); LoadSharedFunctionInfoBytecodeArray(shared);
TNode<IntPtrT> frame_size = ChangeInt32ToIntPtr(LoadObjectField( TNode<IntPtrT> frame_size = ChangeInt32ToIntPtr(LoadObjectField<Uint32T>(
bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32())); bytecode_array, BytecodeArray::kFrameSizeOffset));
TNode<IntPtrT> parameters_and_register_length = TNode<IntPtrT> parameters_and_register_length =
Signed(IntPtrAdd(WordSar(frame_size, IntPtrConstant(kTaggedSizeLog2)), Signed(IntPtrAdd(WordSar(frame_size, IntPtrConstant(kTaggedSizeLog2)),
formal_parameter_count)); formal_parameter_count));
......
...@@ -1235,11 +1235,11 @@ TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) { ...@@ -1235,11 +1235,11 @@ TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) {
TNode<BytecodeArray> bytecode_array = TNode<BytecodeArray> bytecode_array =
LoadSharedFunctionInfoBytecodeArray(shared); LoadSharedFunctionInfoBytecodeArray(shared);
TNode<IntPtrT> formal_parameter_count = ChangeInt32ToIntPtr( TNode<IntPtrT> formal_parameter_count =
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset, ChangeInt32ToIntPtr(LoadObjectField<Uint16T>(
MachineType::Uint16())); shared, SharedFunctionInfo::kFormalParameterCountOffset));
TNode<IntPtrT> frame_size = ChangeInt32ToIntPtr(LoadObjectField( TNode<IntPtrT> frame_size = ChangeInt32ToIntPtr(
bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32())); LoadObjectField<Int32T>(bytecode_array, BytecodeArray::kFrameSizeOffset));
TNode<IntPtrT> size = TNode<IntPtrT> size =
IntPtrAdd(WordSar(frame_size, IntPtrConstant(kTaggedSizeLog2)), IntPtrAdd(WordSar(frame_size, IntPtrConstant(kTaggedSizeLog2)),
formal_parameter_count); formal_parameter_count);
......
...@@ -44,8 +44,8 @@ TNode<RawPtrT> RegExpBuiltinsAssembler::LoadCodeObjectEntry(TNode<Code> code) { ...@@ -44,8 +44,8 @@ TNode<RawPtrT> RegExpBuiltinsAssembler::LoadCodeObjectEntry(TNode<Code> code) {
TVARIABLE(RawPtrT, var_result); TVARIABLE(RawPtrT, var_result);
Label if_code_is_off_heap(this), out(this); Label if_code_is_off_heap(this), out(this);
TNode<Int32T> builtin_index = UncheckedCast<Int32T>( TNode<Int32T> builtin_index =
LoadObjectField(code, Code::kBuiltinIndexOffset, MachineType::Int32())); LoadObjectField<Int32T>(code, Code::kBuiltinIndexOffset);
{ {
GotoIfNot(Word32Equal(builtin_index, Int32Constant(Builtins::kNoBuiltinId)), GotoIfNot(Word32Equal(builtin_index, Int32Constant(Builtins::kNoBuiltinId)),
&if_code_is_off_heap); &if_code_is_off_heap);
......
...@@ -1500,14 +1500,10 @@ void CodeStubAssembler::BranchIfToBooleanIsTrue(SloppyTNode<Object> value, ...@@ -1500,14 +1500,10 @@ void CodeStubAssembler::BranchIfToBooleanIsTrue(SloppyTNode<Object> value,
} }
} }
Node* CodeStubAssembler::LoadFromParentFrame(int offset, MachineType type) { TNode<Object> CodeStubAssembler::LoadFromParentFrame(int offset) {
TNode<RawPtrT> frame_pointer = LoadParentFramePointer(); TNode<RawPtrT> frame_pointer = LoadParentFramePointer();
return Load(type, frame_pointer, IntPtrConstant(offset)); return CAST(
} Load(MachineType::AnyTagged(), frame_pointer, IntPtrConstant(offset)));
Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
MachineType type) {
return Load(type, buffer, IntPtrConstant(offset));
} }
Node* CodeStubAssembler::LoadObjectField(SloppyTNode<HeapObject> object, Node* CodeStubAssembler::LoadObjectField(SloppyTNode<HeapObject> object,
......
...@@ -1023,24 +1023,25 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1023,24 +1023,25 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
void GotoIfForceSlowPath(Label* if_true); void GotoIfForceSlowPath(Label* if_true);
// Load value from current parent frame by given offset in bytes. // Load value from current parent frame by given offset in bytes.
Node* LoadFromParentFrame(int offset, TNode<Object> LoadFromParentFrame(int offset);
MachineType type = MachineType::AnyTagged());
// Load an object pointer from a buffer that isn't in the heap. // Load an object pointer from a buffer that isn't in the heap.
Node* LoadBufferObject(Node* buffer, int offset, MachineType type); template <typename T = Object>
TNode<Object> LoadBufferObject(TNode<RawPtrT> buffer, int offset) { TNode<T> LoadBufferObject(TNode<RawPtrT> buffer, int offset) {
return CAST(LoadBufferObject(buffer, offset, MachineType::AnyTagged())); return CAST(Load(MachineTypeOf<T>::value, buffer, IntPtrConstant(offset)));
}
template <typename T>
TNode<T> LoadBufferData(TNode<RawPtrT> buffer, int offset) {
return UncheckedCast<T>(
Load(MachineTypeOf<T>::value, buffer, IntPtrConstant(offset)));
} }
TNode<RawPtrT> LoadBufferPointer(TNode<RawPtrT> buffer, int offset) { TNode<RawPtrT> LoadBufferPointer(TNode<RawPtrT> buffer, int offset) {
return UncheckedCast<RawPtrT>( return LoadBufferData<RawPtrT>(buffer, offset);
LoadBufferObject(buffer, offset, MachineType::Pointer()));
} }
TNode<Smi> LoadBufferSmi(TNode<RawPtrT> buffer, int offset) { TNode<Smi> LoadBufferSmi(TNode<RawPtrT> buffer, int offset) {
return CAST(LoadBufferObject(buffer, offset, MachineType::TaggedSigned())); return LoadBufferObject<Smi>(buffer, offset);
} }
// Load a field from an object on the heap. // Load a field from an object on the heap.
Node* LoadObjectField(SloppyTNode<HeapObject> object, int offset,
MachineType type);
template <class T, typename std::enable_if< template <class T, typename std::enable_if<
std::is_convertible<TNode<T>, TNode<Object>>::value, std::is_convertible<TNode<T>, TNode<Object>>::value,
int>::type = 0> int>::type = 0>
...@@ -1058,8 +1059,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1058,8 +1059,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return UncheckedCast<Object>( return UncheckedCast<Object>(
LoadObjectField(object, offset, MachineType::AnyTagged())); LoadObjectField(object, offset, MachineType::AnyTagged()));
} }
Node* LoadObjectField(SloppyTNode<HeapObject> object,
SloppyTNode<IntPtrT> offset, MachineType type);
TNode<Object> LoadObjectField(SloppyTNode<HeapObject> object, TNode<Object> LoadObjectField(SloppyTNode<HeapObject> object,
SloppyTNode<IntPtrT> offset) { SloppyTNode<IntPtrT> offset) {
return UncheckedCast<Object>( return UncheckedCast<Object>(
...@@ -3837,7 +3836,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3837,7 +3836,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TVariable<Object>* var_maybe_bigint = nullptr, TVariable<Object>* var_maybe_bigint = nullptr,
TVariable<Smi>* var_feedback = nullptr); TVariable<Smi>* var_feedback = nullptr);
private: Node* LoadObjectField(SloppyTNode<HeapObject> object, int offset,
MachineType type);
Node* LoadObjectField(SloppyTNode<HeapObject> object,
SloppyTNode<IntPtrT> offset, MachineType type);
// Low-level accessors for Descriptor arrays. // Low-level accessors for Descriptor arrays.
template <typename T> template <typename T>
TNode<T> LoadDescriptorArrayElement(TNode<DescriptorArray> object, TNode<T> LoadDescriptorArrayElement(TNode<DescriptorArray> object,
......
...@@ -204,10 +204,10 @@ void AccessorAssembler::HandleLoadAccessor( ...@@ -204,10 +204,10 @@ void AccessorAssembler::HandleLoadAccessor(
CSA_CHECK(this, IsNotCleared(maybe_context)); CSA_CHECK(this, IsNotCleared(maybe_context));
TNode<HeapObject> context = GetHeapObjectAssumeWeak(maybe_context); TNode<HeapObject> context = GetHeapObjectAssumeWeak(maybe_context);
TNode<Foreign> foreign = CAST( TNode<Foreign> foreign = LoadObjectField<Foreign>(
LoadObjectField(call_handler_info, CallHandlerInfo::kJsCallbackOffset)); call_handler_info, CallHandlerInfo::kJsCallbackOffset);
TNode<WordT> callback = TNode<WordT>::UncheckedCast(LoadObjectField( TNode<RawPtrT> callback =
foreign, Foreign::kForeignAddressOffset, MachineType::Pointer())); LoadObjectField<RawPtrT>(foreign, Foreign::kForeignAddressOffset);
TNode<Object> data = TNode<Object> data =
LoadObjectField(call_handler_info, CallHandlerInfo::kDataOffset); LoadObjectField(call_handler_info, CallHandlerInfo::kDataOffset);
...@@ -660,8 +660,8 @@ void AccessorAssembler::HandleLoadICSmiHandlerLoadNamedCase( ...@@ -660,8 +660,8 @@ void AccessorAssembler::HandleLoadICSmiHandlerLoadNamedCase(
Comment("module export"); Comment("module export");
TNode<UintPtrT> index = TNode<UintPtrT> index =
DecodeWord<LoadHandler::ExportsIndexBits>(handler_word); DecodeWord<LoadHandler::ExportsIndexBits>(handler_word);
TNode<Module> module = CAST( TNode<Module> module = LoadObjectField<Module>(
LoadObjectField(CAST(p->receiver()), JSModuleNamespace::kModuleOffset)); CAST(p->receiver()), JSModuleNamespace::kModuleOffset);
TNode<ObjectHashTable> exports = TNode<ObjectHashTable> exports =
LoadObjectField<ObjectHashTable>(module, Module::kExportsOffset); LoadObjectField<ObjectHashTable>(module, Module::kExportsOffset);
TNode<Cell> cell = CAST(LoadFixedArrayElement(exports, index)); TNode<Cell> cell = CAST(LoadFixedArrayElement(exports, index));
......
...@@ -3275,9 +3275,8 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) { ...@@ -3275,9 +3275,8 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
TNode<SharedFunctionInfo> shared = TNode<SharedFunctionInfo> shared =
CAST(LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset)); CAST(LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset));
TNode<Int32T> formal_parameter_count = UncheckedCast<Int32T>( TNode<Int32T> formal_parameter_count = LoadObjectField<Uint16T>(
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset, shared, SharedFunctionInfo::kFormalParameterCountOffset);
MachineType::Uint16()));
ExportParametersAndRegisterFile(array, registers, formal_parameter_count); ExportParametersAndRegisterFile(array, registers, formal_parameter_count);
StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
...@@ -3352,9 +3351,8 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) { ...@@ -3352,9 +3351,8 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
TNode<SharedFunctionInfo> shared = TNode<SharedFunctionInfo> shared =
CAST(LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset)); CAST(LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset));
TNode<Int32T> formal_parameter_count = UncheckedCast<Int32T>( TNode<Int32T> formal_parameter_count = LoadObjectField<Uint16T>(
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset, shared, SharedFunctionInfo::kFormalParameterCountOffset);
MachineType::Uint16()));
ImportRegisterFile( ImportRegisterFile(
CAST(LoadObjectField(generator, CAST(LoadObjectField(generator,
......
...@@ -2854,12 +2854,11 @@ TEST(DirectMemoryTest8BitWord32Immediate) { ...@@ -2854,12 +2854,11 @@ TEST(DirectMemoryTest8BitWord32Immediate) {
const int element_count = 8; const int element_count = 8;
Label bad(&m); Label bad(&m);
TNode<IntPtrT> buffer_node = TNode<RawPtrT> buffer_node = m.PointerConstant(buffer);
m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer));
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
for (size_t j = 0; j < element_count; ++j) { for (size_t j = 0; j < element_count; ++j) {
Node* loaded = m.LoadBufferObject(buffer_node, static_cast<int>(i), TNode<Uint8T> loaded =
MachineType::Uint8()); m.LoadBufferData<Uint8T>(buffer_node, static_cast<int>(i));
TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j]));
if ((buffer[j] & buffer[i]) != 0) { if ((buffer[j] & buffer[i]) != 0) {
m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad);
...@@ -2887,13 +2886,11 @@ TEST(DirectMemoryTest16BitWord32Immediate) { ...@@ -2887,13 +2886,11 @@ TEST(DirectMemoryTest16BitWord32Immediate) {
const int element_count = 8; const int element_count = 8;
Label bad(&m); Label bad(&m);
TNode<IntPtrT> buffer_node = TNode<RawPtrT> buffer_node = m.PointerConstant(buffer);
m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer));
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
for (size_t j = 0; j < element_count; ++j) { for (size_t j = 0; j < element_count; ++j) {
Node* loaded = TNode<Uint16T> loaded = m.LoadBufferData<Uint16T>(
m.LoadBufferObject(buffer_node, static_cast<int>(i * sizeof(int16_t)), buffer_node, static_cast<int>(i * sizeof(int16_t)));
MachineType::Uint16());
TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j]));
if ((buffer[j] & buffer[i]) != 0) { if ((buffer[j] & buffer[i]) != 0) {
m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad);
...@@ -2920,19 +2917,17 @@ TEST(DirectMemoryTest8BitWord32) { ...@@ -2920,19 +2917,17 @@ TEST(DirectMemoryTest8BitWord32) {
int8_t buffer[] = {1, 2, 4, 8, 17, 33, 65, 127, 67, 38}; int8_t buffer[] = {1, 2, 4, 8, 17, 33, 65, 127, 67, 38};
const int element_count = 10; const int element_count = 10;
Label bad(&m); Label bad(&m);
Node* constants[element_count]; TNode<Uint32T> constants[element_count];
TNode<IntPtrT> buffer_node = TNode<RawPtrT> buffer_node = m.PointerConstant(buffer);
m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer));
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
constants[i] = m.LoadBufferObject(buffer_node, static_cast<int>(i), constants[i] = m.LoadBufferData<Uint8T>(buffer_node, static_cast<int>(i));
MachineType::Uint8());
} }
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
for (size_t j = 0; j < element_count; ++j) { for (size_t j = 0; j < element_count; ++j) {
Node* loaded = m.LoadBufferObject(buffer_node, static_cast<int>(i), TNode<Uint8T> loaded =
MachineType::Uint8()); m.LoadBufferData<Uint8T>(buffer_node, static_cast<int>(i));
TNode<Word32T> masked = m.Word32And(loaded, constants[j]); TNode<Word32T> masked = m.Word32And(loaded, constants[j]);
if ((buffer[j] & buffer[i]) != 0) { if ((buffer[j] & buffer[i]) != 0) {
m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad);
...@@ -2966,23 +2961,19 @@ TEST(DirectMemoryTest16BitWord32) { ...@@ -2966,23 +2961,19 @@ TEST(DirectMemoryTest16BitWord32) {
int16_t buffer[] = {1, 2, 4, 8, 12345, 33, 65, 255, 67, 3823}; int16_t buffer[] = {1, 2, 4, 8, 12345, 33, 65, 255, 67, 3823};
const int element_count = 10; const int element_count = 10;
Label bad(&m); Label bad(&m);
Node* constants[element_count]; TNode<Uint32T> constants[element_count];
TNode<IntPtrT> buffer_node1 = TNode<RawPtrT> buffer_node1 = m.PointerConstant(buffer);
m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer));
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
constants[i] = constants[i] = m.LoadBufferData<Uint16T>(
m.LoadBufferObject(buffer_node1, static_cast<int>(i * sizeof(int16_t)), buffer_node1, static_cast<int>(i * sizeof(int16_t)));
MachineType::Uint16());
} }
TNode<IntPtrT> buffer_node2 = TNode<RawPtrT> buffer_node2 = m.PointerConstant(buffer);
m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer));
for (size_t i = 0; i < element_count; ++i) { for (size_t i = 0; i < element_count; ++i) {
for (size_t j = 0; j < element_count; ++j) { for (size_t j = 0; j < element_count; ++j) {
Node* loaded = m.LoadBufferObject(buffer_node1, Node* loaded = m.LoadBufferData<Uint16T>(
static_cast<int>(i * sizeof(int16_t)), buffer_node1, static_cast<int>(i * sizeof(int16_t)));
MachineType::Uint16());
TNode<Word32T> masked = m.Word32And(loaded, constants[j]); TNode<Word32T> masked = m.Word32And(loaded, constants[j]);
if ((buffer[j] & buffer[i]) != 0) { if ((buffer[j] & buffer[i]) != 0) {
m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad);
...@@ -2991,9 +2982,8 @@ TEST(DirectMemoryTest16BitWord32) { ...@@ -2991,9 +2982,8 @@ TEST(DirectMemoryTest16BitWord32) {
} }
// Force a memory access relative to a high-number register. // Force a memory access relative to a high-number register.
loaded = m.LoadBufferObject(buffer_node2, loaded = m.LoadBufferData<Uint16T>(buffer_node2,
static_cast<int>(i * sizeof(int16_t)), static_cast<int>(i * sizeof(int16_t)));
MachineType::Uint16());
masked = m.Word32And(loaded, constants[j]); masked = m.Word32And(loaded, constants[j]);
if ((buffer[j] & buffer[i]) != 0) { if ((buffer[j] & buffer[i]) != 0) {
m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad);
......
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