| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 AST_NODE_LIST(DECLARE_VISIT) | 479 AST_NODE_LIST(DECLARE_VISIT) |
| 480 #undef DECLARE_VISIT | 480 #undef DECLARE_VISIT |
| 481 | 481 |
| 482 // Map for tracking the live variables. | 482 // Map for tracking the live variables. |
| 483 VarUseMap live_vars_; | 483 VarUseMap live_vars_; |
| 484 | 484 |
| 485 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); | 485 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 | 488 |
| 489 // Computes the set of assigned variables and annotates variables proxies |
| 490 // that are trivial sub-expressions and for-loops where the loop variable |
| 491 // is guaranteed to be a smi. |
| 492 class AssignedVariablesAnalyzer : public AstVisitor { |
| 493 public: |
| 494 explicit AssignedVariablesAnalyzer(FunctionLiteral* fun); |
| 495 |
| 496 void Analyze(); |
| 497 |
| 498 private: |
| 499 Variable* FindSmiLoopVariable(ForStatement* stmt); |
| 500 |
| 501 int BitIndex(Variable* var); |
| 502 |
| 503 void RecordAssignedVar(Variable* var); |
| 504 |
| 505 void MarkIfTrivial(Expression* expr); |
| 506 |
| 507 // Visits an expression saving the accumulator before, clearing |
| 508 // it before visting and restoring it after visiting. |
| 509 void ProcessExpression(Expression* expr); |
| 510 |
| 511 // AST node visit functions. |
| 512 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 513 AST_NODE_LIST(DECLARE_VISIT) |
| 514 #undef DECLARE_VISIT |
| 515 |
| 516 FunctionLiteral* fun_; |
| 517 |
| 518 // Accumulator for assigned variables set. |
| 519 BitVector av_; |
| 520 |
| 521 DISALLOW_COPY_AND_ASSIGN(AssignedVariablesAnalyzer); |
| 522 }; |
| 523 |
| 489 } } // namespace v8::internal | 524 } } // namespace v8::internal |
| 490 | 525 |
| 491 | 526 |
| 492 #endif // V8_DATAFLOW_H_ | 527 #endif // V8_DATAFLOW_H_ |
| OLD | NEW |