v8/test/debugger/debug/regress/regress-crbug-323936.js
Leszek Swirski 08f68102f8 [parser] Allow declaring variables without a proxy
Declare Variables with a name and position, rather than by passing
through a VariableProxy. This allows us to not create dummy proxies
for things like function declarations, and allows us to consider those
declarations unused.

As a side-effect, we also have to check if a variable is unused in the
bytecode generator (as it will no longer be allocated), and we end up
skip generating code/SFIs for dead variables/functions.

Change-Id: I4c2c872473f23e124f9456b4b92f87159658f8e0
Reviewed-on: https://chromium-review.googlesource.com/c/1414916
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59088}
2019-01-25 09:10:59 +00:00

58 lines
1.5 KiB
JavaScript

// Copyright 2014 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.
// Flags: --no-always-opt
Debug = debug.Debug;
var step = 0;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (step == 0) {
assertEquals("error", exec_state.frame(0).evaluate("e").value());
exec_state.frame(0).evaluate("write_0('foo')");
exec_state.frame(0).evaluate("write_1('modified')");
} else {
assertEquals("argument", exec_state.frame(0).evaluate("e").value());
exec_state.frame(0).evaluate("write_2('bar')");
}
step++;
} catch (e) {
print(e + e.stack);
exception = e;
}
}
Debug.setListener(listener);
function f(e, x) {
try {
throw "error";
} catch(e) {
// In ES2015 hoisting semantics, 'x' binds to the argument
// and 'e' binds to the exception.
function write_0(v) { e = v }
function write_1(v) { x = v }
// Make sure write_0 and write_1 are 'used' so that they are visible to the
// debugger.
write_0, write_1;
debugger;
assertEquals("foo", e); // overwritten by the debugger
}
assertEquals("argument", e); // debugger did not overwrite
function write_2(v) { e = v }
// Make sure write_2 is 'used' so that it is visible to the debugger.
write_2;
debugger;
assertEquals("bar", e);
assertEquals("modified", x);
}
f("argument")
assertNull(exception);
assertEquals(2, step);