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

Unified Diff: runtime/vm/code_generator_x64.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_x64.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_x64.cc
===================================================================
--- runtime/vm/code_generator_x64.cc (revision 4847)
+++ runtime/vm/code_generator_x64.cc (working copy)
@@ -1797,6 +1797,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.
+ __ movq(TMP, Immediate(Isolate::Current()->stack_limit_address()));
+ __ cmpq(RSP, Address(TMP, 0));
+ Label no_stack_overflow;
+ __ j(ABOVE, &no_stack_overflow);
+ GenerateCallRuntime(AstNode::kNoId,
+ 0,
regis 2012/03/02 01:49:17 Why do you pass kNoId and 0 instead of loop_id and
srdjan 2012/03/02 17:40:00 My mistake, you have done it right. Fixed.
+ kStackOverflowRuntimeEntry);
+ __ Bind(&no_stack_overflow);
+}
+
+
void CodeGenerator::VisitWhileNode(WhileNode* node) {
const Bool& bool_true = Bool::ZoneHandle(Bool::True());
SourceLabel* label = node->label();
@@ -1808,6 +1823,7 @@
__ cmpq(RAX, RDX);
__ j(NOT_EQUAL, label->break_label());
node->body()->Visit(this);
+ HandleBackwardBranch(node->id(), node->token_index());
__ jmp(label->continue_label());
__ Bind(label->break_label());
}
@@ -1819,6 +1835,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());
@@ -1845,6 +1862,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_x64.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698