| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_allocator.h" | 5 #include "vm/flow_graph_allocator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 const bool use_at_end = (j > 0) || (in_ref == NULL) || | 463 const bool use_at_end = (j > 0) || (in_ref == NULL) || |
| 464 !output_same_as_first_input; | 464 !output_same_as_first_input; |
| 465 UseValue(current, block->start_pos(), pos, use, in_ref, use_at_end); | 465 UseValue(current, block->start_pos(), pos, use, in_ref, use_at_end); |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 // Add uses from the deoptimization environment. | 469 // Add uses from the deoptimization environment. |
| 470 // TODO(vegorov): these uses should _not_ require register but for now | 470 // TODO(vegorov): these uses should _not_ require register but for now |
| 471 // they do because we don't support spilling at all. | 471 // they do because we don't support spilling at all. |
| 472 if (current->env() != NULL) { | 472 if (current->env() != NULL) { |
| 473 const GrowableArray<Value*>& values = current->env()->values(); | 473 Environment* env = current->env(); |
| 474 GrowableArray<Location>* locations = current->env()->locations(); | 474 const GrowableArray<Value*>& values = env->values(); |
| 475 | 475 |
| 476 for (intptr_t j = 0; j < values.length(); j++) { | 476 for (intptr_t j = 0; j < values.length(); j++) { |
| 477 Value* val = values[j]; | 477 Value* val = values[j]; |
| 478 if (val->IsUse()) { | 478 if (val->IsUse()) { |
| 479 locations->Add(Location::RequiresRegister()); | 479 env->AddLocation(Location::RequiresRegister()); |
| 480 const intptr_t use = val->AsUse()->definition()->ssa_temp_index(); | 480 const intptr_t use = val->AsUse()->definition()->ssa_temp_index(); |
| 481 UseValue(current, | 481 UseValue(current, |
| 482 block->start_pos(), | 482 block->start_pos(), |
| 483 pos, | 483 pos, |
| 484 use, | 484 use, |
| 485 &(*locations)[j], | 485 env->LocationSlotAt(j), |
| 486 true); | 486 true); |
| 487 } else { | 487 } else { |
| 488 locations->Add(Location::NoLocation()); | 488 env->AddLocation(Location::NoLocation()); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 // Process temps. | 493 // Process temps. |
| 494 for (intptr_t j = 0; j < locs->temp_count(); j++) { | 494 for (intptr_t j = 0; j < locs->temp_count(); j++) { |
| 495 Location temp = locs->temp(j); | 495 Location temp = locs->temp(j); |
| 496 if (temp.IsRegister()) { | 496 if (temp.IsRegister()) { |
| 497 BlockLocation(temp, pos); | 497 BlockLocation(temp, pos); |
| 498 } else if (temp.IsUnallocated()) { | 498 } else if (temp.IsUnallocated()) { |
| 499 UseInterval* temp_interval = new UseInterval( | 499 UseInterval* temp_interval = new UseInterval( |
| 500 kTempVirtualRegister, pos, pos + 1, NULL); | 500 kTempVirtualRegister, pos, pos + 1, NULL); |
| 501 temp_interval->AddUse(NULL, pos, locs->temp_slot(j)); | 501 temp_interval->AddUse(NULL, pos, locs->temp_slot(j)); |
| 502 AddToUnallocated(temp_interval); | 502 AddToUnallocated(temp_interval); |
| 503 } else { | 503 } else { |
| 504 UNREACHABLE(); | 504 UNREACHABLE(); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 | 507 |
| 508 // Block all allocatable registers for calls. | 508 // Block all allocatable registers for calls. |
| 509 if (locs->is_call()) { | 509 if (locs->is_call()) { |
| 510 for (intptr_t reg = 0; reg < kNumberOfCpuRegisters; reg++) { | 510 for (intptr_t reg = 0; reg < kNumberOfCpuRegisters; reg++) { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 | 948 |
| 949 if (FLAG_trace_ssa_allocator) { | 949 if (FLAG_trace_ssa_allocator) { |
| 950 OS::Print("-- ir after allocation -------------------------\n"); | 950 OS::Print("-- ir after allocation -------------------------\n"); |
| 951 FlowGraphPrinter printer(Function::Handle(), block_order_, true); | 951 FlowGraphPrinter printer(Function::Handle(), block_order_, true); |
| 952 printer.PrintBlocks(); | 952 printer.PrintBlocks(); |
| 953 } | 953 } |
| 954 } | 954 } |
| 955 | 955 |
| 956 | 956 |
| 957 } // namespace dart | 957 } // namespace dart |
| OLD | NEW |