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

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

Issue 1303403004: [Interpreter] Add support for parameter variables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_add_bytecodes
Patch Set: Address review comments 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 | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index bb1c69bd87ec327a248887467b8f52a1a6fe2c0e..ebab9f15b14e8a5f35cd10fce8f31154d2697892 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -11,6 +11,7 @@ namespace interpreter {
BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate)
: isolate_(isolate),
bytecode_generated_(false),
+ parameter_count_(-1),
local_register_count_(-1),
temporary_register_count_(0),
temporary_register_next_(0) {}
@@ -25,14 +26,30 @@ void BytecodeArrayBuilder::set_locals_count(int number_of_locals) {
int BytecodeArrayBuilder::locals_count() const { return local_register_count_; }
+void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) {
+ parameter_count_ = number_of_parameters;
+}
+
+
+int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; }
+
+
+Register BytecodeArrayBuilder::Parameter(int param_index) {
+ DCHECK_GE(param_index, 0);
+ DCHECK_LT(param_index, parameter_count_);
+ return Register(kLastParamRegisterIndex - parameter_count_ + param_index + 1);
+}
+
+
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
DCHECK_EQ(bytecode_generated_, false);
+ DCHECK_GE(parameter_count_, 0);
DCHECK_GE(local_register_count_, 0);
int bytecode_size = static_cast<int>(bytecodes_.size());
int register_count = local_register_count_ + temporary_register_count_;
int frame_size = register_count * kPointerSize;
Handle<BytecodeArray> output = isolate_->factory()->NewBytecodeArray(
- bytecode_size, &bytecodes_.front(), frame_size);
+ bytecode_size, &bytecodes_.front(), frame_size, parameter_count_);
bytecode_generated_ = true;
return output;
}
@@ -135,9 +152,12 @@ bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
return false;
case OperandType::kImm8:
return true;
- case OperandType::kReg:
- return Register::FromOperand(operand_value).index() <
- temporary_register_next_;
+ case OperandType::kReg: {
+ int reg_index = Register::FromOperand(operand_value).index();
+ return (reg_index >= 0 && reg_index < temporary_register_next_) ||
+ (reg_index <= kLastParamRegisterIndex &&
+ reg_index > kLastParamRegisterIndex - parameter_count_);
+ }
}
UNREACHABLE();
return false;
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698