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" |
11 #include "vm/stack_frame.h" | 11 #include "vm/stack_frame.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 intptr_t RegisterSet::RegisterCount(intptr_t registers) { | 15 intptr_t RegisterSet::RegisterCount(intptr_t registers) { |
16 // Brian Kernighan's algorithm for counting the bits set. | 16 // Brian Kernighan's algorithm for counting the bits set. |
17 intptr_t count = 0; | 17 intptr_t count = 0; |
18 while (registers != 0) { | 18 while (registers != 0) { |
19 ++count; | 19 ++count; |
20 registers &= (registers - 1); // Clear the least significant bit set. | 20 registers &= (registers - 1); // Clear the least significant bit set. |
21 } | 21 } |
22 return count; | 22 return count; |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 LocationSummary::LocationSummary(intptr_t input_count, | 26 LocationSummary::LocationSummary(Isolate* isolate, |
| 27 intptr_t input_count, |
27 intptr_t temp_count, | 28 intptr_t temp_count, |
28 LocationSummary::ContainsCall contains_call) | 29 LocationSummary::ContainsCall contains_call) |
29 : input_locations_(input_count), | 30 : input_locations_(isolate, input_count), |
30 temp_locations_(temp_count), | 31 temp_locations_(isolate, temp_count), |
31 output_locations_(1), | 32 output_locations_(isolate, 1), |
32 stack_bitmap_(NULL), | 33 stack_bitmap_(NULL), |
33 contains_call_(contains_call), | 34 contains_call_(contains_call), |
34 live_registers_() { | 35 live_registers_() { |
35 for (intptr_t i = 0; i < input_count; i++) { | 36 for (intptr_t i = 0; i < input_count; i++) { |
36 input_locations_.Add(Location()); | 37 input_locations_.Add(Location()); |
37 } | 38 } |
38 for (intptr_t i = 0; i < temp_count; i++) { | 39 for (intptr_t i = 0; i < temp_count; i++) { |
39 temp_locations_.Add(Location()); | 40 temp_locations_.Add(Location()); |
40 } | 41 } |
41 output_locations_.Add(Location()); | 42 output_locations_.Add(Location()); |
42 ASSERT(output_locations_.length() == 1); | 43 ASSERT(output_locations_.length() == 1); |
43 if (contains_call_ != kNoCall) { | |
44 stack_bitmap_ = new BitmapBuilder(); | |
45 } | |
46 } | 44 } |
47 | 45 |
48 | 46 |
49 LocationSummary::LocationSummary(intptr_t input_count, | 47 LocationSummary::LocationSummary(Isolate* isolate, |
50 intptr_t temp_count, | 48 intptr_t input_count, |
51 intptr_t output_count, | 49 intptr_t temp_count, |
52 LocationSummary::ContainsCall contains_call) | 50 intptr_t output_count, |
53 : input_locations_(input_count), | 51 LocationSummary::ContainsCall contains_call) |
54 temp_locations_(temp_count), | 52 : input_locations_(isolate, input_count), |
55 output_locations_(output_count), | 53 temp_locations_(isolate, temp_count), |
| 54 output_locations_(isolate, output_count), |
56 stack_bitmap_(NULL), | 55 stack_bitmap_(NULL), |
57 contains_call_(contains_call), | 56 contains_call_(contains_call), |
58 live_registers_() { | 57 live_registers_() { |
59 for (intptr_t i = 0; i < input_count; i++) { | 58 for (intptr_t i = 0; i < input_count; i++) { |
60 input_locations_.Add(Location()); | 59 input_locations_.Add(Location()); |
61 } | 60 } |
62 for (intptr_t i = 0; i < temp_count; i++) { | 61 for (intptr_t i = 0; i < temp_count; i++) { |
63 temp_locations_.Add(Location()); | 62 temp_locations_.Add(Location()); |
64 } | 63 } |
65 // TODO(johnmccutchan): Remove this assertion once support for multiple | 64 // TODO(johnmccutchan): Remove this assertion once support for multiple |
66 // outputs is complete. | 65 // outputs is complete. |
67 ASSERT(output_count == 1); | 66 ASSERT(output_count == 1); |
68 for (intptr_t i = 0; i < output_count; i++) { | 67 for (intptr_t i = 0; i < output_count; i++) { |
69 output_locations_.Add(Location()); | 68 output_locations_.Add(Location()); |
70 } | 69 } |
71 if (contains_call_ != kNoCall) { | |
72 stack_bitmap_ = new BitmapBuilder(); | |
73 } | |
74 } | 70 } |
75 | 71 |
76 | 72 |
77 LocationSummary* LocationSummary::Make( | 73 LocationSummary* LocationSummary::Make( |
78 intptr_t input_count, | 74 intptr_t input_count, |
79 Location out, | 75 Location out, |
80 LocationSummary::ContainsCall contains_call) { | 76 LocationSummary::ContainsCall contains_call) { |
81 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); | 77 LocationSummary* summary = new LocationSummary( |
| 78 Isolate::Current(),input_count, 0, contains_call); |
82 for (intptr_t i = 0; i < input_count; i++) { | 79 for (intptr_t i = 0; i < input_count; i++) { |
83 summary->set_in(i, Location::RequiresRegister()); | 80 summary->set_in(i, Location::RequiresRegister()); |
84 } | 81 } |
85 summary->set_out(0, out); | 82 summary->set_out(0, out); |
86 return summary; | 83 return summary; |
87 } | 84 } |
88 | 85 |
89 | 86 |
90 Location Location::Pair(Location first, Location second) { | 87 Location Location::Pair(Location first, Location second) { |
91 PairLocation* pair_location = new PairLocation(); | 88 PairLocation* pair_location = new PairLocation(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 270 |
274 if (!out(0).IsInvalid()) { | 271 if (!out(0).IsInvalid()) { |
275 f->Print(" => "); | 272 f->Print(" => "); |
276 out(0).PrintTo(f); | 273 out(0).PrintTo(f); |
277 } | 274 } |
278 | 275 |
279 if (always_calls()) f->Print(" C"); | 276 if (always_calls()) f->Print(" C"); |
280 } | 277 } |
281 | 278 |
282 } // namespace dart | 279 } // namespace dart |
OLD | NEW |