| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 if (!first) PrintF(","); | 43 if (!first) PrintF(","); |
| 44 first = false; | 44 first = false; |
| 45 PrintF("%d", i); | 45 PrintF("%d", i); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 PrintF("}"); | 48 PrintF("}"); |
| 49 } | 49 } |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 | 52 |
| 53 bool AssignedVariablesAnalyzer::Analyze() { | 53 bool AssignedVariablesAnalyzer::Analyze(CompilationInfo* info) { |
| 54 Scope* scope = fun_->scope(); | 54 info_ = info; |
| 55 Scope* scope = info->scope(); |
| 55 int variables = scope->num_parameters() + scope->num_stack_slots(); | 56 int variables = scope->num_parameters() + scope->num_stack_slots(); |
| 56 if (variables == 0) return true; | 57 if (variables == 0) return true; |
| 57 av_.ExpandTo(variables); | 58 av_.ExpandTo(variables); |
| 58 VisitStatements(fun_->body()); | 59 VisitStatements(info->function()->body()); |
| 59 return !HasStackOverflow(); | 60 return !HasStackOverflow(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 | 63 |
| 63 Variable* AssignedVariablesAnalyzer::FindSmiLoopVariable(ForStatement* stmt) { | 64 Variable* AssignedVariablesAnalyzer::FindSmiLoopVariable(ForStatement* stmt) { |
| 64 // The loop must have all necessary parts. | 65 // The loop must have all necessary parts. |
| 65 if (stmt->init() == NULL || stmt->cond() == NULL || stmt->next() == NULL) { | 66 if (stmt->init() == NULL || stmt->cond() == NULL || stmt->next() == NULL) { |
| 66 return NULL; | 67 return NULL; |
| 67 } | 68 } |
| 68 // The initialization statement has to be a simple assignment. | 69 // The initialization statement has to be a simple assignment. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return loop_var; | 123 return loop_var; |
| 123 } | 124 } |
| 124 | 125 |
| 125 int AssignedVariablesAnalyzer::BitIndex(Variable* var) { | 126 int AssignedVariablesAnalyzer::BitIndex(Variable* var) { |
| 126 ASSERT(var != NULL); | 127 ASSERT(var != NULL); |
| 127 ASSERT(var->IsStackAllocated()); | 128 ASSERT(var->IsStackAllocated()); |
| 128 Slot* slot = var->AsSlot(); | 129 Slot* slot = var->AsSlot(); |
| 129 if (slot->type() == Slot::PARAMETER) { | 130 if (slot->type() == Slot::PARAMETER) { |
| 130 return slot->index(); | 131 return slot->index(); |
| 131 } else { | 132 } else { |
| 132 return fun_->scope()->num_parameters() + slot->index(); | 133 return info_->scope()->num_parameters() + slot->index(); |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 | 136 |
| 136 | 137 |
| 137 void AssignedVariablesAnalyzer::RecordAssignedVar(Variable* var) { | 138 void AssignedVariablesAnalyzer::RecordAssignedVar(Variable* var) { |
| 138 ASSERT(var != NULL); | 139 ASSERT(var != NULL); |
| 139 if (var->IsStackAllocated()) { | 140 if (var->IsStackAllocated()) { |
| 140 av_.Add(BitIndex(var)); | 141 av_.Add(BitIndex(var)); |
| 141 } | 142 } |
| 142 } | 143 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 ASSERT(av_.IsEmpty()); | 516 ASSERT(av_.IsEmpty()); |
| 516 } | 517 } |
| 517 | 518 |
| 518 | 519 |
| 519 void AssignedVariablesAnalyzer::VisitDeclaration(Declaration* decl) { | 520 void AssignedVariablesAnalyzer::VisitDeclaration(Declaration* decl) { |
| 520 UNREACHABLE(); | 521 UNREACHABLE(); |
| 521 } | 522 } |
| 522 | 523 |
| 523 | 524 |
| 524 } } // namespace v8::internal | 525 } } // namespace v8::internal |
| OLD | NEW |