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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 621833003: Implement inlined stack-check guards in TurboFan. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « src/compiler/ast-graph-builder.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index d33b05ac18fcd74b2ffe485b6bdc120659e18e95..570a220e7ddeeff428646d720de48afce7774623 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -86,8 +86,8 @@ bool AstGraphBuilder::CreateGraph() {
// Visit declarations within the function scope.
VisitDeclarations(scope->declarations());
- // TODO(mstarzinger): This should do an inlined stack check.
- Node* node = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0));
+ // Build a stack-check before the body.
+ Node* node = BuildStackCheck();
PrepareFrameState(node, BailoutId::FunctionEntry());
// Visit statements in the function body.
@@ -2060,6 +2060,24 @@ Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
}
+Node* AstGraphBuilder::BuildStackCheck() {
+ IfBuilder stack_check(this);
+ Node* limit =
+ NewNode(jsgraph()->machine()->Load(kMachPtr),
+ jsgraph()->ExternalConstant(
+ ExternalReference::address_of_stack_limit(isolate())),
+ jsgraph()->ZeroConstant());
+ Node* stack = NewNode(jsgraph()->machine()->LoadStackPointer());
+ Node* tag = NewNode(jsgraph()->machine()->UintLessThan(), limit, stack);
+ stack_check.If(tag);
+ stack_check.Then();
+ stack_check.Else();
+ Node* guard = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0));
+ stack_check.End();
+ return guard;
+}
+
+
void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id,
OutputFrameStateCombine combine) {
if (OperatorProperties::HasFrameStateInput(node->op())) {
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698