| 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 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 Node* MergeValue(Node* value, Node* other, Node* control); | 187 Node* MergeValue(Node* value, Node* other, Node* control); |
| 188 | 188 |
| 189 // The main node creation chokepoint. Adds context, frame state, effect, | 189 // The main node creation chokepoint. Adds context, frame state, effect, |
| 190 // and control dependencies depending on the operator. | 190 // and control dependencies depending on the operator. |
| 191 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, | 191 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, |
| 192 bool incomplete); | 192 bool incomplete); |
| 193 | 193 |
| 194 // Helper to indicate a node exits the function body. | 194 // Helper to indicate a node exits the function body. |
| 195 void UpdateControlDependencyToLeaveFunction(Node* exit); | 195 void UpdateControlDependencyToLeaveFunction(Node* exit); |
| 196 | 196 |
| 197 // | 197 // Builds deoptimization for a given node. |
| 198 void PrepareFrameState( |
| 199 Node* node, BailoutId ast_id, |
| 200 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()); |
| 201 void PrepareFrameStateAfterAndBefore(Node* node, BailoutId ast_id, |
| 202 OutputFrameStateCombine combine, |
| 203 Node* frame_state_before); |
| 204 |
| 205 BitVector* GetVariablesAssignedInLoop(IterationStatement* stmt); |
| 206 |
| 207 // Check if the given statement is an OSR entry. |
| 208 // If so, record the stack height into the compilation and return {true}. |
| 209 bool CheckOsrEntry(IterationStatement* stmt); |
| 210 |
| 211 // Helper to wrap a Handle<T> into a Unique<T>. |
| 212 template <class T> |
| 213 Unique<T> MakeUnique(Handle<T> object) { |
| 214 return Unique<T>::CreateUninitialized(object); |
| 215 } |
| 216 |
| 217 Node** EnsureInputBufferSize(int size); |
| 218 |
| 219 // Named and keyed loads require a VectorSlotPair for successful lowering. |
| 220 VectorSlotPair CreateVectorSlotPair(FeedbackVectorICSlot slot) const; |
| 221 |
| 222 // =========================================================================== |
| 198 // The following build methods all generate graph fragments and return one | 223 // The following build methods all generate graph fragments and return one |
| 199 // resulting node. The operand stack height remains the same, variables and | 224 // resulting node. The operand stack height remains the same, variables and |
| 200 // other dependencies tracked by the environment might be mutated though. | 225 // other dependencies tracked by the environment might be mutated though. |
| 201 // | |
| 202 | 226 |
| 203 // Builder to create a receiver check for sloppy mode. | 227 // Builder to create a receiver check for sloppy mode. |
| 204 Node* BuildPatchReceiverToGlobalProxy(Node* receiver); | 228 Node* BuildPatchReceiverToGlobalProxy(Node* receiver); |
| 205 | 229 |
| 206 // Builders to create local function and block contexts. | 230 // Builders to create local function and block contexts. |
| 207 Node* BuildLocalFunctionContext(Node* context, Node* closure); | 231 Node* BuildLocalFunctionContext(Node* context, Node* closure); |
| 208 Node* BuildLocalBlockContext(Scope* scope); | 232 Node* BuildLocalBlockContext(Scope* scope); |
| 209 | 233 |
| 210 // Builder to create an arguments object if it is used. | 234 // Builder to create an arguments object if it is used. |
| 211 Node* BuildArgumentsObject(Variable* arguments); | 235 Node* BuildArgumentsObject(Variable* arguments); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // Builders for conditional errors. | 289 // Builders for conditional errors. |
| 266 Node* BuildThrowIfStaticPrototype(Node* name, BailoutId bailout_id); | 290 Node* BuildThrowIfStaticPrototype(Node* name, BailoutId bailout_id); |
| 267 | 291 |
| 268 // Builders for non-local control flow. | 292 // Builders for non-local control flow. |
| 269 Node* BuildReturn(Node* return_value); | 293 Node* BuildReturn(Node* return_value); |
| 270 Node* BuildThrow(Node* exception_value); | 294 Node* BuildThrow(Node* exception_value); |
| 271 | 295 |
| 272 // Builders for binary operations. | 296 // Builders for binary operations. |
| 273 Node* BuildBinaryOp(Node* left, Node* right, Token::Value op); | 297 Node* BuildBinaryOp(Node* left, Node* right, Token::Value op); |
| 274 | 298 |
| 275 // Check if the given statement is an OSR entry. | |
| 276 // If so, record the stack height into the compilation and return {true}. | |
| 277 bool CheckOsrEntry(IterationStatement* stmt); | |
| 278 | |
| 279 // Helper to wrap a Handle<T> into a Unique<T>. | |
| 280 template <class T> | |
| 281 Unique<T> MakeUnique(Handle<T> object) { | |
| 282 return Unique<T>::CreateUninitialized(object); | |
| 283 } | |
| 284 | |
| 285 Node** EnsureInputBufferSize(int size); | |
| 286 | |
| 287 // Named and keyed loads require a VectorSlotPair for successful lowering. | |
| 288 VectorSlotPair CreateVectorSlotPair(FeedbackVectorICSlot slot) const; | |
| 289 | |
| 290 // Process arguments to a call by popping {arity} elements off the operand | 299 // Process arguments to a call by popping {arity} elements off the operand |
| 291 // stack and build a call node using the given call operator. | 300 // stack and build a call node using the given call operator. |
| 292 Node* ProcessArguments(const Operator* op, int arity); | 301 Node* ProcessArguments(const Operator* op, int arity); |
| 293 | 302 |
| 303 // =========================================================================== |
| 304 // The following visitation methods all recursively visit a subtree of the |
| 305 // underlying AST and extent the graph. The operand stack is mutated in a way |
| 306 // consistent with other compilers: |
| 307 // - Expressions pop operands and push result, depending on {AstContext}. |
| 308 // - Statements keep the operand stack balanced. |
| 309 |
| 294 // Visit statements. | 310 // Visit statements. |
| 295 void VisitIfNotNull(Statement* stmt); | 311 void VisitIfNotNull(Statement* stmt); |
| 296 | 312 |
| 297 // Visit expressions. | 313 // Visit expressions. |
| 298 void Visit(Expression* expr); | 314 void Visit(Expression* expr); |
| 299 void VisitForTest(Expression* expr); | 315 void VisitForTest(Expression* expr); |
| 300 void VisitForEffect(Expression* expr); | 316 void VisitForEffect(Expression* expr); |
| 301 void VisitForValue(Expression* expr); | 317 void VisitForValue(Expression* expr); |
| 302 void VisitForValueOrNull(Expression* expr); | 318 void VisitForValueOrNull(Expression* expr); |
| 303 void VisitForValueOrTheHole(Expression* expr); | 319 void VisitForValueOrTheHole(Expression* expr); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 321 void VisitArithmeticExpression(BinaryOperation* expr); | 337 void VisitArithmeticExpression(BinaryOperation* expr); |
| 322 | 338 |
| 323 // Dispatched from VisitForInStatement. | 339 // Dispatched from VisitForInStatement. |
| 324 void VisitForInAssignment(Expression* expr, Node* value, | 340 void VisitForInAssignment(Expression* expr, Node* value, |
| 325 BailoutId bailout_id); | 341 BailoutId bailout_id); |
| 326 void VisitForInBody(ForInStatement* stmt); | 342 void VisitForInBody(ForInStatement* stmt); |
| 327 | 343 |
| 328 // Dispatched from VisitClassLiteral. | 344 // Dispatched from VisitClassLiteral. |
| 329 void VisitClassLiteralContents(ClassLiteral* expr); | 345 void VisitClassLiteralContents(ClassLiteral* expr); |
| 330 | 346 |
| 331 // Builds deoptimization for a given node. | |
| 332 void PrepareFrameState( | |
| 333 Node* node, BailoutId ast_id, | |
| 334 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()); | |
| 335 void PrepareFrameStateAfterAndBefore(Node* node, BailoutId ast_id, | |
| 336 OutputFrameStateCombine combine, | |
| 337 Node* frame_state_before); | |
| 338 | |
| 339 BitVector* GetVariablesAssignedInLoop(IterationStatement* stmt); | |
| 340 | |
| 341 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 347 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 342 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); | 348 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); |
| 343 }; | 349 }; |
| 344 | 350 |
| 345 | 351 |
| 346 // The abstract execution environment for generated code consists of | 352 // The abstract execution environment for generated code consists of |
| 347 // parameter variables, local variables and the operand stack. The | 353 // parameter variables, local variables and the operand stack. The |
| 348 // environment will perform proper SSA-renaming of all tracked nodes | 354 // environment will perform proper SSA-renaming of all tracked nodes |
| 349 // at split and merge points in the control flow. Internally all the | 355 // at split and merge points in the control flow. Internally all the |
| 350 // values are stored in one list using the following layout: | 356 // values are stored in one list using the following layout: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 499 |
| 494 // Prepare environment to be used as loop header. | 500 // Prepare environment to be used as loop header. |
| 495 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 501 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
| 496 }; | 502 }; |
| 497 | 503 |
| 498 } // namespace compiler | 504 } // namespace compiler |
| 499 } // namespace internal | 505 } // namespace internal |
| 500 } // namespace v8 | 506 } // namespace v8 |
| 501 | 507 |
| 502 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 508 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |