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

Unified Diff: src/register-allocator-ia32.cc

Issue 15079: Experimental: this is a substantial change to allow the virtual frame... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years 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 side-by-side diff with in-line comments
Download patch
Index: src/register-allocator-ia32.cc
===================================================================
--- src/register-allocator-ia32.cc (revision 1012)
+++ src/register-allocator-ia32.cc (working copy)
@@ -39,7 +39,7 @@
: type_(REGISTER),
cgen_(cgen) {
data_.reg_ = reg;
- ASSERT(!reg.is(no_reg));
+ ASSERT(reg.is_valid());
cgen_->allocator()->Use(reg);
}
@@ -74,14 +74,30 @@
ASSERT(fresh.is_valid());
cgen_->masm()->Set(fresh.reg(), Immediate(handle()));
// This result becomes a copy of the fresh one.
- cgen_->allocator()->Use(fresh.reg());
- type_ = REGISTER;
- data_.reg_ = fresh.reg();
+ *this = fresh;
}
ASSERT(is_register());
}
+void Result::ToRegister(Register target) {
+ ASSERT(is_valid());
+ if (!is_register() || !reg().is(target)) {
+ Result fresh = cgen_->allocator()->Allocate(target);
+ ASSERT(fresh.is_valid());
+ if (is_register()) {
+ cgen_->masm()->mov(fresh.reg(), reg());
+ } else {
+ ASSERT(is_constant());
+ cgen_->masm()->Set(fresh.reg(), Immediate(handle()));
+ }
+ *this = fresh;
+ }
William Hesse 2008/12/22 13:55:21 I think we are missing the case where this.reg() i
Kevin Millikin (Chromium) 2008/12/22 14:40:00 Yes, according to the comment in the header we do.
+ ASSERT(is_register());
+ ASSERT(reg().is(target));
+}
+
+
// -------------------------------------------------------------------------
// RegisterAllocator implementation.
@@ -113,7 +129,7 @@
ASSERT(cgen_->frame() != NULL);
Register free_reg = cgen_->frame()->SpillAnyRegister();
if (free_reg.is_valid()) {
- ASSERT(!is_used(free_reg.code()));
+ ASSERT(!is_used(free_reg));
return Result(free_reg, cgen_);
}
}
@@ -121,4 +137,22 @@
}
+Result RegisterAllocator::Allocate(Register target) {
+ // If the target is not referenced, it can simply be allocated.
+ if (!is_used(target)) {
+ return Result(target, cgen_);
+ }
+ // If the target is only referenced in the frame, it can be spilled and
+ // then allocated.
+ ASSERT(cgen_->frame() != NULL);
+ if (count(target) == cgen_->frame()->register_count(target)) {
+ cgen_->frame()->Spill(target);
+ ASSERT(!is_used(target));
+ return Result(target, cgen_);
+ }
+ // Otherwise (if it's referenced outside the frame) we cannot allocate it.
+ return Result(cgen_);
+}
+
+
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698