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

Unified Diff: src/interpreter/bytecode-array-builder.h

Issue 1392933002: [Interpreter] Reduce temporary register usage in generated bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate comments from mstarzinger. Created 5 years, 2 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 | « no previous file | src/interpreter/bytecode-array-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-array-builder.h
diff --git a/src/interpreter/bytecode-array-builder.h b/src/interpreter/bytecode-array-builder.h
index 27262e224d0ba606cf9fc26881470ab9fde2f824..3f2415e1be7a97e2f4d77c90071f9f6c847e6764 100644
--- a/src/interpreter/bytecode-array-builder.h
+++ b/src/interpreter/bytecode-array-builder.h
@@ -28,14 +28,14 @@ class BytecodeArrayBuilder {
BytecodeArrayBuilder(Isolate* isolate, Zone* zone);
Handle<BytecodeArray> ToBytecodeArray();
- // Set number of parameters expected by function.
+ // Set the number of parameters expected by function.
void set_parameter_count(int number_of_params);
int parameter_count() const {
DCHECK_GE(parameter_count_, 0);
return parameter_count_;
}
- // Set number of locals required for bytecode array.
+ // Set the number of locals required for bytecode array.
void set_locals_count(int number_of_locals);
int locals_count() const {
DCHECK_GE(local_register_count_, 0);
@@ -57,7 +57,14 @@ class BytecodeArrayBuilder {
Register Parameter(int parameter_index) const;
- // Constant loads to the accumulator.
+ // Return true if the register |reg| represents a parameter or a
+ // local.
+ bool RegisterIsParameterOrLocal(Register reg) const;
+
+ // Return true if the register |reg| represents a temporary register.
+ bool RegisterIsTemporary(Register reg) const;
+
+ // Constant loads to accumulator.
BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value);
BytecodeArrayBuilder& LoadLiteral(Handle<Object> object);
BytecodeArrayBuilder& LoadUndefined();
@@ -66,7 +73,7 @@ class BytecodeArrayBuilder {
BytecodeArrayBuilder& LoadTrue();
BytecodeArrayBuilder& LoadFalse();
- // Global loads to accumulator and stores from the accumulator.
+ // Global loads to the accumulator and stores from the accumulator.
BytecodeArrayBuilder& LoadGlobal(int slot_index);
BytecodeArrayBuilder& StoreGlobal(int slot_index, LanguageMode language_mode);
@@ -140,7 +147,7 @@ class BytecodeArrayBuilder {
BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg,
Strength strength);
- // Casts
+ // Casts.
BytecodeArrayBuilder& CastAccumulatorToBoolean();
BytecodeArrayBuilder& CastAccumulatorToName();
@@ -207,9 +214,14 @@ class BytecodeArrayBuilder {
size_t GetConstantPoolEntry(Handle<Object> object);
- // Scope helpers used by TemporaryRegisterScope
int BorrowTemporaryRegister();
void ReturnTemporaryRegister(int reg_index);
+ int PrepareForConsecutiveTemporaryRegisters(size_t count);
+ void BorrowConsecutiveTemporaryRegister(int reg_index);
+ bool TemporaryRegisterIsLive(Register reg) const;
+
+ Register first_temporary_register() const;
+ Register last_temporary_register() const;
Isolate* isolate_;
Zone* zone_;
@@ -226,10 +238,11 @@ class BytecodeArrayBuilder {
int local_register_count_;
int context_register_count_;
int temporary_register_count_;
- int temporary_register_next_;
+
+ ZoneSet<int> free_temporaries_;
friend class TemporaryRegisterScope;
- DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder);
+ DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder);
};
@@ -273,19 +286,26 @@ class BytecodeLabel final {
// A stack-allocated class than allows the instantiator to allocate
// temporary registers that are cleaned up when scope is closed.
+// TODO(oth): Deprecate TemporaryRegisterScope use. Code should be
+// using result scopes as far as possible.
class TemporaryRegisterScope {
public:
explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder);
~TemporaryRegisterScope();
Register NewRegister();
+ void PrepareForConsecutiveAllocations(size_t count);
+ Register NextConsecutiveRegister();
+
private:
void* operator new(size_t size);
void operator delete(void* p);
BytecodeArrayBuilder* builder_;
- int count_;
- int last_register_index_;
+ const TemporaryRegisterScope* outer_;
+ ZoneVector<int> allocated_;
+ int next_consecutive_register_;
+ int next_consecutive_count_;
DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope);
};
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698