| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/locations.h" | 5 #include "vm/locations.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 return count; | 22 return count; |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 LocationSummary::LocationSummary(intptr_t input_count, | 26 LocationSummary::LocationSummary(intptr_t input_count, |
| 27 intptr_t temp_count, | 27 intptr_t temp_count, |
| 28 LocationSummary::ContainsCall contains_call) | 28 LocationSummary::ContainsCall contains_call) |
| 29 : input_locations_(input_count), | 29 : input_locations_(input_count), |
| 30 temp_locations_(temp_count), | 30 temp_locations_(temp_count), |
| 31 output_location_(), | 31 output_locations_(1), |
| 32 stack_bitmap_(NULL), | 32 stack_bitmap_(NULL), |
| 33 contains_call_(contains_call), | 33 contains_call_(contains_call), |
| 34 live_registers_() { | 34 live_registers_() { |
| 35 for (intptr_t i = 0; i < input_count; i++) { | 35 for (intptr_t i = 0; i < input_count; i++) { |
| 36 input_locations_.Add(Location()); | 36 input_locations_.Add(Location()); |
| 37 } | 37 } |
| 38 for (intptr_t i = 0; i < temp_count; i++) { | 38 for (intptr_t i = 0; i < temp_count; i++) { |
| 39 temp_locations_.Add(Location()); | 39 temp_locations_.Add(Location()); |
| 40 } | 40 } |
| 41 | 41 output_locations_.Add(Location()); |
| 42 ASSERT(output_locations_.length() == 1); |
| 42 if (contains_call_ != kNoCall) { | 43 if (contains_call_ != kNoCall) { |
| 43 stack_bitmap_ = new BitmapBuilder(); | 44 stack_bitmap_ = new BitmapBuilder(); |
| 44 } | 45 } |
| 46 } |
| 47 |
| 48 |
| 49 LocationSummary::LocationSummary(intptr_t input_count, |
| 50 intptr_t temp_count, |
| 51 intptr_t output_count, |
| 52 LocationSummary::ContainsCall contains_call) |
| 53 : input_locations_(input_count), |
| 54 temp_locations_(temp_count), |
| 55 output_locations_(output_count), |
| 56 stack_bitmap_(NULL), |
| 57 contains_call_(contains_call), |
| 58 live_registers_() { |
| 59 for (intptr_t i = 0; i < input_count; i++) { |
| 60 input_locations_.Add(Location()); |
| 61 } |
| 62 for (intptr_t i = 0; i < temp_count; i++) { |
| 63 temp_locations_.Add(Location()); |
| 64 } |
| 65 // TODO(johnmccutchan): Remove this assertion once support for multiple |
| 66 // outputs is complete. |
| 67 ASSERT(output_count == 1); |
| 68 for (intptr_t i = 0; i < output_count; i++) { |
| 69 output_locations_.Add(Location()); |
| 70 } |
| 71 if (contains_call_ != kNoCall) { |
| 72 stack_bitmap_ = new BitmapBuilder(); |
| 73 } |
| 45 } | 74 } |
| 46 | 75 |
| 47 | 76 |
| 48 LocationSummary* LocationSummary::Make( | 77 LocationSummary* LocationSummary::Make( |
| 49 intptr_t input_count, | 78 intptr_t input_count, |
| 50 Location out, | 79 Location out, |
| 51 LocationSummary::ContainsCall contains_call) { | 80 LocationSummary::ContainsCall contains_call) { |
| 52 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); | 81 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); |
| 53 for (intptr_t i = 0; i < input_count; i++) { | 82 for (intptr_t i = 0; i < input_count; i++) { |
| 54 summary->set_in(i, Location::RequiresRegister()); | 83 summary->set_in(i, Location::RequiresRegister()); |
| 55 } | 84 } |
| 56 summary->set_out(out); | 85 summary->set_out(0, out); |
| 57 return summary; | 86 return summary; |
| 58 } | 87 } |
| 59 | 88 |
| 60 | 89 |
| 61 Location Location::RegisterOrConstant(Value* value) { | 90 Location Location::RegisterOrConstant(Value* value) { |
| 62 ConstantInstr* constant = value->definition()->AsConstant(); | 91 ConstantInstr* constant = value->definition()->AsConstant(); |
| 63 return ((constant != NULL) && Assembler::IsSafe(constant->value())) | 92 return ((constant != NULL) && Assembler::IsSafe(constant->value())) |
| 64 ? Location::Constant(constant->value()) | 93 ? Location::Constant(constant->value()) |
| 65 : Location::RequiresRegister(); | 94 : Location::RequiresRegister(); |
| 66 } | 95 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 217 |
| 189 if (temp_count() > 0) { | 218 if (temp_count() > 0) { |
| 190 f->Print(" ["); | 219 f->Print(" ["); |
| 191 for (intptr_t i = 0; i < temp_count(); i++) { | 220 for (intptr_t i = 0; i < temp_count(); i++) { |
| 192 if (i != 0) f->Print(", "); | 221 if (i != 0) f->Print(", "); |
| 193 temp(i).PrintTo(f); | 222 temp(i).PrintTo(f); |
| 194 } | 223 } |
| 195 f->Print("]"); | 224 f->Print("]"); |
| 196 } | 225 } |
| 197 | 226 |
| 198 if (!out().IsInvalid()) { | 227 if (!out(0).IsInvalid()) { |
| 199 f->Print(" => "); | 228 f->Print(" => "); |
| 200 out().PrintTo(f); | 229 out(0).PrintTo(f); |
| 201 } | 230 } |
| 202 | 231 |
| 203 if (always_calls()) f->Print(" C"); | 232 if (always_calls()) f->Print(" C"); |
| 204 } | 233 } |
| 205 | 234 |
| 206 } // namespace dart | 235 } // namespace dart |
| OLD | NEW |