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(Isolate* isolate, | 26 LocationSummary::LocationSummary(Zone* zone, |
27 intptr_t input_count, | 27 intptr_t input_count, |
28 intptr_t temp_count, | 28 intptr_t temp_count, |
29 LocationSummary::ContainsCall contains_call) | 29 LocationSummary::ContainsCall contains_call) |
30 : num_inputs_(input_count), | 30 : num_inputs_(input_count), |
31 num_temps_(temp_count), | 31 num_temps_(temp_count), |
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 #if defined(DEBUG) | 35 #if defined(DEBUG) |
36 writable_inputs_ = 0; | 36 writable_inputs_ = 0; |
37 #endif | 37 #endif |
38 input_locations_ = isolate->current_zone()->Alloc<Location>(num_inputs_); | 38 input_locations_ = zone->Alloc<Location>(num_inputs_); |
39 temp_locations_ = isolate->current_zone()->Alloc<Location>(num_temps_); | 39 temp_locations_ = zone->Alloc<Location>(num_temps_); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 LocationSummary* LocationSummary::Make( | 43 LocationSummary* LocationSummary::Make( |
44 Isolate* isolate, | 44 Zone* zone, |
45 intptr_t input_count, | 45 intptr_t input_count, |
46 Location out, | 46 Location out, |
47 LocationSummary::ContainsCall contains_call) { | 47 LocationSummary::ContainsCall contains_call) { |
48 LocationSummary* summary = new(isolate) LocationSummary( | 48 LocationSummary* summary = new(zone) LocationSummary( |
49 isolate, input_count, 0, contains_call); | 49 zone, input_count, 0, contains_call); |
50 for (intptr_t i = 0; i < input_count; i++) { | 50 for (intptr_t i = 0; i < input_count; i++) { |
51 summary->set_in(i, Location::RequiresRegister()); | 51 summary->set_in(i, Location::RequiresRegister()); |
52 } | 52 } |
53 summary->set_out(0, out); | 53 summary->set_out(0, out); |
54 return summary; | 54 return summary; |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 Location Location::Pair(Location first, Location second) { | 58 Location Location::Pair(Location first, Location second) { |
59 PairLocation* pair_location = new PairLocation(); | 59 PairLocation* pair_location = new PairLocation(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // with the right representation because register allocator does not know | 348 // with the right representation because register allocator does not know |
349 // how they are used within the instruction template. | 349 // how they are used within the instruction template. |
350 ASSERT(in(i).IsMachineRegister()); | 350 ASSERT(in(i).IsMachineRegister()); |
351 ASSERT(live_registers()->Contains(in(i))); | 351 ASSERT(live_registers()->Contains(in(i))); |
352 } | 352 } |
353 } | 353 } |
354 } | 354 } |
355 #endif | 355 #endif |
356 | 356 |
357 } // namespace dart | 357 } // namespace dart |
OLD | NEW |