[csa][cleanup] Remove the use of non-typed Variables

Since we are not using CodeAssemblerVariables anymore, we can properly
scope the class so that the only way to instance one is through the
typed version (i.e TypedCodeAssemblerVariable).

Bug: v8:6949
Change-Id: I3ee99bcbb9421aadd0944af57f6452e832719758
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2290858
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68797}
This commit is contained in:
Santiago Aboy Solanes 2020-07-10 14:52:47 +01:00 committed by Commit Bot
parent b98a183171
commit d4c91e7dc9
6 changed files with 45 additions and 45 deletions

View File

@ -1201,8 +1201,16 @@ class V8_EXPORT_PRIVATE CodeAssembler {
DISALLOW_COPY_AND_ASSIGN(CodeAssembler);
};
// TODO(solanes, v8:6949): this class should be merged into
// TypedCodeAssemblerVariable. It's required to be separate for
// CodeAssemblerVariableLists.
class V8_EXPORT_PRIVATE CodeAssemblerVariable {
public:
Node* value() const;
MachineRepresentation rep() const;
bool IsBound() const;
protected:
explicit CodeAssemblerVariable(CodeAssembler* assembler,
MachineRepresentation rep);
CodeAssemblerVariable(CodeAssembler* assembler, MachineRepresentation rep,
@ -1216,9 +1224,6 @@ class V8_EXPORT_PRIVATE CodeAssemblerVariable {
~CodeAssemblerVariable();
void Bind(Node* value);
Node* value() const;
MachineRepresentation rep() const;
bool IsBound() const;
private:
class Impl;

View File

@ -434,9 +434,7 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
// and then jump to an exit label.
class ExitPoint {
private:
using Node = compiler::Node;
using CodeAssemblerLabel = compiler::CodeAssemblerLabel;
using CodeAssemblerVariable = compiler::CodeAssemblerVariable;
public:
using IndirectReturnHandler = std::function<void(TNode<Object> result)>;

View File

@ -18,7 +18,8 @@ namespace compiler {
namespace {
using Variable = CodeAssemblerVariable;
template <class T>
using TVariable = TypedCodeAssemblerVariable<T>;
TNode<Smi> SmiTag(CodeAssembler* m, Node* value) {
int32_t constant_value;
@ -217,10 +218,10 @@ TEST(VariableMerge1) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
TVariable<Int32T> var1(&m);
CodeAssemblerLabel l1(&m), l2(&m), merge(&m);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
var1 = temp;
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
CHECK_EQ(var1.value(), temp);
@ -236,17 +237,17 @@ TEST(VariableMerge2) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
TVariable<Int32T> var1(&m);
CodeAssemblerLabel l1(&m), l2(&m), merge(&m);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
var1 = temp;
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
CHECK_EQ(var1.value(), temp);
m.Goto(&merge);
m.Bind(&l2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
var1 = temp2;
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
m.Bind(&merge);
@ -257,19 +258,19 @@ TEST(VariableMerge3) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
Variable var2(&m, MachineRepresentation::kTagged);
TVariable<Int32T> var1(&m);
TVariable<Int32T> var2(&m);
CodeAssemblerLabel l1(&m), l2(&m), merge(&m);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
var2.Bind(temp);
var1 = temp;
var2 = temp;
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
CHECK_EQ(var1.value(), temp);
m.Goto(&merge);
m.Bind(&l2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
var1 = temp2;
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
m.Bind(&merge);
@ -282,10 +283,10 @@ TEST(VariableMergeBindFirst) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
TVariable<Int32T> var1(&m);
CodeAssemblerLabel l1(&m), l2(&m), merge(&m, &var1), end(&m);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
var1 = temp;
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
CHECK_EQ(var1.value(), temp);
@ -296,7 +297,7 @@ TEST(VariableMergeBindFirst) {
m.Goto(&end);
m.Bind(&l2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
var1 = temp2;
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
m.Bind(&end);
@ -308,12 +309,12 @@ TEST(VariableMergeSwitch) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
TVariable<Smi> var1(&m);
CodeAssemblerLabel l1(&m), l2(&m), default_label(&m);
CodeAssemblerLabel* labels[] = {&l1, &l2};
int32_t values[] = {1, 2};
TNode<Smi> temp1 = m.SmiConstant(0);
var1.Bind(temp1);
var1 = temp1;
m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
m.Bind(&l1);
CHECK_EQ(temp1, var1.value());
@ -321,11 +322,11 @@ TEST(VariableMergeSwitch) {
m.Bind(&l2);
CHECK_EQ(temp1, var1.value());
TNode<Smi> temp2 = m.SmiConstant(7);
var1.Bind(temp2);
var1 = temp2;
m.Goto(&default_label);
m.Bind(&default_label);
CHECK_EQ(IrOpcode::kPhi, var1.value()->opcode());
CHECK_EQ(2, var1.value()->op()->ValueInputCount());
CHECK_EQ(IrOpcode::kPhi, (*var1.value()).opcode());
CHECK_EQ(2, (*var1.value()).op()->ValueInputCount());
CHECK_EQ(temp1, NodeProperties::GetValueInput(var1.value(), 0));
CHECK_EQ(temp2, NodeProperties::GetValueInput(var1.value(), 1));
m.Return(temp1);
@ -396,14 +397,14 @@ TEST(DeferredCodePhiHints) {
m.Goto(&block1);
m.Bind(&block1);
{
Variable var_object(&m, MachineRepresentation::kTagged);
TVariable<Map> var_object(&m);
CodeAssemblerLabel loop(&m, &var_object);
var_object.Bind(m.SmiConstant(0));
var_object = m.CAST(LoadMap(&m, m.SmiConstant(0)));
m.Goto(&loop);
m.Bind(&loop);
{
Node* map = LoadMap(&m, var_object.value());
var_object.Bind(map);
TNode<Map> map = m.CAST(LoadMap(&m, var_object.value()));
var_object = map;
m.Goto(&loop);
}
}
@ -423,17 +424,17 @@ TEST(TestOutOfScopeVariable) {
&block1, &block4);
m.Bind(&block4);
{
Variable var_object(&m, MachineRepresentation::kTagged);
TVariable<IntPtrT> var_object(&m);
m.Branch(m.WordEqual(m.UncheckedCast<IntPtrT>(m.Parameter(0)),
m.IntPtrConstant(0)),
&block2, &block3);
m.Bind(&block2);
var_object.Bind(m.IntPtrConstant(55));
var_object = m.IntPtrConstant(55);
m.Goto(&block1);
m.Bind(&block3);
var_object.Bind(m.IntPtrConstant(66));
var_object = m.IntPtrConstant(66);
m.Goto(&block1);
}
m.Bind(&block1);
@ -446,7 +447,7 @@ TEST(ExceptionHandler) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeAssembler m(asm_tester.state());
CodeAssembler::TVariable<Object> var(m.SmiConstant(0), &m);
TVariable<Object> var(m.SmiConstant(0), &m);
CodeAssemblerLabel exception(&m, {&var}, CodeAssemblerLabel::kDeferred);
{
ScopedExceptionHandler handler(&m, &exception, &var);

View File

@ -45,16 +45,15 @@ Handle<Code> BuildCaller(Isolate* isolate, CallDescriptor* call_descriptor,
// The first parameter is always the callee.
Handle<Code> callee = BuildCallee(isolate, callee_descriptor);
// defeat the instruction selector.
CodeStubAssembler::Variable target_var(&assembler,
MachineRepresentation::kTagged);
CodeStubAssembler::TVariable<Code> target_var(&assembler);
CodeStubAssembler::Label t(&assembler), f(&assembler),
end(&assembler, &target_var);
__ Branch(__ Int32Constant(0), &t, &f);
__ BIND(&t);
target_var.Bind(__ HeapConstant(callee));
target_var = __ HeapConstant(callee);
__ Goto(&end);
__ BIND(&f);
target_var.Bind(__ HeapConstant(callee));
target_var = __ HeapConstant(callee);
__ Goto(&end);
__ BIND(&end);
params.push_back(target_var.value());

View File

@ -37,7 +37,6 @@ namespace compiler {
namespace {
using Label = CodeAssemblerLabel;
using Variable = CodeAssemblerVariable;
template <class T>
using TVariable = TypedCodeAssemblerVariable<T>;
using PromiseResolvingFunctions = TorqueStructPromiseResolvingFunctions;
@ -3395,18 +3394,18 @@ TEST(SingleInputPhiElimination) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
{
CodeStubAssembler m(asm_tester.state());
Variable temp1(&m, MachineRepresentation::kTagged);
Variable temp2(&m, MachineRepresentation::kTagged);
TVariable<Smi> temp1(&m);
TVariable<Smi> temp2(&m);
Label temp_label(&m, {&temp1, &temp2});
Label end_label(&m, {&temp1, &temp2});
temp1.Bind(m.Parameter(1));
temp2.Bind(m.Parameter(1));
temp1 = m.CAST(m.Parameter(1));
temp2 = m.CAST(m.Parameter(1));
m.Branch(m.TaggedEqual(m.UncheckedCast<Object>(m.Parameter(0)),
m.UncheckedCast<Object>(m.Parameter(1))),
&end_label, &temp_label);
temp1.Bind(m.Parameter(2));
temp2.Bind(m.Parameter(2));
m.BIND(&temp_label);
temp1 = m.CAST(m.Parameter(2));
temp2 = m.CAST(m.Parameter(2));
m.Goto(&end_label);
m.BIND(&end_label);
m.Return(m.UncheckedCast<Object>(temp1.value()));

View File

@ -27,8 +27,6 @@ namespace compiler {
namespace {
using Variable = CodeAssemblerVariable;
class TestTorqueAssembler : public CodeStubAssembler {
public:
explicit TestTorqueAssembler(CodeAssemblerState* state)