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

Unified Diff: src/interpreter/bytecode-register-allocator.cc

Issue 1997653002: [interpreter] Bytecode register optimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Decouple a test from implementation. Created 4 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
« no previous file with comments | « src/interpreter/bytecode-register-allocator.h ('k') | src/interpreter/bytecode-register-optimizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-register-allocator.cc
diff --git a/src/interpreter/bytecode-register-allocator.cc b/src/interpreter/bytecode-register-allocator.cc
index 9bdde9a470ff8182653f6b18bde5042fef5fcd9e..10afcdc76d5572774ee49462e3bb1ecc2740fa42 100644
--- a/src/interpreter/bytecode-register-allocator.cc
+++ b/src/interpreter/bytecode-register-allocator.cc
@@ -14,7 +14,8 @@ TemporaryRegisterAllocator::TemporaryRegisterAllocator(Zone* zone,
int allocation_base)
: free_temporaries_(zone),
allocation_base_(allocation_base),
- allocation_count_(0) {}
+ allocation_count_(0),
+ observer_(nullptr) {}
Register TemporaryRegisterAllocator::first_temporary_register() const {
DCHECK(allocation_count() > 0);
@@ -26,6 +27,12 @@ Register TemporaryRegisterAllocator::last_temporary_register() const {
return Register(allocation_base() + allocation_count() - 1);
}
+void TemporaryRegisterAllocator::set_observer(
+ TemporaryRegisterObserver* observer) {
+ DCHECK(observer_ == nullptr);
+ observer_ = observer;
+}
+
int TemporaryRegisterAllocator::AllocateTemporaryRegister() {
allocation_count_ += 1;
return allocation_base() + allocation_count() - 1;
@@ -140,6 +147,9 @@ void TemporaryRegisterAllocator::BorrowConsecutiveTemporaryRegister(
void TemporaryRegisterAllocator::ReturnTemporaryRegister(int reg_index) {
DCHECK(free_temporaries_.find(reg_index) == free_temporaries_.end());
free_temporaries_.insert(reg_index);
+ if (observer_) {
+ observer_->TemporaryRegisterFreeEvent(Register(reg_index));
+ }
}
BytecodeRegisterAllocator::BytecodeRegisterAllocator(
@@ -156,7 +166,6 @@ BytecodeRegisterAllocator::~BytecodeRegisterAllocator() {
allocated_.clear();
}
-
Register BytecodeRegisterAllocator::NewRegister() {
int allocated = -1;
if (next_consecutive_count_ <= 0) {
@@ -170,7 +179,6 @@ Register BytecodeRegisterAllocator::NewRegister() {
return Register(allocated);
}
-
bool BytecodeRegisterAllocator::RegisterIsAllocatedInThisScope(
Register reg) const {
for (auto i = allocated_.begin(); i != allocated_.end(); i++) {
@@ -179,7 +187,6 @@ bool BytecodeRegisterAllocator::RegisterIsAllocatedInThisScope(
return false;
}
-
void BytecodeRegisterAllocator::PrepareForConsecutiveAllocations(size_t count) {
if (static_cast<int>(count) > next_consecutive_count_) {
next_consecutive_register_ =
@@ -188,7 +195,6 @@ void BytecodeRegisterAllocator::PrepareForConsecutiveAllocations(size_t count) {
}
}
-
Register BytecodeRegisterAllocator::NextConsecutiveRegister() {
DCHECK_GE(next_consecutive_register_, 0);
DCHECK_GT(next_consecutive_count_, 0);
« no previous file with comments | « src/interpreter/bytecode-register-allocator.h ('k') | src/interpreter/bytecode-register-optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698