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

Unified Diff: src/jsregexp.cc

Issue 17416: * Move irregexp backtrack stack to external memory area, instead of the system stack. (Closed)
Patch Set: Added explicit stack check requests to push operations. Created 11 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 side-by-side diff with in-line comments
Download patch
Index: src/jsregexp.cc
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index e072d0de4205e9af92f7ba7e10894a9742039cf6..768872afcce99cf49f35a645f0c764188f1c42b5 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -40,6 +40,7 @@
#include "regexp-macro-assembler.h"
#include "regexp-macro-assembler-tracer.h"
#include "regexp-macro-assembler-irregexp.h"
+#include "regexp-stack.h"
#ifdef ARM
#include "regexp-macro-assembler-arm.h"
@@ -913,7 +914,7 @@ Handle<Object> RegExpImpl::IrregexpExecOnce(Handle<FixedArray> irregexp,
}
res = RegExpMacroAssemblerIA32::Execute(
*code,
- &address,
+ const_cast<Address*>(&address),
start_offset << char_size_shift,
end_offset << char_size_shift,
offsets_vector,
@@ -925,7 +926,7 @@ Handle<Object> RegExpImpl::IrregexpExecOnce(Handle<FixedArray> irregexp,
int byte_offset = char_address - reinterpret_cast<Address>(*subject);
res = RegExpMacroAssemblerIA32::Execute(
*code,
- subject.location(),
+ reinterpret_cast<Address*>(subject.location()),
byte_offset + (start_offset << char_size_shift),
byte_offset + (end_offset << char_size_shift),
offsets_vector,
@@ -1271,7 +1272,8 @@ Handle<FixedArray> RegExpCompiler::Assemble(
List <RegExpNode*> work_list(0);
work_list_ = &work_list;
Label fail;
- macro_assembler->PushBacktrack(&fail);
+ macro_assembler->PushBacktrack(&fail,
+ RegExpMacroAssembler::kNoStackLimitCheck);
GenerationVariant generic_variant;
if (!start->Emit(this, &generic_variant)) {
fail.Unuse();
@@ -1347,8 +1349,17 @@ int GenerationVariant::FindAffectedRegisters(OutSet* affected_registers) {
void GenerationVariant::PushAffectedRegisters(RegExpMacroAssembler* assembler,
int max_register,
OutSet& affected_registers) {
- for (int reg = 0; reg <= max_register; reg++) {
- if (affected_registers.Get(reg)) assembler->PushRegister(reg);
+ // Stay safe and check every half times the limit.
+ int push_limit = (assembler->stack_limit() + 1) / 2;
Erik Corry 2009/01/12 11:50:13 Why plus 1?
Lasse Reichstein 2009/01/12 13:03:59 Rounding up in case the value is one (which it hap
+ for (int reg = 0, pushes = 0; reg <= max_register; reg++) {
+ if (affected_registers.Get(reg)) {
+ pushes++;
+ RegExpMacroAssembler::StackCheckFlag check_stack_limit =
+ (pushes % push_limit) == 0 ?
+ RegExpMacroAssembler::kCheckStackLimit :
+ RegExpMacroAssembler::kNoStackLimitCheck;
+ assembler->PushRegister(reg, check_stack_limit);
+ }
}
}
@@ -1457,7 +1468,7 @@ bool GenerationVariant::Flush(RegExpCompiler* compiler, RegExpNode* successor) {
// Here we have a concrete backtrack location. These are set up by choice
// nodes and so they indicate that we have a deferred save of the current
// position which we may need to emit here.
- assembler->PushCurrentPosition();
+ assembler->PushCurrentPosition(RegExpMacroAssembler::kNoStackLimitCheck);
Erik Corry 2009/01/12 11:50:13 We never emit this with stack limit check so the e
Lasse Reichstein 2009/01/12 13:03:59 What's wrong with needless generality now?!? Ok, r
}
if (cp_offset_ != 0) {
assembler->AdvanceCurrentPosition(cp_offset_);
@@ -1465,7 +1476,7 @@ bool GenerationVariant::Flush(RegExpCompiler* compiler, RegExpNode* successor) {
// Create a new trivial state and generate the node with that.
Label undo;
- assembler->PushBacktrack(&undo);
+ assembler->PushBacktrack(&undo, RegExpMacroAssembler::kCheckStackLimit);
Erik Corry 2009/01/12 11:50:13 We should always emit this with stack limit check
Lasse Reichstein 2009/01/12 13:03:59 Removed too
GenerationVariant new_state;
bool ok = successor->Emit(compiler, &new_state);
@@ -2798,7 +2809,8 @@ bool ChoiceNode::Emit(RegExpCompiler* compiler, GenerationVariant* variant) {
// space.
greedy_loop = true;
ASSERT(variant->stop_node() == NULL);
- macro_assembler->PushCurrentPosition();
+ macro_assembler->PushCurrentPosition(
+ RegExpMacroAssembler::kCheckStackLimit);
Erik Corry 2009/01/12 11:50:13 We don't need to check here. Greedy loops cannot
Lasse Reichstein 2009/01/12 13:03:59 PushCurrentPosition never checks now. We shouldn'
current_variant = &counter_backtrack_variant;
Label greedy_match_failed;
GenerationVariant greedy_match_variant;
« no previous file with comments | « src/assembler.cc ('k') | src/regexp-macro-assembler.h » ('j') | src/regexp-macro-assembler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698