Commit b969586d authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[turbofan] Un-sloppify {CodeAssembler::Return} methods.

R=tebbi@chromium.org
BUG=v8:10021

Change-Id: I39052fa22ea90b392a36e7841f8586c19c8ca9cf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1940156
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65229}
parent 12e06cd4
......@@ -168,7 +168,8 @@ TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) {
}
TF_BUILTIN(ReturnReceiver, CodeStubAssembler) {
Return(Parameter(Descriptor::kReceiver));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Return(receiver);
}
TF_BUILTIN(DebugBreakTrampoline, CodeStubAssembler) {
......
......@@ -310,11 +310,12 @@ PromiseBuiltinsAssembler::AllocatePromiseResolveThenableJobTask(
}
template <typename... TArgs>
Node* PromiseBuiltinsAssembler::InvokeThen(Node* native_context, Node* receiver,
TArgs... args) {
TNode<Object> PromiseBuiltinsAssembler::InvokeThen(Node* native_context,
Node* receiver,
TArgs... args) {
CSA_ASSERT(this, IsNativeContext(native_context));
VARIABLE(var_result, MachineRepresentation::kTagged);
TVARIABLE(Object, var_result);
Label if_fast(this), if_slow(this, Label::kDeferred), done(this, &var_result);
GotoIf(TaggedIsSmi(receiver), &if_slow);
const TNode<Map> receiver_map = LoadMap(receiver);
......@@ -329,11 +330,10 @@ Node* PromiseBuiltinsAssembler::InvokeThen(Node* native_context, Node* receiver,
{
const TNode<Object> then =
LoadContextElement(native_context, Context::PROMISE_THEN_INDEX);
Node* const result =
var_result =
CallJS(CodeFactory::CallFunction(
isolate(), ConvertReceiverMode::kNotNullOrUndefined),
native_context, then, receiver, args...);
var_result.Bind(result);
Goto(&done);
}
......@@ -341,10 +341,9 @@ Node* PromiseBuiltinsAssembler::InvokeThen(Node* native_context, Node* receiver,
{
const TNode<Object> then = GetProperty(native_context, receiver,
isolate()->factory()->then_string());
Node* const result = CallJS(
var_result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined),
native_context, then, receiver, args...);
var_result.Bind(result);
Goto(&done);
}
......@@ -513,7 +512,7 @@ void PromiseBuiltinsAssembler::SetPromiseHandledByIfTrue(
}
TF_BUILTIN(PromiseConstructorLazyDeoptContinuation, PromiseBuiltinsAssembler) {
Node* promise = Parameter(Descriptor::kPromise);
TNode<Object> promise = CAST(Parameter(Descriptor::kPromise));
Node* reject = Parameter(Descriptor::kReject);
Node* exception = Parameter(Descriptor::kException);
Node* const context = Parameter(Descriptor::kContext);
......@@ -707,7 +706,7 @@ TF_BUILTIN(PromiseResolveThenableJob, PromiseBuiltinsAssembler) {
Label if_exception(this, Label::kDeferred);
VARIABLE(var_exception, MachineRepresentation::kTagged, TheHoleConstant());
Node* const result = CallJS(
const TNode<Object> result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined),
native_context, then, thenable, resolve, reject);
GotoIfException(result, &if_exception, &var_exception);
......@@ -716,7 +715,7 @@ TF_BUILTIN(PromiseResolveThenableJob, PromiseBuiltinsAssembler) {
BIND(&if_exception);
{
// We need to reject the {thenable}.
Node* const result = CallJS(
const TNode<Object> result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
native_context, reject, UndefinedConstant(), var_exception.value());
Return(result);
......@@ -785,7 +784,7 @@ void PromiseBuiltinsAssembler::PromiseReactionJob(Node* context, Node* argument,
// promiseCapability.[[Resolve]] function.
const TNode<Object> resolve = LoadObjectField(
promise_or_capability, PromiseCapability::kResolveOffset);
Node* const result = CallJS(
const TNode<Object> result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
context, resolve, UndefinedConstant(), value);
GotoIfException(result, &if_reject, &var_handler_result);
......@@ -818,7 +817,7 @@ void PromiseBuiltinsAssembler::PromiseReactionJob(Node* context, Node* argument,
TheHoleConstant());
const TNode<Object> reject = LoadObjectField(
promise_or_capability, PromiseCapability::kRejectOffset);
Node* const result = CallJS(
const TNode<Object> result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
context, reject, UndefinedConstant(), reason);
GotoIfException(result, &if_exception, &var_exception);
......@@ -1357,7 +1356,7 @@ TF_BUILTIN(ResolvePromise, PromiseBuiltinsAssembler) {
}
}
Node* PromiseBuiltinsAssembler::PerformPromiseAll(
TNode<Object> PromiseBuiltinsAssembler::PerformPromiseAll(
Node* context, Node* constructor, Node* capability,
const IteratorRecord& iterator,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
......@@ -1649,7 +1648,7 @@ void PromiseBuiltinsAssembler::Generate_PromiseAll(
// If iteratorRecord.[[Done]] is false, let result be
// IteratorClose(iterator, result).
// IfAbruptRejectPromise(result, promiseCapability).
Node* const result = PerformPromiseAll(
const TNode<Object> result = PerformPromiseAll(
context, receiver, capability, iterator, create_resolve_element_function,
create_reject_element_function, &reject_promise, &var_exception);
......
......@@ -108,7 +108,7 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
Node* CallResolve(Node* native_context, Node* constructor, Node* resolve,
Node* value, Label* if_exception, Variable* var_exception);
template <typename... TArgs>
Node* InvokeThen(Node* native_context, Node* receiver, TArgs... args);
TNode<Object> InvokeThen(Node* native_context, Node* receiver, TArgs... args);
std::pair<Node*, Node*> CreatePromiseFinallyFunctions(Node* on_finally,
Node* constructor,
......@@ -122,7 +122,7 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
TNode<NativeContext> native_context,
TNode<PromiseCapability> capability)>;
Node* PerformPromiseAll(
TNode<Object> PerformPromiseAll(
Node* context, Node* constructor, Node* capability,
const TorqueStructIteratorRecord& record,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
......
......@@ -4068,7 +4068,7 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray(
return array;
}
Node* CodeStubAssembler::ExtractFastJSArray(
TNode<JSArray> CodeStubAssembler::ExtractFastJSArray(
TNode<Context> context, TNode<JSArray> array, Node* begin, Node* count,
ParameterMode mode, Node* capacity, TNode<AllocationSite> allocation_site) {
TNode<Map> original_array_map = LoadMap(array);
......
......@@ -1872,11 +1872,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<AllocationSite> allocation_site = {},
HoleConversionMode convert_holes = HoleConversionMode::kDontConvert);
Node* ExtractFastJSArray(TNode<Context> context, TNode<JSArray> array,
Node* begin, Node* count,
ParameterMode mode = INTPTR_PARAMETERS,
Node* capacity = nullptr,
TNode<AllocationSite> allocation_site = {});
TNode<JSArray> ExtractFastJSArray(TNode<Context> context,
TNode<JSArray> array, Node* begin,
Node* count,
ParameterMode mode = INTPTR_PARAMETERS,
Node* capacity = nullptr,
TNode<AllocationSite> allocation_site = {});
TNode<FixedArrayBase> AllocateFixedArray(
ElementsKind kind, Node* capacity, ParameterMode mode = INTPTR_PARAMETERS,
......
......@@ -381,23 +381,21 @@ TNode<Context> CodeAssembler::GetJSContextParameter() {
static_cast<int>(call_descriptor->JSParameterCount()))));
}
void CodeAssembler::Return(SloppyTNode<Object> value) {
void CodeAssembler::Return(TNode<Object> value) {
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) {
void CodeAssembler::Return(TNode<Object> value1, TNode<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) {
void CodeAssembler::Return(TNode<Object> value1, TNode<Object> value2,
TNode<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());
......@@ -443,7 +441,7 @@ void CodeAssembler::PopAndReturn(Node* pop, Node* value) {
return raw_assembler()->PopAndReturn(pop, value);
}
void CodeAssembler::ReturnIf(Node* condition, Node* value) {
void CodeAssembler::ReturnIf(Node* condition, TNode<Object> value) {
Label if_return(this), if_continue(this);
Branch(condition, &if_return, &if_continue);
Bind(&if_return);
......
......@@ -539,17 +539,16 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* Parameter(int value);
TNode<Context> GetJSContextParameter();
void Return(SloppyTNode<Object> value);
void Return(SloppyTNode<Object> value1, SloppyTNode<Object> value2);
void Return(SloppyTNode<Object> value1, SloppyTNode<Object> value2,
SloppyTNode<Object> value3);
void Return(TNode<Object> value);
void Return(TNode<Object> value1, TNode<Object> value2);
void Return(TNode<Object> value1, TNode<Object> value2, TNode<Object> value3);
void Return(TNode<Int32T> value);
void Return(TNode<Uint32T> value);
void Return(TNode<WordT>);
void Return(TNode<WordT> value);
void Return(TNode<WordT> value1, TNode<WordT> value2);
void PopAndReturn(Node* pop, Node* value);
void ReturnIf(Node* condition, Node* value);
void ReturnIf(Node* condition, TNode<Object> value);
void AbortCSAAssert(Node* message);
void DebugBreak();
......
......@@ -20,20 +20,21 @@ namespace {
using Variable = CodeAssemblerVariable;
Node* SmiTag(CodeAssembler* m, Node* value) {
TNode<Smi> SmiTag(CodeAssembler* m, Node* value) {
int32_t constant_value;
if (m->ToInt32Constant(value, &constant_value) &&
Smi::IsValid(constant_value)) {
return m->SmiConstant(Smi::FromInt(constant_value));
}
return m->WordShl(value, m->IntPtrConstant(kSmiShiftSize + kSmiTagSize));
return m->BitcastWordToTaggedSigned(
m->WordShl(value, m->IntPtrConstant(kSmiShiftSize + kSmiTagSize)));
}
Node* UndefinedConstant(CodeAssembler* m) {
return m->LoadRoot(RootIndex::kUndefinedValue);
}
Node* SmiFromInt32(CodeAssembler* m, Node* value) {
TNode<Smi> SmiFromInt32(CodeAssembler* m, Node* value) {
value = m->ChangeInt32ToIntPtr(value);
return m->BitcastWordToTaggedSigned(
m->WordShl(value, kSmiShiftSize + kSmiTagSize));
......@@ -160,7 +161,7 @@ TEST(SimpleCallJSFunction0Arg) {
Node* receiver = SmiTag(&m, m.Int32Constant(42));
Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver);
TNode<Object> result = m.CallJS(callable, context, function, receiver);
m.Return(result);
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -183,7 +184,7 @@ TEST(SimpleCallJSFunction1Arg) {
Node* a = SmiTag(&m, m.Int32Constant(13));
Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver, a);
TNode<Object> result = m.CallJS(callable, context, function, receiver, a);
m.Return(result);
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -207,7 +208,8 @@ TEST(SimpleCallJSFunction2Arg) {
Node* b = SmiTag(&m, m.Int32Constant(153));
Callable callable = CodeFactory::Call(isolate);
Node* result = m.CallJS(callable, context, function, receiver, a, b);
TNode<Object> result =
m.CallJS(callable, context, function, receiver, a, b);
m.Return(result);
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -464,7 +466,7 @@ TEST(GotoIfException) {
m.Return(string);
m.Bind(&exception_handler);
m.Return(exception.value());
m.Return(m.UncheckedCast<Object>(exception.value()));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call().ToHandleChecked();
......@@ -525,7 +527,7 @@ TEST(GotoIfExceptionMultiple) {
m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1)))));
m.Bind(&exception_handler3);
m.Return(error.value());
m.Return(m.UncheckedCast<Object>(error.value()));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......
......@@ -147,9 +147,10 @@ Handle<Code> BuildSetupFunction(Isolate* isolate,
}
params.push_back(element);
}
__ Return(tester.raw_assembler_for_testing()->AddNode(
tester.raw_assembler_for_testing()->common()->Call(call_descriptor),
static_cast<int>(params.size()), params.data()));
__ Return(
__ UncheckedCast<Object>(tester.raw_assembler_for_testing()->AddNode(
tester.raw_assembler_for_testing()->common()->Call(call_descriptor),
static_cast<int>(params.size()), params.data())));
return tester.GenerateCodeCloseAndEscape();
}
......
......@@ -1411,7 +1411,7 @@ TEST(TryGetOwnProperty) {
&if_bailout);
m.BIND(&if_found);
m.Return(var_value.value());
m.Return(m.UncheckedCast<Object>(var_value.value()));
m.BIND(&if_not_found);
m.Return(m.HeapConstant(not_found_symbol));
......@@ -2610,8 +2610,8 @@ TEST(NewElementsCapacity) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate, 1);
CodeStubAssembler m(asm_tester.state());
m.Return(m.SmiTag(m.CalculateNewElementsCapacity(
m.SmiUntag(m.Parameter(0)), CodeStubAssembler::INTPTR_PARAMETERS)));
m.Return(
m.SmiTag(m.CalculateNewElementsCapacity(m.SmiUntag(m.Parameter(0)))));
FunctionTester ft(asm_tester.GenerateCode(), 1);
Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate);
......@@ -2640,8 +2640,8 @@ TEST(NewElementsCapacitySmi) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate, 1);
CodeStubAssembler m(asm_tester.state());
m.Return(m.CalculateNewElementsCapacity(m.Parameter(0),
CodeStubAssembler::SMI_PARAMETERS));
m.Return(
m.CalculateNewElementsCapacity(m.UncheckedCast<Smi>(m.Parameter(0))));
FunctionTester ft(asm_tester.GenerateCode(), 1);
Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate);
......@@ -3493,7 +3493,7 @@ TEST(SingleInputPhiElimination) {
m.BIND(&temp_label);
m.Goto(&end_label);
m.BIND(&end_label);
m.Return(temp1.value());
m.Return(m.UncheckedCast<Object>(temp1.value()));
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
// Generating code without an assert is enough to make sure that the
......
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