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 22 matching lines...) Expand all Loading... |
33 #include "ast.h" | 33 #include "ast.h" |
34 #include "compiler.h" | 34 #include "compiler.h" |
35 | 35 |
36 namespace v8 { | 36 namespace v8 { |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 class BitVector BASE_EMBEDDED { | 39 class BitVector BASE_EMBEDDED { |
40 public: | 40 public: |
41 explicit BitVector(int length) | 41 explicit BitVector(int length) |
42 : length_(length), bits_(Vector<uint32_t>::New(1 + length / 32)) { | 42 : length_(length), bits_(Vector<uint32_t>::New(1 + length / 32)) { |
43 ASSERT(length > 0); | |
44 for (int i = 0; i < bits_.length(); i++) { | 43 for (int i = 0; i < bits_.length(); i++) { |
45 bits_[i] = 0; | 44 bits_[i] = 0; |
46 } | 45 } |
47 } | 46 } |
48 | 47 |
49 BitVector(const BitVector& other) | 48 BitVector(const BitVector& other) |
50 : length_(other.length()), | 49 : length_(other.length()), |
51 bits_(Vector<uint32_t>::New(1 + other.length() / 32)) { | 50 bits_(Vector<uint32_t>::New(1 + other.length() / 32)) { |
52 CopyFrom(other); | 51 CopyFrom(other); |
53 } | 52 } |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 AST_NODE_LIST(DECLARE_VISIT) | 489 AST_NODE_LIST(DECLARE_VISIT) |
491 #undef DECLARE_VISIT | 490 #undef DECLARE_VISIT |
492 | 491 |
493 // Map for tracking the live variables. | 492 // Map for tracking the live variables. |
494 VarUseMap live_vars_; | 493 VarUseMap live_vars_; |
495 | 494 |
496 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); | 495 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); |
497 }; | 496 }; |
498 | 497 |
499 | 498 |
| 499 // Computes the set of assigned variables and annotates variables proxies |
| 500 // that are trivial sub-expressions and for-loops where the loop variable |
| 501 // is guaranteed to be a smi. |
| 502 class AssignedVariablesAnalyzer : public AstVisitor { |
| 503 public: |
| 504 explicit AssignedVariablesAnalyzer(FunctionLiteral* fun); |
| 505 |
| 506 void Analyze(); |
| 507 |
| 508 private: |
| 509 Variable* FindSmiLoopVariable(ForStatement* stmt); |
| 510 |
| 511 int BitIndex(Variable* var); |
| 512 |
| 513 void RecordAssignedVar(Variable* var); |
| 514 |
| 515 void MarkIfTrivial(Expression* expr); |
| 516 |
| 517 // Visits an expression saving the accumulator before, clearing |
| 518 // it before visting and restoring it after visiting. |
| 519 void ProcessExpression(Expression* expr); |
| 520 |
| 521 // AST node visit functions. |
| 522 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 523 AST_NODE_LIST(DECLARE_VISIT) |
| 524 #undef DECLARE_VISIT |
| 525 |
| 526 FunctionLiteral* fun_; |
| 527 |
| 528 // Accumulator for assigned variables set. |
| 529 BitVector av_; |
| 530 |
| 531 DISALLOW_COPY_AND_ASSIGN(AssignedVariablesAnalyzer); |
| 532 }; |
| 533 |
500 } } // namespace v8::internal | 534 } } // namespace v8::internal |
501 | 535 |
502 | 536 |
503 #endif // V8_DATAFLOW_H_ | 537 #endif // V8_DATAFLOW_H_ |
OLD | NEW |