Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/src/regexp/jsregexp.h b/src/regexp/jsregexp.h
index 0ad4b79..e55d650 100644
--- a/src/regexp/jsregexp.h
+++ b/src/regexp/jsregexp.h
@@ -8,6 +8,7 @@
#include "src/allocation.h"
#include "src/assembler.h"
#include "src/regexp/regexp-ast.h"
+#include "src/regexp/regexp-macro-assembler.h"
namespace v8 {
namespace internal {
@@ -121,7 +122,6 @@
public:
GlobalCache(Handle<JSRegExp> regexp,
Handle<String> subject,
- bool is_global,
Isolate* isolate);
INLINE(~GlobalCache());
@@ -137,6 +137,8 @@
INLINE(bool HasException()) { return num_matches_ < 0; }
private:
+ int AdvanceZeroLength(int last_index);
+
int num_matches_;
int max_matches_;
int current_match_index_;
@@ -265,28 +267,30 @@
class Entry {
public:
Entry() : from_(0), to_(0), out_set_(NULL) { }
- Entry(uc16 from, uc16 to, OutSet* out_set)
- : from_(from), to_(to), out_set_(out_set) { }
- uc16 from() { return from_; }
- uc16 to() { return to_; }
- void set_to(uc16 value) { to_ = value; }
+ Entry(uc32 from, uc32 to, OutSet* out_set)
+ : from_(from), to_(to), out_set_(out_set) {
+ DCHECK(from <= to);
+ }
+ uc32 from() { return from_; }
+ uc32 to() { return to_; }
+ void set_to(uc32 value) { to_ = value; }
void AddValue(int value, Zone* zone) {
out_set_ = out_set_->Extend(value, zone);
}
OutSet* out_set() { return out_set_; }
private:
- uc16 from_;
- uc16 to_;
+ uc32 from_;
+ uc32 to_;
OutSet* out_set_;
};
class Config {
public:
- typedef uc16 Key;
+ typedef uc32 Key;
typedef Entry Value;
- static const uc16 kNoKey;
+ static const uc32 kNoKey;
static const Entry NoValue() { return Value(); }
- static inline int Compare(uc16 a, uc16 b) {
+ static inline int Compare(uc32 a, uc32 b) {
if (a == b)
return 0;
else if (a < b)
@@ -297,7 +301,7 @@
};
void AddRange(CharacterRange range, int value, Zone* zone);
- OutSet* Get(uc16 value);
+ OutSet* Get(uc32 value);
void Dump();
template <typename Callback>
@@ -315,6 +319,34 @@
};
+// Categorizes character ranges into BMP, non-BMP, lead, and trail surrogates.
+class UnicodeRangeSplitter {
+ public:
+ UnicodeRangeSplitter(Zone* zone, ZoneList<CharacterRange>* base);
+ void Call(uc32 from, DispatchTable::Entry entry);
+
+ ZoneList<CharacterRange>* bmp() { return bmp_; }
+ ZoneList<CharacterRange>* lead_surrogates() { return lead_surrogates_; }
+ ZoneList<CharacterRange>* trail_surrogates() { return trail_surrogates_; }
+ ZoneList<CharacterRange>* non_bmp() const { return non_bmp_; }
+
+ private:
+ static const int kBase = 0;
+ // Separate ranges into
+ static const int kBmpCodePoints = 1;
+ static const int kLeadSurrogates = 2;
+ static const int kTrailSurrogates = 3;
+ static const int kNonBmpCodePoints = 4;
+
+ Zone* zone_;
+ DispatchTable table_;
+ ZoneList<CharacterRange>* bmp_;
+ ZoneList<CharacterRange>* lead_surrogates_;
+ ZoneList<CharacterRange>* trail_surrogates_;
+ ZoneList<CharacterRange>* non_bmp_;
+};
+
+
#define FOR_EACH_NODE_TYPE(VISIT) \
VISIT(End) \
VISIT(Action) \
@@ -690,6 +722,17 @@
read_backward_(read_backward) {
elms_->Add(TextElement::CharClass(that), zone());
}
+ // Create TextNode for a single character class for the given ranges.
+ static TextNode* CreateForCharacterRanges(Zone* zone,
+ ZoneList<CharacterRange>* ranges,
+ bool read_backward,
+ RegExpNode* on_success);
+ // Create TextNode for a surrogate pair with a range given for the
+ // lead and the trail surrogate each.
+ static TextNode* CreateForSurrogatePair(Zone* zone, CharacterRange lead,
+ CharacterRange trail,
+ bool read_backward,
+ RegExpNode* on_success);
virtual void Accept(NodeVisitor* visitor);
virtual void Emit(RegExpCompiler* compiler, Trace* trace);
virtual int EatsAtLeast(int still_to_find, int budget, bool not_at_start);
@@ -813,8 +856,7 @@
class EndNode: public RegExpNode {
public:
enum Action { ACCEPT, BACKTRACK, NEGATIVE_SUBMATCH_SUCCESS };
- explicit EndNode(Action action, Zone* zone)
- : RegExpNode(zone), action_(action) { }
+ EndNode(Action action, Zone* zone) : RegExpNode(zone), action_(action) {}
virtual void Accept(NodeVisitor* visitor);
virtual void Emit(RegExpCompiler* compiler, Trace* trace);
virtual int EatsAtLeast(int still_to_find,
@@ -1440,9 +1482,9 @@
// +-------+ +------------+
class Analysis: public NodeVisitor {
public:
- Analysis(Isolate* isolate, bool ignore_case, bool is_one_byte)
+ Analysis(Isolate* isolate, JSRegExp::Flags flags, bool is_one_byte)
: isolate_(isolate),
- ignore_case_(ignore_case),
+ flags_(flags),
is_one_byte_(is_one_byte),
error_message_(NULL) {}
void EnsureAnalyzed(RegExpNode* node);
@@ -1464,9 +1506,12 @@
Isolate* isolate() const { return isolate_; }
+ bool ignore_case() const { return (flags_ & JSRegExp::kIgnoreCase) != 0; }
+ bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; }
+
private:
Isolate* isolate_;
- bool ignore_case_;
+ JSRegExp::Flags flags_;
bool is_one_byte_;
const char* error_message_;
@@ -1505,8 +1550,8 @@
};
static CompilationResult Compile(Isolate* isolate, Zone* zone,
- RegExpCompileData* input, bool ignore_case,
- bool global, bool multiline, bool sticky,
+ RegExpCompileData* input,
+ JSRegExp::Flags flags,
Handle<String> pattern,
Handle<String> sample_subject,
bool is_one_byte);