diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc index b84eac8e0e..3339125cf3 100644 --- a/src/interpreter/bytecode-generator.cc +++ b/src/interpreter/bytecode-generator.cc @@ -152,7 +152,10 @@ class BytecodeGenerator::ControlScope::DeferredCommands final { : generator_(generator), deferred_(generator->zone()), token_register_(token_register), - result_register_(result_register) {} + result_register_(result_register), + return_token_(-1), + async_return_token_(-1), + rethrow_token_(-1) {} // One recorded control-flow command. struct Entry { @@ -165,8 +168,12 @@ class BytecodeGenerator::ControlScope::DeferredCommands final { // generates a new dispatch token that identifies one particular path. This // expects the result to be in the accumulator. void RecordCommand(Command command, Statement* statement) { - int token = static_cast(deferred_.size()); - deferred_.push_back({command, statement, token}); + int token = GetTokenForCommand(command, statement); + + DCHECK_LT(token, deferred_.size()); + DCHECK_EQ(deferred_[token].command, command); + DCHECK_EQ(deferred_[token].statement, statement); + DCHECK_EQ(deferred_[token].token, token); builder()->StoreAccumulatorInRegister(result_register_); builder()->LoadLiteral(Smi::FromInt(token)); @@ -211,10 +218,57 @@ class BytecodeGenerator::ControlScope::DeferredCommands final { ControlScope* execution_control() { return generator_->execution_control(); } private: + int GetTokenForCommand(Command command, Statement* statement) { + switch (command) { + case CMD_RETURN: + return GetReturnToken(); + case CMD_ASYNC_RETURN: + return GetAsyncReturnToken(); + case CMD_RETHROW: + return GetRethrowToken(); + default: + // TODO(leszeks): We could also search for entries with the same + // command and statement. + return GetNewTokenForCommand(command, statement); + } + } + + int GetReturnToken() { + if (return_token_ == -1) { + return_token_ = GetNewTokenForCommand(CMD_RETURN, nullptr); + } + return return_token_; + } + + int GetAsyncReturnToken() { + if (async_return_token_ == -1) { + async_return_token_ = GetNewTokenForCommand(CMD_ASYNC_RETURN, nullptr); + } + return async_return_token_; + } + + int GetRethrowToken() { + if (rethrow_token_ == -1) { + rethrow_token_ = GetNewTokenForCommand(CMD_RETHROW, nullptr); + } + return rethrow_token_; + } + + int GetNewTokenForCommand(Command command, Statement* statement) { + int token = static_cast(deferred_.size()); + deferred_.push_back({command, statement, token}); + return token; + } + BytecodeGenerator* generator_; ZoneVector deferred_; Register token_register_; Register result_register_; + + // Tokens for commands that don't need a statement. + int return_token_; + int async_return_token_; + int rethrow_token_; }; // Scoped class for dealing with control flow reaching the function level. diff --git a/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden index 862f998f2f..3a4949dd31 100644 --- a/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden +++ b/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -16,7 +16,7 @@ snippet: " " frame size: 19 parameter count: 1 -bytecode array length: 969 +bytecode array length: 953 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -270,7 +270,7 @@ bytecodes: [ B(Ldar), R(12), B(PushContext), R(2), B(PopContext), R(2), - B(Jump), U8(156), + B(Jump), U8(155), B(LdaContextSlot), R(1), U8(12), U8(0), B(Star), R(12), B(LdaContextSlot), R(1), U8(6), U8(0), @@ -302,10 +302,10 @@ bytecodes: [ B(Star), R(15), B(LdaZero), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(37), + B(JumpIfTrue), U8(36), B(LdaSmi), I8(2), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(28), + B(JumpIfTrue), U8(27), B(LdaTrue), B(Star), R(17), B(Mov), R(14), R(16), @@ -315,9 +315,9 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(163), + B(Jump), U8(160), B(Ldar), R(14), B(ReThrow), B(Ldar), R(14), @@ -334,15 +334,15 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(9), B(SwitchOnSmiNoFeedback), U8(19), U8(2), I8(0), - B(Jump), U8(26), + B(Jump), U8(25), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Mov), R(10), R(6), - B(Jump), U8(101), + B(Jump), U8(99), B(PopContext), R(1), B(PopContext), R(1), B(Ldar), R(10), @@ -357,10 +357,10 @@ bytecodes: [ B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), B(LdaCurrentContextSlot), U8(10), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaZero), B(Star), R(5), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(9), B(Ldar), R(closure), B(CreateCatchContext), R(9), U8(12), U8(21), @@ -382,14 +382,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(4), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(5), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -402,16 +402,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(23), U8(6), I8(0), - B(Jump), U8(20), - B(Ldar), R(6), - /* 57 S> */ B(Return), - B(Ldar), R(6), - /* 57 S> */ B(Return), - B(Ldar), R(6), - /* 57 S> */ B(Return), - B(Ldar), R(6), - /* 57 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(23), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 57 S> */ B(Return), B(Ldar), R(6), @@ -437,22 +429,18 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, - Smi [344], - Smi [367], + Smi [343], + Smi [366], Smi [6], - Smi [23], + Smi [22], FIXED_ARRAY_TYPE, - Smi [310], + Smi [306], Smi [6], Smi [9], - Smi [12], - Smi [15], - Smi [18], - Smi [21], ] handlers: [ - [61, 911, 917], - [64, 857, 859], + [61, 907, 913], + [64, 854, 856], [81, 403, 409], [84, 355, 357], [496, 620, 622], @@ -467,7 +455,7 @@ snippet: " " frame size: 19 parameter count: 1 -bytecode array length: 1015 +bytecode array length: 999 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -728,7 +716,7 @@ bytecodes: [ B(Ldar), R(12), B(PushContext), R(2), B(PopContext), R(2), - B(Jump), U8(156), + B(Jump), U8(155), B(LdaContextSlot), R(1), U8(12), U8(0), B(Star), R(12), B(LdaContextSlot), R(1), U8(6), U8(0), @@ -760,10 +748,10 @@ bytecodes: [ B(Star), R(15), B(LdaZero), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(37), + B(JumpIfTrue), U8(36), B(LdaSmi), I8(2), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(28), + B(JumpIfTrue), U8(27), B(LdaTrue), B(Star), R(17), B(Mov), R(14), R(16), @@ -773,9 +761,9 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(180), + B(Jump), U8(177), B(Ldar), R(14), B(ReThrow), B(Ldar), R(14), @@ -792,23 +780,23 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(9), B(SwitchOnSmiNoFeedback), U8(19), U8(3), I8(0), - B(Jump), U8(43), + B(Jump), U8(42), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Mov), R(10), R(6), - B(Jump), U8(118), + B(Jump), U8(116), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(5), B(Mov), R(10), R(6), - B(Jump), U8(101), + B(Jump), U8(99), B(PopContext), R(1), B(PopContext), R(1), B(Ldar), R(10), @@ -823,10 +811,10 @@ bytecodes: [ B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), B(LdaCurrentContextSlot), U8(10), B(Star), R(6), - B(LdaSmi), I8(4), + B(LdaZero), B(Star), R(5), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(9), B(Ldar), R(closure), B(CreateCatchContext), R(9), U8(12), U8(22), @@ -848,14 +836,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(5), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(6), + B(LdaSmi), I8(2), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -868,12 +856,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(24), U8(7), I8(0), - B(Jump), U8(37), - B(Ldar), R(6), - /* 68 S> */ B(Return), - B(Ldar), R(6), - /* 68 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(24), U8(3), I8(0), + B(Jump), U8(25), B(Ldar), R(6), /* 68 S> */ B(Return), B(LdaCurrentContextSlot), U8(10), @@ -883,10 +867,6 @@ bytecodes: [ B(Mov), R(6), R(10), B(CallJSRuntime), U8(%promise_resolve), R(8), U8(3), B(Ldar), R(9), - /* 68 S> */ B(Return), - B(Ldar), R(6), - /* 68 S> */ B(Return), - B(Ldar), R(6), /* 68 S> */ B(Return), B(Ldar), R(6), B(ReThrow), @@ -911,24 +891,20 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, - Smi [344], - Smi [367], + Smi [343], + Smi [366], Smi [6], - Smi [23], - Smi [40], + Smi [22], + Smi [39], FIXED_ARRAY_TYPE, - Smi [327], + Smi [323], Smi [6], Smi [9], - Smi [12], - Smi [15], - Smi [32], - Smi [35], - Smi [38], + Smi [26], ] handlers: [ - [61, 940, 946], - [64, 886, 888], + [61, 936, 942], + [64, 883, 885], [81, 415, 421], [84, 367, 369], [508, 632, 634], @@ -946,7 +922,7 @@ snippet: " " frame size: 19 parameter count: 1 -bytecode array length: 1003 +bytecode array length: 987 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -1216,7 +1192,7 @@ bytecodes: [ B(Ldar), R(12), B(PushContext), R(2), B(PopContext), R(2), - B(Jump), U8(156), + B(Jump), U8(155), B(LdaContextSlot), R(1), U8(12), U8(0), B(Star), R(12), B(LdaContextSlot), R(1), U8(6), U8(0), @@ -1248,10 +1224,10 @@ bytecodes: [ B(Star), R(15), B(LdaZero), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(37), + B(JumpIfTrue), U8(36), B(LdaSmi), I8(2), B(TestEqualStrictNoFeedback), R(15), - B(JumpIfTrue), U8(28), + B(JumpIfTrue), U8(27), B(LdaTrue), B(Star), R(17), B(Mov), R(14), R(16), @@ -1261,9 +1237,9 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(163), + B(Jump), U8(160), B(Ldar), R(14), B(ReThrow), B(Ldar), R(14), @@ -1280,15 +1256,15 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(9), B(SwitchOnSmiNoFeedback), U8(19), U8(2), I8(0), - B(Jump), U8(26), + B(Jump), U8(25), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), B(PopContext), R(1), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Mov), R(10), R(6), - B(Jump), U8(101), + B(Jump), U8(99), B(PopContext), R(1), B(PopContext), R(1), B(Ldar), R(10), @@ -1303,10 +1279,10 @@ bytecodes: [ B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), B(LdaCurrentContextSlot), U8(10), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaZero), B(Star), R(5), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(9), B(Ldar), R(closure), B(CreateCatchContext), R(9), U8(12), U8(21), @@ -1328,14 +1304,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(4), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(5), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -1348,16 +1324,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(23), U8(6), I8(0), - B(Jump), U8(20), - B(Ldar), R(6), - /* 114 S> */ B(Return), - B(Ldar), R(6), - /* 114 S> */ B(Return), - B(Ldar), R(6), - /* 114 S> */ B(Return), - B(Ldar), R(6), - /* 114 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(23), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 114 S> */ B(Return), B(Ldar), R(6), @@ -1383,22 +1351,18 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, - Smi [344], - Smi [367], + Smi [343], + Smi [366], Smi [6], - Smi [23], + Smi [22], FIXED_ARRAY_TYPE, - Smi [310], + Smi [306], Smi [6], Smi [9], - Smi [12], - Smi [15], - Smi [18], - Smi [21], ] handlers: [ - [61, 945, 951], - [64, 891, 893], + [61, 941, 947], + [64, 888, 890], [81, 437, 443], [84, 389, 391], [530, 654, 656], @@ -1414,7 +1378,7 @@ snippet: " " frame size: 12 parameter count: 1 -bytecode array length: 511 +bytecode array length: 508 bytecodes: [ B(CreateFunctionContext), U8(9), B(PushContext), R(0), @@ -1608,14 +1572,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(3), - B(LdaSmi), I8(2), + B(LdaSmi), I8(1), B(Star), R(2), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(2), B(Jump), U8(8), B(Star), R(3), - B(LdaSmi), I8(3), + B(LdaSmi), I8(2), B(Star), R(2), B(LdaTheHole), B(SetPendingMessage), @@ -1628,8 +1592,8 @@ bytecodes: [ B(Ldar), R(4), B(SetPendingMessage), B(Ldar), R(2), - B(SwitchOnSmiNoFeedback), U8(15), U8(4), I8(0), - B(Jump), U8(28), + B(SwitchOnSmiNoFeedback), U8(15), U8(3), I8(0), + B(Jump), U8(25), B(LdaCurrentContextSlot), U8(12), B(Star), R(6), B(LdaUndefined), @@ -1639,8 +1603,6 @@ bytecodes: [ B(Ldar), R(6), /* 96 S> */ B(Return), B(Ldar), R(3), - /* 96 S> */ B(Return), - B(Ldar), R(3), /* 96 S> */ B(Return), B(Ldar), R(3), B(ReThrow), @@ -1666,7 +1628,6 @@ constant pool: [ Smi [6], Smi [23], Smi [26], - Smi [29], ] handlers: [ [17, 445, 451], diff --git a/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden b/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden index f214a2f526..5cc195230c 100644 --- a/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden +++ b/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden @@ -648,7 +648,7 @@ snippet: " " frame size: 15 parameter count: 2 -bytecode array length: 603 +bytecode array length: 596 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -859,7 +859,7 @@ bytecodes: [ B(LdaSmi), I8(1), B(Star), R(6), B(Mov), R(10), R(7), - B(Jump), U8(34), + B(Jump), U8(33), B(PopContext), R(1), B(LdaUndefined), B(Star), R(9), @@ -867,14 +867,14 @@ bytecodes: [ B(Star), R(10), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(9), U8(2), B(Star), R(7), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(6), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(6), B(Jump), U8(8), B(Star), R(7), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), @@ -885,12 +885,8 @@ bytecodes: [ B(Ldar), R(8), B(SetPendingMessage), B(Ldar), R(6), - B(SwitchOnSmiNoFeedback), U8(15), U8(4), I8(0), - B(Jump), U8(14), - B(Ldar), R(7), - /* 55 S> */ B(Return), - B(Ldar), R(7), - B(ReThrow), + B(SwitchOnSmiNoFeedback), U8(15), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(7), /* 55 S> */ B(Return), B(Ldar), R(7), @@ -913,14 +909,12 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, Smi [6], - Smi [450], + Smi [449], Smi [6], Smi [9], - Smi [12], - Smi [15], ] handlers: [ - [56, 553, 559], + [56, 552, 558], [137, 334, 340], [140, 290, 292], [426, 442, 444], @@ -935,7 +929,7 @@ snippet: " " frame size: 18 parameter count: 2 -bytecode array length: 712 +bytecode array length: 701 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -1180,19 +1174,19 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(8), B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0), - B(Jump), U8(28), + B(Jump), U8(27), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaZero), + B(Star), R(5), + B(Mov), R(9), R(6), + B(Jump), U8(46), B(PopContext), R(1), B(PopContext), R(1), B(LdaSmi), I8(1), B(Star), R(5), B(Mov), R(9), R(6), - B(Jump), U8(47), - B(PopContext), R(1), - B(PopContext), R(1), - B(LdaSmi), I8(2), - B(Star), R(5), - B(Mov), R(9), R(6), - B(Jump), U8(34), + B(Jump), U8(33), B(PopContext), R(1), B(LdaUndefined), B(Star), R(8), @@ -1200,14 +1194,14 @@ bytecodes: [ B(Star), R(9), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(8), U8(2), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(4), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -1218,14 +1212,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(17), U8(5), I8(0), - B(Jump), U8(17), - B(Ldar), R(6), - /* 49 S> */ B(Return), - B(Ldar), R(6), - /* 49 S> */ B(Return), - B(Ldar), R(6), - B(ReThrow), + B(SwitchOnSmiNoFeedback), U8(17), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 49 S> */ B(Return), B(Ldar), R(6), @@ -1249,16 +1237,13 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, Smi [6], - Smi [19], - Smi [556], + Smi [18], + Smi [554], Smi [6], Smi [9], - Smi [12], - Smi [15], - Smi [18], ] handlers: [ - [56, 659, 665], + [56, 657, 663], [137, 426, 432], [140, 382, 384], [519, 535, 537], @@ -1273,7 +1258,7 @@ snippet: " " frame size: 14 parameter count: 2 -bytecode array length: 563 +bytecode array length: 559 bytecodes: [ B(CreateFunctionContext), U8(10), B(PushContext), R(0), @@ -1457,8 +1442,8 @@ bytecodes: [ B(Star), R(5), B(LdaZero), B(Star), R(4), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(8), B(Ldar), R(closure), B(CreateCatchContext), R(8), U8(7), U8(13), @@ -1480,14 +1465,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(5), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(4), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(4), B(Jump), U8(8), B(Star), R(5), - B(LdaSmi), I8(2), + B(LdaSmi), I8(1), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -1500,10 +1485,8 @@ bytecodes: [ B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), - B(SwitchOnSmiNoFeedback), U8(14), U8(3), I8(0), - B(Jump), U8(11), - B(Ldar), R(5), - /* 60 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(5), /* 60 S> */ B(Return), B(Ldar), R(5), @@ -1528,10 +1511,9 @@ constant pool: [ FIXED_ARRAY_TYPE, Smi [6], Smi [9], - Smi [12], ] handlers: [ - [21, 514, 520], + [21, 513, 519], [24, 460, 462], [41, 242, 248], [44, 194, 196], @@ -1547,7 +1529,7 @@ snippet: " " frame size: 19 parameter count: 2 -bytecode array length: 743 +bytecode array length: 735 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -1785,7 +1767,7 @@ bytecodes: [ B(LdaZero), B(Star), R(5), B(Mov), R(10), R(6), - B(Jump), U8(101), + B(Jump), U8(99), B(PopContext), R(1), B(PopContext), R(1), B(Ldar), R(10), @@ -1800,10 +1782,10 @@ bytecodes: [ B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), B(LdaCurrentContextSlot), U8(7), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(9), B(Ldar), R(closure), B(CreateCatchContext), R(9), U8(8), U8(15), @@ -1825,14 +1807,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -1845,12 +1827,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(16), U8(4), I8(0), - B(Jump), U8(14), - B(Ldar), R(6), - /* 54 S> */ B(Return), - B(Ldar), R(6), - /* 54 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(16), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 54 S> */ B(Return), B(Ldar), R(6), @@ -1877,12 +1855,10 @@ constant pool: [ FIXED_ARRAY_TYPE, Smi [6], Smi [9], - Smi [12], - Smi [15], ] handlers: [ - [65, 691, 697], - [68, 637, 639], + [65, 689, 695], + [68, 636, 638], [85, 401, 407], [88, 353, 355], [494, 510, 512], diff --git a/test/cctest/interpreter/bytecode_expectations/Generators.golden b/test/cctest/interpreter/bytecode_expectations/Generators.golden index 10f178297a..d5990c69de 100644 --- a/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -13,7 +13,7 @@ snippet: " " frame size: 12 parameter count: 1 -bytecode array length: 181 +bytecode array length: 177 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -62,7 +62,7 @@ bytecodes: [ B(Star), R(4), B(LdaZero), B(Star), R(3), - B(Jump), U8(35), + B(Jump), U8(34), B(Ldar), R(8), /* 11 E> */ B(Throw), B(LdaUndefined), @@ -71,14 +71,14 @@ bytecodes: [ B(Star), R(7), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2), B(Star), R(4), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(3), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(3), B(Jump), U8(8), B(Star), R(4), - B(LdaSmi), I8(2), + B(LdaSmi), I8(1), B(Star), R(3), B(LdaTheHole), B(SetPendingMessage), @@ -89,10 +89,8 @@ bytecodes: [ B(Ldar), R(5), B(SetPendingMessage), B(Ldar), R(3), - B(SwitchOnSmiNoFeedback), U8(1), U8(3), I8(0), - B(Jump), U8(11), - B(Ldar), R(4), - /* 16 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(4), /* 16 S> */ B(Return), B(Ldar), R(4), @@ -104,10 +102,9 @@ constant pool: [ Smi [52], Smi [6], Smi [9], - Smi [12], ] handlers: [ - [52, 134, 140], + [52, 133, 139], ] --- @@ -117,7 +114,7 @@ snippet: " " frame size: 12 parameter count: 1 -bytecode array length: 259 +bytecode array length: 251 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -166,7 +163,7 @@ bytecodes: [ B(Star), R(4), B(LdaZero), B(Star), R(3), - B(Jump), U8(110), + B(Jump), U8(108), B(Ldar), R(8), /* 11 E> */ B(Throw), /* 16 S> */ B(LdaSmi), I8(42), @@ -189,18 +186,18 @@ bytecodes: [ B(Star), R(9), B(LdaZero), B(TestEqualStrictNoFeedback), R(9), - B(JumpIfTrue), U8(29), + B(JumpIfTrue), U8(28), B(LdaSmi), I8(2), B(TestEqualStrictNoFeedback), R(9), - B(JumpIfTrue), U8(20), + B(JumpIfTrue), U8(19), B(LdaTrue), B(Star), R(11), B(Mov), R(8), R(10), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(10), U8(2), B(Star), R(4), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(3), - B(Jump), U8(35), + B(Jump), U8(34), B(Ldar), R(8), /* 16 E> */ B(Throw), B(LdaUndefined), @@ -209,14 +206,14 @@ bytecodes: [ B(Star), R(7), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2), B(Star), R(4), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(3), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(3), B(Jump), U8(8), B(Star), R(4), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(3), B(LdaTheHole), B(SetPendingMessage), @@ -227,12 +224,8 @@ bytecodes: [ B(Ldar), R(5), B(SetPendingMessage), B(Ldar), R(3), - B(SwitchOnSmiNoFeedback), U8(2), U8(4), I8(0), - B(Jump), U8(14), - B(Ldar), R(4), - /* 25 S> */ B(Return), - B(Ldar), R(4), - /* 25 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(4), /* 25 S> */ B(Return), B(Ldar), R(4), @@ -245,11 +238,9 @@ constant pool: [ Smi [126], Smi [6], Smi [9], - Smi [12], - Smi [15], ] handlers: [ - [52, 209, 215], + [52, 207, 213], ] --- @@ -259,7 +250,7 @@ snippet: " " frame size: 18 parameter count: 1 -bytecode array length: 708 +bytecode array length: 697 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -502,19 +493,19 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(8), B(SwitchOnSmiNoFeedback), U8(15), U8(2), I8(0), - B(Jump), U8(28), + B(Jump), U8(27), + B(PopContext), R(1), + B(PopContext), R(1), + B(LdaZero), + B(Star), R(5), + B(Mov), R(9), R(6), + B(Jump), U8(46), B(PopContext), R(1), B(PopContext), R(1), B(LdaSmi), I8(1), B(Star), R(5), B(Mov), R(9), R(6), - B(Jump), U8(47), - B(PopContext), R(1), - B(PopContext), R(1), - B(LdaSmi), I8(2), - B(Star), R(5), - B(Mov), R(9), R(6), - B(Jump), U8(34), + B(Jump), U8(33), B(PopContext), R(1), B(LdaUndefined), B(Star), R(8), @@ -522,14 +513,14 @@ bytecodes: [ B(Star), R(9), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(8), U8(2), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(4), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -540,14 +531,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(18), U8(5), I8(0), - B(Jump), U8(17), - B(Ldar), R(6), - /* 44 S> */ B(Return), - B(Ldar), R(6), - /* 44 S> */ B(Return), - B(Ldar), R(6), - B(ReThrow), + B(SwitchOnSmiNoFeedback), U8(18), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 44 S> */ B(Return), B(Ldar), R(6), @@ -572,16 +557,13 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], FIXED_ARRAY_TYPE, Smi [6], - Smi [19], - Smi [556], + Smi [18], + Smi [554], Smi [6], Smi [9], - Smi [12], - Smi [15], - Smi [18], ] handlers: [ - [52, 655, 661], + [52, 653, 659], [133, 422, 428], [136, 378, 380], [515, 531, 533], diff --git a/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden b/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden index 31828cf549..4fc48bf8d3 100644 --- a/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden +++ b/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden @@ -273,7 +273,7 @@ snippet: " " frame size: 15 parameter count: 1 -bytecode array length: 339 +bytecode array length: 335 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -322,7 +322,7 @@ bytecodes: [ B(Star), R(7), B(LdaZero), B(Star), R(6), - B(Jump), U8(193), + B(Jump), U8(192), B(Ldar), R(11), /* 11 E> */ B(Throw), B(Ldar), R(closure), @@ -400,14 +400,14 @@ bytecodes: [ B(Star), R(10), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(9), U8(2), B(Star), R(7), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(6), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(6), B(Jump), U8(8), B(Star), R(7), - B(LdaSmi), I8(2), + B(LdaSmi), I8(1), B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), @@ -418,10 +418,8 @@ bytecodes: [ B(Ldar), R(8), B(SetPendingMessage), B(Ldar), R(6), - B(SwitchOnSmiNoFeedback), U8(4), U8(3), I8(0), - B(Jump), U8(11), - B(Ldar), R(7), - /* 62 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(4), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(7), /* 62 S> */ B(Return), B(Ldar), R(7), @@ -436,10 +434,9 @@ constant pool: [ FIXED_ARRAY_TYPE, Smi [6], Smi [9], - Smi [12], ] handlers: [ - [52, 292, 298], + [52, 291, 297], ] --- @@ -451,7 +448,7 @@ snippet: " " frame size: 14 parameter count: 1 -bytecode array length: 452 +bytecode array length: 444 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -550,7 +547,7 @@ bytecodes: [ B(JumpIfFalse), U8(4), B(Jump), U8(6), B(PopContext), R(2), - B(Jump), U8(158), + B(Jump), U8(157), B(Ldar), R(3), B(SwitchOnSmiNoFeedback), U8(5), U8(1), I8(1), B(LdaSmi), I8(-2), @@ -563,7 +560,7 @@ bytecodes: [ B(Star), R(8), B(LdaSmi), I8(1), B(TestEqual), R(8), U8(6), - B(JumpIfFalse), U8(102), + B(JumpIfFalse), U8(101), /* 18 E> */ B(StackCheck), /* 47 S> */ B(LdaCurrentContextSlot), U8(4), B(Star), R(8), @@ -585,10 +582,10 @@ bytecodes: [ B(Star), R(11), B(LdaZero), B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(37), + B(JumpIfTrue), U8(36), B(LdaSmi), I8(2), B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(28), + B(JumpIfTrue), U8(27), B(LdaTrue), B(Star), R(13), B(Mov), R(10), R(12), @@ -598,16 +595,16 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(73), + B(Jump), U8(72), B(Ldar), R(10), /* 47 E> */ B(Throw), B(LdaZero), B(StaContextSlot), R(1), U8(7), U8(0), B(LdaCurrentContextSlot), U8(4), /* 54 E> */ B(StaContextSlot), R(1), U8(5), U8(0), - B(JumpLoop), U8(131), I8(1), + B(JumpLoop), U8(130), I8(1), B(LdaContextSlot), R(1), U8(7), U8(0), B(Star), R(8), B(LdaSmi), I8(1), @@ -616,7 +613,7 @@ bytecodes: [ B(PopContext), R(2), B(Jump), U8(7), B(PopContext), R(2), - B(JumpLoop), U8(239), I8(0), + B(JumpLoop), U8(238), I8(0), B(PopContext), R(1), B(LdaUndefined), B(Star), R(8), @@ -624,14 +621,14 @@ bytecodes: [ B(Star), R(9), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(8), U8(2), B(Star), R(6), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -642,12 +639,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(7), U8(4), I8(0), - B(Jump), U8(14), - B(Ldar), R(6), - /* 56 S> */ B(Return), - B(Ldar), R(6), - /* 56 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 56 S> */ B(Return), B(Ldar), R(6), @@ -662,14 +655,12 @@ constant pool: [ Smi [84], FIXED_ARRAY_TYPE, Smi [60], - Smi [303], + Smi [301], Smi [6], Smi [9], - Smi [12], - Smi [15], ] handlers: [ - [52, 402, 408], + [52, 400, 406], ] --- @@ -681,7 +672,7 @@ snippet: " " frame size: 12 parameter count: 1 -bytecode array length: 304 +bytecode array length: 300 bytecodes: [ B(CreateFunctionContext), U8(5), B(PushContext), R(0), @@ -772,8 +763,8 @@ bytecodes: [ B(Star), R(5), B(LdaZero), B(Star), R(4), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(8), B(Ldar), R(closure), B(CreateCatchContext), R(8), U8(3), U8(4), @@ -795,14 +786,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(5), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(4), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(4), B(Jump), U8(8), B(Star), R(5), - B(LdaSmi), I8(2), + B(LdaSmi), I8(1), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -815,10 +806,8 @@ bytecodes: [ B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), - B(SwitchOnSmiNoFeedback), U8(5), U8(3), I8(0), - B(Jump), U8(11), - B(Ldar), R(5), - /* 67 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(5), /* 67 S> */ B(Return), B(Ldar), R(5), @@ -834,10 +823,9 @@ constant pool: [ FIXED_ARRAY_TYPE, Smi [6], Smi [9], - Smi [12], ] handlers: [ - [17, 255, 261], + [17, 254, 260], [20, 201, 203], ] @@ -850,7 +838,7 @@ snippet: " " frame size: 15 parameter count: 1 -bytecode array length: 491 +bytecode array length: 483 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -983,7 +971,7 @@ bytecodes: [ B(Star), R(6), B(LdaZero), B(Star), R(5), - B(Jump), U8(136), + B(Jump), U8(134), B(Ldar), R(11), B(ReThrow), B(LdaZero), @@ -1010,10 +998,10 @@ bytecodes: [ B(CallJSRuntime), U8(%promise_resolve), R(9), U8(3), B(LdaCurrentContextSlot), U8(6), B(Star), R(6), - B(LdaSmi), I8(1), + B(LdaZero), B(Star), R(5), - B(Jump), U8(68), - B(Jump), U8(54), + B(Jump), U8(67), + B(Jump), U8(53), B(Star), R(9), B(Ldar), R(closure), B(CreateCatchContext), R(9), U8(5), U8(6), @@ -1035,14 +1023,14 @@ bytecodes: [ B(PopContext), R(1), B(PopContext), R(1), B(Star), R(6), - B(LdaSmi), I8(2), + B(LdaZero), B(Star), R(5), B(Jump), U8(14), B(LdaSmi), I8(-1), B(Star), R(5), B(Jump), U8(8), B(Star), R(6), - B(LdaSmi), I8(3), + B(LdaSmi), I8(1), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -1055,12 +1043,8 @@ bytecodes: [ B(Ldar), R(7), B(SetPendingMessage), B(Ldar), R(5), - B(SwitchOnSmiNoFeedback), U8(7), U8(4), I8(0), - B(Jump), U8(14), - B(Ldar), R(6), - /* 61 S> */ B(Return), - B(Ldar), R(6), - /* 61 S> */ B(Return), + B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0), + B(Jump), U8(8), B(Ldar), R(6), /* 61 S> */ B(Return), B(Ldar), R(6), @@ -1078,11 +1062,9 @@ constant pool: [ FIXED_ARRAY_TYPE, Smi [6], Smi [9], - Smi [12], - Smi [15], ] handlers: [ - [61, 439, 445], - [64, 385, 387], + [61, 437, 443], + [64, 384, 386], ]