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

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

Issue 2369873002: [Interpreter] Replace BytecodeRegisterAllocator with a simple bump pointer. (Closed)
Patch Set: Rebase Created 4 years, 3 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.h » ('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 b6683cfd0eaf75dd0c7cfad58279694fec195f8a..d8698fe9595a62e796d27f6b0dffd59e04ed1e84 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -28,7 +28,7 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(
parameter_count_(parameter_count),
local_register_count_(locals_count),
context_register_count_(context_count),
- temporary_allocator_(zone, fixed_register_count()),
+ register_allocator_(fixed_register_count()),
bytecode_array_writer_(zone, &constant_array_builder_,
source_position_mode),
pipeline_(&bytecode_array_writer_) {
@@ -46,7 +46,8 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(
if (FLAG_ignition_reo) {
pipeline_ = new (zone) BytecodeRegisterOptimizer(
- zone, &temporary_allocator_, parameter_count, pipeline_);
+ zone, &register_allocator_, fixed_register_count(), parameter_count,
+ pipeline_);
}
return_position_ =
@@ -69,10 +70,6 @@ Register BytecodeArrayBuilder::Parameter(int parameter_index) const {
return Register::FromParameterIndex(parameter_index, parameter_count());
}
-bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const {
- return reg.is_parameter() || reg.index() < locals_count();
-}
-
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(Isolate* isolate) {
DCHECK(return_seen_in_block_);
DCHECK(!bytecode_generated_);
@@ -80,8 +77,7 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(Isolate* isolate) {
Handle<FixedArray> handler_table =
handler_table_builder()->ToHandlerTable(isolate);
- return pipeline_->ToBytecodeArray(isolate,
- fixed_and_temporary_register_count(),
+ return pipeline_->ToBytecodeArray(isolate, total_register_count(),
parameter_count(), handler_table);
}
@@ -729,45 +725,38 @@ void BytecodeArrayBuilder::EnsureReturn() {
}
BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable,
- Register receiver_args,
- size_t receiver_args_count,
+ RegisterList args,
int feedback_slot,
TailCallMode tail_call_mode) {
if (tail_call_mode == TailCallMode::kDisallow) {
Output(Bytecode::kCall, RegisterOperand(callable),
- RegisterOperand(receiver_args), UnsignedOperand(receiver_args_count),
+ RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()),
UnsignedOperand(feedback_slot));
} else {
DCHECK(tail_call_mode == TailCallMode::kAllow);
Output(Bytecode::kTailCall, RegisterOperand(callable),
- RegisterOperand(receiver_args), UnsignedOperand(receiver_args_count),
+ RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()),
UnsignedOperand(feedback_slot));
}
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor,
- Register first_arg,
- size_t arg_count,
+ RegisterList args,
int feedback_slot_id) {
- if (!first_arg.is_valid()) {
- DCHECK_EQ(0u, arg_count);
- first_arg = Register(0);
- }
Output(Bytecode::kNew, RegisterOperand(constructor),
- RegisterOperand(first_arg), UnsignedOperand(arg_count),
+ RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()),
UnsignedOperand(feedback_slot_id));
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
- Runtime::FunctionId function_id, Register first_arg, size_t arg_count) {
+ Runtime::FunctionId function_id, RegisterList args) {
DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size);
DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort);
- if (!first_arg.is_valid()) {
- DCHECK_EQ(0u, arg_count);
- first_arg = Register(0);
- }
Bytecode bytecode;
uint32_t id;
if (IntrinsicsHelper::IsSupported(function_id)) {
@@ -777,29 +766,42 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
bytecode = Bytecode::kCallRuntime;
id = static_cast<uint32_t>(function_id);
}
- Output(bytecode, id, RegisterOperand(first_arg), UnsignedOperand(arg_count));
+ Output(bytecode, id, RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()));
return *this;
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
+ Runtime::FunctionId function_id, Register arg) {
+ return CallRuntime(function_id, RegisterList(arg.index(), 1));
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
+ Runtime::FunctionId function_id) {
+ return CallRuntime(function_id, RegisterList());
+}
+
BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair(
- Runtime::FunctionId function_id, Register first_arg, size_t arg_count,
- Register first_return) {
+ Runtime::FunctionId function_id, RegisterList args, Register first_return) {
DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size);
DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort);
- if (!first_arg.is_valid()) {
- DCHECK_EQ(0u, arg_count);
- first_arg = Register(0);
- }
Output(Bytecode::kCallRuntimeForPair, static_cast<uint16_t>(function_id),
- RegisterOperand(first_arg), UnsignedOperand(arg_count),
- RegisterOperand(first_return));
+ RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()), RegisterOperand(first_return));
return *this;
}
-BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(
- int context_index, Register receiver_args, size_t receiver_args_count) {
+BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair(
+ Runtime::FunctionId function_id, Register arg, Register first_return) {
+ return CallRuntimeForPair(function_id, RegisterList(arg.index(), 1),
+ first_return);
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index,
+ RegisterList args) {
Output(Bytecode::kCallJSRuntime, UnsignedOperand(context_index),
- RegisterOperand(receiver_args), UnsignedOperand(receiver_args_count));
+ RegisterOperand(args.first_register()),
+ UnsignedOperand(args.register_count()));
return *this;
}
@@ -832,10 +834,6 @@ void BytecodeArrayBuilder::SetReturnPosition() {
latest_source_info_.MakeStatementPosition(return_position_);
}
-bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
- return temporary_register_allocator()->RegisterIsLive(reg);
-}
-
bool BytecodeArrayBuilder::RegisterIsValid(Register reg) const {
if (!reg.is_valid()) {
return false;
@@ -850,7 +848,7 @@ bool BytecodeArrayBuilder::RegisterIsValid(Register reg) const {
} else if (reg.index() < fixed_register_count()) {
return true;
} else {
- return TemporaryRegisterIsLive(reg);
+ return register_allocator()->RegisterIsLive(reg);
}
}
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698