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