| 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 #include "src/compiler/liveness-analyzer.h" | 10 #include "src/compiler/liveness-analyzer.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 // The main node creation chokepoint. Adds context, frame state, effect, | 202 // The main node creation chokepoint. Adds context, frame state, effect, |
| 203 // and control dependencies depending on the operator. | 203 // and control dependencies depending on the operator. |
| 204 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, | 204 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, |
| 205 bool incomplete); | 205 bool incomplete); |
| 206 | 206 |
| 207 // Helper to indicate a node exits the function body. | 207 // Helper to indicate a node exits the function body. |
| 208 void UpdateControlDependencyToLeaveFunction(Node* exit); | 208 void UpdateControlDependencyToLeaveFunction(Node* exit); |
| 209 | 209 |
| 210 // Builds deoptimization for a given node. | 210 // Builds deoptimization for a given node. |
| 211 void PrepareFrameState( | 211 void PrepareFrameState(Node* node, BailoutId ast_id, |
| 212 Node* node, BailoutId ast_id, | 212 OutputFrameStateCombine framestate_combine = |
| 213 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()); | 213 OutputFrameStateCombine::Ignore()); |
| 214 | 214 |
| 215 BitVector* GetVariablesAssignedInLoop(IterationStatement* stmt); | 215 BitVector* GetVariablesAssignedInLoop(IterationStatement* stmt); |
| 216 | 216 |
| 217 // Check if the given statement is an OSR entry. | 217 // Check if the given statement is an OSR entry. |
| 218 // If so, record the stack height into the compilation and return {true}. | 218 // If so, record the stack height into the compilation and return {true}. |
| 219 bool CheckOsrEntry(IterationStatement* stmt); | 219 bool CheckOsrEntry(IterationStatement* stmt); |
| 220 | 220 |
| 221 // Computes local variable liveness and replaces dead variables in | 221 // Computes local variable liveness and replaces dead variables in |
| 222 // frame states with the undefined values. | 222 // frame states with the undefined values. |
| 223 void ClearNonLiveSlotsInFrameStates(); | 223 void ClearNonLiveSlotsInFrameStates(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 246 Node* BuildLocalScriptContext(Scope* scope); | 246 Node* BuildLocalScriptContext(Scope* scope); |
| 247 Node* BuildLocalBlockContext(Scope* scope); | 247 Node* BuildLocalBlockContext(Scope* scope); |
| 248 | 248 |
| 249 // Builder to create an arguments object if it is used. | 249 // Builder to create an arguments object if it is used. |
| 250 Node* BuildArgumentsObject(Variable* arguments); | 250 Node* BuildArgumentsObject(Variable* arguments); |
| 251 | 251 |
| 252 // Builder to create an array of rest parameters if used | 252 // Builder to create an array of rest parameters if used |
| 253 Node* BuildRestArgumentsArray(Variable* rest, int index); | 253 Node* BuildRestArgumentsArray(Variable* rest, int index); |
| 254 | 254 |
| 255 // Builders for variable load and assignment. | 255 // Builders for variable load and assignment. |
| 256 Node* BuildVariableAssignment( | 256 Node* BuildVariableAssignment(Variable* var, Node* value, Token::Value op, |
| 257 FrameStateBeforeAndAfter& states, Variable* var, Node* value, | 257 BailoutId bailout_id, |
| 258 Token::Value op, BailoutId bailout_id, | 258 FrameStateBeforeAndAfter& states, |
| 259 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()); | 259 OutputFrameStateCombine framestate_combine = |
| 260 OutputFrameStateCombine::Ignore()); |
| 260 Node* BuildVariableDelete(Variable* var, BailoutId bailout_id, | 261 Node* BuildVariableDelete(Variable* var, BailoutId bailout_id, |
| 261 OutputFrameStateCombine combine); | 262 OutputFrameStateCombine framestate_combine); |
| 262 Node* BuildVariableLoad(FrameStateBeforeAndAfter& states, Variable* var, | 263 Node* BuildVariableLoad(Variable* var, BailoutId bailout_id, |
| 263 BailoutId bailout_id, const VectorSlotPair& feedback, | 264 FrameStateBeforeAndAfter& states, |
| 264 OutputFrameStateCombine combine, | 265 const VectorSlotPair& feedback, |
| 266 OutputFrameStateCombine framestate_combine, |
| 265 ContextualMode mode = CONTEXTUAL); | 267 ContextualMode mode = CONTEXTUAL); |
| 266 | 268 |
| 269 // Builders for variables using the global object. |
| 270 Node* BuildGlobalVariableLoad(Variable* var, BailoutId bailout_id, |
| 271 FrameStateBeforeAndAfter& states, |
| 272 const VectorSlotPair& feedback, |
| 273 OutputFrameStateCombine framestate_combine, |
| 274 ContextualMode contextual_mode); |
| 275 |
| 276 // Builders for variables using dynamic lookup. |
| 277 Node* BuildDynamicVariableLoad(Variable* var, BailoutId bailout_id, |
| 278 ContextualMode contextual_mode); |
| 279 |
| 267 // Builders for property loads and stores. | 280 // Builders for property loads and stores. |
| 268 Node* BuildKeyedLoad(Node* receiver, Node* key, | 281 Node* BuildKeyedLoad(Node* receiver, Node* key, |
| 269 const VectorSlotPair& feedback); | 282 const VectorSlotPair& feedback); |
| 270 Node* BuildNamedLoad(Node* receiver, Handle<Name> name, | 283 Node* BuildNamedLoad(Node* receiver, Handle<Name> name, |
| 271 const VectorSlotPair& feedback, | 284 const VectorSlotPair& feedback, |
| 272 ContextualMode mode = NOT_CONTEXTUAL); | 285 ContextualMode mode = NOT_CONTEXTUAL); |
| 273 Node* BuildKeyedStore(Node* receiver, Node* key, Node* value, | 286 Node* BuildKeyedStore(Node* receiver, Node* key, Node* value, |
| 274 TypeFeedbackId id); | 287 TypeFeedbackId id); |
| 275 Node* BuildNamedStore(Node* receiver, Handle<Name>, Node* value, | 288 Node* BuildNamedStore(Node* receiver, Handle<Name>, Node* value, |
| 276 TypeFeedbackId id); | 289 TypeFeedbackId id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 Node* BuildThrow(Node* exception_value); | 326 Node* BuildThrow(Node* exception_value); |
| 314 | 327 |
| 315 // Builders for binary operations. | 328 // Builders for binary operations. |
| 316 Node* BuildBinaryOp(Node* left, Node* right, Token::Value op); | 329 Node* BuildBinaryOp(Node* left, Node* right, Token::Value op); |
| 317 | 330 |
| 318 // Process arguments to a call by popping {arity} elements off the operand | 331 // Process arguments to a call by popping {arity} elements off the operand |
| 319 // stack and build a call node using the given call operator. | 332 // stack and build a call node using the given call operator. |
| 320 Node* ProcessArguments(const Operator* op, int arity); | 333 Node* ProcessArguments(const Operator* op, int arity); |
| 321 | 334 |
| 322 // =========================================================================== | 335 // =========================================================================== |
| 336 // The following build methods have the same contract as the above ones, but |
| 337 // they can also return {NULL} to indicate that no fragment was built. Note |
| 338 // that these are optimizations, disabling any of them should still produce |
| 339 // correct graphs. |
| 340 |
| 341 // Optimizers for variable load and assignment requiring dynamic lookup. |
| 342 Node* TryDynamicGlobalVariableLoad(Variable* variable, BailoutId bailout_id, |
| 343 FrameStateBeforeAndAfter& states, |
| 344 const VectorSlotPair& feedback, |
| 345 OutputFrameStateCombine framestate_combine, |
| 346 ContextualMode contextual_mode); |
| 347 |
| 348 // =========================================================================== |
| 323 // The following visitation methods all recursively visit a subtree of the | 349 // The following visitation methods all recursively visit a subtree of the |
| 324 // underlying AST and extent the graph. The operand stack is mutated in a way | 350 // underlying AST and extent the graph. The operand stack is mutated in a way |
| 325 // consistent with other compilers: | 351 // consistent with other compilers: |
| 326 // - Expressions pop operands and push result, depending on {AstContext}. | 352 // - Expressions pop operands and push result, depending on {AstContext}. |
| 327 // - Statements keep the operand stack balanced. | 353 // - Statements keep the operand stack balanced. |
| 328 | 354 |
| 329 // Visit statements. | 355 // Visit statements. |
| 330 void VisitIfNotNull(Statement* stmt); | 356 void VisitIfNotNull(Statement* stmt); |
| 331 | 357 |
| 332 // Visit expressions. | 358 // Visit expressions. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 531 |
| 506 // Prepare environment to be used as loop header. | 532 // Prepare environment to be used as loop header. |
| 507 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 533 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
| 508 }; | 534 }; |
| 509 | 535 |
| 510 } // namespace compiler | 536 } // namespace compiler |
| 511 } // namespace internal | 537 } // namespace internal |
| 512 } // namespace v8 | 538 } // namespace v8 |
| 513 | 539 |
| 514 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 540 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |