Commit a4183e59 authored by jgruber's avatar jgruber Committed by Commit bot

[stubs] Add initializing constructor to CSA::Variable

It's a common pattern to create a Variable and immediately initialize
it. This adds a new constructor to make that pattern more natural.

BUG=

Review-Url: https://codereview.chromium.org/2657533003
Cr-Commit-Position: refs/heads/master@{#42649}
parent efc8cb16
......@@ -170,11 +170,11 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(Node* context,
Node* const limit = IntPtrAdd(
IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex), num_indices);
Variable var_from_cursor(this, MachineType::PointerRepresentation());
Variable var_to_cursor(this, MachineType::PointerRepresentation());
var_from_cursor.Bind(IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 2));
var_to_cursor.Bind(IntPtrConstant(1));
Variable var_from_cursor(
this, MachineType::PointerRepresentation(),
IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 2));
Variable var_to_cursor(this, MachineType::PointerRepresentation(),
IntPtrConstant(1));
Variable* vars[] = {&var_from_cursor, &var_to_cursor};
Label loop(this, 2, vars);
......@@ -492,14 +492,12 @@ Node* RegExpBuiltinsAssembler::FlagsGetter(Node* const context,
Node* const int_zero = IntPtrConstant(0);
Node* const int_one = IntPtrConstant(1);
Variable var_length(this, MachineType::PointerRepresentation());
Variable var_length(this, MachineType::PointerRepresentation(), int_zero);
Variable var_flags(this, MachineType::PointerRepresentation());
// First, count the number of characters we will need and check which flags
// are set.
var_length.Bind(int_zero);
if (is_fastpath) {
// Refer to JSRegExp's flag property on the fast-path.
Node* const flags_smi = LoadObjectField(regexp, JSRegExp::kFlagsOffset);
......@@ -559,8 +557,8 @@ Node* RegExpBuiltinsAssembler::FlagsGetter(Node* const context,
Node* const result = AllocateSeqOneByteString(context, var_length.value());
Node* const flags_intptr = var_flags.value();
Variable var_offset(this, MachineType::PointerRepresentation());
var_offset.Bind(
Variable var_offset(
this, MachineType::PointerRepresentation(),
IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag));
#define CASE_FOR_FLAG(FLAG, CHAR) \
......@@ -591,8 +589,7 @@ Node* RegExpBuiltinsAssembler::IsRegExp(Node* const context,
Node* const maybe_receiver) {
Label out(this), if_isregexp(this);
Variable var_result(this, MachineRepresentation::kWord32);
var_result.Bind(Int32Constant(0));
Variable var_result(this, MachineRepresentation::kWord32, Int32Constant(0));
GotoIf(TaggedIsSmi(maybe_receiver), &out);
GotoUnless(IsJSReceiver(maybe_receiver), &out);
......@@ -676,13 +673,9 @@ TF_BUILTIN(RegExpConstructor, RegExpBuiltinsAssembler) {
Isolate* isolate = this->isolate();
Variable var_flags(this, MachineRepresentation::kTagged);
Variable var_pattern(this, MachineRepresentation::kTagged);
Variable var_new_target(this, MachineRepresentation::kTagged);
var_flags.Bind(flags);
var_pattern.Bind(pattern);
var_new_target.Bind(new_target);
Variable var_flags(this, MachineRepresentation::kTagged, flags);
Variable var_pattern(this, MachineRepresentation::kTagged, pattern);
Variable var_new_target(this, MachineRepresentation::kTagged, new_target);
Node* const native_context = LoadNativeContext(context);
Node* const regexp_function =
......@@ -814,11 +807,8 @@ TF_BUILTIN(RegExpPrototypeCompile, RegExpBuiltinsAssembler) {
"RegExp.prototype.compile");
Node* const receiver = maybe_receiver;
Variable var_flags(this, MachineRepresentation::kTagged);
Variable var_pattern(this, MachineRepresentation::kTagged);
var_flags.Bind(maybe_flags);
var_pattern.Bind(maybe_pattern);
Variable var_flags(this, MachineRepresentation::kTagged, maybe_flags);
Variable var_pattern(this, MachineRepresentation::kTagged, maybe_pattern);
// Handle a JSRegExp pattern.
{
......@@ -1306,11 +1296,9 @@ TF_BUILTIN(RegExpPrototypeTest, RegExpBuiltinsAssembler) {
Node* RegExpBuiltinsAssembler::AdvanceStringIndex(Node* const string,
Node* const index,
Node* const is_unicode) {
Variable var_result(this, MachineRepresentation::kTagged);
// Default to last_index + 1.
Node* const index_plus_one = SmiAdd(index, SmiConstant(1));
var_result.Bind(index_plus_one);
Variable var_result(this, MachineRepresentation::kTagged, index_plus_one);
Label if_isunicode(this), out(this);
Branch(is_unicode, &if_isunicode, &out);
......
This diff is collapsed.
......@@ -700,6 +700,13 @@ CodeAssemblerVariable::CodeAssemblerVariable(CodeAssembler* assembler,
state_->variables_.insert(impl_);
}
CodeAssemblerVariable::CodeAssemblerVariable(CodeAssembler* assembler,
MachineRepresentation rep,
Node* initial_value)
: CodeAssemblerVariable(assembler, rep) {
Bind(initial_value);
}
CodeAssemblerVariable::~CodeAssemblerVariable() {
state_->variables_.erase(impl_);
}
......
......@@ -413,6 +413,8 @@ class CodeAssemblerVariable {
public:
explicit CodeAssemblerVariable(CodeAssembler* assembler,
MachineRepresentation rep);
CodeAssemblerVariable(CodeAssembler* assembler, MachineRepresentation rep,
Node* initial_value);
~CodeAssemblerVariable();
void Bind(Node* value);
Node* value() const;
......
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