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