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

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

Issue 1288333002: [interpreter]: Update BytecodeArrayBuilder register handling. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 ccc5d5dec830d2780bbebfcfa86a3a8b132bb4cb..564ecf3fbefc82727c6a95804bf9132f0a16a034 100644
--- a/src/interpreter/bytecode-array-builder.h
+++ b/src/interpreter/bytecode-array-builder.h
@@ -17,6 +17,8 @@ class Isolate;
namespace interpreter {
+class Register;
+
class BytecodeArrayBuilder {
public:
explicit BytecodeArrayBuilder(Isolate* isolate);
@@ -26,7 +28,7 @@ class BytecodeArrayBuilder {
void set_locals_count(int number_of_locals);
int locals_count() const;
- // Constant loads to accumulator
+ // Constant loads to accumulator.
BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value);
BytecodeArrayBuilder& LoadUndefined();
BytecodeArrayBuilder& LoadNull();
@@ -34,14 +36,14 @@ class BytecodeArrayBuilder {
BytecodeArrayBuilder& LoadTrue();
BytecodeArrayBuilder& LoadFalse();
- // Register-accumulator transfers
- BytecodeArrayBuilder& LoadAccumulatorWithRegister(int reg);
- BytecodeArrayBuilder& StoreAccumulatorInRegister(int reg);
+ // Register-accumulator transfers.
+ BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg);
+ BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg);
- // Operators
- BytecodeArrayBuilder& BinaryOperation(Token::Value binop, int reg);
+ // Operators.
+ BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg);
- // Flow Control
+ // Flow Control.
BytecodeArrayBuilder& Return();
private:
@@ -56,7 +58,7 @@ class BytecodeArrayBuilder {
uint8_t operand_value) const;
int BorrowTemporaryRegister();
- void ReturnTemporaryRegister(int reg);
+ void ReturnTemporaryRegister(int reg_index);
Isolate* isolate_;
std::vector<uint8_t> bytecodes_;
@@ -70,13 +72,35 @@ class BytecodeArrayBuilder {
DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder);
};
+// An interpreter register which is located in the function's regsiter file
+// in its stack-frame.
+class Register {
+ public:
+ static const int kMaxRegisterIndex = 128;
+
+ explicit Register(int index) : index_(index) {
+ DCHECK_GE(index_, 0);
+ DCHECK_LE(index_, kMaxRegisterIndex);
+ }
+
+ int index() { return index_; }
+ uint8_t ToOperand() { return static_cast<uint8_t>(-index_); }
+ static Register FromOperand(uint8_t operand) { return Register(-operand); }
+
+ private:
+ void* operator new(size_t size);
+ void operator delete(void* p);
+
+ int index_;
+};
+
// A stack-allocated class than allows the instantiator to allocate
// temporary registers that are cleaned up when scope is closed.
class TemporaryRegisterScope {
public:
explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder);
~TemporaryRegisterScope();
- int NewRegister();
+ Register NewRegister();
private:
void* operator new(size_t size);
@@ -84,7 +108,7 @@ class TemporaryRegisterScope {
BytecodeArrayBuilder* builder_;
int count_;
- int register_;
+ int last_register_index_;
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