Skip to content

Truly independent web browser

LibJS: Simplify await completion bytecode

Shannon Boothc6ce89da4a73
diff --git a/Libraries/LibJS/Rust/src/bytecode/codegen/generators.rs b/Libraries/LibJS/Rust/src/bytecode/codegen/generators.rs
index 76863dc89d9..e1b65ba6b38 100644
--- a/Libraries/LibJS/Rust/src/bytecode/codegen/generators.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/codegen/generators.rs
@@ -53,8 +53,6 @@ pub(super) fn generate_await_of_value(generator: &mut Generator<'_>, value: &Sco
let received_completion = generator.allocate_register();
let received_completion_type = generator.allocate_register();
let received_completion_value = generator.allocate_register();
- let acc = accumulator(generator);
- generator.emit_mov(&received_completion, &acc);
generate_await_with_completions(
generator,
value,
@@ -195,16 +193,15 @@ pub(super) fn generate_await_with_completions(
let normal_block = generator.new_label();
let throw_block = generator.new_label();
- let is_normal = generator.allocate_register();
let normal_type = generator.add_constant_number(f64::from(CompletionType::Normal as u8));
let arith_feedback = generator.next_arith_feedback();
- generator.emit(op::StrictlyEquals {
+ generator.emit(op::JumpStrictlyEquals {
arith_feedback,
- dst: is_normal.operand(),
lhs: received_completion_type.operand(),
rhs: normal_type.operand(),
+ true_target: normal_block,
+ false_target: throw_block,
});
- generator.emit_jump_if(&is_normal, normal_block, throw_block);
generator.bind_reachable_label(throw_block);
generator.emit(op::Throw {
@@ -814,8 +811,6 @@ pub(super) fn emit_dispose_resources(
generator.emit_jump_if(&done, done_block, await_block);
generator.bind_reachable_label(await_block);
- let acc = generator.scoped_operand(Operand::register(Register::ACCUMULATOR));
- generator.emit_mov(&await_completion, &acc);
generator.emit(op::Await {
continuation_label: continuation_block,
argument: awaited_value.operand(),
diff --git a/Tests/LibJS/Bytecode/expected/async-await-in-try-catch.txt b/Tests/LibJS/Bytecode/expected/async-await-in-try-catch.txt
index 993463af14d..e7564e4dde3 100644
--- a/Tests/LibJS/Bytecode/expected/async-await-in-try-catch.txt
+++ b/Tests/LibJS/Bytecode/expected/async-await-in-try-catch.txt
@@ -13,8 +13,8 @@ block0:
[ 18] End value:reg5
-f$801a8a71 async-await-in-try-catch.js:2:5
- Registers: 10
+f$a1d5011b async-await-in-try-catch.js:2:5
+ Registers: 9
Blocks: 7
Locals: e~0
Constants:
@@ -28,32 +28,30 @@ block0:
block1:
[ 3] EnterObjectEnvironment dst:reg5, object:arg0
- [ 6] Mov dst:reg6, src:reg0
- [ 9] Await continuation_label:block2, argument:Int32(1)
+ [ 6] Await continuation_label:block2, argument:Int32(1)
block2:
- [ f] Mov dst:reg6, src:reg0
- [ 12] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ 16] StrictlyEqualsRhsInt32 arith_feedback:0, dst:reg9, lhs:reg7, rhs:1
- [ 1f] JumpIf condition:reg9, true_target:block4, false_target:block3
+ [ c] Mov dst:reg6, src:reg0
+ [ f] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 13] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg7, rhs:1, true_target:block4, false_target:block3
block3:
- [ 29] Throw src:reg8
+ [ 23] Throw src:reg8
block4:
- [ 2b] Mov dst:reg6, src:reg8
- [ 2e] SetLexicalEnvironment environment:reg4
- [ 30] Jump target:block6
+ [ 25] Mov dst:reg6, src:reg8
+ [ 28] SetLexicalEnvironment environment:reg4
+ [ 2a] Jump target:block6
block5:
- [ 35] Catch value_feedback:0, dst:reg5
- [ 39] SetLexicalEnvironment environment:reg4
- [ 3b] Mov dst:e~0, src:<Empty>
- [ 3e] Mov dst:e~0, src:reg5
- [ 41] Jump target:block6
+ [ 2f] Catch value_feedback:0, dst:reg5
+ [ 33] SetLexicalEnvironment environment:reg4
+ [ 35] Mov dst:e~0, src:<Empty>
+ [ 38] Mov dst:e~0, src:reg5
+ [ 3b] Jump target:block6
block6:
- [ 46] Yield value:Undefined
+ [ 40] Yield value:Undefined
Exception handlers:
- [ 3 .. 35] => handler block5
+ [ 3 .. 2f] => handler block5
diff --git a/Tests/LibJS/Bytecode/expected/async-await.txt b/Tests/LibJS/Bytecode/expected/async-await.txt
index facc6e81e1c..6e7adc48b8c 100644
--- a/Tests/LibJS/Bytecode/expected/async-await.txt
+++ b/Tests/LibJS/Bytecode/expected/async-await.txt
@@ -12,8 +12,8 @@ block0:
[ 13] End value:reg5
-f$cd3b914e async-await.js:7:5
- Registers: 10
+f$ec3216e8 async-await.js:7:5
+ Registers: 9
Blocks: 4
Constants:
[0] = Int32(42)
@@ -23,18 +23,16 @@ block0:
[ 1] GetGlobal value_feedback:0, dst:reg5, `Promise`
[ 9] GetById dst:reg6, base:reg5, `resolve`
[ 10] Call call_feedback:0, dst:reg5, callee:reg6, this_value:reg5, arguments:[Int32(42)]
- [ 18] Mov dst:reg6, src:reg0
- [ 1b] Await continuation_label:block1, argument:reg5
+ [ 18] Await continuation_label:block1, argument:reg5
block1:
- [ 21] Mov dst:reg6, src:reg0
- [ 24] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ 28] StrictlyEqualsRhsInt32 arith_feedback:0, dst:reg9, lhs:reg7, rhs:1
- [ 31] JumpIf condition:reg9, true_target:block3, false_target:block2
+ [ 1e] Mov dst:reg6, src:reg0
+ [ 21] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 25] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg7, rhs:1, true_target:block3, false_target:block2
block2:
- [ 3b] Throw src:reg8
+ [ 35] Throw src:reg8
block3:
- [ 3d] Mov dst:reg5, src:reg8
- [ 40] Yield value:reg5
+ [ 37] Mov dst:reg5, src:reg8
+ [ 3a] Yield value:reg5
diff --git a/Tests/LibJS/Bytecode/expected/async-generator-yield-await.txt b/Tests/LibJS/Bytecode/expected/async-generator-yield-await.txt
index 3a029b15444..b2ab0934546 100644
--- a/Tests/LibJS/Bytecode/expected/async-generator-yield-await.txt
+++ b/Tests/LibJS/Bytecode/expected/async-generator-yield-await.txt
@@ -13,8 +13,8 @@ block0:
[ 14] End value:reg5
-f$2d76a1c1 async-generator-yield-await.js:4:5
- Registers: 14
+f$5eac5b38 async-generator-yield-await.js:4:5
+ Registers: 13
Blocks: 17
Constants:
[0] = Undefined
@@ -24,69 +24,66 @@ block0:
[ 1] Yield continuation_label:block1, value:Undefined
block1:
- [ 8] Mov dst:reg5, src:reg0
- [ b] Await continuation_label:block2, argument:arg0
+ [ 8] Await continuation_label:block2, argument:arg0
block2:
- [ 11] Mov dst:reg5, src:reg0
- [ 14] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
- [ 18] StrictlyEqualsRhsInt32 arith_feedback:0, dst:reg8, lhs:reg6, rhs:1
- [ 21] JumpIf condition:reg8, true_target:block4, false_target:block3
+ [ e] Mov dst:reg5, src:reg0
+ [ 11] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
+ [ 15] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg6, rhs:1, true_target:block4, false_target:block3
block3:
- [ 2b] Throw src:reg7
+ [ 25] Throw src:reg7
block4:
- [ 2d] Mov dst:reg5, src:reg7
- [ 30] Await continuation_label:block5, argument:reg5
+ [ 27] Mov dst:reg5, src:reg7
+ [ 2a] Await continuation_label:block5, argument:reg5
block5:
- [ 36] Mov dst:reg6, src:reg0
- [ 39] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ 3d] StrictlyEqualsRhsInt32 arith_feedback:1, dst:reg9, lhs:reg7, rhs:1
- [ 46] JumpIf condition:reg9, true_target:block7, false_target:block6
+ [ 30] Mov dst:reg6, src:reg0
+ [ 33] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 37] JumpStrictlyEqualsRhsInt32 arith_feedback:1, lhs:reg7, rhs:1, true_target:block7, false_target:block6
block6:
- [ 50] Throw src:reg8
+ [ 47] Throw src:reg8
block7:
- [ 52] Yield continuation_label:block8, value:reg8
+ [ 49] Yield continuation_label:block8, value:reg8
block8:
- [ 59] Mov dst:reg6, src:reg0
- [ 5c] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ 60] StrictlyInequalsRhsInt32 arith_feedback:2, dst:reg10, lhs:reg7, rhs:4
- [ 69] JumpIf condition:reg10, true_target:block12, false_target:block9
+ [ 50] Mov dst:reg6, src:reg0
+ [ 53] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 57] StrictlyInequalsRhsInt32 arith_feedback:2, dst:reg9, lhs:reg7, rhs:4
+ [ 60] JumpIf condition:reg9, true_target:block12, false_target:block9
block9:
- [ 73] Await continuation_label:block10, argument:reg8
+ [ 6a] Await continuation_label:block10, argument:reg8
block10:
- [ 79] Mov dst:reg6, src:reg0
- [ 7c] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ 80] StrictlyEqualsRhsInt32 arith_feedback:3, dst:reg11, lhs:reg7, rhs:5
- [ 89] JumpIf condition:reg11, true_target:block12, false_target:block11
+ [ 70] Mov dst:reg6, src:reg0
+ [ 73] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 77] StrictlyEqualsRhsInt32 arith_feedback:3, dst:reg10, lhs:reg7, rhs:5
+ [ 80] JumpIf condition:reg10, true_target:block12, false_target:block11
block11:
- [ 93] SetCompletionType completion:reg6
- [ 96] Jump target:block12
+ [ 8a] SetCompletionType completion:reg6
+ [ 8d] Jump target:block12
block12:
- [ 9b] Mov dst:reg6, src:reg0
- [ 9e] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
- [ a2] StrictlyEqualsRhsInt32 arith_feedback:4, dst:reg12, lhs:reg7, rhs:1
- [ ab] JumpIf condition:reg12, true_target:block16, false_target:block13
+ [ 92] Mov dst:reg6, src:reg0
+ [ 95] GetCompletionFields type_dst:reg7, value_dst:reg8, completion:reg6
+ [ 99] StrictlyEqualsRhsInt32 arith_feedback:4, dst:reg11, lhs:reg7, rhs:1
+ [ a2] JumpIf condition:reg11, true_target:block16, false_target:block13
block13:
- [ b5] StrictlyEqualsRhsInt32 arith_feedback:5, dst:reg13, lhs:reg7, rhs:5
- [ be] JumpIf condition:reg13, true_target:block14, false_target:block15
+ [ ac] StrictlyEqualsRhsInt32 arith_feedback:5, dst:reg12, lhs:reg7, rhs:5
+ [ b5] JumpIf condition:reg12, true_target:block14, false_target:block15
block14:
- [ c8] Throw src:reg8
+ [ bf] Throw src:reg8
block15:
- [ ca] Yield value:reg8
+ [ c1] Yield value:reg8
block16:
- [ d1] Mov dst:reg5, src:reg8
- [ d4] Yield value:Undefined
+ [ c8] Mov dst:reg5, src:reg8
+ [ cb] Yield value:Undefined
diff --git a/Tests/LibJS/Bytecode/expected/async-generator-yield.txt b/Tests/LibJS/Bytecode/expected/async-generator-yield.txt
index 902b3c51c08..35f96b87a80 100644
--- a/Tests/LibJS/Bytecode/expected/async-generator-yield.txt
+++ b/Tests/LibJS/Bytecode/expected/async-generator-yield.txt
@@ -13,8 +13,8 @@ block0:
[ 14] End value:reg5
-f$fb3e4c58 async-generator-yield.js:5:5
- Registers: 13
+f$ebc3098b async-generator-yield.js:5:5
+ Registers: 12
Blocks: 14
Constants:
[0] = Undefined
@@ -29,50 +29,49 @@ block1:
block2:
[ e] Mov dst:reg5, src:reg0
[ 11] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
- [ 15] StrictlyEqualsRhsInt32 arith_feedback:0, dst:reg8, lhs:reg6, rhs:1
- [ 1e] JumpIf condition:reg8, true_target:block4, false_target:block3
+ [ 15] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg6, rhs:1, true_target:block4, false_target:block3
block3:
- [ 28] Throw src:reg7
+ [ 25] Throw src:reg7
block4:
- [ 2a] Yield continuation_label:block5, value:reg7
+ [ 27] Yield continuation_label:block5, value:reg7
block5:
- [ 31] Mov dst:reg5, src:reg0
- [ 34] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
- [ 38] StrictlyInequalsRhsInt32 arith_feedback:1, dst:reg9, lhs:reg6, rhs:4
- [ 41] JumpIf condition:reg9, true_target:block9, false_target:block6
+ [ 2e] Mov dst:reg5, src:reg0
+ [ 31] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
+ [ 35] StrictlyInequalsRhsInt32 arith_feedback:1, dst:reg8, lhs:reg6, rhs:4
+ [ 3e] JumpIf condition:reg8, true_target:block9, false_target:block6
block6:
- [ 4b] Await continuation_label:block7, argument:reg7
+ [ 48] Await continuation_label:block7, argument:reg7
block7:
- [ 51] Mov dst:reg5, src:reg0
- [ 54] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
- [ 58] StrictlyEqualsRhsInt32 arith_feedback:2, dst:reg10, lhs:reg6, rhs:5
- [ 61] JumpIf condition:reg10, true_target:block9, false_target:block8
+ [ 4e] Mov dst:reg5, src:reg0
+ [ 51] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
+ [ 55] StrictlyEqualsRhsInt32 arith_feedback:2, dst:reg9, lhs:reg6, rhs:5
+ [ 5e] JumpIf condition:reg9, true_target:block9, false_target:block8
block8:
- [ 6b] SetCompletionType completion:reg5
- [ 6e] Jump target:block9
+ [ 68] SetCompletionType completion:reg5
+ [ 6b] Jump target:block9
block9:
- [ 73] Mov dst:reg5, src:reg0
- [ 76] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
- [ 7a] StrictlyEqualsRhsInt32 arith_feedback:3, dst:reg11, lhs:reg6, rhs:1
- [ 83] JumpIf condition:reg11, true_target:block13, false_target:block10
+ [ 70] Mov dst:reg5, src:reg0
+ [ 73] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
+ [ 77] StrictlyEqualsRhsInt32 arith_feedback:3, dst:reg10, lhs:reg6, rhs:1
+ [ 80] JumpIf condition:reg10, true_target:block13, false_target:block10
block10:
- [ 8d] StrictlyEqualsRhsInt32 arith_feedback:4, dst:reg12, lhs:reg6, rhs:5
- [ 96] JumpIf condition:reg12, true_target:block11, false_target:block12
+ [ 8a] StrictlyEqualsRhsInt32 arith_feedback:4, dst:reg11, lhs:reg6, rhs:5
+ [ 93] JumpIf condition:reg11, true_target:block11, false_target:block12
block11:
- [ a0] Throw src:reg7
+ [ 9d] Throw src:reg7
block12:
- [ a2] Yield value:reg7
+ [ 9f] Yield value:reg7
block13:
- [ a9] Mov dst:reg5, src:reg7
- [ ac] Yield value:Undefined
+ [ a6] Mov dst:reg5, src:reg7
+ [ a9] Yield value:Undefined
diff --git a/Tests/LibJS/Bytecode/expected/await-completion.txt b/Tests/LibJS/Bytecode/expected/await-completion.txt
new file mode 100644
index 00000000000..10f22488f77
--- /dev/null
+++ b/Tests/LibJS/Bytecode/expected/await-completion.txt
@@ -0,0 +1,90 @@
+$6da4372b await-completion.js:9:1
+ Registers: 7
+ Blocks: 1
+ Constants:
+ [0] = Undefined
+ [1] = Int32(1)
+ [2] = Null
+
+block0:
+ [ 0] Enter
+ [ 1] Mov dst:reg5, src:Undefined
+ [ 4] GetGlobal value_feedback:0, dst:reg6, `awaitValue`
+ [ c] Call call_feedback:0, dst:reg5, callee:reg6, this_value:Undefined, arguments:[Int32(1)]
+ [ 14] GetGlobal value_feedback:1, dst:reg6, `disposeResource`
+ [ 1c] Call call_feedback:1, dst:reg5, callee:reg6, this_value:Undefined, arguments:[Null]
+ [ 24] End value:reg5
+
+
+awaitValue$d94b9f31 await-completion.js:2:5
+ Registers: 8
+ Blocks: 4
+
+block0:
+ [ 0] Enter
+ [ 1] Await continuation_label:block1, argument:arg0
+
+block1:
+ [ 7] Mov dst:reg5, src:reg0
+ [ a] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
+ [ e] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg6, rhs:1, true_target:block3, false_target:block2
+
+block2:
+ [ 1e] Throw src:reg7
+
+block3:
+ [ 20] Mov dst:reg5, src:reg7
+ [ 23] Yield value:reg5
+
+
+disposeResource$76784907 await-completion.js:6:5
+ Registers: 13
+ Blocks: 10
+ Locals: resource~0
+ Constants:
+ [0] = Int32(0)
+ [1] = Int32(1)
+ [2] = Undefined
+
+block0:
+ [ 0] Enter
+ [ 1] NewDisposableResourceStack dst:reg5
+
+block1:
+ [ 3] AddDisposableResource stack:reg5, value:arg0, hint:1
+ [ a] Mov dst:resource~0, src:arg0
+ [ d] Mov dst:reg6, src:Int32(0)
+ [ 10] Jump target:block3
+
+block2:
+ [ 15] Catch value_feedback:0, dst:reg7
+ [ 19] Mov dst:reg6, src:Int32(1)
+
+block3:
+ [ 1c] Mov dst:reg9, src:Int32(1)
+ [ 1f] Mov dst:reg10, src:Undefined
+ [ 22] Jump target:block4
+
+block4:
+ [ 27] AsyncDisposeResourcesStep done:reg11, awaited_value:reg12, stack:reg5, completion_type:reg6, completion_value:reg7, await_completion_type:reg9, await_completion_value:reg10
+ [ 2f] JumpIf condition:reg11, true_target:block7, false_target:block5
+
+block5:
+ [ 39] Await continuation_label:block6, argument:reg12
+
+block6:
+ [ 3f] Mov dst:reg8, src:reg0
+ [ 42] GetCompletionFields type_dst:reg9, value_dst:reg10, completion:reg8
+ [ 46] Jump target:block4
+
+block7:
+ [ 4b] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg6, rhs:0, true_target:block9, false_target:block8
+
+block8:
+ [ 5b] Throw src:reg7
+
+block9:
+ [ 5d] Yield value:Undefined
+
+Exception handlers:
+ [ 3 .. 15] => handler block2
diff --git a/Tests/LibJS/Bytecode/expected/for-of-iterator-close.txt b/Tests/LibJS/Bytecode/expected/for-of-iterator-close.txt
index 19ddae02ace..72f09e79d5b 100644
--- a/Tests/LibJS/Bytecode/expected/for-of-iterator-close.txt
+++ b/Tests/LibJS/Bytecode/expected/for-of-iterator-close.txt
@@ -94,8 +94,8 @@ Exception handlers:
[ 37 .. 3a] => handler block3
-forAwaitOfBreak$b48a9efa for-of-iterator-close.js:16:22
- Registers: 18
+forAwaitOfBreak$adc39dcb for-of-iterator-close.js:16:22
+ Registers: 17
Blocks: 23
Locals: x~0
Constants:
@@ -110,91 +110,85 @@ block0:
block1:
[ 10] Call call_feedback:0, dst:reg11, callee:reg7, this_value:reg6
- [ 17] Mov dst:reg12, src:reg0
- [ 1a] Await continuation_label:block2, argument:reg11
+ [ 17] Await continuation_label:block2, argument:reg11
block2:
- [ 20] Mov dst:reg12, src:reg0
- [ 23] GetCompletionFields type_dst:reg13, value_dst:reg14, completion:reg12
- [ 27] StrictlyEqualsRhsInt32 arith_feedback:0, dst:reg15, lhs:reg13, rhs:1
- [ 30] JumpIf condition:reg15, true_target:block4, false_target:block3
+ [ 1d] Mov dst:reg12, src:reg0
+ [ 20] GetCompletionFields type_dst:reg13, value_dst:reg14, completion:reg12
+ [ 24] JumpStrictlyEqualsRhsInt32 arith_feedback:0, lhs:reg13, rhs:1, true_target:block4, false_target:block3
block3:
- [ 3a] Throw src:reg14
+ [ 34] Throw src:reg14
block4:
- [ 3c] ThrowIfNotObject src:reg14
- [ 3e] GetById dst:reg10, base:reg14, `done`
- [ 45] JumpTrue condition:reg10, target:block22
+ [ 36] ThrowIfNotObject src:reg14
+ [ 38] GetById dst:reg10, base:reg14, `done`
+ [ 3f] JumpTrue condition:reg10, target:block22
block5:
- [ 4b] GetById dst:reg9, base:reg14, `value`
+ [ 45] GetById dst:reg9, base:reg14, `value`
block6:
- [ 52] Mov dst:x~0, src:reg9
- [ 55] JumpStrictlyEqualsRhsInt32 arith_feedback:1, lhs:x~0, rhs:2, true_target:block7, false_target:block13
+ [ 4c] Mov dst:x~0, src:reg9
+ [ 4f] JumpStrictlyEqualsRhsInt32 arith_feedback:1, lhs:x~0, rhs:2, true_target:block7, false_target:block13
block7:
- [ 65] GetMethod dst:reg11, object:reg6, `return`
- [ 6c] JumpUndefined condition:reg11, true_target:block12, false_target:block8
+ [ 5f] GetMethod dst:reg11, object:reg6, `return`
+ [ 66] JumpUndefined condition:reg11, true_target:block12, false_target:block8
block8:
- [ 76] Call call_feedback:1, dst:reg12, callee:reg11, this_value:reg6
- [ 7d] Mov dst:reg13, src:reg0
- [ 80] Await continuation_label:block9, argument:reg12
+ [ 70] Call call_feedback:1, dst:reg12, callee:reg11, this_value:reg6
+ [ 77] Await continuation_label:block9, argument:reg12
block9:
- [ 86] Mov dst:reg13, src:reg0
- [ 89] GetCompletionFields type_dst:reg14, value_dst:reg15, completion:reg13
- [ 8d] StrictlyEqualsRhsInt32 arith_feedback:2, dst:reg16, lhs:reg14, rhs:1
- [ 96] JumpIf condition:reg16, true_target:block11, false_target:block10
+ [ 7d] Mov dst:reg13, src:reg0
+ [ 80] GetCompletionFields type_dst:reg14, value_dst:reg15, completion:reg13
+ [ 84] JumpStrictlyEqualsRhsInt32 arith_feedback:2, lhs:reg14, rhs:1, true_target:block11, false_target:block10
block10:
- [ a0] Throw src:reg15
+ [ 94] Throw src:reg15
block11:
- [ a2] ThrowIfNotObject src:reg15
+ [ 96] ThrowIfNotObject src:reg15
block12:
- [ a4] Jump target:block22
+ [ 98] Jump target:block22
block13:
- [ a9] JumpLoop target:block1
+ [ 9d] JumpLoop target:block1
block14:
- [ ae] Catch value_feedback:0, dst:reg11
+ [ a2] Catch value_feedback:0, dst:reg11
block15:
- [ b2] GetMethod dst:reg12, object:reg6, `return`
- [ b9] JumpUndefined condition:reg12, true_target:block21, false_target:block16
+ [ a6] GetMethod dst:reg12, object:reg6, `return`
+ [ ad] JumpUndefined condition:reg12, true_target:block21, false_target:block16
block16:
- [ c3] Call call_feedback:2, dst:reg13, callee:reg12, this_value:reg6
- [ ca] Mov dst:reg14, src:reg0
- [ cd] Await continuation_label:block17, argument:reg13
+ [ b7] Call call_feedback:2, dst:reg13, callee:reg12, this_value:reg6
+ [ be] Await continuation_label:block17, argument:reg13
block17:
- [ d3] Mov dst:reg14, src:reg0
- [ d6] GetCompletionFields type_dst:reg15, value_dst:reg16, completion:reg14
- [ da] StrictlyEqualsRhsInt32 arith_feedback:3, dst:reg17, lhs:reg15, rhs:1
- [ e3] JumpIf condition:reg17, true_target:block19, false_target:block18
+ [ c4] Mov dst:reg14, src:reg0
+ [ c7] GetCompletionFields type_dst:reg15, value_dst:reg16, completion:reg14
+ [ cb] JumpStrictlyEqualsRhsInt32 arith_feedback:3, lhs:reg15, rhs:1, true_target:block19, false_target:block18
block18:
- [ ed] Throw src:reg16
+ [ db] Throw src:reg16
block19:
- [ ef] Jump target:block21
+ [ dd] Jump target:block21
block20:
- [ f4] Catch value_feedback:1, dst:reg12
+ [ e2] Catch value_feedback:1, dst:reg12
block21:
- [ f8] Throw src:reg11
+ [ e6] Throw src:reg11
block22:
- [ fa] Yield value:Undefined
+ [ e8] Yield value:Undefined
Exception handlers:
- [ 52 .. 65] => handler block14
- [ a9 .. ae] => handler block14
- [ b2 .. f4] => handler block20
+ [ 4c .. 5f] => handler block14
+ [ 9d .. a2] => handler block14
+ [ a6 .. e2] => handler block20
diff --git a/Tests/LibJS/Bytecode/input/await-completion.js b/Tests/LibJS/Bytecode/input/await-completion.js
new file mode 100644
index 00000000000..38e053e75c6
--- /dev/null
+++ b/Tests/LibJS/Bytecode/input/await-completion.js
@@ -0,0 +1,10 @@
+async function awaitValue(value) {
+ return await value;
+}
+
+async function disposeResource(value) {
+ await using resource = value;
+}
+
+awaitValue(1);
+disposeResource(null);