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