Commit e260bd53 authored by mythria's avatar mythria Committed by Commit bot

[Interpreter] Fixes a bug when popping context to correct level on break/continue.

The current implementation does not consider the case when the context of
the control scope and the current context differ. It is possible that they are
different in some cases for example: with statements. This cl fixes this.

BUG=v8:4280,v8:4680
LOG=N

Review URL: https://codereview.chromium.org/1768123002

Cr-Commit-Position: refs/heads/master@{#34609}
parent 679d9503
......@@ -362,16 +362,22 @@ class BytecodeGenerator::ControlScopeForTryFinally final
void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) {
ControlScope* current = this;
ContextScope* context = this->context();
ContextScope* context = generator()->execution_context();
do {
if (current->Execute(command, statement)) { return; }
current = current->outer();
if (current->context() != context) {
// Pop context to the expected depth.
// Pop context to the expected depth for break and continue. For return
// and throw it is not required to pop. Debugger expects that the
// context is not popped on return. So do not pop on return.
// TODO(rmcilroy): Only emit a single context pop.
generator()->builder()->PopContext(current->context()->reg());
if (command == CMD_BREAK || command == CMD_CONTINUE) {
generator()->builder()->PopContext(current->context()->reg());
}
context = current->context();
}
if (current->Execute(command, statement)) {
return;
}
current = current->outer();
} while (current != nullptr);
UNREACHABLE();
}
......
......@@ -106,7 +106,7 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 47
bytecode array length: 45
bytecodes: [
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
......@@ -126,7 +126,6 @@ bytecodes: [
B(LdaSmi8), U8(2),
B(StaContextSlot), R(context), U8(4),
B(CreateClosure), U8(1), U8(0),
B(PopContext), R(0),
B(Return),
]
constant pool: [
......
......@@ -13,7 +13,7 @@ snippet: "
"
frame size: 5
parameter count: 1
bytecode array length: 40
bytecode array length: 38
bytecodes: [
B(StackCheck),
B(Mov), R(context), R(1),
......@@ -30,7 +30,6 @@ bytecodes: [
B(Ldar), R(1),
B(PushContext), R(0),
B(LdaSmi8), U8(2),
B(PopContext), R(0),
B(Return),
B(LdaUndefined),
B(Return),
......
......@@ -13,7 +13,7 @@ snippet: "
"
frame size: 5
parameter count: 1
bytecode array length: 47
bytecode array length: 45
bytecodes: [
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
......@@ -33,7 +33,6 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kPushWithContext), R(3), U8(2),
B(PushContext), R(1),
B(LdaLookupSlot), U8(1),
B(PopContext), R(0),
B(Return),
]
constant pool: [
......
......@@ -882,8 +882,6 @@
# TODO(mythria, 4680): possibly problem with line numbers.
'es6/regress/regress-468661': [FAIL],
# with statements no longer always have a block as their body
'regress/regress-95485': [SKIP],
}], # ignition == True
['ignition == True and arch == arm64', {
......
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