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

Side by Side Diff: src/register-allocator-ia32.cc

Issue 17004: Experimental: add a has_valid_frame predicate to the code generator... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 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 | « src/jump-target-ia32.cc ('k') | src/virtual-frame-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 Result fresh = cgen_->allocator()->Allocate(target); 86 Result fresh = cgen_->allocator()->Allocate(target);
87 ASSERT(fresh.is_valid()); 87 ASSERT(fresh.is_valid());
88 if (is_register()) { 88 if (is_register()) {
89 cgen_->masm()->mov(fresh.reg(), reg()); 89 cgen_->masm()->mov(fresh.reg(), reg());
90 } else { 90 } else {
91 ASSERT(is_constant()); 91 ASSERT(is_constant());
92 cgen_->masm()->Set(fresh.reg(), Immediate(handle())); 92 cgen_->masm()->Set(fresh.reg(), Immediate(handle()));
93 } 93 }
94 *this = fresh; 94 *this = fresh;
95 } else if (is_register() && reg().is(target)) { 95 } else if (is_register() && reg().is(target)) {
96 ASSERT(cgen_->frame() != NULL); 96 ASSERT(cgen_->has_valid_frame());
97 cgen_->frame()->Spill(target); 97 cgen_->frame()->Spill(target);
98 ASSERT(cgen_->allocator()->count(target) == 1); 98 ASSERT(cgen_->allocator()->count(target) == 1);
99 } 99 }
100 ASSERT(is_register()); 100 ASSERT(is_register());
101 ASSERT(reg().is(target)); 101 ASSERT(reg().is(target));
102 } 102 }
103 103
104 104
105 // ------------------------------------------------------------------------- 105 // -------------------------------------------------------------------------
106 // RegisterAllocator implementation. 106 // RegisterAllocator implementation.
(...skipping 16 matching lines...) Expand all
123 } 123 }
124 } 124 }
125 return Result(cgen_); 125 return Result(cgen_);
126 } 126 }
127 127
128 128
129 Result RegisterAllocator::Allocate() { 129 Result RegisterAllocator::Allocate() {
130 Result result = AllocateWithoutSpilling(); 130 Result result = AllocateWithoutSpilling();
131 if (!result.is_valid()) { 131 if (!result.is_valid()) {
132 // Ask the current frame to spill a register. 132 // Ask the current frame to spill a register.
133 ASSERT(cgen_->frame() != NULL); 133 ASSERT(cgen_->has_valid_frame());
134 Register free_reg = cgen_->frame()->SpillAnyRegister(); 134 Register free_reg = cgen_->frame()->SpillAnyRegister();
135 if (free_reg.is_valid()) { 135 if (free_reg.is_valid()) {
136 ASSERT(!is_used(free_reg)); 136 ASSERT(!is_used(free_reg));
137 return Result(free_reg, cgen_); 137 return Result(free_reg, cgen_);
138 } 138 }
139 } 139 }
140 return result; 140 return result;
141 } 141 }
142 142
143 143
144 Result RegisterAllocator::Allocate(Register target) { 144 Result RegisterAllocator::Allocate(Register target) {
145 // If the target is not referenced, it can simply be allocated. 145 // If the target is not referenced, it can simply be allocated.
146 if (!is_used(target)) { 146 if (!is_used(target)) {
147 return Result(target, cgen_); 147 return Result(target, cgen_);
148 } 148 }
149 // If the target is only referenced in the frame, it can be spilled and 149 // If the target is only referenced in the frame, it can be spilled and
150 // then allocated. 150 // then allocated.
151 ASSERT(cgen_->frame() != NULL); 151 ASSERT(cgen_->has_valid_frame());
152 if (count(target) == cgen_->frame()->register_count(target)) { 152 if (count(target) == cgen_->frame()->register_count(target)) {
153 cgen_->frame()->Spill(target); 153 cgen_->frame()->Spill(target);
154 ASSERT(!is_used(target)); 154 ASSERT(!is_used(target));
155 return Result(target, cgen_); 155 return Result(target, cgen_);
156 } 156 }
157 // Otherwise (if it's referenced outside the frame) we cannot allocate it. 157 // Otherwise (if it's referenced outside the frame) we cannot allocate it.
158 return Result(cgen_); 158 return Result(cgen_);
159 } 159 }
160 160
161 161
162 } } // namespace v8::internal 162 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jump-target-ia32.cc ('k') | src/virtual-frame-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698