Commit 7e237ad3 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Use RegisterList for kRegTriple and kRegPair operands.

BUG=v8:4280

Review-Url: https://codereview.chromium.org/2384123002
Cr-Commit-Position: refs/heads/master@{#40002}
parent 479e8f23
......@@ -652,9 +652,10 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Debugger() {
}
BytecodeArrayBuilder& BytecodeArrayBuilder::ForInPrepare(
Register receiver, Register cache_info_triple) {
Register receiver, RegisterList cache_info_triple) {
DCHECK_EQ(3, cache_info_triple.register_count());
Output(Bytecode::kForInPrepare, RegisterOperand(receiver),
RegisterOperand(cache_info_triple));
RegisterOperand(cache_info_triple.first_register()));
return *this;
}
......@@ -666,10 +667,12 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::ForInContinue(
}
BytecodeArrayBuilder& BytecodeArrayBuilder::ForInNext(
Register receiver, Register index, Register cache_type_array_pair,
Register receiver, Register index, RegisterList cache_type_array_pair,
int feedback_slot) {
DCHECK_EQ(2, cache_type_array_pair.register_count());
Output(Bytecode::kForInNext, RegisterOperand(receiver),
RegisterOperand(index), RegisterOperand(cache_type_array_pair),
RegisterOperand(index),
RegisterOperand(cache_type_array_pair.first_register()),
UnsignedOperand(feedback_slot));
return *this;
}
......@@ -774,19 +777,22 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
}
BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair(
Runtime::FunctionId function_id, RegisterList args, Register first_return) {
Runtime::FunctionId function_id, RegisterList args,
RegisterList return_pair) {
DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size);
DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort);
DCHECK_EQ(2, return_pair.register_count());
Output(Bytecode::kCallRuntimeForPair, static_cast<uint16_t>(function_id),
RegisterOperand(args.first_register()),
UnsignedOperand(args.register_count()), RegisterOperand(first_return));
UnsignedOperand(args.register_count()),
RegisterOperand(return_pair.first_register()));
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair(
Runtime::FunctionId function_id, Register arg, Register first_return) {
Runtime::FunctionId function_id, Register arg, RegisterList return_pair) {
return CallRuntimeForPair(function_id, RegisterList(arg.index(), 1),
first_return);
return_pair);
}
BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index,
......
......@@ -205,13 +205,16 @@ class BytecodeArrayBuilder final : public ZoneObject {
// Call the runtime function with |function_id| and arguments |args|, that
// returns a pair of values. The return values will be returned in
// <first_return> and <first_return + 1>.
// |return_pair|.
BytecodeArrayBuilder& CallRuntimeForPair(Runtime::FunctionId function_id,
RegisterList args,
Register first_return);
// Call the runtime function with |function_id| with single argument |arg|.
RegisterList return_pair);
// Call the runtime function with |function_id| with single argument |arg|
// that returns a pair of values. The return values will be returned in
// |return_pair|.
BytecodeArrayBuilder& CallRuntimeForPair(Runtime::FunctionId function_id,
Register arg, Register first_return);
Register arg,
RegisterList return_pair);
// Call the JS runtime function with |context_index| and arguments |args|.
BytecodeArrayBuilder& CallJSRuntime(int context_index, RegisterList args);
......@@ -265,10 +268,10 @@ class BytecodeArrayBuilder final : public ZoneObject {
// Complex flow control.
BytecodeArrayBuilder& ForInPrepare(Register receiver,
Register cache_info_triple);
RegisterList cache_info_triple);
BytecodeArrayBuilder& ForInContinue(Register index, Register cache_length);
BytecodeArrayBuilder& ForInNext(Register receiver, Register index,
Register cache_type_array_pair,
RegisterList cache_type_array_pair,
int feedback_slot);
BytecodeArrayBuilder& ForInStep(Register index);
......
......@@ -1202,7 +1202,7 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Used as kRegTriple and kRegPair in ForInPrepare and ForInNext.
RegisterList triple = register_allocator()->NewRegisterList(3);
Register cache_length = triple[2];
builder()->ForInPrepare(receiver, triple.first_register());
builder()->ForInPrepare(receiver, triple);
// Set up loop counter
Register index = register_allocator()->NewRegister();
......@@ -1215,7 +1215,7 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
builder()->ForInContinue(index, cache_length);
loop_builder.BreakIfFalse();
FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
builder()->ForInNext(receiver, index, triple.first_register(),
builder()->ForInNext(receiver, index, triple.Truncate(2),
feedback_index(slot));
loop_builder.ContinueIfUndefined();
VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot());
......@@ -2378,11 +2378,13 @@ void BytecodeGenerator::VisitCall(Call* expr) {
// Call %LoadLookupSlotForCall to get the callee and receiver.
DCHECK(Register::AreContiguous(callee, receiver));
RegisterList result_pair(callee.index(), 2);
Variable* variable = callee_expr->AsVariableProxy()->var();
builder()
->LoadLiteral(variable->name())
.StoreAccumulatorInRegister(name)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name, callee);
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name,
result_pair);
break;
}
// Fall through.
......
......@@ -34,6 +34,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
Register other(reg.index() + 1);
Register wide(128);
RegisterList reg_list;
RegisterList pair(0, 2), triple(0, 3);
// Emit argument creation operations.
builder.CreateArguments(CreateArgumentsType::kMappedArguments)
......@@ -127,7 +128,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.Call(reg, reg_list, 1)
.Call(reg, reg_list, 1, TailCallMode::kAllow)
.CallRuntime(Runtime::kIsArray, reg)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, reg_list, other)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, reg_list, pair)
.CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg_list);
// Emit binary operator invocations.
......@@ -261,13 +262,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
BytecodeLabel after_rethrow;
builder.ReThrow().Bind(&after_rethrow);
builder.ForInPrepare(reg, reg)
builder.ForInPrepare(reg, triple)
.ForInContinue(reg, reg)
.ForInNext(reg, reg, reg, 1)
.ForInStep(reg);
builder.ForInPrepare(reg, wide)
.ForInContinue(reg, other)
.ForInNext(wide, wide, wide, 1024)
.ForInNext(reg, reg, pair, 1)
.ForInStep(reg);
// Wide constant pool loads
......
......@@ -31,6 +31,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
Smi* smi_1 = Smi::FromInt(-65536);
Register reg_0(0);
Register reg_1(1);
RegisterList pair(0, 2);
RegisterList triple(0, 3);
Register param = Register::FromParameterIndex(2, builder.parameter_count());
Handle<String> name = factory->NewStringFromStaticChars("abc");
int name_index = 2;
......@@ -54,8 +56,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
.LoadNamedProperty(reg_1, name, feedback_slot)
.BinaryOperation(Token::Value::ADD, reg_0, 3)
.StoreAccumulatorInRegister(param)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, reg_0)
.ForInPrepare(reg_0, reg_0)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair)
.ForInPrepare(reg_0, triple)
.CallRuntime(Runtime::kLoadIC_Miss, reg_0)
.Debugger()
.LoadGlobal(0x10000000, TypeofMode::NOT_INSIDE_TYPEOF)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment