Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2356)

Unified Diff: src/jsregexp.h

Issue 7374002: Refactor allocation policies. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/json-parser.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jsregexp.h
diff --git a/src/jsregexp.h b/src/jsregexp.h
index 13f9e2ea06bfd777801d09b05a207560c0cad51a..df4a1bb4a933c439832bcd63bd4d788631beeb27 100644
--- a/src/jsregexp.h
+++ b/src/jsregexp.h
@@ -287,7 +287,8 @@ class CharacterRange {
bool IsEverything(uc16 max) { return from_ == 0 && to_ >= max; }
bool IsSingleton() { return (from_ == to_); }
void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii);
- static void Split(ZoneList<CharacterRange>* base,
+ static void Split(Zone* zone,
+ ZoneList<CharacterRange>* base,
Vector<const uc16> overlay,
ZoneList<CharacterRange>** included,
ZoneList<CharacterRange>** excluded);
@@ -338,7 +339,7 @@ class CharacterRange {
class OutSet: public ZoneObject {
public:
OutSet() : first_(0), remaining_(NULL), successors_(NULL) { }
- OutSet* Extend(unsigned value);
+ OutSet* Extend(Zone* zone, unsigned value);
bool Get(unsigned value);
static const unsigned kFirstLimit = 32;
@@ -346,7 +347,7 @@ class OutSet: public ZoneObject {
// Destructively set a value in this set. In most cases you want
// to use Extend instead to ensure that only one instance exists
// that contains the same values.
- void Set(unsigned value);
+ void Set(Zone* zone, unsigned value);
// The successors are a list of sets that contain the same values
// as this set and the one more value that is not present in this
@@ -374,7 +375,9 @@ class DispatchTable : public ZoneObject {
uc16 from() { return from_; }
uc16 to() { return to_; }
void set_to(uc16 value) { to_ = value; }
- void AddValue(int value) { out_set_ = out_set_->Extend(value); }
+ void AddValue(Zone* zone, int value) {
+ out_set_ = out_set_->Extend(zone, value);
+ }
OutSet* out_set() { return out_set_; }
private:
uc16 from_;
@@ -398,6 +401,8 @@ class DispatchTable : public ZoneObject {
}
};
+ explicit DispatchTable(Zone* zone) : zone_(zone), tree_(zone) {}
+
void AddRange(CharacterRange range, int value);
OutSet* Get(uc16 value);
void Dump();
@@ -408,6 +413,7 @@ class DispatchTable : public ZoneObject {
// There can't be a static empty set since it allocates its
// successors in a zone and caches them.
OutSet* empty() { return &empty_; }
+ Zone* zone_;
OutSet empty_;
ZoneSplayTree<Config>* tree() { return &tree_; }
ZoneSplayTree<Config> tree_;
@@ -529,9 +535,9 @@ class SiblingList {
int length() {
return list_ == NULL ? 0 : list_->length();
}
- void Ensure(RegExpNode* parent) {
+ void Ensure(Zone* zone, RegExpNode* parent) {
if (list_ == NULL) {
- list_ = new ZoneList<RegExpNode*>(2);
+ list_ = ZoneList<RegExpNode*>::New(zone, 2);
list_->Add(parent);
}
}
@@ -645,8 +651,8 @@ class RegExpNode: public ZoneObject {
// Static version of EnsureSibling that expresses the fact that the
// result has the same type as the input.
template <class C>
- static C* EnsureSibling(C* node, NodeInfo* info, bool* cloned) {
- return static_cast<C*>(node->EnsureSibling(info, cloned));
+ static C* EnsureSibling(Zone* zone, C* node, NodeInfo* info, bool* cloned) {
+ return static_cast<C*>(node->EnsureSibling(zone, info, cloned));
}
SiblingList* siblings() { return &siblings_; }
@@ -654,14 +660,14 @@ class RegExpNode: public ZoneObject {
// Return the set of possible next characters recognized by the regexp
// (or a safe subset, potentially the set of all characters).
- ZoneList<CharacterRange>* FirstCharacterSet();
+ ZoneList<CharacterRange>* FirstCharacterSet(Zone* zone);
// Compute (if possible within the budget of traversed nodes) the
// possible first characters of the input matched by this node and
// its continuation. Returns the remaining budget after the computation.
// If the budget is spent, the result is negative, and the cached
// first_character_set_ value isn't set.
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
// Get and set the cached first character set value.
ZoneList<CharacterRange>* first_character_set() {
@@ -687,7 +693,7 @@ class RegExpNode: public ZoneObject {
// If no node exists a new one will be created by cloning the current
// node. The result will always be an instance of the same concrete
// class as this node.
- RegExpNode* EnsureSibling(NodeInfo* info, bool* cloned);
+ RegExpNode* EnsureSibling(Zone* zone, NodeInfo* info, bool* cloned);
// Returns a clone of this node initialized using the copy constructor
// of its concrete class. Note that the node may have to be pre-
@@ -792,7 +798,7 @@ class ActionNode: public SeqRegExpNode {
// TODO(erikcorry): We should allow some action nodes in greedy loops.
virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; }
virtual ActionNode* Clone() { return new ActionNode(*this); }
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
private:
union {
struct {
@@ -836,10 +842,11 @@ class TextNode: public SeqRegExpNode {
RegExpNode* on_success)
: SeqRegExpNode(on_success),
elms_(elms) { }
- TextNode(RegExpCharacterClass* that,
+ TextNode(Zone* zone,
+ RegExpCharacterClass* that,
RegExpNode* on_success)
: SeqRegExpNode(on_success),
- elms_(new ZoneList<TextElement>(1)) {
+ elms_(ZoneList<TextElement>::New(zone, 1)) {
elms_->Add(TextElement::CharClass(that));
}
virtual void Accept(NodeVisitor* visitor);
@@ -852,7 +859,7 @@ class TextNode: public SeqRegExpNode {
int characters_filled_in,
bool not_at_start);
ZoneList<TextElement>* elements() { return elms_; }
- void MakeCaseIndependent(bool is_ascii);
+ void MakeCaseIndependent(Zone* zone, bool is_ascii);
virtual int GreedyLoopTextLength();
virtual TextNode* Clone() {
TextNode* result = new TextNode(*this);
@@ -860,7 +867,7 @@ class TextNode: public SeqRegExpNode {
return result;
}
void CalculateOffsets();
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
private:
enum TextEmitPassType {
NON_ASCII_MATCH, // Check for characters that can't match.
@@ -921,7 +928,7 @@ class AssertionNode: public SeqRegExpNode {
RegExpCompiler* compiler,
int filled_in,
bool not_at_start);
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
virtual AssertionNode* Clone() { return new AssertionNode(*this); }
AssertionNodeType type() { return type_; }
void set_type(AssertionNodeType type) { type_ = type; }
@@ -954,7 +961,7 @@ class BackReferenceNode: public SeqRegExpNode {
return;
}
virtual BackReferenceNode* Clone() { return new BackReferenceNode(*this); }
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
private:
int start_reg_;
int end_reg_;
@@ -1025,7 +1032,7 @@ class Guard: public ZoneObject {
class GuardedAlternative {
public:
explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { }
- void AddGuard(Guard* guard);
+ void AddGuard(Zone* zone, Guard* guard);
RegExpNode* node() { return node_; }
void set_node(RegExpNode* node) { node_ = node; }
ZoneList<Guard*>* guards() { return guards_; }
@@ -1041,15 +1048,15 @@ class AlternativeGeneration;
class ChoiceNode: public RegExpNode {
public:
- explicit ChoiceNode(int expected_size)
- : alternatives_(new ZoneList<GuardedAlternative>(expected_size)),
+ ChoiceNode(Zone* zone, int expected_size)
+ : alternatives_(ZoneList<GuardedAlternative>::New(zone, expected_size)),
table_(NULL),
not_at_start_(false),
being_calculated_(false) { }
virtual void Accept(NodeVisitor* visitor);
void AddAlternative(GuardedAlternative node) { alternatives()->Add(node); }
ZoneList<GuardedAlternative>* alternatives() { return alternatives_; }
- DispatchTable* GetTable(bool ignore_case);
+ DispatchTable* GetTable(Zone* zone, bool ignore_case);
virtual void Emit(RegExpCompiler* compiler, Trace* trace);
virtual int EatsAtLeast(int still_to_find,
int recursion_depth,
@@ -1097,9 +1104,10 @@ class ChoiceNode: public RegExpNode {
class NegativeLookaheadChoiceNode: public ChoiceNode {
public:
- explicit NegativeLookaheadChoiceNode(GuardedAlternative this_must_fail,
+ explicit NegativeLookaheadChoiceNode(Zone* zone,
+ GuardedAlternative this_must_fail,
GuardedAlternative then_do_this)
- : ChoiceNode(2) {
+ : ChoiceNode(zone, 2) {
AddAlternative(this_must_fail);
AddAlternative(then_do_this);
}
@@ -1116,14 +1124,14 @@ class NegativeLookaheadChoiceNode: public ChoiceNode {
// characters, but on a negative lookahead the negative branch did not take
// part in that calculation (EatsAtLeast) so the assumptions don't hold.
virtual bool try_to_emit_quick_check_for_alternative(int i) { return i != 0; }
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
};
class LoopChoiceNode: public ChoiceNode {
public:
- explicit LoopChoiceNode(bool body_can_be_zero_length)
- : ChoiceNode(2),
+ LoopChoiceNode(Zone* zone, bool body_can_be_zero_length)
+ : ChoiceNode(zone, 2),
loop_node_(NULL),
continue_node_(NULL),
body_can_be_zero_length_(body_can_be_zero_length) { }
@@ -1137,7 +1145,7 @@ class LoopChoiceNode: public ChoiceNode {
RegExpCompiler* compiler,
int characters_filled_in,
bool not_at_start);
- virtual int ComputeFirstCharacterSet(int budget);
+ virtual int ComputeFirstCharacterSet(Zone* zone, int budget);
virtual LoopChoiceNode* Clone() { return new LoopChoiceNode(*this); }
RegExpNode* loop_node() { return loop_node_; }
RegExpNode* continue_node() { return continue_node_; }
@@ -1302,12 +1310,13 @@ class Trace {
void InvalidateCurrentCharacter();
void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler);
private:
- int FindAffectedRegisters(OutSet* affected_registers);
- void PerformDeferredActions(RegExpMacroAssembler* macro,
- int max_register,
- OutSet& affected_registers,
- OutSet* registers_to_pop,
- OutSet* registers_to_clear);
+ int FindAffectedRegisters(Zone* zone, OutSet* affected_registers);
+ void PerformDeferredActions(Zone* zone,
+ RegExpMacroAssembler* macro,
+ int max_register,
+ OutSet& affected_registers,
+ OutSet* registers_to_pop,
+ OutSet* registers_to_clear);
void RestoreAffectedRegisters(RegExpMacroAssembler* macro,
int max_register,
OutSet& registers_to_pop,
@@ -1340,8 +1349,9 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
// dispatch table of a choice node.
class DispatchTableConstructor: public NodeVisitor {
public:
- DispatchTableConstructor(DispatchTable* table, bool ignore_case)
- : table_(table),
+ DispatchTableConstructor(Zone* zone, DispatchTable* table, bool ignore_case)
+ : zone_(zone),
+ table_(table),
choice_index_(-1),
ignore_case_(ignore_case) { }
@@ -1362,6 +1372,7 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
void set_choice_index(int value) { choice_index_ = value; }
protected:
+ Zone* zone_;
DispatchTable* table_;
int choice_index_;
bool ignore_case_;
@@ -1382,8 +1393,9 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
// +-------+ +------------+
class Analysis: public NodeVisitor {
public:
- Analysis(bool ignore_case, bool is_ascii)
- : ignore_case_(ignore_case),
+ Analysis(Zone* zone, bool ignore_case, bool is_ascii)
+ : zone_(zone),
+ ignore_case_(ignore_case),
is_ascii_(is_ascii),
error_message_(NULL) { }
void EnsureAnalyzed(RegExpNode* node);
@@ -1403,6 +1415,7 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
error_message_ = error_message;
}
private:
+ Zone* zone_;
bool ignore_case_;
bool is_ascii_;
const char* error_message_;
« no previous file with comments | « src/json-parser.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698