Commit ef2f091f authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[ignition] Avoid possible unnecessary Mov around GetIterator

Wrap the obj and method registers in BuildGetIterator in a register
allocation scope, so that they don't get materialised before the
JumpIfJSReceiver jump if they don't have to.

Bug: v8:9649
Change-Id: I8dfdd06a23c396124c495b5cb83c078080f1a7c9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1768583
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63393}
parent 02becb16
......@@ -14,6 +14,7 @@
#include "src/interpreter/bytecode-jump-table.h"
#include "src/interpreter/bytecode-label.h"
#include "src/interpreter/bytecode-register-allocator.h"
#include "src/interpreter/bytecode-register.h"
#include "src/interpreter/control-flow-builders.h"
#include "src/logging/log.h"
#include "src/objects/debug-objects.h"
......@@ -5300,11 +5301,12 @@ void BytecodeGenerator::VisitImportCallExpression(ImportCallExpression* expr) {
}
void BytecodeGenerator::BuildGetIterator(IteratorType hint) {
RegisterList args = register_allocator()->NewRegisterList(1);
Register method = register_allocator()->NewRegister();
Register obj = args[0];
if (hint == IteratorType::kAsync) {
RegisterAllocationScope scope(this);
Register obj = register_allocator()->NewRegister();
Register method = register_allocator()->NewRegister();
// Set method to GetMethod(obj, @@asyncIterator)
builder()->StoreAccumulatorInRegister(obj).LoadAsyncIteratorProperty(
obj, feedback_index(feedback_spec()->AddLoadICSlot()));
......@@ -5314,7 +5316,8 @@ void BytecodeGenerator::BuildGetIterator(IteratorType hint) {
// Let iterator be Call(method, obj)
builder()->StoreAccumulatorInRegister(method).CallProperty(
method, args, feedback_index(feedback_spec()->AddCallICSlot()));
method, RegisterList(obj),
feedback_index(feedback_spec()->AddCallICSlot()));
// If Type(iterator) is not Object, throw a TypeError exception.
builder()->JumpIfJSReceiver(&done);
......@@ -5328,7 +5331,7 @@ void BytecodeGenerator::BuildGetIterator(IteratorType hint) {
.StoreAccumulatorInRegister(method);
// Let syncIterator be Call(syncMethod, obj)
builder()->CallProperty(method, args,
builder()->CallProperty(method, RegisterList(obj),
feedback_index(feedback_spec()->AddCallICSlot()));
// Return CreateAsyncFromSyncIterator(syncIterator)
......@@ -5339,15 +5342,22 @@ void BytecodeGenerator::BuildGetIterator(IteratorType hint) {
builder()->Bind(&done);
} else {
// Let method be GetMethod(obj, @@iterator).
builder()
->StoreAccumulatorInRegister(obj)
.GetIterator(obj, feedback_index(feedback_spec()->AddLoadICSlot()))
.StoreAccumulatorInRegister(method);
{
RegisterAllocationScope scope(this);
// Let iterator be Call(method, obj).
builder()->CallProperty(method, args,
feedback_index(feedback_spec()->AddCallICSlot()));
Register obj = register_allocator()->NewRegister();
Register method = register_allocator()->NewRegister();
// Let method be GetMethod(obj, @@iterator).
builder()
->StoreAccumulatorInRegister(obj)
.GetIterator(obj, feedback_index(feedback_spec()->AddLoadICSlot()))
.StoreAccumulatorInRegister(method);
// Let iterator be Call(method, obj).
builder()->CallProperty(method, RegisterList(obj),
feedback_index(feedback_spec()->AddCallICSlot()));
}
// If Type(iterator) is not Object, throw a TypeError exception.
BytecodeLabel no_type_error;
......
......@@ -141,9 +141,9 @@ handlers: [
snippet: "
var a = [ 1, 2 ]; return [ 0, ...a ];
"
frame size: 8
frame size: 7
parameter count: 1
bytecode array length: 83
bytecode array length: 80
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
......@@ -155,19 +155,18 @@ bytecodes: [
B(GetIterator), R(0), U8(2),
B(Star), R(6),
B(CallProperty0), R(6), R(0), U8(4),
B(Mov), R(0), R(5),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(4),
B(LdaNamedProperty), R(4), U8(3), U8(6),
B(Star), R(3),
B(CallProperty0), R(3), R(4), U8(15),
B(Star), R(7),
B(Star), R(5),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(LdaNamedProperty), R(7), U8(4), U8(17),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
B(LdaNamedProperty), R(5), U8(4), U8(17),
B(JumpIfToBooleanTrue), U8(19),
B(LdaNamedProperty), R(7), U8(5), U8(8),
B(LdaNamedProperty), R(5), U8(5), U8(8),
B(StaInArrayLiteral), R(2), R(1), U8(13),
B(Ldar), R(1),
B(Inc), U8(12),
......
......@@ -65,7 +65,7 @@ handlers: [
snippet: "
Math.max(0, ...[1, 2, 3], 4);
"
frame size: 10
frame size: 9
parameter count: 1
bytecode array length: 106
bytecodes: [
......@@ -90,12 +90,12 @@ bytecodes: [
B(LdaNamedProperty), R(6), U8(5), U8(10),
B(Star), R(5),
B(CallProperty0), R(5), R(6), U8(19),
B(Star), R(9),
B(Star), R(7),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1),
B(LdaNamedProperty), R(9), U8(6), U8(21),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(LdaNamedProperty), R(7), U8(6), U8(21),
B(JumpIfToBooleanTrue), U8(19),
B(LdaNamedProperty), R(9), U8(7), U8(12),
B(LdaNamedProperty), R(7), U8(7), U8(12),
B(StaInArrayLiteral), R(4), R(3), U8(17),
B(Ldar), R(3),
B(Inc), U8(16),
......
......@@ -98,7 +98,7 @@ snippet: "
function* f() { for (let x of [42]) yield x }
f();
"
frame size: 17
frame size: 15
parameter count: 1
bytecode array length: 258
bytecodes: [
......@@ -128,83 +128,83 @@ bytecodes: [
B(LdaNamedProperty), R(5), U8(5), U8(5),
B(Star), R(4),
B(LdaFalse),
B(Star), R(8),
B(Mov), R(context), R(11),
B(Star), R(6),
B(Mov), R(context), R(9),
B(LdaTrue),
B(Star), R(8),
B(Star), R(6),
/* 25 S> */ B(CallProperty0), R(4), R(5), U8(7),
B(Star), R(12),
B(Star), R(10),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(LdaNamedProperty), R(12), U8(6), U8(9),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1),
B(LdaNamedProperty), R(10), U8(6), U8(9),
B(JumpIfToBooleanTrue), U8(64),
B(LdaNamedProperty), R(12), U8(7), U8(11),
B(Star), R(12),
B(LdaNamedProperty), R(10), U8(7), U8(11),
B(Star), R(10),
B(LdaFalse),
B(Star), R(8),
B(Mov), R(12), R(1),
B(Star), R(6),
B(Mov), R(10), R(1),
/* 16 E> */ B(StackCheck),
/* 25 S> */ B(Mov), R(1), R(3),
/* 36 S> */ B(LdaFalse),
B(Star), R(14),
B(Mov), R(3), R(13),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(13), U8(2),
/* 36 E> */ B(SuspendGenerator), R(0), R(0), U8(13), U8(1),
B(ResumeGenerator), R(0), R(0), U8(13),
B(Star), R(13),
B(Star), R(12),
B(Mov), R(3), R(11),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2),
/* 36 E> */ B(SuspendGenerator), R(0), R(0), U8(11), U8(1),
B(ResumeGenerator), R(0), R(0), U8(11),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0),
B(Ldar), R(13),
B(Ldar), R(11),
/* 36 E> */ B(Throw),
B(LdaSmi), I8(1),
B(Star), R(9),
B(Mov), R(13), R(10),
B(Star), R(7),
B(Mov), R(11), R(8),
B(Jump), U8(20),
B(Ldar), R(13),
B(Ldar), R(11),
B(JumpLoop), U8(81), I8(0),
B(LdaSmi), I8(-1),
B(Star), R(10),
B(Star), R(9),
B(Star), R(8),
B(Star), R(7),
B(Jump), U8(7),
B(Star), R(10),
B(Star), R(8),
B(LdaZero),
B(Star), R(9),
B(Star), R(7),
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(11),
B(Ldar), R(8),
B(Star), R(9),
B(Ldar), R(6),
B(JumpIfToBooleanTrue), U8(58),
B(LdaNamedProperty), R(5), U8(10), U8(13),
B(Star), R(13),
B(Star), R(11),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(14),
B(Mov), R(context), R(12),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(15),
B(Star), R(13),
B(LdaConstant), U8(11),
B(Star), R(16),
B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2),
B(Star), R(14),
B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2),
B(Throw),
B(CallProperty0), R(13), R(5), U8(15),
B(CallProperty0), R(11), R(5), U8(15),
B(JumpIfJSReceiver), U8(21),
B(Star), R(15),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1),
B(Jump), U8(12),
B(Star), R(14),
B(Star), R(12),
B(LdaZero),
B(TestReferenceEqual), R(9),
B(TestReferenceEqual), R(7),
B(JumpIfTrue), U8(5),
B(Ldar), R(14),
B(Ldar), R(12),
B(ReThrow),
B(Ldar), R(11),
B(SetPendingMessage),
B(Ldar), R(9),
B(SetPendingMessage),
B(Ldar), R(7),
B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(10),
B(Ldar), R(8),
B(ReThrow),
B(Ldar), R(10),
B(Ldar), R(8),
/* 44 S> */ B(Return),
B(LdaUndefined),
/* 44 S> */ B(Return),
......@@ -236,7 +236,7 @@ snippet: "
function* f() { yield* g() }
f();
"
frame size: 9
frame size: 8
parameter count: 1
bytecode array length: 210
bytecodes: [
......@@ -277,24 +277,24 @@ bytecodes: [
B(Jump), U8(63),
B(LdaNamedProperty), R(3), U8(8), U8(12),
B(JumpIfUndefinedOrNull), U8(11),
B(Star), R(8),
B(CallProperty1), R(8), R(3), R(4), U8(14),
B(Star), R(6),
B(CallProperty1), R(6), R(3), R(4), U8(14),
B(Jump), U8(48),
B(Ldar), R(4),
/* 54 S> */ B(Return),
B(LdaNamedProperty), R(3), U8(9), U8(16),
B(JumpIfUndefinedOrNull), U8(11),
B(Star), R(8),
B(CallProperty1), R(8), R(3), R(4), U8(18),
B(Star), R(6),
B(CallProperty1), R(6), R(3), R(4), U8(18),
B(Jump), U8(30),
B(LdaNamedProperty), R(3), U8(8), U8(20),
B(JumpIfUndefinedOrNull), U8(19),
B(Star), R(8),
B(CallProperty0), R(8), R(3), U8(22),
B(Star), R(6),
B(CallProperty0), R(6), R(3), U8(22),
B(Jump), U8(2),
B(JumpIfJSReceiver), U8(9),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1),
B(Star), R(6),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1),
B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0),
B(Star), R(1),
B(JumpIfJSReceiver), U8(7),
......@@ -302,8 +302,8 @@ bytecodes: [
B(LdaNamedProperty), R(1), U8(10), U8(24),
B(JumpIfToBooleanTrue), U8(24),
B(Ldar), R(1),
/* 43 E> */ B(SuspendGenerator), R(0), R(0), U8(8), U8(1),
B(ResumeGenerator), R(0), R(0), U8(8),
/* 43 E> */ B(SuspendGenerator), R(0), R(0), U8(6), U8(1),
B(ResumeGenerator), R(0), R(0), U8(6),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(Star), R(2),
......
......@@ -92,7 +92,7 @@ snippet: "
class A { constructor(...args) { this.args = args; } }
new A(0, ...[1, 2, 3], 4);
"
frame size: 10
frame size: 9
parameter count: 1
bytecode array length: 130
bytecodes: [
......@@ -127,12 +127,12 @@ bytecodes: [
B(LdaNamedProperty), R(6), U8(6), U8(6),
B(Star), R(5),
B(CallProperty0), R(5), R(6), U8(15),
B(Star), R(9),
B(Star), R(7),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1),
B(LdaNamedProperty), R(9), U8(7), U8(17),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(LdaNamedProperty), R(7), U8(7), U8(17),
B(JumpIfToBooleanTrue), U8(19),
B(LdaNamedProperty), R(9), U8(8), U8(8),
B(LdaNamedProperty), R(7), U8(8), U8(8),
B(StaInArrayLiteral), R(4), R(3), U8(13),
B(Ldar), R(3),
B(Inc), U8(12),
......
......@@ -91,9 +91,9 @@ snippet: "
test = new B(1, 2, 3).constructor;
})();
"
frame size: 13
frame size: 12
parameter count: 1
bytecode array length: 127
bytecode array length: 124
bytecodes: [
B(CreateRestParameter),
B(Star), R(3),
......@@ -114,7 +114,6 @@ bytecodes: [
B(GetIterator), R(3), U8(4),
B(Star), R(11),
B(CallProperty0), R(11), R(3), U8(6),
B(Mov), R(3), R(10),
B(Mov), R(1), R(4),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
......@@ -122,12 +121,12 @@ bytecodes: [
B(LdaNamedProperty), R(9), U8(0), U8(8),
B(Star), R(8),
B(CallProperty0), R(8), R(9), U8(14),
B(Star), R(12),
B(Star), R(10),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(LdaNamedProperty), R(12), U8(1), U8(16),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1),
B(LdaNamedProperty), R(10), U8(1), U8(16),
B(JumpIfToBooleanTrue), U8(19),
B(LdaNamedProperty), R(12), U8(2), U8(10),
B(LdaNamedProperty), R(10), U8(2), U8(10),
B(StaInArrayLiteral), R(7), R(6), U8(1),
B(Ldar), R(6),
B(Inc), U8(3),
......
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