Commit 8d34a6f4 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[graph-builder] Fix parameter index access in VisitSuspendGenerator

The second argument of FromParameterIndex should be the parameter count, including the receiver.

Previously it worked by chance, because the code was trying to access the receiver but did not include it in the parameter count, accessing the first argument. This does not work anymore when the arguments are reversed (V8_REVERSE_JSARGS).

Change-Id: I8ca9054a99d074c130f9a9b444e7b8a379840991
Bug: v8:10201
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2282531Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68742}
parent a53778ba
......@@ -3623,8 +3623,7 @@ void BytecodeGraphBuilder::VisitSuspendGenerator() {
// Store the parameters.
for (int i = 0; i < parameter_count_without_receiver; i++) {
value_inputs[3 + count_written++] =
environment()->LookupRegister(interpreter::Register::FromParameterIndex(
i, parameter_count_without_receiver));
environment()->LookupRegister(bytecode_iterator().GetParameter(i));
}
// Store the registers.
......
......@@ -190,6 +190,18 @@ FeedbackSlot BytecodeArrayAccessor::GetSlotOperand(int operand_index) const {
return FeedbackVector::ToSlot(index);
}
Register BytecodeArrayAccessor::GetReceiver() const {
return Register::FromParameterIndex(0, bytecode_array()->parameter_count());
}
Register BytecodeArrayAccessor::GetParameter(int parameter_index) const {
DCHECK_GE(parameter_index, 0);
// The parameter indices are shifted by 1 (receiver is the
// first entry).
return Register::FromParameterIndex(parameter_index + 1,
bytecode_array()->parameter_count());
}
Register BytecodeArrayAccessor::GetRegisterOperand(int operand_index) const {
OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index);
......
......@@ -109,6 +109,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayAccessor {
int32_t GetImmediateOperand(int operand_index) const;
uint32_t GetIndexOperand(int operand_index) const;
FeedbackSlot GetSlotOperand(int operand_index) const;
Register GetReceiver() const;
Register GetParameter(int parameter_index) const;
uint32_t GetRegisterCountOperand(int operand_index) const;
Register GetRegisterOperand(int operand_index) const;
int GetRegisterOperandRange(int operand_index) const;
......
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