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

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

Issue 10399136: CTX and TMP registers may not be allocated. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « runtime/vm/constants_ia32.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) 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/locations.h" 5 #include "vm/locations.h"
6 6
7 #include "vm/intermediate_language.h" 7 #include "vm/intermediate_language.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
11 11
12 static Register AllocateFreeRegister( 12 static Register AllocateFreeRegister(
13 EmbeddedArray<bool, kNumberOfCpuRegisters>* blocked_registers) { 13 EmbeddedArray<bool, kNumberOfCpuRegisters>* blocked_registers) {
14 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) { 14 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) {
15 if (!blocked_registers->At(regno)) { 15 if (!blocked_registers->At(regno)) {
16 blocked_registers->SetAt(regno, true); 16 blocked_registers->SetAt(regno, true);
17 return static_cast<Register>(regno); 17 return static_cast<Register>(regno);
18 } 18 }
19 } 19 }
20 UNREACHABLE(); 20 UNREACHABLE();
21 return kNoRegister; 21 return kNoRegister;
22 } 22 }
23 23
24 24
25 void LocationSummary::AllocateRegisters() { 25 void LocationSummary::AllocateRegisters() {
26 EmbeddedArray<bool, kNumberOfCpuRegisters> blocked_registers; 26 EmbeddedArray<bool, kNumberOfCpuRegisters> blocked_registers;
27 27
28 // Mark all registers free. 28 // Mark all available registers free.
29 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { 29 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) {
30 blocked_registers[i] = false; 30 blocked_registers[i] = false;
31 } 31 }
32 32
33 // Mark all fixed registers as used. 33 // Mark all fixed registers as used.
34 for (intptr_t i = 0; i < count(); i++) { 34 for (intptr_t i = 0; i < count(); i++) {
35 Location loc = in(i); 35 Location loc = in(i);
36 if (loc.kind() == Location::kRegister) { 36 if (loc.kind() == Location::kRegister) {
37 ASSERT(!blocked_registers[loc.reg()]); 37 ASSERT(!blocked_registers[loc.reg()]);
38 blocked_registers[loc.reg()] = true; 38 blocked_registers[loc.reg()] = true;
39 } 39 }
40 } 40 }
41 41
42 // Do not allocate known registers.
43 blocked_registers[CTX] = true;
44 if (TMP != kNoRegister) {
45 blocked_registers[TMP] = true;
46 }
47
42 // Allocate all unallocated input locations. 48 // Allocate all unallocated input locations.
43 for (intptr_t i = 0; i < count(); i++) { 49 for (intptr_t i = 0; i < count(); i++) {
44 Location loc = in(i); 50 Location loc = in(i);
45 if (loc.kind() == Location::kUnallocated) { 51 if (loc.kind() == Location::kUnallocated) {
46 ASSERT(loc.policy() == Location::kRequiresRegister); 52 ASSERT(loc.policy() == Location::kRequiresRegister);
47 set_in(i, Location::RegisterLocation( 53 set_in(i, Location::RegisterLocation(
48 AllocateFreeRegister(&blocked_registers))); 54 AllocateFreeRegister(&blocked_registers)));
49 } 55 }
50 } 56 }
51 57
52 Location result_location = out(); 58 Location result_location = out();
53 if (result_location.kind() == Location::kUnallocated) { 59 if (result_location.kind() == Location::kUnallocated) {
54 switch (result_location.policy()) { 60 switch (result_location.policy()) {
55 case Location::kRequiresRegister: 61 case Location::kRequiresRegister:
56 result_location = Location::RegisterLocation( 62 result_location = Location::RegisterLocation(
57 AllocateFreeRegister(&blocked_registers)); 63 AllocateFreeRegister(&blocked_registers));
58 break; 64 break;
59 case Location::kSameAsFirstInput: 65 case Location::kSameAsFirstInput:
60 result_location = in(0); 66 result_location = in(0);
61 break; 67 break;
62 } 68 }
63 set_out(result_location); 69 set_out(result_location);
64 } 70 }
65 } 71 }
66 72
67 73
68 } // namespace dart 74 } // namespace dart
69 75
OLDNEW
« no previous file with comments | « runtime/vm/constants_ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698