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

Unified Diff: runtime/vm/code_generator_ia32.cc

Issue 9562045: Added stack overflow checks at backward branches in order to allow interrupting endless loops. Bett… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 | « runtime/vm/code_generator_ia32.h ('k') | runtime/vm/code_generator_x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_ia32.cc
===================================================================
--- runtime/vm/code_generator_ia32.cc (revision 4887)
+++ runtime/vm/code_generator_ia32.cc (working copy)
@@ -1809,6 +1809,21 @@
}
+void CodeGenerator::HandleBackwardBranch(
+ intptr_t loop_id, intptr_t token_index) {
+ // Use stack overflow check to eventually stop execution of loops.
+ // This is necessary only if a loop does not have calls.
+ __ cmpl(ESP,
+ Address::Absolute(Isolate::Current()->stack_limit_address()));
+ Label no_stack_overflow;
+ __ j(ABOVE, &no_stack_overflow);
+ GenerateCallRuntime(loop_id,
+ token_index,
+ kStackOverflowRuntimeEntry);
+ __ Bind(&no_stack_overflow);
+}
+
+
void CodeGenerator::VisitWhileNode(WhileNode* node) {
const Bool& bool_true = Bool::ZoneHandle(Bool::True());
SourceLabel* label = node->label();
@@ -1820,6 +1835,7 @@
__ cmpl(EAX, EDX);
__ j(NOT_EQUAL, label->break_label());
node->body()->Visit(this);
+ HandleBackwardBranch(node->id(), node->token_index());
__ jmp(label->continue_label());
__ Bind(label->break_label());
}
@@ -1831,6 +1847,7 @@
Label loop;
__ Bind(&loop);
node->body()->Visit(this);
+ HandleBackwardBranch(node->id(), node->token_index());
__ Bind(label->continue_label());
node->condition()->Visit(this);
GenerateConditionTypeCheck(node->id(), node->condition()->token_index());
@@ -1857,6 +1874,7 @@
__ j(NOT_EQUAL, label->break_label());
}
node->body()->Visit(this);
+ HandleBackwardBranch(node->id(), node->token_index());
__ Bind(label->continue_label());
node->increment()->Visit(this);
__ jmp(&loop);
« no previous file with comments | « runtime/vm/code_generator_ia32.h ('k') | runtime/vm/code_generator_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698