Fixed bytecode generation of spread operation

During spread operation, after VisitForAccumulatorValue,
set the position of the current expression again

Bug: chromium:929844
Change-Id: I6e9ca87587789f9cb21e939d4405414c8170b232
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2379531
Commit-Queue: HyeockJin Kim <kherootz@gmail.com>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69677}
This commit is contained in:
HyeockJinKim 2020-08-27 22:19:10 +09:00 committed by Commit Bot
parent 78b04f24d0
commit 02a42939e7
6 changed files with 9 additions and 6 deletions

View File

@ -104,6 +104,7 @@ Henrique Ferreiro <henrique.ferreiro@gmail.com>
Hirofumi Mako <mkhrfm@gmail.com>
Honggyu Kim <honggyu.kp@gmail.com>
Huáng Jùnliàng <jlhwung@gmail.com>
HyeockJin Kim <kherootz@gmail.com>
Iain Ireland <iireland@mozilla.com>
Ingvar Stepanyan <me@rreverser.com>
Ioseb Dzmanashvili <ioseb.dzmanashvili@gmail.com>

View File

@ -2921,6 +2921,7 @@ void BytecodeGenerator::BuildCreateArrayLiteral(
// If we have a leading spread, use CreateArrayFromIterable to create
// an array from it and then add the remaining components to that array.
VisitForAccumulatorValue(*current);
builder()->SetExpressionPosition((*current)->AsSpread()->expression());
builder()->CreateArrayFromIterable().StoreAccumulatorInRegister(array);
if (++current != end) {
@ -3021,6 +3022,7 @@ void BytecodeGenerator::BuildCreateArrayLiteral(
builder()->SetExpressionAsStatementPosition(
subexpr->AsSpread()->expression());
VisitForAccumulatorValue(subexpr->AsSpread()->expression());
builder()->SetExpressionPosition(subexpr->AsSpread()->expression());
IteratorRecord iterator = BuildGetIteratorRecord(IteratorType::kNormal);
Register value = register_allocator()->NewRegister();

View File

@ -123,7 +123,7 @@ bytecode array length: 8
bytecodes: [
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(0),
/* 52 S> */ B(CreateArrayFromIterable),
/* 64 S> */ B(CreateArrayFromIterable),
/* 68 S> */ B(Return),
]
constant pool: [
@ -146,7 +146,7 @@ bytecodes: [
B(Star), R(2),
B(LdaConstant), U8(2),
/* 67 S> */ B(Star), R(1),
B(GetIterator), R(0), U8(2), U8(4),
/* 67 E> */ B(GetIterator), R(0), U8(2), U8(4),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(4),
@ -188,7 +188,7 @@ bytecode array length: 24
bytecodes: [
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(0),
/* 52 S> */ B(CreateArrayFromIterable),
/* 64 S> */ B(CreateArrayFromIterable),
B(Star), R(2),
B(LdaNamedProperty), R(2), U8(1), U8(1),
B(Star), R(1),

View File

@ -77,7 +77,7 @@ bytecodes: [
B(Star), R(3),
/* 49 S> */ B(CreateArrayLiteral), U8(4), U8(5), U8(37),
B(Star), R(7),
B(GetIterator), R(7), U8(6), U8(8),
/* 49 E> */ B(GetIterator), R(7), U8(6), U8(8),
B(Mov), R(0), R(2),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),

View File

@ -111,7 +111,7 @@ bytecodes: [
B(Star), R(2),
/* 101 S> */ B(CreateArrayLiteral), U8(5), U8(1), U8(37),
B(Star), R(6),
B(GetIterator), R(6), U8(2), U8(4),
/* 101 E> */ B(GetIterator), R(6), U8(2), U8(4),
B(Mov), R(4), R(1),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),

View File

@ -108,7 +108,7 @@ bytecodes: [
B(Ldar), R(6),
B(Inc), U8(3),
/* 152 S> */ B(Star), R(6),
B(GetIterator), R(3), U8(4), U8(6),
/* 152 E> */ B(GetIterator), R(3), U8(4), U8(6),
B(Mov), R(1), R(4),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),