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

Unified Diff: src/interpreter-irregexp.cc

Issue 151119: - Avoid allocating an overly large stack frame in the irregexp (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter-irregexp.cc
===================================================================
--- src/interpreter-irregexp.cc (revision 2313)
+++ src/interpreter-irregexp.cc (working copy)
@@ -115,17 +115,17 @@
}
-#define BYTECODE(name) \
- case BC_##name: \
- TraceInterpreter(code_base, \
- pc, \
- backtrack_sp - backtrack_stack, \
- current, \
- current_char, \
- BC_##name##_LENGTH, \
+#define BYTECODE(name) \
+ case BC_##name: \
+ TraceInterpreter(code_base, \
+ pc, \
+ backtrack_sp - backtrack_stack_base, \
+ current, \
+ current_char, \
+ BC_##name##_LENGTH, \
#name);
#else
-#define BYTECODE(name) \
+#define BYTECODE(name) \
case BC_##name:
#endif
@@ -150,9 +150,12 @@
uint32_t current_char) {
const byte* pc = code_base;
static const int kBacktrackStackSize = 10000;
- int backtrack_stack[kBacktrackStackSize];
+ // Use a SmartPointer here to ensure that the memory gets freed when the
+ // matching finishes.
+ SmartPointer<int> backtrack_stack(NewArray<int>(kBacktrackStackSize));
+ int* backtrack_stack_base = *backtrack_stack;
+ int* backtrack_sp = backtrack_stack_base;
int backtrack_stack_space = kBacktrackStackSize;
- int* backtrack_sp = backtrack_stack;
#ifdef DEBUG
if (FLAG_trace_regexp_bytecodes) {
PrintF("\n\nStart bytecode interpreter\n\n");
@@ -202,13 +205,13 @@
pc += BC_SET_CP_TO_REGISTER_LENGTH;
break;
BYTECODE(SET_REGISTER_TO_SP)
- registers[insn >> BYTECODE_SHIFT] = backtrack_sp - backtrack_stack;
+ registers[insn >> BYTECODE_SHIFT] = backtrack_sp - backtrack_stack_base;
pc += BC_SET_REGISTER_TO_SP_LENGTH;
break;
BYTECODE(SET_SP_TO_REGISTER)
- backtrack_sp = backtrack_stack + registers[insn >> BYTECODE_SHIFT];
+ backtrack_sp = backtrack_stack_base + registers[insn >> BYTECODE_SHIFT];
backtrack_stack_space = kBacktrackStackSize -
- (backtrack_sp - backtrack_stack);
+ (backtrack_sp - backtrack_stack_base);
pc += BC_SET_SP_TO_REGISTER_LENGTH;
break;
BYTECODE(POP_CP)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698