Truly independent web browser
LibJS: Avoid preserving discarded postfix update results
Shannon Boothd2f556f98f1c
diff --git a/Libraries/LibJS/Rust/src/bytecode/codegen/stream.rs b/Libraries/LibJS/Rust/src/bytecode/codegen/stream.rsindex d88ebb4f80f..a25a08f889c 100644--- a/Libraries/LibJS/Rust/src/bytecode/codegen/stream.rs+++ b/Libraries/LibJS/Rust/src/bytecode/codegen/stream.rs@@ -3422,7 +3422,7 @@ impl Generator<'_> {}// NB: The old value is in a temporary of its own by now.let value = old_value;- let result = if prefixed {+ let result = if prefixed || !value_is_used {let arith_feedback = self.next_arith_feedback();match operator {UpdateOp::Increment => self.put(op::Increment {diff --git a/Tests/LibJS/Bytecode/expected/computed-update-register-order.txt b/Tests/LibJS/Bytecode/expected/computed-update-register-order.txtindex 8affb6a792c..f6c0b6a5ed4 100644--- a/Tests/LibJS/Bytecode/expected/computed-update-register-order.txt+++ b/Tests/LibJS/Bytecode/expected/computed-update-register-order.txt@@ -13,8 +13,8 @@ block0:[ 3a] End value:reg5-test$12dcfbfe computed-update-register-order.js:5:9- Registers: 7+test$63093b0f computed-update-register-order.js:5:9+ Registers: 6Blocks: 1Constants:[0] = Int32(3)@@ -23,11 +23,11 @@ test$12dcfbfe computed-update-register-order.js:5:9block0:[ 0] Enter[ 1] GetByValue keyed_feedback:0, dst:reg5, base:arg0, property:Int32(3)- [ 9] PostfixIncrement arith_feedback:0, dst:reg6, src:reg5- [ e] PutByValue keyed_feedback:1, base:arg0, property:Int32(3), src:reg5, kind:Normal- [ 17] GetGlobal value_feedback:0, dst:reg5, `foo`- [ 1f] Call call_feedback:0, dst:reg5, callee:reg5, this_value:Undefined, arguments:[arg0]- [ 27] End value:Undefined+ [ 9] Increment arith_feedback:0, dst:reg5+ [ d] PutByValue keyed_feedback:1, base:arg0, property:Int32(3), src:reg5, kind:Normal+ [ 16] GetGlobal value_feedback:0, dst:reg5, `foo`+ [ 1e] Call call_feedback:0, dst:reg5, callee:reg5, this_value:Undefined, arguments:[arg0]+ [ 26] End value:Undefinedfoo$0284f477 computed-update-register-order.js:2:5diff --git a/Tests/LibJS/Bytecode/expected/for-loop-scoping.txt b/Tests/LibJS/Bytecode/expected/for-loop-scoping.txtindex 5a5b305cf0f..3f6ad75000b 100644--- a/Tests/LibJS/Bytecode/expected/for-loop-scoping.txt+++ b/Tests/LibJS/Bytecode/expected/for-loop-scoping.txt@@ -15,7 +15,7 @@ block0:[ 2a] End value:reg5-forLetClosure$9f1b29f2 for-loop-scoping.js:2:15+forLetClosure$ef476903 for-loop-scoping.js:2:15Registers: 8Blocks: 4Locals: fns~0@@ -46,19 +46,19 @@ block1:[ 77] CreateVariable `i`, is_immutable:false, is_global:false, is_strict:false[ 7e] InitializeLexicalBinding `i`, src:reg6[ 85] GetBinding value_feedback:2, dst:reg6, `i`- [ 8e] PostfixIncrement arith_feedback:0, dst:reg7, src:reg6- [ 93] SetLexicalBinding `i`, src:reg6+ [ 8e] Increment arith_feedback:0, dst:reg6+ [ 92] SetLexicalBinding `i`, src:reg6block2:- [ 9a] GetBinding value_feedback:3, dst:reg6, `i`- [ a3] JumpLessThanLoopRhsInt32 arith_feedback:1, lhs:reg6, rhs:3, true_target:block1, false_target:block3+ [ 99] GetBinding value_feedback:3, dst:reg6, `i`+ [ a2] JumpLessThanLoopRhsInt32 arith_feedback:1, lhs:reg6, rhs:3, true_target:block1, false_target:block3block3:- [ b3] SetLexicalEnvironment environment:reg4- [ b5] GetById dst:reg5, base:fns~0, `map`- [ bc] NewFunction dst:reg6, shared_function_data_index:1- [ c3] Call call_feedback:1, dst:reg5, callee:reg5, this_value:fns~0, arguments:[reg6]- [ cb] Return value:reg5+ [ b2] SetLexicalEnvironment environment:reg4+ [ b4] GetById dst:reg5, base:fns~0, `map`+ [ bb] NewFunction dst:reg6, shared_function_data_index:1+ [ c2] Call call_feedback:1, dst:reg5, callee:reg5, this_value:fns~0, arguments:[reg6]+ [ ca] Return value:reg5map$d1c6bef1 BuiltinFile:275:11diff --git a/Tests/LibJS/Bytecode/expected/for-try-finally-continue.txt b/Tests/LibJS/Bytecode/expected/for-try-finally-continue.txtindex 79a4d909994..b7346b92d66 100644--- a/Tests/LibJS/Bytecode/expected/for-try-finally-continue.txt+++ b/Tests/LibJS/Bytecode/expected/for-try-finally-continue.txt@@ -1,4 +1,4 @@-$afc7ccd3 for-try-finally-continue.js:1:5+$bf430fa0 for-try-finally-continue.js:1:5Registers: 9Blocks: 14Locals: e~0@@ -53,24 +53,24 @@ block8:block9:[ 69] GetGlobal value_feedback:2, dst:reg6, `i`- [ 71] PostfixIncrement arith_feedback:2, dst:reg7, src:reg6- [ 76] SetGlobal `i`, src:reg6+ [ 71] Increment arith_feedback:2, dst:reg6+ [ 75] SetGlobal `i`, src:reg6block10:- [ 7c] GetGlobal value_feedback:3, dst:reg6, `i`- [ 84] JumpLessThanLoopRhsInt32 arith_feedback:3, lhs:reg6, rhs:5, true_target:block1, false_target:block11+ [ 7b] GetGlobal value_feedback:3, dst:reg6, `i`+ [ 83] JumpLessThanLoopRhsInt32 arith_feedback:3, lhs:reg6, rhs:5, true_target:block1, false_target:block11block11:- [ 94] GetGlobal value_feedback:4, dst:reg6, `i`- [ 9c] StrictlyInequalsRhsInt32 arith_feedback:4, dst:reg6, lhs:reg6, rhs:5- [ a5] Mov dst:reg5, src:Undefined- [ a8] JumpFalse condition:reg6, target:block13+ [ 93] GetGlobal value_feedback:4, dst:reg6, `i`+ [ 9b] StrictlyInequalsRhsInt32 arith_feedback:4, dst:reg6, lhs:reg6, rhs:5+ [ a4] Mov dst:reg5, src:Undefined+ [ a7] JumpFalse condition:reg6, target:block13block12:- [ ae] Throw src:String("bad")+ [ ad] Throw src:String("bad")block13:- [ b0] End value:reg5+ [ af] End value:reg5Exception handlers:[ 15 .. 1d] => handler block3diff --git a/Tests/LibJS/Bytecode/expected/super-evaluation-order.txt b/Tests/LibJS/Bytecode/expected/super-evaluation-order.txtindex 985564a2d8b..28b4624704a 100644--- a/Tests/LibJS/Bytecode/expected/super-evaluation-order.txt+++ b/Tests/LibJS/Bytecode/expected/super-evaluation-order.txt@@ -70,8 +70,8 @@ block0:[ c] End value:Undefined-update$411e0be6 super-evaluation-order.js:9:16- Registers: 8+update$914a4af7 super-evaluation-order.js:9:16+ Registers: 7Blocks: 1Constants:[0] = Undefined@@ -80,6 +80,6 @@ block0:[ 0] Enter[ 1] ResolveSuperBase dst:reg5[ 3] GetByIdWithThis dst:reg6, base:reg5, `x`, this_value:this- [ b] PostfixIncrement arith_feedback:0, dst:reg7, src:reg6- [ 10] PutByIdWithThis base:reg5, this_value:this, `x`, src:reg6, kind:Normal- [ 19] End value:Undefined+ [ b] Increment arith_feedback:0, dst:reg6+ [ f] PutByIdWithThis base:reg5, this_value:this, `x`, src:reg6, kind:Normal+ [ 18] End value:Undefineddiff --git a/Tests/LibJS/Bytecode/expected/update-member-expression.txt b/Tests/LibJS/Bytecode/expected/update-member-expression.txtindex 906ba4746ce..59231c6b9c0 100644--- a/Tests/LibJS/Bytecode/expected/update-member-expression.txt+++ b/Tests/LibJS/Bytecode/expected/update-member-expression.txt@@ -16,8 +16,8 @@ block0:[ 2c] End value:reg5-postfix_increment$0720e4ab update-member-expression.js:6:14- Registers: 7+postfix_increment$b6f4a59a update-member-expression.js:6:14+ Registers: 6Blocks: 1Constants:[0] = Undefined@@ -25,9 +25,9 @@ postfix_increment$0720e4ab update-member-expression.js:6:14block0:[ 0] Enter[ 1] GetById dst:reg5, base:arg0, `count`- [ 8] PostfixIncrement arith_feedback:0, dst:reg6, src:reg5- [ d] PutById base:arg0, `count`, src:reg5, kind:Normal- [ 15] End value:Undefined+ [ 8] Increment arith_feedback:0, dst:reg5+ [ c] PutById base:arg0, `count`, src:reg5, kind:Normal+ [ 14] End value:Undefinedprefix_decrement$0bcd8e6c update-member-expression.js:10:5