Commit 485067c6 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Add file-level typedefs to builtins-regexp.cc

This removes lots of boilerplate typedefs, with the caveat of renaming
CSA::Label and Variable to CLabel and CVariable within builtins-regexp.

BUG=v8:5339

Review-Url: https://codereview.chromium.org/2524363002
Cr-Commit-Position: refs/heads/master@{#41281}
parent b6d2bacd
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
typedef compiler::Node Node;
typedef CodeStubAssembler::Label CLabel;
typedef CodeStubAssembler::Variable CVariable;
typedef compiler::CodeAssemblerState CodeAssemblerState;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ES6 section 21.2 RegExp Objects // ES6 section 21.2 RegExp Objects
...@@ -170,34 +175,26 @@ BUILTIN(RegExpPrototypeCompile) { ...@@ -170,34 +175,26 @@ BUILTIN(RegExpPrototypeCompile) {
namespace { namespace {
compiler::Node* FastLoadLastIndex(CodeStubAssembler* a, compiler::Node* context, Node* FastLoadLastIndex(CodeStubAssembler* a, Node* context, Node* regexp) {
compiler::Node* regexp) {
// Load the in-object field. // Load the in-object field.
static const int field_offset = static const int field_offset =
JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize; JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
return a->LoadObjectField(regexp, field_offset); return a->LoadObjectField(regexp, field_offset);
} }
compiler::Node* SlowLoadLastIndex(CodeStubAssembler* a, compiler::Node* context, Node* SlowLoadLastIndex(CodeStubAssembler* a, Node* context, Node* regexp) {
compiler::Node* regexp) {
// Load through the GetProperty stub. // Load through the GetProperty stub.
typedef compiler::Node Node;
Node* const name = Node* const name =
a->HeapConstant(a->isolate()->factory()->lastIndex_string()); a->HeapConstant(a->isolate()->factory()->lastIndex_string());
Callable getproperty_callable = CodeFactory::GetProperty(a->isolate()); Callable getproperty_callable = CodeFactory::GetProperty(a->isolate());
return a->CallStub(getproperty_callable, context, regexp, name); return a->CallStub(getproperty_callable, context, regexp, name);
} }
compiler::Node* LoadLastIndex(CodeStubAssembler* a, compiler::Node* context, Node* LoadLastIndex(CodeStubAssembler* a, Node* context, Node* has_initialmap,
compiler::Node* has_initialmap, Node* regexp) {
compiler::Node* regexp) { CVariable var_value(a, MachineRepresentation::kTagged);
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
Variable var_value(a, MachineRepresentation::kTagged); CLabel out(a), if_unmodified(a), if_modified(a);
Label out(a), if_unmodified(a), if_modified(a);
a->Branch(has_initialmap, &if_unmodified, &if_modified); a->Branch(has_initialmap, &if_unmodified, &if_modified);
a->Bind(&if_unmodified); a->Bind(&if_unmodified);
...@@ -218,20 +215,18 @@ compiler::Node* LoadLastIndex(CodeStubAssembler* a, compiler::Node* context, ...@@ -218,20 +215,18 @@ compiler::Node* LoadLastIndex(CodeStubAssembler* a, compiler::Node* context,
// The fast-path of StoreLastIndex when regexp is guaranteed to be an unmodified // The fast-path of StoreLastIndex when regexp is guaranteed to be an unmodified
// JSRegExp instance. // JSRegExp instance.
void FastStoreLastIndex(CodeStubAssembler* a, compiler::Node* context, void FastStoreLastIndex(CodeStubAssembler* a, Node* context, Node* regexp,
compiler::Node* regexp, compiler::Node* value) { Node* value) {
// Store the in-object field. // Store the in-object field.
static const int field_offset = static const int field_offset =
JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize; JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
a->StoreObjectField(regexp, field_offset, value); a->StoreObjectField(regexp, field_offset, value);
} }
void SlowStoreLastIndex(CodeStubAssembler* a, compiler::Node* context, void SlowStoreLastIndex(CodeStubAssembler* a, Node* context, Node* regexp,
compiler::Node* regexp, compiler::Node* value) { Node* value) {
// Store through runtime. // Store through runtime.
// TODO(ishell): Use SetPropertyStub here once available. // TODO(ishell): Use SetPropertyStub here once available.
typedef compiler::Node Node;
Node* const name = Node* const name =
a->HeapConstant(a->isolate()->factory()->lastIndex_string()); a->HeapConstant(a->isolate()->factory()->lastIndex_string());
Node* const language_mode = a->SmiConstant(Smi::FromInt(STRICT)); Node* const language_mode = a->SmiConstant(Smi::FromInt(STRICT));
...@@ -239,12 +234,9 @@ void SlowStoreLastIndex(CodeStubAssembler* a, compiler::Node* context, ...@@ -239,12 +234,9 @@ void SlowStoreLastIndex(CodeStubAssembler* a, compiler::Node* context,
language_mode); language_mode);
} }
void StoreLastIndex(CodeStubAssembler* a, compiler::Node* context, void StoreLastIndex(CodeStubAssembler* a, Node* context, Node* has_initialmap,
compiler::Node* has_initialmap, compiler::Node* regexp, Node* regexp, Node* value) {
compiler::Node* value) { CLabel out(a), if_unmodified(a), if_modified(a);
typedef CodeStubAssembler::Label Label;
Label out(a), if_unmodified(a), if_modified(a);
a->Branch(has_initialmap, &if_unmodified, &if_modified); a->Branch(has_initialmap, &if_unmodified, &if_modified);
a->Bind(&if_unmodified); a->Bind(&if_unmodified);
...@@ -262,16 +254,10 @@ void StoreLastIndex(CodeStubAssembler* a, compiler::Node* context, ...@@ -262,16 +254,10 @@ void StoreLastIndex(CodeStubAssembler* a, compiler::Node* context,
a->Bind(&out); a->Bind(&out);
} }
compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate, Node* ConstructNewResultFromMatchInfo(Isolate* isolate, CodeStubAssembler* a,
CodeStubAssembler* a, Node* context, Node* match_info,
compiler::Node* context, Node* string) {
compiler::Node* match_info, CLabel out(a);
compiler::Node* string) {
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Label out(a);
CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS;
Node* const num_indices = a->SmiUntag(a->LoadFixedArrayElement( Node* const num_indices = a->SmiUntag(a->LoadFixedArrayElement(
...@@ -301,15 +287,15 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate, ...@@ -301,15 +287,15 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate,
Node* const limit = a->IntPtrAdd( Node* const limit = a->IntPtrAdd(
a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex), num_indices); a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex), num_indices);
Variable var_from_cursor(a, MachineType::PointerRepresentation()); CVariable var_from_cursor(a, MachineType::PointerRepresentation());
Variable var_to_cursor(a, MachineType::PointerRepresentation()); CVariable var_to_cursor(a, MachineType::PointerRepresentation());
var_from_cursor.Bind( var_from_cursor.Bind(
a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 2)); a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 2));
var_to_cursor.Bind(a->IntPtrConstant(1)); var_to_cursor.Bind(a->IntPtrConstant(1));
Variable* vars[] = {&var_from_cursor, &var_to_cursor}; CVariable* vars[] = {&var_from_cursor, &var_to_cursor};
Label loop(a, 2, vars); CLabel loop(a, 2, vars);
a->Goto(&loop); a->Goto(&loop);
a->Bind(&loop); a->Bind(&loop);
...@@ -318,7 +304,7 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate, ...@@ -318,7 +304,7 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate,
Node* const to_cursor = var_to_cursor.value(); Node* const to_cursor = var_to_cursor.value();
Node* const start = a->LoadFixedArrayElement(match_info, from_cursor); Node* const start = a->LoadFixedArrayElement(match_info, from_cursor);
Label next_iter(a); CLabel next_iter(a);
a->GotoIf(a->SmiEqual(start, a->SmiConstant(Smi::FromInt(-1))), &next_iter); a->GotoIf(a->SmiEqual(start, a->SmiConstant(Smi::FromInt(-1))), &next_iter);
Node* const from_cursor_plus1 = Node* const from_cursor_plus1 =
...@@ -341,22 +327,16 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate, ...@@ -341,22 +327,16 @@ compiler::Node* ConstructNewResultFromMatchInfo(Isolate* isolate,
// ES#sec-regexp.prototype.exec // ES#sec-regexp.prototype.exec
// RegExp.prototype.exec ( string ) // RegExp.prototype.exec ( string )
compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, Node* context,
compiler::Node* context, Node* maybe_receiver, Node* maybe_string) {
compiler::Node* maybe_receiver,
compiler::Node* maybe_string) {
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* const isolate = a->isolate(); Isolate* const isolate = a->isolate();
Node* const null = a->NullConstant(); Node* const null = a->NullConstant();
Node* const int_zero = a->IntPtrConstant(0); Node* const int_zero = a->IntPtrConstant(0);
Node* const smi_zero = a->SmiConstant(Smi::kZero); Node* const smi_zero = a->SmiConstant(Smi::kZero);
Variable var_result(a, MachineRepresentation::kTagged); CVariable var_result(a, MachineRepresentation::kTagged);
Label out(a); CLabel out(a);
// Ensure {maybe_receiver} is a JSRegExp. // Ensure {maybe_receiver} is a JSRegExp.
Node* const regexp_map = a->ThrowIfNotInstanceType( Node* const regexp_map = a->ThrowIfNotInstanceType(
...@@ -386,10 +366,10 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -386,10 +366,10 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
a->WordNotEqual(is_global_or_sticky, int_zero); a->WordNotEqual(is_global_or_sticky, int_zero);
// Grab and possibly update last index. // Grab and possibly update last index.
Label run_exec(a); CLabel run_exec(a);
Variable var_lastindex(a, MachineRepresentation::kTagged); CVariable var_lastindex(a, MachineRepresentation::kTagged);
{ {
Label if_doupdate(a), if_dontupdate(a); CLabel if_doupdate(a), if_dontupdate(a);
a->Branch(should_update_last_index, &if_doupdate, &if_dontupdate); a->Branch(should_update_last_index, &if_doupdate, &if_dontupdate);
a->Bind(&if_doupdate); a->Bind(&if_doupdate);
...@@ -402,7 +382,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -402,7 +382,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
a->CallStub(tolength_callable, context, regexp_lastindex); a->CallStub(tolength_callable, context, regexp_lastindex);
var_lastindex.Bind(lastindex); var_lastindex.Bind(lastindex);
Label if_isoob(a, Label::kDeferred); CLabel if_isoob(a, CLabel::kDeferred);
a->GotoUnless(a->TaggedIsSmi(lastindex), &if_isoob); a->GotoUnless(a->TaggedIsSmi(lastindex), &if_isoob);
a->GotoUnless(a->SmiLessThanOrEqual(lastindex, string_length), &if_isoob); a->GotoUnless(a->SmiLessThanOrEqual(lastindex, string_length), &if_isoob);
a->Goto(&run_exec); a->Goto(&run_exec);
...@@ -423,7 +403,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -423,7 +403,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
} }
Node* match_indices; Node* match_indices;
Label successful_match(a); CLabel successful_match(a);
a->Bind(&run_exec); a->Bind(&run_exec);
{ {
// Get last match info from the context. // Get last match info from the context.
...@@ -439,7 +419,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -439,7 +419,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
// Return early if exec failed, possibly updating last index. // Return early if exec failed, possibly updating last index.
a->GotoUnless(a->WordEqual(match_indices, null), &successful_match); a->GotoUnless(a->WordEqual(match_indices, null), &successful_match);
Label return_null(a); CLabel return_null(a);
a->GotoUnless(should_update_last_index, &return_null); a->GotoUnless(should_update_last_index, &return_null);
StoreLastIndex(a, context, has_initialmap, regexp, smi_zero); StoreLastIndex(a, context, has_initialmap, regexp, smi_zero);
...@@ -450,7 +430,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -450,7 +430,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
a->Goto(&out); a->Goto(&out);
} }
Label construct_result(a); CLabel construct_result(a);
a->Bind(&successful_match); a->Bind(&successful_match);
{ {
a->GotoUnless(should_update_last_index, &construct_result); a->GotoUnless(should_update_last_index, &construct_result);
...@@ -480,9 +460,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a, ...@@ -480,9 +460,7 @@ compiler::Node* RegExpPrototypeExecInternal(CodeStubAssembler* a,
// ES#sec-regexp.prototype.exec // ES#sec-regexp.prototype.exec
// RegExp.prototype.exec ( string ) // RegExp.prototype.exec ( string )
void Builtins::Generate_RegExpPrototypeExec( void Builtins::Generate_RegExpPrototypeExec(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Node* const maybe_receiver = a.Parameter(0); Node* const maybe_receiver = a.Parameter(0);
...@@ -496,17 +474,12 @@ void Builtins::Generate_RegExpPrototypeExec( ...@@ -496,17 +474,12 @@ void Builtins::Generate_RegExpPrototypeExec(
namespace { namespace {
compiler::Node* ThrowIfNotJSReceiver(CodeStubAssembler* a, Isolate* isolate, Node* ThrowIfNotJSReceiver(CodeStubAssembler* a, Isolate* isolate,
compiler::Node* context, Node* context, Node* value,
compiler::Node* value, MessageTemplate::Template msg_template,
MessageTemplate::Template msg_template, char const* method_name) {
char const* method_name) { CLabel out(a), throw_exception(a, CLabel::kDeferred);
typedef compiler::Node Node; CVariable var_value_map(a, MachineRepresentation::kTagged);
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
Label out(a), throw_exception(a, Label::kDeferred);
Variable var_value_map(a, MachineRepresentation::kTagged);
a->GotoIf(a->TaggedIsSmi(value), &throw_exception); a->GotoIf(a->TaggedIsSmi(value), &throw_exception);
...@@ -538,11 +511,7 @@ compiler::Node* ThrowIfNotJSReceiver(CodeStubAssembler* a, Isolate* isolate, ...@@ -538,11 +511,7 @@ compiler::Node* ThrowIfNotJSReceiver(CodeStubAssembler* a, Isolate* isolate,
return var_value_map.value(); return var_value_map.value();
} }
compiler::Node* IsInitialRegExpMap(CodeStubAssembler* a, Node* IsInitialRegExpMap(CodeStubAssembler* a, Node* context, Node* map) {
compiler::Node* context,
compiler::Node* map) {
typedef compiler::Node Node;
Node* const native_context = a->LoadNativeContext(context); Node* const native_context = a->LoadNativeContext(context);
Node* const regexp_fun = Node* const regexp_fun =
a->LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX); a->LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX);
...@@ -557,12 +526,8 @@ compiler::Node* IsInitialRegExpMap(CodeStubAssembler* a, ...@@ -557,12 +526,8 @@ compiler::Node* IsInitialRegExpMap(CodeStubAssembler* a,
// We use a fairly coarse granularity for this and simply check whether both // We use a fairly coarse granularity for this and simply check whether both
// the regexp itself is unmodified (i.e. its map has not changed) and its // the regexp itself is unmodified (i.e. its map has not changed) and its
// prototype is unmodified. // prototype is unmodified.
void BranchIfFastPath(CodeStubAssembler* a, compiler::Node* context, void BranchIfFastPath(CodeStubAssembler* a, Node* context, Node* map,
compiler::Node* map, CLabel* if_isunmodified, CLabel* if_ismodified) {
CodeStubAssembler::Label* if_isunmodified,
CodeStubAssembler::Label* if_ismodified) {
typedef compiler::Node Node;
Node* const native_context = a->LoadNativeContext(context); Node* const native_context = a->LoadNativeContext(context);
Node* const regexp_fun = Node* const regexp_fun =
a->LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX); a->LoadContextElement(native_context, Context::REGEXP_FUNCTION_INDEX);
...@@ -586,11 +551,7 @@ void BranchIfFastPath(CodeStubAssembler* a, compiler::Node* context, ...@@ -586,11 +551,7 @@ void BranchIfFastPath(CodeStubAssembler* a, compiler::Node* context,
} // namespace } // namespace
void Builtins::Generate_RegExpPrototypeFlagsGetter( void Builtins::Generate_RegExpPrototypeFlagsGetter(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Node* const receiver = a.Parameter(0); Node* const receiver = a.Parameter(0);
...@@ -604,20 +565,20 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter( ...@@ -604,20 +565,20 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter(
MessageTemplate::kRegExpNonObject, MessageTemplate::kRegExpNonObject,
"RegExp.prototype.flags"); "RegExp.prototype.flags");
Variable var_length(&a, MachineType::PointerRepresentation()); CVariable var_length(&a, MachineType::PointerRepresentation());
Variable var_flags(&a, MachineType::PointerRepresentation()); CVariable var_flags(&a, 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); var_length.Bind(int_zero);
Label if_isunmodifiedjsregexp(&a), CLabel if_isunmodifiedjsregexp(&a),
if_isnotunmodifiedjsregexp(&a, Label::kDeferred); if_isnotunmodifiedjsregexp(&a, CLabel::kDeferred);
a.Branch(IsInitialRegExpMap(&a, context, map), &if_isunmodifiedjsregexp, a.Branch(IsInitialRegExpMap(&a, context, map), &if_isunmodifiedjsregexp,
&if_isnotunmodifiedjsregexp); &if_isnotunmodifiedjsregexp);
Label construct_string(&a); CLabel construct_string(&a);
a.Bind(&if_isunmodifiedjsregexp); a.Bind(&if_isunmodifiedjsregexp);
{ {
// Refer to JSRegExp's flag property on the fast-path. // Refer to JSRegExp's flag property on the fast-path.
...@@ -625,7 +586,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter( ...@@ -625,7 +586,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter(
Node* const flags_intptr = a.SmiUntag(flags_smi); Node* const flags_intptr = a.SmiUntag(flags_smi);
var_flags.Bind(flags_intptr); var_flags.Bind(flags_intptr);
Label label_global(&a), label_ignorecase(&a), label_multiline(&a), CLabel label_global(&a), label_ignorecase(&a), label_multiline(&a),
label_unicode(&a), label_sticky(&a); label_unicode(&a), label_sticky(&a);
#define CASE_FOR_FLAG(FLAG, LABEL, NEXT_LABEL) \ #define CASE_FOR_FLAG(FLAG, LABEL, NEXT_LABEL) \
...@@ -653,7 +614,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter( ...@@ -653,7 +614,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter(
var_flags.Bind(int_zero); var_flags.Bind(int_zero);
Callable getproperty_callable = CodeFactory::GetProperty(a.isolate()); Callable getproperty_callable = CodeFactory::GetProperty(a.isolate());
Label label_global(&a), label_ignorecase(&a), label_multiline(&a), CLabel label_global(&a), label_ignorecase(&a), label_multiline(&a),
label_unicode(&a), label_sticky(&a); label_unicode(&a), label_sticky(&a);
#define CASE_FOR_FLAG(NAME, FLAG, LABEL, NEXT_LABEL) \ #define CASE_FOR_FLAG(NAME, FLAG, LABEL, NEXT_LABEL) \
...@@ -663,7 +624,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter( ...@@ -663,7 +624,7 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter(
a.HeapConstant(isolate->factory()->NewStringFromAsciiChecked(NAME)); \ a.HeapConstant(isolate->factory()->NewStringFromAsciiChecked(NAME)); \
Node* const flag = \ Node* const flag = \
a.CallStub(getproperty_callable, context, receiver, name); \ a.CallStub(getproperty_callable, context, receiver, name); \
Label if_isflagset(&a); \ CLabel if_isflagset(&a); \
a.BranchIfToBooleanIsTrue(flag, &if_isflagset, &NEXT_LABEL); \ a.BranchIfToBooleanIsTrue(flag, &if_isflagset, &NEXT_LABEL); \
a.Bind(&if_isflagset); \ a.Bind(&if_isflagset); \
var_length.Bind(a.IntPtrAdd(var_length.value(), int_one)); \ var_length.Bind(a.IntPtrAdd(var_length.value(), int_one)); \
...@@ -691,11 +652,11 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter( ...@@ -691,11 +652,11 @@ void Builtins::Generate_RegExpPrototypeFlagsGetter(
a.AllocateSeqOneByteString(context, var_length.value()); a.AllocateSeqOneByteString(context, var_length.value());
Node* const flags_intptr = var_flags.value(); Node* const flags_intptr = var_flags.value();
Variable var_offset(&a, MachineType::PointerRepresentation()); CVariable var_offset(&a, MachineType::PointerRepresentation());
var_offset.Bind( var_offset.Bind(
a.IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag)); a.IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag));
Label label_global(&a), label_ignorecase(&a), label_multiline(&a), CLabel label_global(&a), label_ignorecase(&a), label_multiline(&a),
label_unicode(&a), label_sticky(&a), out(&a); label_unicode(&a), label_sticky(&a), out(&a);
#define CASE_FOR_FLAG(FLAG, CHAR, LABEL, NEXT_LABEL) \ #define CASE_FOR_FLAG(FLAG, CHAR, LABEL, NEXT_LABEL) \
...@@ -792,11 +753,8 @@ BUILTIN(RegExpPrototypeSpeciesGetter) { ...@@ -792,11 +753,8 @@ BUILTIN(RegExpPrototypeSpeciesGetter) {
namespace { namespace {
// Fast-path implementation for flag checks on an unmodified JSRegExp instance. // Fast-path implementation for flag checks on an unmodified JSRegExp instance.
compiler::Node* FastFlagGetter(CodeStubAssembler* a, Node* FastFlagGetter(CodeStubAssembler* a, Node* const regexp,
compiler::Node* const regexp, JSRegExp::Flag flag) {
JSRegExp::Flag flag) {
typedef compiler::Node Node;
Node* const smi_zero = a->SmiConstant(Smi::kZero); Node* const smi_zero = a->SmiConstant(Smi::kZero);
Node* const flags = a->LoadObjectField(regexp, JSRegExp::kFlagsOffset); Node* const flags = a->LoadObjectField(regexp, JSRegExp::kFlagsOffset);
Node* const mask = a->SmiConstant(Smi::FromInt(flag)); Node* const mask = a->SmiConstant(Smi::FromInt(flag));
...@@ -808,17 +766,14 @@ compiler::Node* FastFlagGetter(CodeStubAssembler* a, ...@@ -808,17 +766,14 @@ compiler::Node* FastFlagGetter(CodeStubAssembler* a,
void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag, void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag,
v8::Isolate::UseCounterFeature counter, v8::Isolate::UseCounterFeature counter,
const char* method_name) { const char* method_name) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Node* const receiver = a->Parameter(0); Node* const receiver = a->Parameter(0);
Node* const context = a->Parameter(3); Node* const context = a->Parameter(3);
Isolate* isolate = a->isolate(); Isolate* isolate = a->isolate();
// Check whether we have an unmodified regexp instance. // Check whether we have an unmodified regexp instance.
Label if_isunmodifiedjsregexp(a), CLabel if_isunmodifiedjsregexp(a),
if_isnotunmodifiedjsregexp(a, Label::kDeferred); if_isnotunmodifiedjsregexp(a, CLabel::kDeferred);
a->GotoIf(a->TaggedIsSmi(receiver), &if_isnotunmodifiedjsregexp); a->GotoIf(a->TaggedIsSmi(receiver), &if_isnotunmodifiedjsregexp);
...@@ -844,7 +799,7 @@ void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag, ...@@ -844,7 +799,7 @@ void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag,
regexp_fun, JSFunction::kPrototypeOrInitialMapOffset); regexp_fun, JSFunction::kPrototypeOrInitialMapOffset);
Node* const initial_prototype = a->LoadMapPrototype(initial_map); Node* const initial_prototype = a->LoadMapPrototype(initial_map);
Label if_isprototype(a), if_isnotprototype(a); CLabel if_isprototype(a), if_isnotprototype(a);
a->Branch(a->WordEqual(receiver, initial_prototype), &if_isprototype, a->Branch(a->WordEqual(receiver, initial_prototype), &if_isprototype,
&if_isnotprototype); &if_isnotprototype);
...@@ -871,8 +826,7 @@ void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag, ...@@ -871,8 +826,7 @@ void Generate_FlagGetter(CodeStubAssembler* a, JSRegExp::Flag flag,
} // namespace } // namespace
// ES6 21.2.5.4. // ES6 21.2.5.4.
void Builtins::Generate_RegExpPrototypeGlobalGetter( void Builtins::Generate_RegExpPrototypeGlobalGetter(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
CodeStubAssembler a(state); CodeStubAssembler a(state);
Generate_FlagGetter(&a, JSRegExp::kGlobal, Generate_FlagGetter(&a, JSRegExp::kGlobal,
v8::Isolate::kRegExpPrototypeOldFlagGetter, v8::Isolate::kRegExpPrototypeOldFlagGetter,
...@@ -881,7 +835,7 @@ void Builtins::Generate_RegExpPrototypeGlobalGetter( ...@@ -881,7 +835,7 @@ void Builtins::Generate_RegExpPrototypeGlobalGetter(
// ES6 21.2.5.5. // ES6 21.2.5.5.
void Builtins::Generate_RegExpPrototypeIgnoreCaseGetter( void Builtins::Generate_RegExpPrototypeIgnoreCaseGetter(
compiler::CodeAssemblerState* state) { CodeAssemblerState* state) {
CodeStubAssembler a(state); CodeStubAssembler a(state);
Generate_FlagGetter(&a, JSRegExp::kIgnoreCase, Generate_FlagGetter(&a, JSRegExp::kIgnoreCase,
v8::Isolate::kRegExpPrototypeOldFlagGetter, v8::Isolate::kRegExpPrototypeOldFlagGetter,
...@@ -890,7 +844,7 @@ void Builtins::Generate_RegExpPrototypeIgnoreCaseGetter( ...@@ -890,7 +844,7 @@ void Builtins::Generate_RegExpPrototypeIgnoreCaseGetter(
// ES6 21.2.5.7. // ES6 21.2.5.7.
void Builtins::Generate_RegExpPrototypeMultilineGetter( void Builtins::Generate_RegExpPrototypeMultilineGetter(
compiler::CodeAssemblerState* state) { CodeAssemblerState* state) {
CodeStubAssembler a(state); CodeStubAssembler a(state);
Generate_FlagGetter(&a, JSRegExp::kMultiline, Generate_FlagGetter(&a, JSRegExp::kMultiline,
v8::Isolate::kRegExpPrototypeOldFlagGetter, v8::Isolate::kRegExpPrototypeOldFlagGetter,
...@@ -898,8 +852,7 @@ void Builtins::Generate_RegExpPrototypeMultilineGetter( ...@@ -898,8 +852,7 @@ void Builtins::Generate_RegExpPrototypeMultilineGetter(
} }
// ES6 21.2.5.12. // ES6 21.2.5.12.
void Builtins::Generate_RegExpPrototypeStickyGetter( void Builtins::Generate_RegExpPrototypeStickyGetter(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
CodeStubAssembler a(state); CodeStubAssembler a(state);
Generate_FlagGetter(&a, JSRegExp::kSticky, Generate_FlagGetter(&a, JSRegExp::kSticky,
v8::Isolate::kRegExpPrototypeStickyGetter, v8::Isolate::kRegExpPrototypeStickyGetter,
...@@ -908,7 +861,7 @@ void Builtins::Generate_RegExpPrototypeStickyGetter( ...@@ -908,7 +861,7 @@ void Builtins::Generate_RegExpPrototypeStickyGetter(
// ES6 21.2.5.15. // ES6 21.2.5.15.
void Builtins::Generate_RegExpPrototypeUnicodeGetter( void Builtins::Generate_RegExpPrototypeUnicodeGetter(
compiler::CodeAssemblerState* state) { CodeAssemblerState* state) {
CodeStubAssembler a(state); CodeStubAssembler a(state);
Generate_FlagGetter(&a, JSRegExp::kUnicode, Generate_FlagGetter(&a, JSRegExp::kUnicode,
v8::Isolate::kRegExpPrototypeUnicodeGetter, v8::Isolate::kRegExpPrototypeUnicodeGetter,
...@@ -1001,18 +954,14 @@ BUILTIN(RegExpRightContextGetter) { ...@@ -1001,18 +954,14 @@ BUILTIN(RegExpRightContextGetter) {
namespace { namespace {
// ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S ) // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
compiler::Node* RegExpExec(CodeStubAssembler* a, compiler::Node* context, Node* RegExpExec(CodeStubAssembler* a, Node* context, Node* recv,
compiler::Node* recv, compiler::Node* string) { Node* string) {
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* isolate = a->isolate(); Isolate* isolate = a->isolate();
Node* const null = a->NullConstant(); Node* const null = a->NullConstant();
Variable var_result(a, MachineRepresentation::kTagged); CVariable var_result(a, MachineRepresentation::kTagged);
Label out(a), call_builtin_exec(a), slow_path(a, Label::kDeferred); CLabel out(a), call_builtin_exec(a), slow_path(a, CLabel::kDeferred);
Node* const map = a->LoadMap(recv); Node* const map = a->LoadMap(recv);
BranchIfFastPath(a, context, map, &call_builtin_exec, &slow_path); BranchIfFastPath(a, context, map, &call_builtin_exec, &slow_path);
...@@ -1035,7 +984,7 @@ compiler::Node* RegExpExec(CodeStubAssembler* a, compiler::Node* context, ...@@ -1035,7 +984,7 @@ compiler::Node* RegExpExec(CodeStubAssembler* a, compiler::Node* context,
Node* const exec = a->CallStub(getproperty_callable, context, recv, name); Node* const exec = a->CallStub(getproperty_callable, context, recv, name);
// Is {exec} callable? // Is {exec} callable?
Label if_iscallable(a), if_isnotcallable(a); CLabel if_iscallable(a), if_isnotcallable(a);
a->GotoIf(a->TaggedIsSmi(exec), &if_isnotcallable); a->GotoIf(a->TaggedIsSmi(exec), &if_isnotcallable);
...@@ -1073,9 +1022,7 @@ compiler::Node* RegExpExec(CodeStubAssembler* a, compiler::Node* context, ...@@ -1073,9 +1022,7 @@ compiler::Node* RegExpExec(CodeStubAssembler* a, compiler::Node* context,
// ES#sec-regexp.prototype.test // ES#sec-regexp.prototype.test
// RegExp.prototype.test ( S ) // RegExp.prototype.test ( S )
void Builtins::Generate_RegExpPrototypeTest( void Builtins::Generate_RegExpPrototypeTest(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Isolate* const isolate = a.isolate(); Isolate* const isolate = a.isolate();
...@@ -1176,13 +1123,9 @@ BUILTIN(RegExpPrototypeMatch) { ...@@ -1176,13 +1123,9 @@ BUILTIN(RegExpPrototypeMatch) {
namespace { namespace {
void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
compiler::Node* const receiver, Node* const receiver,
compiler::Node* const string, Node* const string, Node* const context,
compiler::Node* const context,
bool is_fastpath) { bool is_fastpath) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* const isolate = a->isolate(); Isolate* const isolate = a->isolate();
Node* const smi_zero = a->SmiConstant(Smi::kZero); Node* const smi_zero = a->SmiConstant(Smi::kZero);
...@@ -1196,7 +1139,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, ...@@ -1196,7 +1139,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
if (is_fastpath) { if (is_fastpath) {
FastStoreLastIndex(a, context, receiver, smi_zero); FastStoreLastIndex(a, context, receiver, smi_zero);
} else { } else {
Label next(a); CLabel next(a);
a->GotoIf(a->SameValue(previous_last_index, smi_zero, context), &next); a->GotoIf(a->SameValue(previous_last_index, smi_zero, context), &next);
SlowStoreLastIndex(a, context, receiver, smi_zero); SlowStoreLastIndex(a, context, receiver, smi_zero);
...@@ -1213,7 +1156,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, ...@@ -1213,7 +1156,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
if (is_fastpath) { if (is_fastpath) {
FastStoreLastIndex(a, context, receiver, previous_last_index); FastStoreLastIndex(a, context, receiver, previous_last_index);
} else { } else {
Label next(a); CLabel next(a);
Node* const current_last_index = SlowLoadLastIndex(a, context, receiver); Node* const current_last_index = SlowLoadLastIndex(a, context, receiver);
a->GotoIf(a->SameValue(current_last_index, previous_last_index, context), a->GotoIf(a->SameValue(current_last_index, previous_last_index, context),
...@@ -1226,7 +1169,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, ...@@ -1226,7 +1169,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
// Return -1 if no match was found. // Return -1 if no match was found.
{ {
Label next(a); CLabel next(a);
a->GotoUnless(a->WordEqual(match_indices, a->NullConstant()), &next); a->GotoUnless(a->WordEqual(match_indices, a->NullConstant()), &next);
a->Return(a->SmiConstant(-1)); a->Return(a->SmiConstant(-1));
a->Bind(&next); a->Bind(&next);
...@@ -1234,7 +1177,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, ...@@ -1234,7 +1177,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
// Return the index of the match. // Return the index of the match.
{ {
Label fast_result(a), slow_result(a, Label::kDeferred); CLabel fast_result(a), slow_result(a, CLabel::kDeferred);
Node* const native_context = a->LoadNativeContext(context); Node* const native_context = a->LoadNativeContext(context);
Node* const initial_regexp_result_map = Node* const initial_regexp_result_map =
...@@ -1267,10 +1210,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a, ...@@ -1267,10 +1210,7 @@ void Generate_RegExpPrototypeSearchBody(CodeStubAssembler* a,
// ES#sec-regexp.prototype-@@search // ES#sec-regexp.prototype-@@search
// RegExp.prototype [ @@search ] ( string ) // RegExp.prototype [ @@search ] ( string )
void Builtins::Generate_RegExpPrototypeSearch( void Builtins::Generate_RegExpPrototypeSearch(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Isolate* const isolate = a.isolate(); Isolate* const isolate = a.isolate();
...@@ -1289,7 +1229,7 @@ void Builtins::Generate_RegExpPrototypeSearch( ...@@ -1289,7 +1229,7 @@ void Builtins::Generate_RegExpPrototypeSearch(
// Convert {maybe_string} to a String. // Convert {maybe_string} to a String.
Node* const string = a.ToString(context, maybe_string); Node* const string = a.ToString(context, maybe_string);
Label fast_path(&a), slow_path(&a); CLabel fast_path(&a), slow_path(&a);
BranchIfFastPath(&a, context, map, &fast_path, &slow_path); BranchIfFastPath(&a, context, map, &fast_path, &slow_path);
a.Bind(&fast_path); a.Bind(&fast_path);
...@@ -1645,16 +1585,12 @@ BUILTIN(RegExpPrototypeSplit) { ...@@ -1645,16 +1585,12 @@ BUILTIN(RegExpPrototypeSplit) {
namespace { namespace {
compiler::Node* ReplaceGlobalCallableFastPath( Node* ReplaceGlobalCallableFastPath(CodeStubAssembler* a, Node* context,
CodeStubAssembler* a, compiler::Node* context, compiler::Node* regexp, Node* regexp, Node* subject_string,
compiler::Node* subject_string, compiler::Node* replace_callable) { Node* replace_callable) {
// The fast path is reached only if {receiver} is a global unmodified // The fast path is reached only if {receiver} is a global unmodified
// JSRegExp instance and {replace_callable} is callable. // JSRegExp instance and {replace_callable} is callable.
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* const isolate = a->isolate(); Isolate* const isolate = a->isolate();
Node* const null = a->NullConstant(); Node* const null = a->NullConstant();
...@@ -1665,8 +1601,8 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1665,8 +1601,8 @@ compiler::Node* ReplaceGlobalCallableFastPath(
Node* const native_context = a->LoadNativeContext(context); Node* const native_context = a->LoadNativeContext(context);
Label out(a); CLabel out(a);
Variable var_result(a, MachineRepresentation::kTagged); CVariable var_result(a, MachineRepresentation::kTagged);
// Set last index to 0. // Set last index to 0.
FastStoreLastIndex(a, context, regexp, smi_zero); FastStoreLastIndex(a, context, regexp, smi_zero);
...@@ -1713,7 +1649,7 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1713,7 +1649,7 @@ compiler::Node* ReplaceGlobalCallableFastPath(
last_match_info, last_match_info,
a->IntPtrConstant(RegExpMatchInfo::kNumberOfCapturesIndex), 0, mode); a->IntPtrConstant(RegExpMatchInfo::kNumberOfCapturesIndex), 0, mode);
Label if_hasexplicitcaptures(a), if_noexplicitcaptures(a), create_result(a); CLabel if_hasexplicitcaptures(a), if_noexplicitcaptures(a), create_result(a);
a->Branch(a->SmiEqual(num_capture_registers, a->SmiConstant(Smi::FromInt(2))), a->Branch(a->SmiEqual(num_capture_registers, a->SmiConstant(Smi::FromInt(2))),
&if_noexplicitcaptures, &if_hasexplicitcaptures); &if_noexplicitcaptures, &if_hasexplicitcaptures);
...@@ -1726,15 +1662,15 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1726,15 +1662,15 @@ compiler::Node* ReplaceGlobalCallableFastPath(
// input string and some replacements that were returned from the replace // input string and some replacements that were returned from the replace
// function. // function.
Variable var_match_start(a, MachineRepresentation::kTagged); CVariable var_match_start(a, MachineRepresentation::kTagged);
var_match_start.Bind(smi_zero); var_match_start.Bind(smi_zero);
Node* const end = a->SmiUntag(res_length); Node* const end = a->SmiUntag(res_length);
Variable var_i(a, MachineType::PointerRepresentation()); CVariable var_i(a, MachineType::PointerRepresentation());
var_i.Bind(int_zero); var_i.Bind(int_zero);
Variable* vars[] = {&var_i, &var_match_start}; CVariable* vars[] = {&var_i, &var_match_start};
Label loop(a, 2, vars); CLabel loop(a, 2, vars);
a->Goto(&loop); a->Goto(&loop);
a->Bind(&loop); a->Bind(&loop);
{ {
...@@ -1745,13 +1681,13 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1745,13 +1681,13 @@ compiler::Node* ReplaceGlobalCallableFastPath(
CodeStubAssembler::INTPTR_PARAMETERS; CodeStubAssembler::INTPTR_PARAMETERS;
Node* const elem = a->LoadFixedArrayElement(res_elems, i, 0, mode); Node* const elem = a->LoadFixedArrayElement(res_elems, i, 0, mode);
Label if_issmi(a), if_isstring(a), loop_epilogue(a); CLabel if_issmi(a), if_isstring(a), loop_epilogue(a);
a->Branch(a->TaggedIsSmi(elem), &if_issmi, &if_isstring); a->Branch(a->TaggedIsSmi(elem), &if_issmi, &if_isstring);
a->Bind(&if_issmi); a->Bind(&if_issmi);
{ {
// Integers represent slices of the original string. // Integers represent slices of the original string.
Label if_isnegativeorzero(a), if_ispositive(a); CLabel if_isnegativeorzero(a), if_ispositive(a);
a->BranchIfSmiLessThanOrEqual(elem, smi_zero, &if_isnegativeorzero, a->BranchIfSmiLessThanOrEqual(elem, smi_zero, &if_isnegativeorzero,
&if_ispositive); &if_ispositive);
...@@ -1823,7 +1759,7 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1823,7 +1759,7 @@ compiler::Node* ReplaceGlobalCallableFastPath(
Node* const elem = Node* const elem =
a->LoadFixedArrayElement(res_elems, index, 0, mode); a->LoadFixedArrayElement(res_elems, index, 0, mode);
Label do_continue(a); CLabel do_continue(a);
a->GotoIf(a->TaggedIsSmi(elem), &do_continue); a->GotoIf(a->TaggedIsSmi(elem), &do_continue);
// elem must be an Array. // elem must be an Array.
...@@ -1867,28 +1803,22 @@ compiler::Node* ReplaceGlobalCallableFastPath( ...@@ -1867,28 +1803,22 @@ compiler::Node* ReplaceGlobalCallableFastPath(
return var_result.value(); return var_result.value();
} }
compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, Node* context,
compiler::Node* context, Node* regexp, Node* subject_string,
compiler::Node* regexp, Node* replace_string) {
compiler::Node* subject_string,
compiler::Node* replace_string) {
// The fast path is reached only if {receiver} is an unmodified // The fast path is reached only if {receiver} is an unmodified
// JSRegExp instance, {replace_value} is non-callable, and // JSRegExp instance, {replace_value} is non-callable, and
// ToString({replace_value}) does not contain '$', i.e. we're doing a simple // ToString({replace_value}) does not contain '$', i.e. we're doing a simple
// string replacement. // string replacement.
typedef CodeStubAssembler::Variable Variable;
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Isolate* const isolate = a->isolate(); Isolate* const isolate = a->isolate();
Node* const null = a->NullConstant(); Node* const null = a->NullConstant();
Node* const int_zero = a->IntPtrConstant(0); Node* const int_zero = a->IntPtrConstant(0);
Node* const smi_zero = a->SmiConstant(Smi::kZero); Node* const smi_zero = a->SmiConstant(Smi::kZero);
Label out(a); CLabel out(a);
Variable var_result(a, MachineRepresentation::kTagged); CVariable var_result(a, MachineRepresentation::kTagged);
// Load the last match info. // Load the last match info.
Node* const native_context = a->LoadNativeContext(context); Node* const native_context = a->LoadNativeContext(context);
...@@ -1896,7 +1826,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, ...@@ -1896,7 +1826,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a,
native_context, Context::REGEXP_LAST_MATCH_INFO_INDEX); native_context, Context::REGEXP_LAST_MATCH_INFO_INDEX);
// Is {regexp} global? // Is {regexp} global?
Label if_isglobal(a), if_isnonglobal(a); CLabel if_isglobal(a), if_isnonglobal(a);
Node* const flags = a->LoadObjectField(regexp, JSRegExp::kFlagsOffset); Node* const flags = a->LoadObjectField(regexp, JSRegExp::kFlagsOffset);
Node* const is_global = Node* const is_global =
a->WordAnd(a->SmiUntag(flags), a->IntPtrConstant(JSRegExp::kGlobal)); a->WordAnd(a->SmiUntag(flags), a->IntPtrConstant(JSRegExp::kGlobal));
...@@ -1921,7 +1851,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, ...@@ -1921,7 +1851,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a,
a->CallStub(exec_callable, context, regexp, subject_string, smi_zero, a->CallStub(exec_callable, context, regexp, subject_string, smi_zero,
last_match_info); last_match_info);
Label if_matched(a), if_didnotmatch(a); CLabel if_matched(a), if_didnotmatch(a);
a->Branch(a->WordEqual(match_indices, null), &if_didnotmatch, &if_matched); a->Branch(a->WordEqual(match_indices, null), &if_didnotmatch, &if_matched);
a->Bind(&if_didnotmatch); a->Bind(&if_didnotmatch);
...@@ -1945,7 +1875,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, ...@@ -1945,7 +1875,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a,
a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 1), 0, mode); a->IntPtrConstant(RegExpMatchInfo::kFirstCaptureIndex + 1), 0, mode);
Node* const subject_end = a->LoadStringLength(subject_string); Node* const subject_end = a->LoadStringLength(subject_string);
Label if_replaceisempty(a), if_replaceisnotempty(a); CLabel if_replaceisempty(a), if_replaceisnotempty(a);
Node* const replace_length = a->LoadStringLength(replace_string); Node* const replace_length = a->LoadStringLength(replace_string);
a->Branch(a->SmiEqual(replace_length, smi_zero), &if_replaceisempty, a->Branch(a->SmiEqual(replace_length, smi_zero), &if_replaceisempty,
&if_replaceisnotempty); &if_replaceisnotempty);
...@@ -1990,10 +1920,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a, ...@@ -1990,10 +1920,7 @@ compiler::Node* ReplaceSimpleStringFastPath(CodeStubAssembler* a,
// ES#sec-regexp.prototype-@@replace // ES#sec-regexp.prototype-@@replace
// RegExp.prototype [ @@replace ] ( string, replaceValue ) // RegExp.prototype [ @@replace ] ( string, replaceValue )
void Builtins::Generate_RegExpPrototypeReplace( void Builtins::Generate_RegExpPrototypeReplace(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Isolate* const isolate = a.isolate(); Isolate* const isolate = a.isolate();
...@@ -2017,14 +1944,14 @@ void Builtins::Generate_RegExpPrototypeReplace( ...@@ -2017,14 +1944,14 @@ void Builtins::Generate_RegExpPrototypeReplace(
Node* const string = a.CallStub(tostring_callable, context, maybe_string); Node* const string = a.CallStub(tostring_callable, context, maybe_string);
// Fast-path checks: 1. Is the {receiver} an unmodified JSRegExp instance? // Fast-path checks: 1. Is the {receiver} an unmodified JSRegExp instance?
Label checkreplacecallable(&a), runtime(&a, Label::kDeferred), fastpath(&a); CLabel checkreplacecallable(&a), runtime(&a, CLabel::kDeferred), fastpath(&a);
BranchIfFastPath(&a, context, map, &checkreplacecallable, &runtime); BranchIfFastPath(&a, context, map, &checkreplacecallable, &runtime);
a.Bind(&checkreplacecallable); a.Bind(&checkreplacecallable);
Node* const regexp = receiver; Node* const regexp = receiver;
// 2. Is {replace_value} callable? // 2. Is {replace_value} callable?
Label checkreplacestring(&a), if_iscallable(&a); CLabel checkreplacestring(&a), if_iscallable(&a);
a.GotoIf(a.TaggedIsSmi(replace_value), &checkreplacestring); a.GotoIf(a.TaggedIsSmi(replace_value), &checkreplacestring);
Node* const replace_value_map = a.LoadMap(replace_value); Node* const replace_value_map = a.LoadMap(replace_value);
...@@ -2054,7 +1981,7 @@ void Builtins::Generate_RegExpPrototypeReplace( ...@@ -2054,7 +1981,7 @@ void Builtins::Generate_RegExpPrototypeReplace(
Node* const replace_callable = replace_value; Node* const replace_callable = replace_value;
// Check if the {regexp} is global. // Check if the {regexp} is global.
Label if_isglobal(&a), if_isnotglobal(&a); CLabel if_isglobal(&a), if_isnotglobal(&a);
Node* const is_global = FastFlagGetter(&a, regexp, JSRegExp::kGlobal); Node* const is_global = FastFlagGetter(&a, regexp, JSRegExp::kGlobal);
a.Branch(is_global, &if_isglobal, &if_isnotglobal); a.Branch(is_global, &if_isglobal, &if_isnotglobal);
...@@ -2084,10 +2011,7 @@ void Builtins::Generate_RegExpPrototypeReplace( ...@@ -2084,10 +2011,7 @@ void Builtins::Generate_RegExpPrototypeReplace(
// Simple string matching functionality for internal use which does not modify // Simple string matching functionality for internal use which does not modify
// the last match info. // the last match info.
void Builtins::Generate_RegExpInternalMatch( void Builtins::Generate_RegExpInternalMatch(CodeAssemblerState* state) {
compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
CodeStubAssembler a(state); CodeStubAssembler a(state);
Isolate* const isolate = a.isolate(); Isolate* const isolate = a.isolate();
...@@ -2107,7 +2031,7 @@ void Builtins::Generate_RegExpInternalMatch( ...@@ -2107,7 +2031,7 @@ void Builtins::Generate_RegExpInternalMatch(
Node* const match_indices = a.CallStub(exec_callable, context, regexp, string, Node* const match_indices = a.CallStub(exec_callable, context, regexp, string,
smi_zero, internal_match_info); smi_zero, internal_match_info);
Label if_matched(&a), if_didnotmatch(&a); CLabel if_matched(&a), if_didnotmatch(&a);
a.Branch(a.WordEqual(match_indices, null), &if_didnotmatch, &if_matched); a.Branch(a.WordEqual(match_indices, null), &if_didnotmatch, &if_matched);
a.Bind(&if_didnotmatch); a.Bind(&if_didnotmatch);
......
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