| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 class BitVector: public ZoneObject { | 40 class BitVector: public ZoneObject { |
| 41 public: | 41 public: |
| 42 explicit BitVector(int length) | 42 explicit BitVector(int length) |
| 43 : length_(length), | 43 : length_(length), |
| 44 data_length_(SizeFor(length)), | 44 data_length_(SizeFor(length)), |
| 45 data_(Zone::NewArray<uint32_t>(data_length_)) { | 45 data_(Zone::NewArray<uint32_t>(data_length_)) { |
| 46 ASSERT(length > 0); |
| 46 Clear(); | 47 Clear(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 BitVector(const BitVector& other) | 50 BitVector(const BitVector& other) |
| 50 : length_(other.length()), | 51 : length_(other.length()), |
| 51 data_length_(SizeFor(length_)), | 52 data_length_(SizeFor(length_)), |
| 52 data_(Zone::NewArray<uint32_t>(data_length_)) { | 53 data_(Zone::NewArray<uint32_t>(data_length_)) { |
| 53 CopyFrom(other); | 54 CopyFrom(other); |
| 54 } | 55 } |
| 55 | 56 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 AST_NODE_LIST(DECLARE_VISIT) | 479 AST_NODE_LIST(DECLARE_VISIT) |
| 479 #undef DECLARE_VISIT | 480 #undef DECLARE_VISIT |
| 480 | 481 |
| 481 // Map for tracking the live variables. | 482 // Map for tracking the live variables. |
| 482 VarUseMap live_vars_; | 483 VarUseMap live_vars_; |
| 483 | 484 |
| 484 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); | 485 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); |
| 485 }; | 486 }; |
| 486 | 487 |
| 487 | 488 |
| 488 // Computes the set of assigned variables and annotates variables proxies | |
| 489 // that are trivial sub-expressions and for-loops where the loop variable | |
| 490 // is guaranteed to be a smi. | |
| 491 class AssignedVariablesAnalyzer : public AstVisitor { | |
| 492 public: | |
| 493 explicit AssignedVariablesAnalyzer(FunctionLiteral* fun); | |
| 494 | |
| 495 void Analyze(); | |
| 496 | |
| 497 private: | |
| 498 Variable* FindSmiLoopVariable(ForStatement* stmt); | |
| 499 | |
| 500 int BitIndex(Variable* var); | |
| 501 | |
| 502 void RecordAssignedVar(Variable* var); | |
| 503 | |
| 504 void MarkIfTrivial(Expression* expr); | |
| 505 | |
| 506 // Visits an expression saving the accumulator before, clearing | |
| 507 // it before visting and restoring it after visiting. | |
| 508 void ProcessExpression(Expression* expr); | |
| 509 | |
| 510 // AST node visit functions. | |
| 511 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | |
| 512 AST_NODE_LIST(DECLARE_VISIT) | |
| 513 #undef DECLARE_VISIT | |
| 514 | |
| 515 FunctionLiteral* fun_; | |
| 516 | |
| 517 // Accumulator for assigned variables set. | |
| 518 BitVector av_; | |
| 519 | |
| 520 DISALLOW_COPY_AND_ASSIGN(AssignedVariablesAnalyzer); | |
| 521 }; | |
| 522 | |
| 523 } } // namespace v8::internal | 489 } } // namespace v8::internal |
| 524 | 490 |
| 525 | 491 |
| 526 #endif // V8_DATAFLOW_H_ | 492 #endif // V8_DATAFLOW_H_ |
| OLD | NEW |