| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 if (instr->IsAllocate()) { | 58 if (instr->IsAllocate()) { |
| 59 CollectIfNoEscapingUses(instr); | 59 CollectIfNoEscapingUses(instr); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 HCapturedObject* HEscapeAnalysisPhase::NewState(HInstruction* previous) { | 66 HCapturedObject* HEscapeAnalysisPhase::NewState(HInstruction* previous) { |
| 67 Zone* zone = graph()->zone(); | 67 Zone* zone = graph()->zone(); |
| 68 HCapturedObject* state = new(zone) HCapturedObject(number_of_values_, zone); | 68 HCapturedObject* state = |
| 69 new(zone) HCapturedObject(number_of_values_, number_of_objects_, zone); |
| 69 state->InsertAfter(previous); | 70 state->InsertAfter(previous); |
| 70 return state; | 71 return state; |
| 71 } | 72 } |
| 72 | 73 |
| 73 | 74 |
| 74 // Create a new state for replacing HAllocate instructions. | 75 // Create a new state for replacing HAllocate instructions. |
| 75 HCapturedObject* HEscapeAnalysisPhase::NewStateForAllocation( | 76 HCapturedObject* HEscapeAnalysisPhase::NewStateForAllocation( |
| 76 HInstruction* previous) { | 77 HInstruction* previous) { |
| 77 HConstant* undefined = graph()->GetConstantUndefined(); | 78 HConstant* undefined = graph()->GetConstantUndefined(); |
| 78 HCapturedObject* state = NewState(previous); | 79 HCapturedObject* state = NewState(previous); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (store->has_transition()) { | 177 if (store->has_transition()) { |
| 177 state->SetOperandAt(0, store->transition()); | 178 state->SetOperandAt(0, store->transition()); |
| 178 } | 179 } |
| 179 store->DeleteAndReplaceWith(NULL); | 180 store->DeleteAndReplaceWith(NULL); |
| 180 if (FLAG_trace_escape_analysis) { | 181 if (FLAG_trace_escape_analysis) { |
| 181 PrintF("Replacing store #%d%s\n", instr->id(), | 182 PrintF("Replacing store #%d%s\n", instr->id(), |
| 182 store->has_transition() ? " (with transition)" : ""); | 183 store->has_transition() ? " (with transition)" : ""); |
| 183 } | 184 } |
| 184 break; | 185 break; |
| 185 } | 186 } |
| 186 case HValue::kSimulate: { | |
| 187 HSimulate* simulate = HSimulate::cast(instr); | |
| 188 // TODO(mstarzinger): This doesn't track deltas for values on the | |
| 189 // operand stack yet. Find a repro test case and fix this. | |
| 190 for (int i = 0; i < simulate->OperandCount(); i++) { | |
| 191 if (simulate->OperandAt(i) != allocate) continue; | |
| 192 simulate->SetOperandAt(i, state); | |
| 193 } | |
| 194 break; | |
| 195 } | |
| 196 case HValue::kArgumentsObject: | 187 case HValue::kArgumentsObject: |
| 197 case HValue::kCapturedObject: { | 188 case HValue::kCapturedObject: |
| 189 case HValue::kSimulate: { |
| 198 for (int i = 0; i < instr->OperandCount(); i++) { | 190 for (int i = 0; i < instr->OperandCount(); i++) { |
| 199 if (instr->OperandAt(i) != allocate) continue; | 191 if (instr->OperandAt(i) != allocate) continue; |
| 200 instr->SetOperandAt(i, state); | 192 instr->SetOperandAt(i, state); |
| 201 } | 193 } |
| 202 break; | 194 break; |
| 203 } | 195 } |
| 204 case HValue::kCheckHeapObject: { | 196 case HValue::kCheckHeapObject: { |
| 205 HCheckHeapObject* check = HCheckHeapObject::cast(instr); | 197 HCheckHeapObject* check = HCheckHeapObject::cast(instr); |
| 206 if (check->value() != allocate) continue; | 198 if (check->value() != allocate) continue; |
| 207 check->DeleteAndReplaceWith(NULL); | 199 check->DeleteAndReplaceWith(NULL); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 265 |
| 274 | 266 |
| 275 void HEscapeAnalysisPhase::PerformScalarReplacement() { | 267 void HEscapeAnalysisPhase::PerformScalarReplacement() { |
| 276 for (int i = 0; i < captured_.length(); i++) { | 268 for (int i = 0; i < captured_.length(); i++) { |
| 277 HAllocate* allocate = HAllocate::cast(captured_.at(i)); | 269 HAllocate* allocate = HAllocate::cast(captured_.at(i)); |
| 278 | 270 |
| 279 // Compute number of scalar values and start with clean slate. | 271 // Compute number of scalar values and start with clean slate. |
| 280 if (!allocate->size()->IsInteger32Constant()) continue; | 272 if (!allocate->size()->IsInteger32Constant()) continue; |
| 281 int size_in_bytes = allocate->size()->GetInteger32Constant(); | 273 int size_in_bytes = allocate->size()->GetInteger32Constant(); |
| 282 number_of_values_ = size_in_bytes / kPointerSize; | 274 number_of_values_ = size_in_bytes / kPointerSize; |
| 275 number_of_objects_++; |
| 283 block_states_.Clear(); | 276 block_states_.Clear(); |
| 284 | 277 |
| 285 // Perform actual analysis steps. | 278 // Perform actual analysis steps. |
| 286 AnalyzeDataFlow(allocate); | 279 AnalyzeDataFlow(allocate); |
| 287 | 280 |
| 288 cumulative_values_ += number_of_values_; | 281 cumulative_values_ += number_of_values_; |
| 289 ASSERT(allocate->HasNoUses()); | 282 ASSERT(allocate->HasNoUses()); |
| 290 ASSERT(!allocate->IsLinked()); | 283 ASSERT(!allocate->IsLinked()); |
| 291 } | 284 } |
| 292 } | 285 } |
| 293 | 286 |
| 294 | 287 |
| 295 } } // namespace v8::internal | 288 } } // namespace v8::internal |
| OLD | NEW |