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

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

Issue 1283313003: [interpreter]: Update BytecodeArrayBuilder register handling. (Closed) Base URL: ssh://rmcilroy.lon.corp.google.com///usr/local/google/code/v8_full/v8@master
Patch Set: Fix define in OperandTypeToString 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') | src/interpreter/bytecodes.h » ('J')
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..70b881596419c1f6e1f850e7e88a7120c75e3648 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,34 @@ 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_LE(index_, kMaxRegisterIndex);
oth 2015/08/13 10:29:55 Probably worth having a lower bounds DCHECK too.
rmcilroy 2015/08/13 10:44:22 Done.
+ }
+
+ 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 +107,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') | src/interpreter/bytecodes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698