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

Side by Side Diff: src/ast.h

Issue 507051: Attempt to make \b\w+ faster. Slight performance increase on, e.g., string unpacking. (Closed)
Patch Set: Addressed review comments. Created 10 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/arm/regexp-macro-assembler-arm.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 standard_set_type_(standard_set_type) {} 1519 standard_set_type_(standard_set_type) {}
1520 explicit CharacterSet(ZoneList<CharacterRange>* ranges) 1520 explicit CharacterSet(ZoneList<CharacterRange>* ranges)
1521 : ranges_(ranges), 1521 : ranges_(ranges),
1522 standard_set_type_(0) {} 1522 standard_set_type_(0) {}
1523 ZoneList<CharacterRange>* ranges(); 1523 ZoneList<CharacterRange>* ranges();
1524 uc16 standard_set_type() { return standard_set_type_; } 1524 uc16 standard_set_type() { return standard_set_type_; }
1525 void set_standard_set_type(uc16 special_set_type) { 1525 void set_standard_set_type(uc16 special_set_type) {
1526 standard_set_type_ = special_set_type; 1526 standard_set_type_ = special_set_type;
1527 } 1527 }
1528 bool is_standard() { return standard_set_type_ != 0; } 1528 bool is_standard() { return standard_set_type_ != 0; }
1529 void Canonicalize();
1529 private: 1530 private:
1530 ZoneList<CharacterRange>* ranges_; 1531 ZoneList<CharacterRange>* ranges_;
1531 // If non-zero, the value represents a standard set (e.g., all whitespace 1532 // If non-zero, the value represents a standard set (e.g., all whitespace
1532 // characters) without having to expand the ranges. 1533 // characters) without having to expand the ranges.
1533 uc16 standard_set_type_; 1534 uc16 standard_set_type_;
1534 }; 1535 };
1535 1536
1536 1537
1537 class RegExpCharacterClass: public RegExpTree { 1538 class RegExpCharacterClass: public RegExpTree {
1538 public: 1539 public:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 }; 1613 };
1613 ZoneList<TextElement>* elements() { return &elements_; } 1614 ZoneList<TextElement>* elements() { return &elements_; }
1614 private: 1615 private:
1615 ZoneList<TextElement> elements_; 1616 ZoneList<TextElement> elements_;
1616 int length_; 1617 int length_;
1617 }; 1618 };
1618 1619
1619 1620
1620 class RegExpQuantifier: public RegExpTree { 1621 class RegExpQuantifier: public RegExpTree {
1621 public: 1622 public:
1622 RegExpQuantifier(int min, int max, bool is_greedy, RegExpTree* body) 1623 enum Type { GREEDY, NON_GREEDY, POSSESSIVE };
1623 : min_(min), 1624 RegExpQuantifier(int min, int max, Type type, RegExpTree* body)
1625 : body_(body),
1626 min_(min),
1624 max_(max), 1627 max_(max),
1625 is_greedy_(is_greedy), 1628 min_match_(min * body->min_match()),
1626 body_(body), 1629 type_(type) {
1627 min_match_(min * body->min_match()) {
1628 if (max > 0 && body->max_match() > kInfinity / max) { 1630 if (max > 0 && body->max_match() > kInfinity / max) {
1629 max_match_ = kInfinity; 1631 max_match_ = kInfinity;
1630 } else { 1632 } else {
1631 max_match_ = max * body->max_match(); 1633 max_match_ = max * body->max_match();
1632 } 1634 }
1633 } 1635 }
1634 virtual void* Accept(RegExpVisitor* visitor, void* data); 1636 virtual void* Accept(RegExpVisitor* visitor, void* data);
1635 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1637 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1636 RegExpNode* on_success); 1638 RegExpNode* on_success);
1637 static RegExpNode* ToNode(int min, 1639 static RegExpNode* ToNode(int min,
1638 int max, 1640 int max,
1639 bool is_greedy, 1641 bool is_greedy,
1640 RegExpTree* body, 1642 RegExpTree* body,
1641 RegExpCompiler* compiler, 1643 RegExpCompiler* compiler,
1642 RegExpNode* on_success, 1644 RegExpNode* on_success,
1643 bool not_at_start = false); 1645 bool not_at_start = false);
1644 virtual RegExpQuantifier* AsQuantifier(); 1646 virtual RegExpQuantifier* AsQuantifier();
1645 virtual Interval CaptureRegisters(); 1647 virtual Interval CaptureRegisters();
1646 virtual bool IsQuantifier(); 1648 virtual bool IsQuantifier();
1647 virtual int min_match() { return min_match_; } 1649 virtual int min_match() { return min_match_; }
1648 virtual int max_match() { return max_match_; } 1650 virtual int max_match() { return max_match_; }
1649 int min() { return min_; } 1651 int min() { return min_; }
1650 int max() { return max_; } 1652 int max() { return max_; }
1651 bool is_greedy() { return is_greedy_; } 1653 bool is_possessive() { return type_ == POSSESSIVE; }
1654 bool is_non_greedy() { return type_ == NON_GREEDY; }
1655 bool is_greedy() { return type_ == GREEDY; }
1652 RegExpTree* body() { return body_; } 1656 RegExpTree* body() { return body_; }
1653 private: 1657 private:
1658 RegExpTree* body_;
1654 int min_; 1659 int min_;
1655 int max_; 1660 int max_;
1656 bool is_greedy_;
1657 RegExpTree* body_;
1658 int min_match_; 1661 int min_match_;
1659 int max_match_; 1662 int max_match_;
1663 Type type_;
1660 }; 1664 };
1661 1665
1662 1666
1663 class RegExpCapture: public RegExpTree { 1667 class RegExpCapture: public RegExpTree {
1664 public: 1668 public:
1665 explicit RegExpCapture(RegExpTree* body, int index) 1669 explicit RegExpCapture(RegExpTree* body, int index)
1666 : body_(body), index_(index) { } 1670 : body_(body), index_(index) { }
1667 virtual void* Accept(RegExpVisitor* visitor, void* data); 1671 virtual void* Accept(RegExpVisitor* visitor, void* data);
1668 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1672 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1669 RegExpNode* on_success); 1673 RegExpNode* on_success);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 #undef DEF_VISIT 1796 #undef DEF_VISIT
1793 1797
1794 private: 1798 private:
1795 bool stack_overflow_; 1799 bool stack_overflow_;
1796 }; 1800 };
1797 1801
1798 1802
1799 } } // namespace v8::internal 1803 } } // namespace v8::internal
1800 1804
1801 #endif // V8_AST_H_ 1805 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm/regexp-macro-assembler-arm.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698