| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Visit implicit declaration of the function name. | 81 // Visit implicit declaration of the function name. |
| 82 if (scope->is_function_scope() && scope->function() != NULL) { | 82 if (scope->is_function_scope() && scope->function() != NULL) { |
| 83 VisitVariableDeclaration(scope->function()); | 83 VisitVariableDeclaration(scope->function()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Visit declarations within the function scope. | 86 // Visit declarations within the function scope. |
| 87 VisitDeclarations(scope->declarations()); | 87 VisitDeclarations(scope->declarations()); |
| 88 | 88 |
| 89 // TODO(mstarzinger): This should do an inlined stack check. | 89 // Build a stack-check before the body. |
| 90 Node* node = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0)); | 90 Node* node = BuildStackCheck(); |
| 91 PrepareFrameState(node, BailoutId::FunctionEntry()); | 91 PrepareFrameState(node, BailoutId::FunctionEntry()); |
| 92 | 92 |
| 93 // Visit statements in the function body. | 93 // Visit statements in the function body. |
| 94 VisitStatements(info()->function()->body()); | 94 VisitStatements(info()->function()->body()); |
| 95 if (HasStackOverflow()) return false; | 95 if (HasStackOverflow()) return false; |
| 96 | 96 |
| 97 // Emit tracing call if requested to do so. | 97 // Emit tracing call if requested to do so. |
| 98 if (FLAG_trace) { | 98 if (FLAG_trace) { |
| 99 // TODO(mstarzinger): Only traces implicit return. | 99 // TODO(mstarzinger): Only traces implicit return. |
| 100 Node* return_value = jsgraph()->UndefinedConstant(); | 100 Node* return_value = jsgraph()->UndefinedConstant(); |
| (...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 js_op = javascript()->Modulus(); | 2053 js_op = javascript()->Modulus(); |
| 2054 break; | 2054 break; |
| 2055 default: | 2055 default: |
| 2056 UNREACHABLE(); | 2056 UNREACHABLE(); |
| 2057 js_op = NULL; | 2057 js_op = NULL; |
| 2058 } | 2058 } |
| 2059 return NewNode(js_op, left, right); | 2059 return NewNode(js_op, left, right); |
| 2060 } | 2060 } |
| 2061 | 2061 |
| 2062 | 2062 |
| 2063 Node* AstGraphBuilder::BuildStackCheck() { |
| 2064 IfBuilder stack_check(this); |
| 2065 Node* limit = |
| 2066 NewNode(jsgraph()->machine()->Load(kMachPtr), |
| 2067 jsgraph()->ExternalConstant( |
| 2068 ExternalReference::address_of_stack_limit(isolate())), |
| 2069 jsgraph()->ZeroConstant()); |
| 2070 Node* stack = NewNode(jsgraph()->machine()->LoadStackPointer()); |
| 2071 Node* tag = NewNode(jsgraph()->machine()->UintLessThan(), limit, stack); |
| 2072 stack_check.If(tag); |
| 2073 stack_check.Then(); |
| 2074 stack_check.Else(); |
| 2075 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0)); |
| 2076 stack_check.End(); |
| 2077 return guard; |
| 2078 } |
| 2079 |
| 2080 |
| 2063 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, | 2081 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, |
| 2064 OutputFrameStateCombine combine) { | 2082 OutputFrameStateCombine combine) { |
| 2065 if (OperatorProperties::HasFrameStateInput(node->op())) { | 2083 if (OperatorProperties::HasFrameStateInput(node->op())) { |
| 2066 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == | 2084 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == |
| 2067 IrOpcode::kDead); | 2085 IrOpcode::kDead); |
| 2068 NodeProperties::ReplaceFrameStateInput( | 2086 NodeProperties::ReplaceFrameStateInput( |
| 2069 node, environment()->Checkpoint(ast_id, combine)); | 2087 node, environment()->Checkpoint(ast_id, combine)); |
| 2070 } | 2088 } |
| 2071 } | 2089 } |
| 2072 | 2090 |
| 2073 } | 2091 } |
| 2074 } | 2092 } |
| 2075 } // namespace v8::internal::compiler | 2093 } // namespace v8::internal::compiler |
| OLD | NEW |