Commit 02fee655 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[interpreter] Avoid redundant {PopContext} instructions.

This avoids emitting redundant {PopContext} bytecode instructions when
non-local control-flow leaves the method body. It also folds multiple
such {PopContext} instructions into one, in case several scoping levels
are crossed at one. Only the expected context of the target of a local
control-flow transfer matters.

R=rmcilroy@chromium.org
TEST=debugger/regress/regress-crbug-724858
BUG=chromium:724858

Change-Id: Id4a47ae9fea25e75ae1af13619720b16a3975edf
Reviewed-on: https://chromium-review.googlesource.com/512545Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45507}
parent bf2f18ff
...@@ -84,7 +84,6 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED { ...@@ -84,7 +84,6 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
} }
Register reg() const { return register_; } Register reg() const { return register_; }
bool ShouldPopContext() { return should_pop_context_; }
private: private:
const BytecodeArrayBuilder* builder() const { return generator_->builder(); } const BytecodeArrayBuilder* builder() const { return generator_->builder(); }
...@@ -129,6 +128,11 @@ class BytecodeGenerator::ControlScope BASE_EMBEDDED { ...@@ -129,6 +128,11 @@ class BytecodeGenerator::ControlScope BASE_EMBEDDED {
void PerformCommand(Command command, Statement* statement); void PerformCommand(Command command, Statement* statement);
virtual bool Execute(Command command, Statement* statement) = 0; virtual bool Execute(Command command, Statement* statement) = 0;
// Helper to pop the context chain to a depth expected by this control scope.
// Note that it is the responsibility of each individual {Execute} method to
// trigger this when commands are handled and control-flow continues locally.
void PopContextToExpectedDepth();
BytecodeGenerator* generator() const { return generator_; } BytecodeGenerator* generator() const { return generator_; }
ControlScope* outer() const { return outer_; } ControlScope* outer() const { return outer_; }
ContextScope* context() const { return context_; } ContextScope* context() const { return context_; }
...@@ -306,12 +310,15 @@ class BytecodeGenerator::ControlScopeForTopLevel final ...@@ -306,12 +310,15 @@ class BytecodeGenerator::ControlScopeForTopLevel final
case CMD_CONTINUE: case CMD_CONTINUE:
UNREACHABLE(); UNREACHABLE();
case CMD_RETURN: case CMD_RETURN:
// No need to pop contexts, execution leaves the method body.
generator()->BuildReturn(); generator()->BuildReturn();
return true; return true;
case CMD_ASYNC_RETURN: case CMD_ASYNC_RETURN:
// No need to pop contexts, execution leaves the method body.
generator()->BuildAsyncReturn(); generator()->BuildAsyncReturn();
return true; return true;
case CMD_RETHROW: case CMD_RETHROW:
// No need to pop contexts, execution leaves the method body.
generator()->BuildReThrow(); generator()->BuildReThrow();
return true; return true;
} }
...@@ -335,6 +342,7 @@ class BytecodeGenerator::ControlScopeForBreakable final ...@@ -335,6 +342,7 @@ class BytecodeGenerator::ControlScopeForBreakable final
if (statement != statement_) return false; if (statement != statement_) return false;
switch (command) { switch (command) {
case CMD_BREAK: case CMD_BREAK:
PopContextToExpectedDepth();
control_builder_->Break(); control_builder_->Break();
return true; return true;
case CMD_CONTINUE: case CMD_CONTINUE:
...@@ -371,9 +379,11 @@ class BytecodeGenerator::ControlScopeForIteration final ...@@ -371,9 +379,11 @@ class BytecodeGenerator::ControlScopeForIteration final
if (statement != statement_) return false; if (statement != statement_) return false;
switch (command) { switch (command) {
case CMD_BREAK: case CMD_BREAK:
PopContextToExpectedDepth();
loop_builder_->Break(); loop_builder_->Break();
return true; return true;
case CMD_CONTINUE: case CMD_CONTINUE:
PopContextToExpectedDepth();
loop_builder_->Continue(); loop_builder_->Continue();
return true; return true;
case CMD_RETURN: case CMD_RETURN:
...@@ -406,6 +416,8 @@ class BytecodeGenerator::ControlScopeForTryCatch final ...@@ -406,6 +416,8 @@ class BytecodeGenerator::ControlScopeForTryCatch final
case CMD_ASYNC_RETURN: case CMD_ASYNC_RETURN:
break; break;
case CMD_RETHROW: case CMD_RETHROW:
// No need to pop contexts, execution re-enters the method body via the
// stack unwinding mechanism which itself restores contexts correctly.
generator()->BuildReThrow(); generator()->BuildReThrow();
return true; return true;
} }
...@@ -432,6 +444,7 @@ class BytecodeGenerator::ControlScopeForTryFinally final ...@@ -432,6 +444,7 @@ class BytecodeGenerator::ControlScopeForTryFinally final
case CMD_RETURN: case CMD_RETURN:
case CMD_ASYNC_RETURN: case CMD_ASYNC_RETURN:
case CMD_RETHROW: case CMD_RETHROW:
PopContextToExpectedDepth();
commands_->RecordCommand(command, statement); commands_->RecordCommand(command, statement);
try_finally_builder_->LeaveTry(); try_finally_builder_->LeaveTry();
return true; return true;
...@@ -447,25 +460,23 @@ class BytecodeGenerator::ControlScopeForTryFinally final ...@@ -447,25 +460,23 @@ class BytecodeGenerator::ControlScopeForTryFinally final
void BytecodeGenerator::ControlScope::PerformCommand(Command command, void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) { Statement* statement) {
ControlScope* current = this; ControlScope* current = this;
ContextScope* context = generator()->execution_context();
// Pop context to the expected depth but do not pop the outermost context.
if (context != current->context() && context->ShouldPopContext()) {
generator()->builder()->PopContext(current->context()->reg());
}
do { do {
if (current->Execute(command, statement)) { if (current->Execute(command, statement)) {
return; return;
} }
current = current->outer(); current = current->outer();
if (current->context() != context && context->ShouldPopContext()) {
// Pop context to the expected depth.
// TODO(rmcilroy): Only emit a single context pop.
generator()->builder()->PopContext(current->context()->reg());
}
} while (current != nullptr); } while (current != nullptr);
UNREACHABLE(); UNREACHABLE();
} }
void BytecodeGenerator::ControlScope::PopContextToExpectedDepth() {
// Pop context to the expected depth. Note that this can in fact pop multiple
// contexts at once because the {PopContext} bytecode takes a saved register.
if (generator()->execution_context() != context()) {
generator()->builder()->PopContext(context()->reg());
}
}
class BytecodeGenerator::RegisterAllocationScope final { class BytecodeGenerator::RegisterAllocationScope final {
public: public:
explicit RegisterAllocationScope(BytecodeGenerator* generator) explicit RegisterAllocationScope(BytecodeGenerator* generator)
......
...@@ -695,13 +695,13 @@ snippet: " ...@@ -695,13 +695,13 @@ snippet: "
" "
frame size: 4 frame size: 4
parameter count: 1 parameter count: 1
bytecode array length: 54 bytecode array length: 52
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaZero), /* 42 S> */ B(LdaZero),
B(Star), R(1), B(Star), R(1),
/* 52 S> */ B(Ldar), R(1), /* 52 S> */ B(Ldar), R(1),
B(JumpIfToBooleanFalse), U8(46), B(JumpIfToBooleanFalse), U8(44),
/* 45 E> */ B(StackCheck), /* 45 E> */ B(StackCheck),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateBlockContext), U8(0), B(CreateBlockContext), U8(0),
...@@ -714,15 +714,14 @@ bytecodes: [ ...@@ -714,15 +714,14 @@ bytecodes: [
/* 73 E> */ B(StaCurrentContextSlot), U8(4), /* 73 E> */ B(StaCurrentContextSlot), U8(4),
B(Mov), R(0), R(2), B(Mov), R(0), R(2),
/* 106 S> */ B(LdaCurrentContextSlot), U8(4), /* 106 S> */ B(LdaCurrentContextSlot), U8(4),
B(JumpIfToBooleanFalse), U8(8), B(JumpIfToBooleanFalse), U8(6),
/* 113 S> */ B(PopContext), R(3), /* 113 S> */ B(PopContext), R(3),
B(PopContext), R(3),
B(Jump), U8(10), B(Jump), U8(10),
/* 126 S> */ B(LdaCurrentContextSlot), U8(4), /* 126 S> */ B(LdaCurrentContextSlot), U8(4),
B(Inc), U8(4), B(Inc), U8(4),
/* 127 E> */ B(StaCurrentContextSlot), U8(4), /* 127 E> */ B(StaCurrentContextSlot), U8(4),
B(PopContext), R(3), B(PopContext), R(3),
B(JumpLoop), U8(45), I8(0), B(JumpLoop), U8(43), I8(0),
B(LdaUndefined), B(LdaUndefined),
/* 137 S> */ B(Return), /* 137 S> */ B(Return),
] ]
......
...@@ -102,7 +102,7 @@ snippet: " ...@@ -102,7 +102,7 @@ snippet: "
" "
frame size: 2 frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 32 bytecode array length: 30
bytecodes: [ bytecodes: [
B(CreateFunctionContext), U8(1), B(CreateFunctionContext), U8(1),
B(PushContext), R(0), B(PushContext), R(0),
...@@ -119,7 +119,6 @@ bytecodes: [ ...@@ -119,7 +119,6 @@ bytecodes: [
/* 69 S> */ B(LdaSmi), I8(2), /* 69 S> */ B(LdaSmi), I8(2),
/* 69 E> */ B(StaCurrentContextSlot), U8(4), /* 69 E> */ B(StaCurrentContextSlot), U8(4),
/* 72 S> */ B(CreateClosure), U8(1), U8(3), U8(2), /* 72 S> */ B(CreateClosure), U8(1), U8(3), U8(2),
B(PopContext), R(0),
/* 104 S> */ B(Return), /* 104 S> */ B(Return),
] ]
constant pool: [ constant pool: [
......
...@@ -154,7 +154,7 @@ snippet: " ...@@ -154,7 +154,7 @@ snippet: "
" "
frame size: 22 frame size: 22
parameter count: 2 parameter count: 2
bytecode array length: 345 bytecode array length: 343
bytecodes: [ bytecodes: [
B(CreateFunctionContext), U8(4), B(CreateFunctionContext), U8(4),
B(PushContext), R(7), B(PushContext), R(7),
...@@ -299,8 +299,7 @@ bytecodes: [ ...@@ -299,8 +299,7 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(10), B(TestEqualStrictNoFeedback), R(10),
B(JumpIfFalse), U8(7), B(JumpIfFalse), U8(5),
B(PopContext), R(7),
B(Ldar), R(11), B(Ldar), R(11),
B(ReThrow), B(ReThrow),
B(PopContext), R(8), B(PopContext), R(8),
...@@ -644,7 +643,7 @@ snippet: " ...@@ -644,7 +643,7 @@ snippet: "
" "
frame size: 15 frame size: 15
parameter count: 2 parameter count: 2
bytecode array length: 589 bytecode array length: 587
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -849,8 +848,7 @@ bytecodes: [ ...@@ -849,8 +848,7 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(9), B(TestEqualStrictNoFeedback), R(9),
B(JumpIfFalse), U8(15), B(JumpIfFalse), U8(13),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(Star), R(6), B(Star), R(6),
...@@ -904,12 +902,12 @@ constant pool: [ ...@@ -904,12 +902,12 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [446], Smi [444],
Smi [6], Smi [6],
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[55, 546, 552], [55, 544, 550],
[134, 331, 337], [134, 331, 337],
[137, 287, 289], [137, 287, 289],
[423, 439, 441], [423, 439, 441],
...@@ -924,7 +922,7 @@ snippet: " ...@@ -924,7 +922,7 @@ snippet: "
" "
frame size: 17 frame size: 17
parameter count: 2 parameter count: 2
bytecode array length: 695 bytecode array length: 681
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -1019,7 +1017,7 @@ bytecodes: [ ...@@ -1019,7 +1017,7 @@ bytecodes: [
B(LdaContextSlot), R(1), U8(8), U8(0), B(LdaContextSlot), R(1), U8(8), U8(0),
B(Star), R(12), B(Star), R(12),
B(LdaNamedProperty), R(12), U8(6), U8(11), B(LdaNamedProperty), R(12), U8(6), U8(11),
B(JumpIfToBooleanTrue), U8(142), B(JumpIfToBooleanTrue), U8(132),
B(LdaContextSlot), R(1), U8(8), U8(0), B(LdaContextSlot), R(1), U8(8), U8(0),
B(Star), R(12), B(Star), R(12),
B(LdaNamedProperty), R(12), U8(7), U8(13), B(LdaNamedProperty), R(12), U8(7), U8(13),
...@@ -1056,20 +1054,15 @@ bytecodes: [ ...@@ -1056,20 +1054,15 @@ bytecodes: [
B(Star), R(14), B(Star), R(14),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(14), B(TestEqualStrictNoFeedback), R(14),
B(JumpIfTrue), U8(40), B(JumpIfTrue), U8(30),
B(LdaSmi), I8(2), B(LdaSmi), I8(2),
B(TestEqualStrictNoFeedback), R(14), B(TestEqualStrictNoFeedback), R(14),
B(JumpIfTrue), U8(31), B(JumpIfTrue), U8(21),
B(LdaTrue), B(LdaTrue),
B(Star), R(16), B(Star), R(16),
B(Mov), R(13), R(15), B(Mov), R(13), R(15),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(15), U8(2), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(15), U8(2),
B(PopContext), R(2), B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(Star), R(9), B(Star), R(9),
B(LdaZero), B(LdaZero),
B(Star), R(8), B(Star), R(8),
...@@ -1079,7 +1072,7 @@ bytecodes: [ ...@@ -1079,7 +1072,7 @@ bytecodes: [
B(PopContext), R(2), B(PopContext), R(2),
B(LdaZero), B(LdaZero),
B(StaContextSlot), R(1), U8(9), U8(0), B(StaContextSlot), R(1), U8(9), U8(0),
B(JumpLoop), U8(210), I8(0), B(JumpLoop), U8(200), I8(0),
B(Jump), U8(44), B(Jump), U8(44),
B(Star), R(12), B(Star), R(12),
B(Ldar), R(closure), B(Ldar), R(closure),
...@@ -1169,14 +1162,12 @@ bytecodes: [ ...@@ -1169,14 +1162,12 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(Ldar), R(8), B(Ldar), R(8),
B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0), B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0),
B(Jump), U8(27), B(Jump), U8(23),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Mov), R(9), R(6), B(Mov), R(9), R(6),
B(Jump), U8(46), B(Jump), U8(44),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(Star), R(5), B(Star), R(5),
...@@ -1232,16 +1223,16 @@ constant pool: [ ...@@ -1232,16 +1223,16 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [6], Smi [6],
Smi [18], Smi [16],
Smi [552], Smi [538],
Smi [6], Smi [6],
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[55, 652, 658], [55, 638, 644],
[134, 421, 427], [134, 411, 417],
[137, 377, 379], [137, 367, 369],
[514, 530, 532], [504, 520, 522],
] ]
--- ---
...@@ -1253,7 +1244,7 @@ snippet: " ...@@ -1253,7 +1244,7 @@ snippet: "
" "
frame size: 14 frame size: 14
parameter count: 2 parameter count: 2
bytecode array length: 556 bytecode array length: 550
bytecodes: [ bytecodes: [
B(CreateFunctionContext), U8(10), B(CreateFunctionContext), U8(10),
B(PushContext), R(0), B(PushContext), R(0),
...@@ -1420,9 +1411,7 @@ bytecodes: [ ...@@ -1420,9 +1411,7 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(8), B(TestEqualStrictNoFeedback), R(8),
B(JumpIfFalse), U8(9), B(JumpIfFalse), U8(5),
B(PopContext), R(1),
B(PopContext), R(1),
B(Ldar), R(9), B(Ldar), R(9),
B(ReThrow), B(ReThrow),
B(PopContext), R(1), B(PopContext), R(1),
...@@ -1437,8 +1426,8 @@ bytecodes: [ ...@@ -1437,8 +1426,8 @@ bytecodes: [
B(Star), R(5), B(Star), R(5),
B(LdaZero), B(LdaZero),
B(Star), R(4), B(Star), R(4),
B(Jump), U8(67), B(Jump), U8(65),
B(Jump), U8(53), B(Jump), U8(51),
B(Star), R(8), B(Star), R(8),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateCatchContext), R(8), U8(7), U8(12), B(CreateCatchContext), R(8), U8(7), U8(12),
...@@ -1458,7 +1447,6 @@ bytecodes: [ ...@@ -1458,7 +1447,6 @@ bytecodes: [
B(CallJSRuntime), U8(%promise_internal_reject), R(8), U8(4), B(CallJSRuntime), U8(%promise_internal_reject), R(8), U8(4),
B(LdaContextSlot), R(1), U8(13), U8(0), B(LdaContextSlot), R(1), U8(13), U8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(PopContext), R(1),
B(Star), R(5), B(Star), R(5),
B(LdaZero), B(LdaZero),
B(Star), R(4), B(Star), R(4),
...@@ -1507,8 +1495,8 @@ constant pool: [ ...@@ -1507,8 +1495,8 @@ constant pool: [
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[21, 510, 516], [21, 504, 510],
[24, 457, 459], [24, 453, 455],
[41, 242, 248], [41, 242, 248],
[44, 194, 196], [44, 194, 196],
[334, 350, 352], [334, 350, 352],
...@@ -1523,7 +1511,7 @@ snippet: " ...@@ -1523,7 +1511,7 @@ snippet: "
" "
frame size: 18 frame size: 18
parameter count: 2 parameter count: 2
bytecode array length: 732 bytecode array length: 710
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -1593,7 +1581,7 @@ bytecodes: [ ...@@ -1593,7 +1581,7 @@ bytecodes: [
B(LdaContextSlot), R(1), U8(10), U8(0), B(LdaContextSlot), R(1), U8(10), U8(0),
B(Star), R(13), B(Star), R(13),
B(LdaNamedProperty), R(13), U8(5), U8(11), B(LdaNamedProperty), R(13), U8(5), U8(11),
B(JumpIfToBooleanTrue), U8(165), B(JumpIfToBooleanTrue), U8(155),
B(LdaContextSlot), R(1), U8(10), U8(0), B(LdaContextSlot), R(1), U8(10), U8(0),
B(Star), R(13), B(Star), R(13),
B(LdaNamedProperty), R(13), U8(6), U8(13), B(LdaNamedProperty), R(13), U8(6), U8(13),
...@@ -1637,20 +1625,15 @@ bytecodes: [ ...@@ -1637,20 +1625,15 @@ bytecodes: [
B(Star), R(15), B(Star), R(15),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(15), B(TestEqualStrictNoFeedback), R(15),
B(JumpIfTrue), U8(40), B(JumpIfTrue), U8(30),
B(LdaSmi), I8(2), B(LdaSmi), I8(2),
B(TestEqualStrictNoFeedback), R(15), B(TestEqualStrictNoFeedback), R(15),
B(JumpIfTrue), U8(31), B(JumpIfTrue), U8(21),
B(LdaTrue), B(LdaTrue),
B(Star), R(17), B(Star), R(17),
B(Mov), R(14), R(16), B(Mov), R(14), R(16),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2),
B(PopContext), R(2), B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(Star), R(10), B(Star), R(10),
B(LdaZero), B(LdaZero),
B(Star), R(9), B(Star), R(9),
...@@ -1660,7 +1643,7 @@ bytecodes: [ ...@@ -1660,7 +1643,7 @@ bytecodes: [
B(PopContext), R(2), B(PopContext), R(2),
B(LdaZero), B(LdaZero),
B(StaContextSlot), R(1), U8(11), U8(0), B(StaContextSlot), R(1), U8(11), U8(0),
B(JumpLoop), U8(233), I8(0), B(JumpLoop), U8(223), I8(0),
B(Jump), U8(48), B(Jump), U8(48),
B(Star), R(13), B(Star), R(13),
B(Ldar), R(closure), B(Ldar), R(closure),
...@@ -1753,17 +1736,12 @@ bytecodes: [ ...@@ -1753,17 +1736,12 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(Ldar), R(9), B(Ldar), R(9),
B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0), B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0),
B(Jump), U8(25), B(Jump), U8(15),
B(PopContext), R(1),
B(PopContext), R(1),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Mov), R(10), R(6), B(Mov), R(10), R(6),
B(Jump), U8(99), B(Jump), U8(93),
B(PopContext), R(1),
B(PopContext), R(1),
B(Ldar), R(10), B(Ldar), R(10),
B(ReThrow), B(ReThrow),
B(PopContext), R(1), B(PopContext), R(1),
...@@ -1778,8 +1756,8 @@ bytecodes: [ ...@@ -1778,8 +1756,8 @@ bytecodes: [
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Jump), U8(67), B(Jump), U8(65),
B(Jump), U8(53), B(Jump), U8(51),
B(Star), R(9), B(Star), R(9),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateCatchContext), R(9), U8(8), U8(15), B(CreateCatchContext), R(9), U8(8), U8(15),
...@@ -1799,7 +1777,6 @@ bytecodes: [ ...@@ -1799,7 +1777,6 @@ bytecodes: [
B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4),
B(LdaContextSlot), R(1), U8(7), U8(0), B(LdaContextSlot), R(1), U8(7), U8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(PopContext), R(1),
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
...@@ -1845,16 +1822,16 @@ constant pool: [ ...@@ -1845,16 +1822,16 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [6], Smi [6],
Smi [22], Smi [16],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [6], Smi [6],
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[64, 686, 692], [64, 664, 670],
[67, 633, 635], [67, 613, 615],
[84, 398, 404], [84, 388, 394],
[87, 350, 352], [87, 340, 342],
[491, 507, 509], [481, 497, 499],
] ]
...@@ -250,7 +250,7 @@ snippet: " ...@@ -250,7 +250,7 @@ snippet: "
" "
frame size: 17 frame size: 17
parameter count: 1 parameter count: 1
bytecode array length: 691 bytecode array length: 677
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -343,7 +343,7 @@ bytecodes: [ ...@@ -343,7 +343,7 @@ bytecodes: [
B(LdaContextSlot), R(1), U8(7), U8(0), B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(12), B(Star), R(12),
B(LdaNamedProperty), R(12), U8(7), U8(12), B(LdaNamedProperty), R(12), U8(7), U8(12),
B(JumpIfToBooleanTrue), U8(142), B(JumpIfToBooleanTrue), U8(132),
B(LdaContextSlot), R(1), U8(7), U8(0), B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(12), B(Star), R(12),
B(LdaNamedProperty), R(12), U8(8), U8(14), B(LdaNamedProperty), R(12), U8(8), U8(14),
...@@ -380,20 +380,15 @@ bytecodes: [ ...@@ -380,20 +380,15 @@ bytecodes: [
B(Star), R(14), B(Star), R(14),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(14), B(TestEqualStrictNoFeedback), R(14),
B(JumpIfTrue), U8(40), B(JumpIfTrue), U8(30),
B(LdaSmi), I8(2), B(LdaSmi), I8(2),
B(TestEqualStrictNoFeedback), R(14), B(TestEqualStrictNoFeedback), R(14),
B(JumpIfTrue), U8(31), B(JumpIfTrue), U8(21),
B(LdaTrue), B(LdaTrue),
B(Star), R(16), B(Star), R(16),
B(Mov), R(13), R(15), B(Mov), R(13), R(15),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(15), U8(2), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(15), U8(2),
B(PopContext), R(2), B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(Star), R(9), B(Star), R(9),
B(LdaZero), B(LdaZero),
B(Star), R(8), B(Star), R(8),
...@@ -403,7 +398,7 @@ bytecodes: [ ...@@ -403,7 +398,7 @@ bytecodes: [
B(PopContext), R(2), B(PopContext), R(2),
B(LdaZero), B(LdaZero),
B(StaContextSlot), R(1), U8(8), U8(0), B(StaContextSlot), R(1), U8(8), U8(0),
B(JumpLoop), U8(210), I8(0), B(JumpLoop), U8(200), I8(0),
B(Jump), U8(44), B(Jump), U8(44),
B(Star), R(12), B(Star), R(12),
B(Ldar), R(closure), B(Ldar), R(closure),
...@@ -493,14 +488,12 @@ bytecodes: [ ...@@ -493,14 +488,12 @@ bytecodes: [
B(SetPendingMessage), B(SetPendingMessage),
B(Ldar), R(8), B(Ldar), R(8),
B(SwitchOnSmiNoFeedback), U8(15), U8(2), I8(0), B(SwitchOnSmiNoFeedback), U8(15), U8(2), I8(0),
B(Jump), U8(27), B(Jump), U8(23),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Mov), R(9), R(6), B(Mov), R(9), R(6),
B(Jump), U8(46), B(Jump), U8(44),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(Star), R(5), B(Star), R(5),
...@@ -557,16 +550,16 @@ constant pool: [ ...@@ -557,16 +550,16 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [6], Smi [6],
Smi [18], Smi [16],
Smi [552], Smi [538],
Smi [6], Smi [6],
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[51, 648, 654], [51, 634, 640],
[130, 417, 423], [130, 407, 413],
[133, 373, 375], [133, 363, 365],
[510, 526, 528], [500, 516, 518],
] ]
--- ---
......
...@@ -448,7 +448,7 @@ snippet: " ...@@ -448,7 +448,7 @@ snippet: "
" "
frame size: 13 frame size: 13
parameter count: 1 parameter count: 1
bytecode array length: 438 bytecode array length: 432
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -547,7 +547,7 @@ bytecodes: [ ...@@ -547,7 +547,7 @@ bytecodes: [
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(6), B(Jump), U8(6),
B(PopContext), R(2), B(PopContext), R(2),
B(Jump), U8(155), B(Jump), U8(149),
B(Ldar), R(3), B(Ldar), R(3),
B(SwitchOnSmiNoFeedback), U8(5), U8(1), I8(1), B(SwitchOnSmiNoFeedback), U8(5), U8(1), I8(1),
B(LdaSmi), I8(-2), B(LdaSmi), I8(-2),
...@@ -560,7 +560,7 @@ bytecodes: [ ...@@ -560,7 +560,7 @@ bytecodes: [
B(Star), R(8), B(Star), R(8),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(TestEqual), R(8), U8(6), B(TestEqual), R(8), U8(6),
B(JumpIfFalse), U8(99), B(JumpIfFalse), U8(93),
/* 18 E> */ B(StackCheck), /* 18 E> */ B(StackCheck),
/* 47 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0), /* 47 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0),
B(Star), R(8), B(Star), R(8),
...@@ -582,17 +582,14 @@ bytecodes: [ ...@@ -582,17 +582,14 @@ bytecodes: [
B(Star), R(10), B(Star), R(10),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(10), B(TestEqualStrictNoFeedback), R(10),
B(JumpIfTrue), U8(36), B(JumpIfTrue), U8(30),
B(LdaSmi), I8(2), B(LdaSmi), I8(2),
B(TestEqualStrictNoFeedback), R(10), B(TestEqualStrictNoFeedback), R(10),
B(JumpIfTrue), U8(27), B(JumpIfTrue), U8(21),
B(LdaTrue), B(LdaTrue),
B(Star), R(12), B(Star), R(12),
B(Mov), R(9), R(11), B(Mov), R(9), R(11),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
...@@ -604,7 +601,7 @@ bytecodes: [ ...@@ -604,7 +601,7 @@ bytecodes: [
B(StaContextSlot), R(1), U8(7), U8(0), B(StaContextSlot), R(1), U8(7), U8(0),
B(LdaCurrentContextSlot), U8(4), B(LdaCurrentContextSlot), U8(4),
/* 54 E> */ B(StaContextSlot), R(1), U8(5), U8(0), /* 54 E> */ B(StaContextSlot), R(1), U8(5), U8(0),
B(JumpLoop), U8(128), I8(1), B(JumpLoop), U8(122), I8(1),
B(LdaContextSlot), R(1), U8(7), U8(0), B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(8), B(Star), R(8),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
...@@ -613,7 +610,7 @@ bytecodes: [ ...@@ -613,7 +610,7 @@ bytecodes: [
B(PopContext), R(2), B(PopContext), R(2),
B(Jump), U8(7), B(Jump), U8(7),
B(PopContext), R(2), B(PopContext), R(2),
B(JumpLoop), U8(236), I8(0), B(JumpLoop), U8(230), I8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaUndefined), B(LdaUndefined),
B(Star), R(8), B(Star), R(8),
...@@ -655,12 +652,12 @@ constant pool: [ ...@@ -655,12 +652,12 @@ constant pool: [
Smi [84], Smi [84],
FIXED_ARRAY_TYPE, FIXED_ARRAY_TYPE,
Smi [60], Smi [60],
Smi [299], Smi [293],
Smi [6], Smi [6],
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[51, 395, 401], [51, 389, 395],
] ]
--- ---
...@@ -672,7 +669,7 @@ snippet: " ...@@ -672,7 +669,7 @@ snippet: "
" "
frame size: 12 frame size: 12
parameter count: 1 parameter count: 1
bytecode array length: 300 bytecode array length: 298
bytecodes: [ bytecodes: [
B(CreateFunctionContext), U8(5), B(CreateFunctionContext), U8(5),
B(PushContext), R(0), B(PushContext), R(0),
...@@ -763,8 +760,8 @@ bytecodes: [ ...@@ -763,8 +760,8 @@ bytecodes: [
B(Star), R(5), B(Star), R(5),
B(LdaZero), B(LdaZero),
B(Star), R(4), B(Star), R(4),
B(Jump), U8(67), B(Jump), U8(65),
B(Jump), U8(53), B(Jump), U8(51),
B(Star), R(8), B(Star), R(8),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateCatchContext), R(8), U8(3), U8(4), B(CreateCatchContext), R(8), U8(3), U8(4),
...@@ -784,7 +781,6 @@ bytecodes: [ ...@@ -784,7 +781,6 @@ bytecodes: [
B(CallJSRuntime), U8(%promise_internal_reject), R(8), U8(4), B(CallJSRuntime), U8(%promise_internal_reject), R(8), U8(4),
B(LdaContextSlot), R(1), U8(8), U8(0), B(LdaContextSlot), R(1), U8(8), U8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(PopContext), R(1),
B(Star), R(5), B(Star), R(5),
B(LdaZero), B(LdaZero),
B(Star), R(4), B(Star), R(4),
...@@ -825,7 +821,7 @@ constant pool: [ ...@@ -825,7 +821,7 @@ constant pool: [
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[17, 254, 260], [17, 252, 258],
[20, 201, 203], [20, 201, 203],
] ]
...@@ -838,7 +834,7 @@ snippet: " ...@@ -838,7 +834,7 @@ snippet: "
" "
frame size: 14 frame size: 14
parameter count: 1 parameter count: 1
bytecode array length: 480 bytecode array length: 465
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25), B(JumpIfUndefined), U8(25),
...@@ -912,7 +908,7 @@ bytecodes: [ ...@@ -912,7 +908,7 @@ bytecodes: [
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(6), B(Jump), U8(6),
B(PopContext), R(2), B(PopContext), R(2),
B(Jump), U8(185), B(Jump), U8(172),
B(Ldar), R(3), B(Ldar), R(3),
B(SwitchOnSmiNoFeedback), U8(4), U8(1), I8(0), B(SwitchOnSmiNoFeedback), U8(4), U8(1), I8(0),
B(LdaSmi), I8(-2), B(LdaSmi), I8(-2),
...@@ -925,7 +921,7 @@ bytecodes: [ ...@@ -925,7 +921,7 @@ bytecodes: [
B(Star), R(9), B(Star), R(9),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(TestEqual), R(9), U8(6), B(TestEqual), R(9), U8(6),
B(JumpIfFalse), U8(126), B(JumpIfFalse), U8(116),
/* 23 E> */ B(StackCheck), /* 23 E> */ B(StackCheck),
/* 52 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0), /* 52 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0),
B(Star), R(9), B(Star), R(9),
...@@ -954,40 +950,35 @@ bytecodes: [ ...@@ -954,40 +950,35 @@ bytecodes: [
B(Star), R(11), B(Star), R(11),
B(LdaZero), B(LdaZero),
B(TestEqualStrictNoFeedback), R(11), B(TestEqualStrictNoFeedback), R(11),
B(JumpIfTrue), U8(40), B(JumpIfTrue), U8(30),
B(LdaSmi), I8(2), B(LdaSmi), I8(2),
B(TestEqualStrictNoFeedback), R(11), B(TestEqualStrictNoFeedback), R(11),
B(JumpIfTrue), U8(31), B(JumpIfTrue), U8(21),
B(LdaTrue), B(LdaTrue),
B(Star), R(13), B(Star), R(13),
B(Mov), R(10), R(12), B(Mov), R(10), R(12),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(12), U8(2), B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(12), U8(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(1),
B(PopContext), R(1),
B(PopContext), R(1),
B(PopContext), R(1), B(PopContext), R(1),
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Jump), U8(134), B(Jump), U8(129),
B(Ldar), R(10), B(Ldar), R(10),
B(ReThrow), B(ReThrow),
B(LdaZero), B(LdaZero),
B(StaContextSlot), R(1), U8(9), U8(0), B(StaContextSlot), R(1), U8(9), U8(0),
B(LdaCurrentContextSlot), U8(4), B(LdaCurrentContextSlot), U8(4),
/* 59 E> */ B(StaContextSlot), R(1), U8(7), U8(0), /* 59 E> */ B(StaContextSlot), R(1), U8(7), U8(0),
B(JumpLoop), U8(155), I8(1), B(JumpLoop), U8(145), I8(1),
B(LdaContextSlot), R(1), U8(9), U8(0), B(LdaContextSlot), R(1), U8(9), U8(0),
B(Star), R(9), B(Star), R(9),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(TestEqual), R(9), U8(7), B(TestEqual), R(9), U8(7),
B(JumpIfFalse), U8(6), B(JumpIfFalse), U8(6),
B(PopContext), R(2), B(PopContext), R(2),
B(Jump), U8(10), B(Jump), U8(7),
B(PopContext), R(2), B(PopContext), R(2),
B(Wide), B(JumpLoop), U16(264), I16(0), B(JumpLoop), U8(253), I8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(LdaUndefined), B(LdaUndefined),
B(Star), R(9), B(Star), R(9),
...@@ -1000,8 +991,8 @@ bytecodes: [ ...@@ -1000,8 +991,8 @@ bytecodes: [
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
B(Jump), U8(67), B(Jump), U8(65),
B(Jump), U8(53), B(Jump), U8(51),
B(Star), R(9), B(Star), R(9),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateCatchContext), R(9), U8(5), U8(6), B(CreateCatchContext), R(9), U8(5), U8(6),
...@@ -1021,7 +1012,6 @@ bytecodes: [ ...@@ -1021,7 +1012,6 @@ bytecodes: [
B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4),
B(LdaContextSlot), R(1), U8(6), U8(0), B(LdaContextSlot), R(1), U8(6), U8(0),
B(PopContext), R(1), B(PopContext), R(1),
B(PopContext), R(1),
B(Star), R(6), B(Star), R(6),
B(LdaZero), B(LdaZero),
B(Star), R(5), B(Star), R(5),
...@@ -1064,7 +1054,7 @@ constant pool: [ ...@@ -1064,7 +1054,7 @@ constant pool: [
Smi [9], Smi [9],
] ]
handlers: [ handlers: [
[60, 434, 440], [60, 419, 425],
[63, 381, 383], [63, 368, 370],
] ]
...@@ -11,13 +11,13 @@ snippet: " ...@@ -11,13 +11,13 @@ snippet: "
" "
frame size: 3 frame size: 3
parameter count: 1 parameter count: 1
bytecode array length: 32 bytecode array length: 30
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
B(Mov), R(context), R(1), B(Mov), R(context), R(1),
/* 40 S> */ B(LdaSmi), I8(1), /* 40 S> */ B(LdaSmi), I8(1),
/* 75 S> */ B(Return), /* 75 S> */ B(Return),
B(Jump), U8(23), B(Jump), U8(21),
B(Star), R(2), B(Star), R(2),
B(Ldar), R(closure), B(Ldar), R(closure),
B(CreateCatchContext), R(2), U8(0), U8(1), B(CreateCatchContext), R(2), U8(0), U8(1),
...@@ -27,7 +27,6 @@ bytecodes: [ ...@@ -27,7 +27,6 @@ bytecodes: [
B(Ldar), R(1), B(Ldar), R(1),
B(PushContext), R(0), B(PushContext), R(0),
/* 63 S> */ B(LdaSmi), I8(2), /* 63 S> */ B(LdaSmi), I8(2),
B(PopContext), R(0),
/* 75 S> */ B(Return), /* 75 S> */ B(Return),
B(LdaUndefined), B(LdaUndefined),
/* 75 S> */ B(Return), /* 75 S> */ B(Return),
......
...@@ -11,7 +11,7 @@ snippet: " ...@@ -11,7 +11,7 @@ snippet: "
" "
frame size: 2 frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 22 bytecode array length: 20
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(1), /* 34 S> */ B(CreateObjectLiteral), U8(0), U8(3), U8(1), R(1),
...@@ -21,7 +21,6 @@ bytecodes: [ ...@@ -21,7 +21,6 @@ bytecodes: [
B(CreateWithContext), R(1), U8(1), B(CreateWithContext), R(1), U8(1),
B(PushContext), R(0), B(PushContext), R(0),
/* 50 S> */ B(LdaLookupSlot), U8(2), /* 50 S> */ B(LdaLookupSlot), U8(2),
B(PopContext), R(0),
/* 62 S> */ B(Return), /* 62 S> */ B(Return),
] ]
constant pool: [ constant pool: [
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const Debug = debug.Debug;
let exception = null;
let step_count = 0;
Debug.setListener((event, execState, eventData, data) => {
if (event != Debug.DebugEvent.Break) return;
try {
const line = execState.frame(0).sourceLineText();
print(line);
const [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line);
assertEquals(step_count++, parseInt(expected_count));
if (step != "Continue") execState.prepareStep(Debug.StepAction[step]);
} catch (e) {
print(e, e.stack);
exception = e;
}
});
function f(x) {
debugger; // B0 StepNext
with ({}) { // B1 StepNext
return x; // B2 StepNext
}
} // B3 Continue
f(42);
assertNull(exception);
assertEquals(4, step_count);
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