Index: src/jsregexp.h |
diff --git a/src/jsregexp.h b/src/jsregexp.h |
index 3601c1a1e82901ef6819b3fee627abedae8f403f..fa4ef5d09f44e4dd0d0492d45a72d5c70143d5e1 100644 |
--- a/src/jsregexp.h |
+++ b/src/jsregexp.h |
@@ -78,7 +78,8 @@ class RegExpImpl { |
static Handle<Object> Exec(Handle<JSRegExp> regexp, |
Handle<String> subject, |
int index, |
- Handle<JSArray> lastMatchInfo); |
+ Handle<JSArray> lastMatchInfo, |
+ Zone* zone); |
// Prepares a JSRegExp object with Irregexp-specific data. |
static void IrregexpInitialize(Handle<JSRegExp> re, |
@@ -107,7 +108,8 @@ class RegExpImpl { |
// as its "registers" argument. If the regexp cannot be compiled, |
// an exception is set as pending, and this function returns negative. |
static int IrregexpPrepare(Handle<JSRegExp> regexp, |
- Handle<String> subject); |
+ Handle<String> subject, |
+ Zone* zone); |
// Calculate the size of offsets vector for the case of global regexp |
// and the number of matches this vector is able to store. |
@@ -124,7 +126,8 @@ class RegExpImpl { |
static int IrregexpExecRaw(Handle<JSRegExp> regexp, |
Handle<String> subject, |
int index, |
- Vector<int> registers); |
+ Vector<int> registers, |
+ Zone* zone); |
// Execute an Irregexp bytecode pattern. |
// On a successful match, the result is a JSArray containing |
@@ -133,7 +136,8 @@ class RegExpImpl { |
static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, |
Handle<String> subject, |
int index, |
- Handle<JSArray> lastMatchInfo); |
+ Handle<JSArray> lastMatchInfo, |
+ Zone* zone); |
// Array index in the lastMatchInfo array. |
static const int kLastCaptureCount = 0; |
@@ -198,9 +202,11 @@ class RegExpImpl { |
static String* two_byte_cached_string_; |
static bool CompileIrregexp( |
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii); |
+ Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii, |
+ Zone* zone); |
static inline bool EnsureCompiledIrregexp( |
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii); |
+ Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii, |
+ Zone* zone); |
// Set the subject cache. The previous string buffer is not deleted, so the |
@@ -534,7 +540,8 @@ extern int kUninitializedRegExpNodePlaceHolder; |
class RegExpNode: public ZoneObject { |
public: |
- RegExpNode() : replacement_(NULL), trace_count_(0) { |
+ explicit RegExpNode(Zone* zone) |
+ : replacement_(NULL), trace_count_(0), zone_(zone) { |
bm_info_[0] = bm_info_[1] = NULL; |
} |
virtual ~RegExpNode(); |
@@ -628,6 +635,8 @@ class RegExpNode: public ZoneObject { |
return bm_info_[not_at_start ? 1 : 0]; |
} |
+ Zone* zone() { return zone_; } |
+ |
protected: |
enum LimitResult { DONE, CONTINUE }; |
RegExpNode* replacement_; |
@@ -649,6 +658,8 @@ class RegExpNode: public ZoneObject { |
// deferred operations in the current trace and generating a goto. |
int trace_count_; |
BoyerMooreLookahead* bm_info_[2]; |
+ |
+ Zone* zone_; |
}; |
@@ -682,7 +693,7 @@ class Interval { |
class SeqRegExpNode: public RegExpNode { |
public: |
explicit SeqRegExpNode(RegExpNode* on_success) |
- : on_success_(on_success) { } |
+ : RegExpNode(on_success->zone()), on_success_(on_success) { } |
RegExpNode* on_success() { return on_success_; } |
void set_on_success(RegExpNode* node) { on_success_ = node; } |
virtual RegExpNode* FilterASCII(int depth); |
@@ -800,8 +811,8 @@ class TextNode: public SeqRegExpNode { |
TextNode(RegExpCharacterClass* that, |
RegExpNode* on_success) |
: SeqRegExpNode(on_success), |
- elms_(new ZoneList<TextElement>(1)) { |
- elms_->Add(TextElement::CharClass(that)); |
+ elms_(new ZoneList<TextElement>(1, zone())) { |
+ elms_->Add(TextElement::CharClass(that), zone()); |
} |
virtual void Accept(NodeVisitor* visitor); |
virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
@@ -936,7 +947,8 @@ class BackReferenceNode: public SeqRegExpNode { |
class EndNode: public RegExpNode { |
public: |
enum Action { ACCEPT, BACKTRACK, NEGATIVE_SUBMATCH_SUCCESS }; |
- explicit EndNode(Action action) : action_(action) { } |
+ explicit 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, |
@@ -968,8 +980,9 @@ class NegativeSubmatchSuccess: public EndNode { |
NegativeSubmatchSuccess(int stack_pointer_reg, |
int position_reg, |
int clear_capture_count, |
- int clear_capture_start) |
- : EndNode(NEGATIVE_SUBMATCH_SUCCESS), |
+ int clear_capture_start, |
+ Zone* zone) |
+ : EndNode(NEGATIVE_SUBMATCH_SUCCESS, zone), |
stack_pointer_register_(stack_pointer_reg), |
current_position_register_(position_reg), |
clear_capture_count_(clear_capture_count), |
@@ -1021,13 +1034,16 @@ class AlternativeGeneration; |
class ChoiceNode: public RegExpNode { |
public: |
- explicit ChoiceNode(int expected_size) |
- : alternatives_(new ZoneList<GuardedAlternative>(expected_size)), |
+ explicit ChoiceNode(int expected_size, Zone* zone) |
+ : RegExpNode(zone), |
+ alternatives_(new ZoneList<GuardedAlternative>(expected_size, zone)), |
table_(NULL), |
not_at_start_(false), |
being_calculated_(false) { } |
virtual void Accept(NodeVisitor* visitor); |
- void AddAlternative(GuardedAlternative node) { alternatives()->Add(node); } |
+ void AddAlternative(GuardedAlternative node) { |
+ alternatives()->Add(node, zone()); |
+ } |
ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } |
DispatchTable* GetTable(bool ignore_case); |
virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
@@ -1083,8 +1099,9 @@ class ChoiceNode: public RegExpNode { |
class NegativeLookaheadChoiceNode: public ChoiceNode { |
public: |
explicit NegativeLookaheadChoiceNode(GuardedAlternative this_must_fail, |
- GuardedAlternative then_do_this) |
- : ChoiceNode(2) { |
+ GuardedAlternative then_do_this, |
+ Zone* zone) |
+ : ChoiceNode(2, zone) { |
AddAlternative(this_must_fail); |
AddAlternative(then_do_this); |
} |
@@ -1116,8 +1133,8 @@ class NegativeLookaheadChoiceNode: public ChoiceNode { |
class LoopChoiceNode: public ChoiceNode { |
public: |
- explicit LoopChoiceNode(bool body_can_be_zero_length) |
- : ChoiceNode(2), |
+ explicit LoopChoiceNode(bool body_can_be_zero_length, Zone* zone) |
+ : ChoiceNode(2, zone), |
loop_node_(NULL), |
continue_node_(NULL), |
body_can_be_zero_length_(body_can_be_zero_length) { } |
@@ -1202,15 +1219,15 @@ ContainedInLattice AddRange(ContainedInLattice a, |
class BoyerMoorePositionInfo : public ZoneObject { |
public: |
- BoyerMoorePositionInfo() |
- : map_(new ZoneList<bool>(kMapSize)), |
+ explicit BoyerMoorePositionInfo(Zone* zone) |
+ : map_(new ZoneList<bool>(kMapSize, zone)), |
map_count_(0), |
w_(kNotYet), |
s_(kNotYet), |
d_(kNotYet), |
surrogate_(kNotYet) { |
for (int i = 0; i < kMapSize; i++) { |
- map_->Add(false); |
+ map_->Add(false, zone); |
} |
} |
@@ -1239,7 +1256,7 @@ class BoyerMoorePositionInfo : public ZoneObject { |
class BoyerMooreLookahead : public ZoneObject { |
public: |
- BoyerMooreLookahead(int length, RegExpCompiler* compiler); |
+ BoyerMooreLookahead(int length, RegExpCompiler* compiler, Zone* zone); |
int length() { return length_; } |
int max_char() { return max_char_; } |
@@ -1589,7 +1606,7 @@ class RegExpEngine: public AllStatic { |
bool multiline, |
Handle<String> pattern, |
Handle<String> sample_subject, |
- bool is_ascii); |
+ bool is_ascii, Zone* zone); |
static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
}; |