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

Unified Diff: src/register-allocator.cc

Issue 113455: Clean up the Result class. Reduce the size of Result from four words... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
Index: src/register-allocator.cc
===================================================================
--- src/register-allocator.cc (revision 1960)
+++ src/register-allocator.cc (working copy)
@@ -35,42 +35,27 @@
// -------------------------------------------------------------------------
// Result implementation.
-Result::Result(Register reg, CodeGenerator* cgen)
- : static_type_(),
- type_(REGISTER),
- cgen_(cgen) {
- data_.reg_ = reg;
+CodeGenerator* Result::cgen_ = NULL;
+
+
+Result::Result(Register reg) {
ASSERT(reg.is_valid());
cgen_->allocator()->Use(reg);
+ value_ = StaticTypeField::encode(StaticType::UNKNOWN_TYPE)
+ | TypeField::encode(REGISTER)
+ | DataField::encode(reg.code_);
}
-Result::Result(Register reg, CodeGenerator* cgen, StaticType static_type)
- : static_type_(static_type),
- type_(REGISTER),
- cgen_(cgen) {
- data_.reg_ = reg;
+Result::Result(Register reg, StaticType type) {
ASSERT(reg.is_valid());
cgen_->allocator()->Use(reg);
+ value_ = StaticTypeField::encode(type.static_type_)
+ | TypeField::encode(REGISTER)
+ | DataField::encode(reg.code_);
}
-void Result::CopyTo(Result* destination) const {
- destination->static_type_ = static_type_;
- destination->type_ = type();
- destination->cgen_ = cgen_;
-
- if (is_register()) {
- destination->data_.reg_ = reg();
- cgen_->allocator()->Use(reg());
- } else if (is_constant()) {
- destination->data_.handle_ = data_.handle_;
- } else {
- ASSERT(!is_valid());
- }
-}
-
-
// -------------------------------------------------------------------------
// RegisterAllocator implementation.
@@ -80,9 +65,9 @@
int free_reg = registers_.ScanForFreeRegister();
if (free_reg < kNumRegisters) {
Register free_result = { free_reg };
- return Result(free_result, cgen_);
+ return Result(free_result);
}
- return Result(cgen_);
+ return Result();
}
@@ -94,7 +79,7 @@
Register free_reg = cgen_->frame()->SpillAnyRegister();
if (free_reg.is_valid()) {
ASSERT(!is_used(free_reg));
- return Result(free_reg, cgen_);
+ return Result(free_reg);
}
}
return result;
@@ -104,7 +89,7 @@
Result RegisterAllocator::Allocate(Register target) {
// If the target is not referenced, it can simply be allocated.
if (!is_used(target)) {
- return Result(target, cgen_);
+ return Result(target);
}
// If the target is only referenced in the frame, it can be spilled and
// then allocated.
@@ -112,10 +97,10 @@
if (cgen_->frame()->is_used(target) && count(target) == 1) {
cgen_->frame()->Spill(target);
ASSERT(!is_used(target));
- return Result(target, cgen_);
+ return Result(target);
}
// Otherwise (if it's referenced outside the frame) we cannot allocate it.
- return Result(cgen_);
+ return Result();
}

Powered by Google App Engine
This is Rietveld 408576698