Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: runtime/vm/locations.cc

Issue 207063002: Refactor to support multiple outputs in location summary (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/locations.h ('K') | « runtime/vm/locations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(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 intptr_t output_count)
29 : input_locations_(input_count), 30 : input_locations_(input_count),
30 temp_locations_(temp_count), 31 temp_locations_(temp_count),
31 output_location_(), 32 output_locations_(output_count),
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 }
42 // TODO(johnmccutchan): Remove this assertion.
43 ASSERT(output_count == 1);
44 for (intptr_t i = 0; i < output_count; i++) {
45 output_locations_.Add(Location());
46 }
41 47
42 if (contains_call_ != kNoCall) { 48 if (contains_call_ != kNoCall) {
43 stack_bitmap_ = new BitmapBuilder(); 49 stack_bitmap_ = new BitmapBuilder();
44 } 50 }
45 } 51 }
46 52
47 53
48 LocationSummary* LocationSummary::Make( 54 LocationSummary* LocationSummary::Make(
49 intptr_t input_count, 55 intptr_t input_count,
50 Location out, 56 Location out,
51 LocationSummary::ContainsCall contains_call) { 57 LocationSummary::ContainsCall contains_call) {
52 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); 58 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call);
53 for (intptr_t i = 0; i < input_count; i++) { 59 for (intptr_t i = 0; i < input_count; i++) {
54 summary->set_in(i, Location::RequiresRegister()); 60 summary->set_in(i, Location::RequiresRegister());
55 } 61 }
56 summary->set_out(out); 62 summary->set_out(0, out);
57 return summary; 63 return summary;
58 } 64 }
59 65
60 66
61 Location Location::RegisterOrConstant(Value* value) { 67 Location Location::RegisterOrConstant(Value* value) {
62 ConstantInstr* constant = value->definition()->AsConstant(); 68 ConstantInstr* constant = value->definition()->AsConstant();
63 return ((constant != NULL) && Assembler::IsSafe(constant->value())) 69 return ((constant != NULL) && Assembler::IsSafe(constant->value()))
64 ? Location::Constant(constant->value()) 70 ? Location::Constant(constant->value())
65 : Location::RequiresRegister(); 71 : Location::RequiresRegister();
66 } 72 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 194
189 if (temp_count() > 0) { 195 if (temp_count() > 0) {
190 f->Print(" ["); 196 f->Print(" [");
191 for (intptr_t i = 0; i < temp_count(); i++) { 197 for (intptr_t i = 0; i < temp_count(); i++) {
192 if (i != 0) f->Print(", "); 198 if (i != 0) f->Print(", ");
193 temp(i).PrintTo(f); 199 temp(i).PrintTo(f);
194 } 200 }
195 f->Print("]"); 201 f->Print("]");
196 } 202 }
197 203
198 if (!out().IsInvalid()) { 204 if (!out(0).IsInvalid()) {
199 f->Print(" => "); 205 f->Print(" => ");
200 out().PrintTo(f); 206 out(0).PrintTo(f);
201 } 207 }
202 208
203 if (always_calls()) f->Print(" C"); 209 if (always_calls()) f->Print(" C");
204 } 210 }
205 211
206 } // namespace dart 212 } // namespace dart
OLDNEW
« runtime/vm/locations.h ('K') | « runtime/vm/locations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698