Commit ca6587c0 authored by yangguo's avatar yangguo Committed by Commit bot

[regexp] do not store flags as bitfield in the parser.

This reverts a small part of e709aa24 in an attempt to recover
lost page_cycler performance.

R=jkummerow@chromium.org
BUG=chromium:580973
LOG=N

Review URL: https://codereview.chromium.org/1651073002

Cr-Commit-Position: refs/heads/master@{#33637}
parent a1a8dd14
...@@ -26,7 +26,9 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error, ...@@ -26,7 +26,9 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error,
captures_(NULL), captures_(NULL),
in_(in), in_(in),
current_(kEndMarker), current_(kEndMarker),
flags_(flags), ignore_case_(flags & JSRegExp::kIgnoreCase),
multiline_(flags & JSRegExp::kMultiline),
unicode_(flags & JSRegExp::kUnicode),
next_pos_(0), next_pos_(0),
captures_started_(0), captures_started_(0),
capture_count_(0), capture_count_(0),
...@@ -38,9 +40,8 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error, ...@@ -38,9 +40,8 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error,
Advance(); Advance();
} }
template <bool update_position> template <bool update_position>
uc32 RegExpParser::ReadNext() { inline uc32 RegExpParser::ReadNext() {
int position = next_pos_; int position = next_pos_;
uc32 c0 = in()->Get(position); uc32 c0 = in()->Get(position);
position++; position++;
...@@ -169,7 +170,7 @@ RegExpTree* RegExpParser::ParsePattern() { ...@@ -169,7 +170,7 @@ RegExpTree* RegExpParser::ParsePattern() {
RegExpTree* RegExpParser::ParseDisjunction() { RegExpTree* RegExpParser::ParseDisjunction() {
// Used to store current state while parsing subexpressions. // Used to store current state while parsing subexpressions.
RegExpParserState initial_state(NULL, INITIAL, RegExpLookaround::LOOKAHEAD, 0, RegExpParserState initial_state(NULL, INITIAL, RegExpLookaround::LOOKAHEAD, 0,
flags_, zone()); ignore_case(), unicode(), zone());
RegExpParserState* state = &initial_state; RegExpParserState* state = &initial_state;
// Cache the builder in a local variable for quick access. // Cache the builder in a local variable for quick access.
RegExpBuilder* builder = initial_state.builder(); RegExpBuilder* builder = initial_state.builder();
...@@ -303,9 +304,9 @@ RegExpTree* RegExpParser::ParseDisjunction() { ...@@ -303,9 +304,9 @@ RegExpTree* RegExpParser::ParseDisjunction() {
captures_started_++; captures_started_++;
} }
// Store current state and begin new disjunction parsing. // Store current state and begin new disjunction parsing.
state = state = new (zone()) RegExpParserState(
new (zone()) RegExpParserState(state, subexpr_type, lookaround_type, state, subexpr_type, lookaround_type, captures_started_,
captures_started_, flags_, zone()); ignore_case(), unicode(), zone());
builder = state->builder(); builder = state->builder();
continue; continue;
} }
...@@ -1080,11 +1081,11 @@ bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone, ...@@ -1080,11 +1081,11 @@ bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone,
return !parser.failed(); return !parser.failed();
} }
RegExpBuilder::RegExpBuilder(Zone* zone, bool ignore_case, bool unicode)
RegExpBuilder::RegExpBuilder(Zone* zone, JSRegExp::Flags flags)
: zone_(zone), : zone_(zone),
pending_empty_(false), pending_empty_(false),
flags_(flags), ignore_case_(ignore_case),
unicode_(unicode),
characters_(NULL), characters_(NULL),
pending_surrogate_(kNoPendingSurrogate), pending_surrogate_(kNoPendingSurrogate),
terms_(), terms_(),
......
...@@ -99,7 +99,7 @@ class BufferedZoneList { ...@@ -99,7 +99,7 @@ class BufferedZoneList {
// Accumulates RegExp atoms and assertions into lists of terms and alternatives. // Accumulates RegExp atoms and assertions into lists of terms and alternatives.
class RegExpBuilder : public ZoneObject { class RegExpBuilder : public ZoneObject {
public: public:
RegExpBuilder(Zone* zone, JSRegExp::Flags flags); RegExpBuilder(Zone* zone, bool ignore_case, bool unicode);
void AddCharacter(uc16 character); void AddCharacter(uc16 character);
void AddUnicodeCharacter(uc32 character); void AddUnicodeCharacter(uc32 character);
// "Adds" an empty expression. Does nothing except consume a // "Adds" an empty expression. Does nothing except consume a
...@@ -126,12 +126,13 @@ class RegExpBuilder : public ZoneObject { ...@@ -126,12 +126,13 @@ class RegExpBuilder : public ZoneObject {
bool NeedsDesugaringForUnicode(RegExpCharacterClass* cc); bool NeedsDesugaringForUnicode(RegExpCharacterClass* cc);
bool NeedsDesugaringForIgnoreCase(uc32 c); bool NeedsDesugaringForIgnoreCase(uc32 c);
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } bool ignore_case() const { return ignore_case_; }
bool ignore_case() const { return (flags_ & JSRegExp::kIgnoreCase) != 0; } bool unicode() const { return unicode_; }
Zone* zone_; Zone* zone_;
bool pending_empty_; bool pending_empty_;
JSRegExp::Flags flags_; bool ignore_case_;
bool unicode_;
ZoneList<uc16>* characters_; ZoneList<uc16>* characters_;
uc16 pending_surrogate_; uc16 pending_surrogate_;
BufferedZoneList<RegExpTree, 2> terms_; BufferedZoneList<RegExpTree, 2> terms_;
...@@ -195,8 +196,9 @@ class RegExpParser BASE_EMBEDDED { ...@@ -195,8 +196,9 @@ class RegExpParser BASE_EMBEDDED {
int captures_started() { return captures_started_; } int captures_started() { return captures_started_; }
int position() { return next_pos_ - 1; } int position() { return next_pos_ - 1; }
bool failed() { return failed_; } bool failed() { return failed_; }
bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } bool ignore_case() const { return ignore_case_; }
bool multiline() const { return (flags_ & JSRegExp::kMultiline) != 0; } bool multiline() const { return multiline_; }
bool unicode() const { return unicode_; }
static bool IsSyntaxCharacterOrSlash(uc32 c); static bool IsSyntaxCharacterOrSlash(uc32 c);
...@@ -217,10 +219,10 @@ class RegExpParser BASE_EMBEDDED { ...@@ -217,10 +219,10 @@ class RegExpParser BASE_EMBEDDED {
RegExpParserState(RegExpParserState* previous_state, RegExpParserState(RegExpParserState* previous_state,
SubexpressionType group_type, SubexpressionType group_type,
RegExpLookaround::Type lookaround_type, RegExpLookaround::Type lookaround_type,
int disjunction_capture_index, JSRegExp::Flags flags, int disjunction_capture_index, bool ignore_case,
Zone* zone) bool unicode, Zone* zone)
: previous_state_(previous_state), : previous_state_(previous_state),
builder_(new (zone) RegExpBuilder(zone, flags)), builder_(new (zone) RegExpBuilder(zone, ignore_case, unicode)),
group_type_(group_type), group_type_(group_type),
lookaround_type_(lookaround_type), lookaround_type_(lookaround_type),
disjunction_capture_index_(disjunction_capture_index) {} disjunction_capture_index_(disjunction_capture_index) {}
...@@ -275,7 +277,9 @@ class RegExpParser BASE_EMBEDDED { ...@@ -275,7 +277,9 @@ class RegExpParser BASE_EMBEDDED {
ZoneList<RegExpCapture*>* captures_; ZoneList<RegExpCapture*>* captures_;
FlatStringReader* in_; FlatStringReader* in_;
uc32 current_; uc32 current_;
JSRegExp::Flags flags_; bool ignore_case_;
bool multiline_;
bool unicode_;
int next_pos_; int next_pos_;
int captures_started_; int captures_started_;
// The capture count is only valid after we have scanned for captures. // The capture count is only valid after we have scanned for captures.
......
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