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

Unified Diff: src/ast/ast.h

Issue 1522353002: [regexp] break recursion in mutually recursive capture/back references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: one more Created 5 years 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 | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index b4f2992e047215ac95d2c61b96a98d64afbfb5a1..eae0bda0e10adfb472385b903390a500669bf311 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -3180,24 +3180,21 @@ class RegExpLookaround final : public RegExpTree {
class RegExpBackReference final : public RegExpTree {
public:
explicit RegExpBackReference(RegExpCapture* capture)
- : capture_(capture) { }
+ : capture_(capture), max_match_(kUninitialized) {}
void* Accept(RegExpVisitor* visitor, void* data) override;
RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
RegExpBackReference* AsBackReference() override;
bool IsBackReference() override;
int min_match() override { return 0; }
- // The capture may not be completely parsed yet, if the reference occurs
- // before the capture. In the ordinary case, nothing has been captured yet,
- // so the back reference must have the length 0. If the back reference is
- // inside a lookbehind, effectively making it a forward reference, we return
- // 0 since lookbehinds have a length of 0.
- int max_match() override {
- return capture_->body() ? capture_->max_match() : 0;
- }
+ int max_match() override;
int index() { return capture_->index(); }
RegExpCapture* capture() { return capture_; }
private:
+ static const int kUninitialized = -1;
+ static const int kRecursionMarker = -2;
+
RegExpCapture* capture_;
+ int max_match_;
};
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698