[turbofan] Remove unsafe {CodeAssembler::ReturnRaw}.
This removes the aforementioned untyped method and switches all users to the typed TNode<> version. Those versions now contain proper checks to compare the static information against the return count and types stored in the call descriptor. R=leszeks@chromium.org BUG=v8:10021 Change-Id: I393ea6211babc100e007fb1678877d36efa7bbf7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1939753 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#65225}
This commit is contained in:
parent
5253d7bf15
commit
4e9ac5066c
@ -25,7 +25,7 @@ TF_BUILTIN(BigIntToI64, CodeStubAssembler) {
|
||||
TVARIABLE(UintPtrT, var_high);
|
||||
|
||||
BigIntToRawBytes(n, &var_low, &var_high);
|
||||
ReturnRaw(var_low.value());
|
||||
Return(var_low.value());
|
||||
}
|
||||
|
||||
// https://tc39.github.io/proposal-bigint/#sec-to-big-int64
|
||||
@ -43,8 +43,7 @@ TF_BUILTIN(BigIntToI32Pair, CodeStubAssembler) {
|
||||
TVARIABLE(UintPtrT, var_high);
|
||||
|
||||
BigIntToRawBytes(bigint, &var_low, &var_high);
|
||||
Return(SloppyTNode<Object>(var_low.value()),
|
||||
SloppyTNode<Object>(var_high.value()));
|
||||
Return(var_low.value(), var_high.value());
|
||||
}
|
||||
|
||||
// https://tc39.github.io/proposal-bigint/#sec-bigint-constructor-number-value
|
||||
|
@ -81,7 +81,7 @@ TF_BUILTIN(WasmAtomicNotify, WasmBuiltinsAssembler) {
|
||||
TNode<Smi> result_smi =
|
||||
UncheckedCast<Smi>(CallRuntime(Runtime::kWasmAtomicNotify, context,
|
||||
instance, address_number, count_number));
|
||||
ReturnRaw(SmiToInt32(result_smi));
|
||||
Return(Unsigned(SmiToInt32(result_smi)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(WasmI32AtomicWait, WasmBuiltinsAssembler) {
|
||||
@ -101,7 +101,7 @@ TF_BUILTIN(WasmI32AtomicWait, WasmBuiltinsAssembler) {
|
||||
TNode<Smi> result_smi = UncheckedCast<Smi>(
|
||||
CallRuntime(Runtime::kWasmI32AtomicWait, context, instance,
|
||||
address_number, expected_value_number, timeout_number));
|
||||
ReturnRaw(SmiToInt32(result_smi));
|
||||
Return(Unsigned(SmiToInt32(result_smi)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(WasmI64AtomicWait, WasmBuiltinsAssembler) {
|
||||
@ -126,7 +126,7 @@ TF_BUILTIN(WasmI64AtomicWait, WasmBuiltinsAssembler) {
|
||||
TNode<Smi> result_smi = UncheckedCast<Smi>(CallRuntime(
|
||||
Runtime::kWasmI64AtomicWait, context, instance, address_number,
|
||||
expected_value_high_number, expected_value_low_number, timeout_number));
|
||||
ReturnRaw(SmiToInt32(result_smi));
|
||||
Return(Unsigned(SmiToInt32(result_smi)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(WasmMemoryGrow, WasmBuiltinsAssembler) {
|
||||
@ -143,11 +143,10 @@ TF_BUILTIN(WasmMemoryGrow, WasmBuiltinsAssembler) {
|
||||
TNode<Object> context = LoadContextFromInstance(instance);
|
||||
TNode<Smi> ret_smi = UncheckedCast<Smi>(
|
||||
CallRuntime(Runtime::kWasmMemoryGrow, context, instance, num_pages_smi));
|
||||
TNode<Int32T> ret = SmiToInt32(ret_smi);
|
||||
ReturnRaw(ret);
|
||||
Return(SmiToInt32(ret_smi));
|
||||
|
||||
BIND(&num_pages_out_of_range);
|
||||
ReturnRaw(Int32Constant(-1));
|
||||
Return(Int32Constant(-1));
|
||||
}
|
||||
|
||||
TF_BUILTIN(WasmTableGet, WasmBuiltinsAssembler) {
|
||||
|
@ -382,24 +382,64 @@ TNode<Context> CodeAssembler::GetJSContextParameter() {
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(SloppyTNode<Object> value) {
|
||||
// TODO(leszeks): This could also return a non-object, depending on the call
|
||||
// descriptor. We should probably have multiple return overloads with
|
||||
// different TNode types which DCHECK the call descriptor.
|
||||
DCHECK_EQ(1, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(0).IsTagged());
|
||||
return raw_assembler()->Return(value);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(SloppyTNode<Object> value1,
|
||||
SloppyTNode<Object> value2) {
|
||||
DCHECK_EQ(2, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(0).IsTagged());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(1).IsTagged());
|
||||
return raw_assembler()->Return(value1, value2);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(SloppyTNode<Object> value1,
|
||||
SloppyTNode<Object> value2,
|
||||
SloppyTNode<Object> value3) {
|
||||
DCHECK_EQ(3, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(0).IsTagged());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(1).IsTagged());
|
||||
DCHECK(raw_assembler()->call_descriptor()->GetReturnType(2).IsTagged());
|
||||
return raw_assembler()->Return(value1, value2, value3);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(TNode<Int32T> value) {
|
||||
DCHECK_EQ(1, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK_EQ(MachineType::Int32(),
|
||||
raw_assembler()->call_descriptor()->GetReturnType(0));
|
||||
return raw_assembler()->Return(value);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(TNode<Uint32T> value) {
|
||||
DCHECK_EQ(1, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK_EQ(MachineType::Uint32(),
|
||||
raw_assembler()->call_descriptor()->GetReturnType(0));
|
||||
return raw_assembler()->Return(value);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(TNode<WordT> value) {
|
||||
DCHECK_EQ(1, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK_EQ(
|
||||
MachineType::PointerRepresentation(),
|
||||
raw_assembler()->call_descriptor()->GetReturnType(0).representation());
|
||||
return raw_assembler()->Return(value);
|
||||
}
|
||||
|
||||
void CodeAssembler::Return(TNode<WordT> value1, TNode<WordT> value2) {
|
||||
DCHECK_EQ(2, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
DCHECK_EQ(
|
||||
MachineType::PointerRepresentation(),
|
||||
raw_assembler()->call_descriptor()->GetReturnType(0).representation());
|
||||
DCHECK_EQ(
|
||||
MachineType::PointerRepresentation(),
|
||||
raw_assembler()->call_descriptor()->GetReturnType(1).representation());
|
||||
return raw_assembler()->Return(value1, value2);
|
||||
}
|
||||
|
||||
void CodeAssembler::PopAndReturn(Node* pop, Node* value) {
|
||||
DCHECK_EQ(1, raw_assembler()->call_descriptor()->ReturnCount());
|
||||
return raw_assembler()->PopAndReturn(pop, value);
|
||||
}
|
||||
|
||||
@ -411,10 +451,6 @@ void CodeAssembler::ReturnIf(Node* condition, Node* value) {
|
||||
Bind(&if_continue);
|
||||
}
|
||||
|
||||
void CodeAssembler::ReturnRaw(Node* value) {
|
||||
return raw_assembler()->Return(value);
|
||||
}
|
||||
|
||||
void CodeAssembler::AbortCSAAssert(Node* message) {
|
||||
raw_assembler()->AbortCSAAssert(message);
|
||||
}
|
||||
|
@ -543,12 +543,14 @@ class V8_EXPORT_PRIVATE CodeAssembler {
|
||||
void Return(SloppyTNode<Object> value1, SloppyTNode<Object> value2);
|
||||
void Return(SloppyTNode<Object> value1, SloppyTNode<Object> value2,
|
||||
SloppyTNode<Object> value3);
|
||||
void Return(TNode<Int32T> value);
|
||||
void Return(TNode<Uint32T> value);
|
||||
void Return(TNode<WordT>);
|
||||
void Return(TNode<WordT> value1, TNode<WordT> value2);
|
||||
void PopAndReturn(Node* pop, Node* value);
|
||||
|
||||
void ReturnIf(Node* condition, Node* value);
|
||||
|
||||
void ReturnRaw(Node* value);
|
||||
|
||||
void AbortCSAAssert(Node* message);
|
||||
void DebugBreak();
|
||||
void Unreachable();
|
||||
|
@ -25,7 +25,7 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) {
|
||||
CodeAssemblerTester tester(isolate, call_descriptor, "callee");
|
||||
CodeStubAssembler assembler(tester.state());
|
||||
int param_count = static_cast<int>(call_descriptor->StackParameterCount());
|
||||
Node* sum = __ IntPtrConstant(0);
|
||||
TNode<IntPtrT> sum = __ IntPtrConstant(0);
|
||||
for (int i = 0; i < param_count; ++i) {
|
||||
TNode<IntPtrT> product =
|
||||
__ Signed(__ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1)));
|
||||
@ -70,7 +70,7 @@ Handle<Code> BuildCaller(Isolate* isolate, CallDescriptor* call_descriptor,
|
||||
} else {
|
||||
Node* result = tester.raw_assembler_for_testing()->CallN(
|
||||
callee_descriptor, param_count + 1, params.data());
|
||||
__ Return(result);
|
||||
__ Return(__ UncheckedCast<IntPtrT>(result));
|
||||
}
|
||||
return tester.GenerateCodeCloseAndEscape();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) {
|
||||
CodeAssemblerTester tester(isolate, call_descriptor, "callee");
|
||||
CodeStubAssembler assembler(tester.state());
|
||||
int param_count = static_cast<int>(call_descriptor->StackParameterCount());
|
||||
Node* sum = __ IntPtrConstant(0);
|
||||
TNode<IntPtrT> sum = __ IntPtrConstant(0);
|
||||
for (int i = 0; i < param_count; ++i) {
|
||||
TNode<WordT> product =
|
||||
__ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1));
|
||||
|
Loading…
Reference in New Issue
Block a user