Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,40 @@
// Copyright 2023 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: --allow-natives-syntax --sparkplug
var foo = {
  [Symbol.toPrimitive]() {return "xyz";}
}
function f() {
  var v = foo;
  var o = {[v]: v};
  return o["xyz"];
};
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
  if (event == Debug.DebugEvent.Break) {
  }
};
// Add the debug event listener.
Debug.setListener(listener);
%DebugPrint(f());
%CompileBaseline(f);
%DebugPrint(f());
foo[Symbol.toPrimitive] = function(hint) {
  print("Setting breakpoint...");
  const breakid = Debug.setBreakPoint(f, 3);
  return "xyz";
};
%DebugPrint(f());
// Get rid of the debug event listener.
Debug.setListener(null);

View File

@ -0,0 +1,31 @@
// Copyright 2021 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.
var Debug = debug.Debug;
let exception = null;
function listener(event, execState, eventData, data) {
if (event != Debug.DebugEvent.Break) return;
try {
execState.frame().evaluate("var a = 1").value();
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
function foo(arg) {
return function() {
// Context allocate arg.
arg;
debugger;
}
}
foo()();
assertNotNull(exception);
assertContains(
"Identifier 'a' cannot be declared with 'var' in current evaluation scope",
exception.message);

View File

@ -0,0 +1,73 @@
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
var exceptionThrown = false;
var state = 0;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var line = event_data.sourceLineText();
print('break: ' + line);
assertEquals('// BREAK', line.substr(-8),
"should not break outside evaluate");
switch (state) {
case 0:
state = 1;
// While in the debugger and stepping through a set of instructions
// executed in the evaluate command, the stepping must stop at the end
// of the said set of instructions and not step further into native
// debugger code.
exec_state.frame(0).evaluate(
"print('A');\n" +
"debugger;\n" +
"print('B');");
break;
case 1:
assertUnreachable();
break;
}
}
} catch (e) {
print(e);
exceptionThrown = true;
}
}
// Add the debug event listener.
Debug.setListener(listener);
function a() {
} // BREAK
// Set a break point and call to invoke the debug event listener.
Debug.setBreakPoint(a, 0, 0);
a();
assertFalse(exceptionThrown);

View File

@ -0,0 +1,72 @@
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --stack-size=100
function f() {
var i = 0;
// Stack-allocate to reach the end of stack quickly.
var _A0 = 00; var _A1 = 01; var _A2 = 02; var _A3 = 03; var _A4 = 04;
var _B0 = 05; var _B1 = 06; var _B2 = 07; var _B3 = 08; var _B4 = 09;
var _C0 = 10; var _C1 = 11; var _C2 = 12; var _C3 = 13; var _C4 = 14;
var _D0 = 15; var _D1 = 16; var _D2 = 17; var _D3 = 18; var _D4 = 19;
var _E0 = 20; var _E1 = 21; var _E2 = 22; var _E3 = 23; var _E4 = 24;
var _F0 = 25; var _F1 = 26; var _F2 = 27; var _F3 = 28; var _F4 = 29;
var _G0 = 30; var _G1 = 31; var _G2 = 32; var _G3 = 33; var _G4 = 34;
var _H0 = 35; var _H1 = 36; var _H2 = 37; var _H3 = 38; var _H4 = 39;
var _I0 = 40; var _I1 = 41; var _I2 = 42; var _I3 = 43; var _I4 = 44;
var _J0 = 45; var _J1 = 46; var _J2 = 47; var _J3 = 48; var _J4 = 49;
var _K0 = 50; var _K1 = 51; var _K2 = 52; var _K3 = 53; var _K4 = 54;
var _L0 = 55; var _L1 = 56; var _L2 = 57; var _L3 = 58; var _L4 = 59;
var _M0 = 60; var _M1 = 61; var _M2 = 62; var _M3 = 63; var _M4 = 64;
var _N0 = 65; var _N1 = 66; var _N2 = 67; var _N3 = 68; var _N4 = 69;
var _O0 = 70; var _O1 = 71; var _O2 = 72; var _O3 = 73; var _O4 = 74;
var _P0 = 75; var _P1 = 76; var _P2 = 77; var _P3 = 78; var _P4 = 79;
var _Q0 = 80; var _Q1 = 81; var _Q2 = 82; var _Q3 = 83; var _Q4 = 84;
var _R0 = 85; var _R1 = 86; var _R2 = 87; var _R3 = 88; var _R4 = 89;
var _S0 = 90; var _S1 = 91; var _S2 = 92; var _S3 = 93; var _S4 = 94;
var _T0 = 95; var _T1 = 96; var _T2 = 97; var _T3 = 98; var _T4 = 99;
f();
};
Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
exec_state.frame(0).evaluate("i");
} catch (e) {
}
};
Debug.setListener(listener);
var bp = Debug.setBreakPoint(f, 1);
assertThrows(function() { f(); }, RangeError);
Debug.setListener(null);

View File

@ -0,0 +1,15 @@
// Copyright 2024 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: --enable-inspector
var Debug = debug.Debug;
Debug.sendMessageForMethodChecked('Runtime.enable', {});
const {msgid, msg} = Debug.createMessage('Runtime.evaluate', {
expression: 'while(true) {}',
throwOnSideEffect: true,
timeout: 1000,
})
Debug.sendMessage(msg);
Debug.takeReplyChecked(msgid).toString();

View File

@ -0,0 +1,21 @@
// Copyright 2016 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.
Debug = debug.Debug;
Debug.setListener(function() {});
function factory() {
return function* generator() {
debugger;
yield 42;
}
}
Debug.setBreakPoint(function(){}, 0, 0);
var generator = factory();
var obj = generator();
obj.next();
Debug.setBreakPoint(factory, 0, 0);
obj.next();

View File

@ -0,0 +1,21 @@
// Copyright 2016 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.
Debug = debug.Debug;
Debug.setListener(function() {});
function main() {
function* boo() {
debugger;
yield 42;
}
var gen = boo();
gen.next();
Debug.setBreakPoint(main, 0, 0);
gen.next();
}
main();

View File

@ -0,0 +1,29 @@
// Copyright 2016 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.
Debug = debug.Debug;
let n = 0;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
if (n++ == 0) {
Debug.setBreakPoint(main, 0, 0);
}
}
}
Debug.setListener(listener);
function main() {
function* boo() {
debugger;
yield;
}
var gen = boo();
gen.next();
gen.next();
}
main();

View File

@ -0,0 +1,32 @@
// Copyright 2016 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.
var Debug = debug.Debug;
var step_count = 0;
function listener(event, execState, eventData, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var line = execState.frame(0).sourceLineText();
print(line);
var [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);
quit(1);
}
}
Debug.setListener(listener);
async function f() {
var a = 1;
debugger; // B0 StepOver
print(1); // B1 StepOver
return a + // B2 StepOver
0; // B3 Continue
}
f();

View File

@ -0,0 +1,49 @@
// 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.
function f() {
throw new Error();
}
function g() {
try {
f();
} catch (e) {
return 1; // Break
}
}
function h() {
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();
var Debug = debug.Debug;
var step_count = 0;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
step_count++;
exec_state.prepareStep(Debug.StepAction.StepOver);
} else if (event == Debug.DebugEvent.Break) {
step_count++;
try {
assertTrue(exec_state.frame().sourceLineText().includes('Break'));
} catch (e) {
exception = e;
print(e);
}
}
}
Debug.setListener(listener);
Debug.setBreakOnException();
%OptimizeFunctionOnNextCall(h);
h();
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,46 @@
// 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.
function f() {
debugger;
return 1;
}
function g() {
return f(); // Break
}
function h() {
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();
var Debug = debug.Debug;
var step_count = 0;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (step_count == 0) {
exec_state.prepareStep(Debug.StepAction.StepOut);
} else {
assertTrue(exec_state.frame().sourceLineText().includes('Break'));
}
step_count++;
} catch (e) {
exception = e;
print(e);
}
}
Debug.setListener(listener);
%OptimizeFunctionOnNextCall(h);
h();
Debug.setListener(null);
assertNull(exception);
assertEquals(2, step_count);

View File

@ -0,0 +1,38 @@
// 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.
function f() {
debugger;
}
function g() {
f();
}
function h() {
'use strict';
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var all_scopes = exec_state.frame().allScopes();
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
%OptimizeFunctionOnNextCall(h);
h();
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,56 @@
// 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.
// This test fails without defeating TDZ check elision because 'return x;'
// below, without a ThrowReferenceErrorIfHole bytecode, becomes a return
// position breakpoint. Return position breakpoints can only inspect the
// function scope because their source position is always at the end of the
// function.
function* serialize() {
debugger;
switch (0) {
case 0:
let x = 1; // Defeat TDZ check elision
case 1:
return x; // Check scopes
}
}
let exception = null;
let step_count = 0;
let scopes_checked = false;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (exec_state.frame().sourceLineText().includes("Check scopes")) {
let expected = [ debug.ScopeType.Block,
debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global ];
for (let i = 0; i < exec_state.frame().scopeCount(); i++) {
assertEquals(expected[i], exec_state.frame().scope(i).scopeType());
}
scopes_checked = true;
}
if (step_count++ < 3) exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
exception = e;
print(e, e.stack);
}
}
let Debug = debug.Debug;
Debug.setListener(listener);
let gen = serialize();
gen.next();
Debug.setListener(null);
assertNull(exception);
assertEquals(4, step_count);
assertTrue(scopes_checked);

View File

@ -0,0 +1,26 @@
// 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.
// Flags: --enable-inspector --allow-natives-syntax
const Debug = debug.Debug;
Debug.setListener(() => {});
var a = [0,1,2,3,4,5,6,7,8,9];
var f = function() {
a.forEach(function(v) {
try {
throw new Error();
} catch (e) {
}
});
};
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
f();
f();

View File

@ -0,0 +1,81 @@
// Copyright 2018 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.
Debug = debug.Debug
// Test that the side-effect check is not bypassed in optimized code.
var exception = null;
var counter = 0;
function f1() {
counter++;
}
function wrapper1() {
for (var i = 0; i < 4; i++) {
// Get this function optimized before calling to increment.
// Check that that call performs the necessary side-effect checks.
%OptimizeOsr();
%PrepareFunctionForOptimization(wrapper1);
}
f1();
}
%PrepareFunctionForOptimization(wrapper1);
function f2() {
counter++;
}
function wrapper2(call) {
if (call) f2();
}
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
function success(expectation, source) {
assertEquals(expectation,
exec_state.frame(0).evaluate(source, true).value());
}
function fail(source) {
assertThrows(() => exec_state.frame(0).evaluate(source, true),
EvalError);
}
wrapper1();
wrapper1();
fail("wrapper1()");
%PrepareFunctionForOptimization(wrapper2);
wrapper2(true);
wrapper2(false);
wrapper2(true);
%OptimizeFunctionOnNextCall(wrapper2);
wrapper2(false);
fail("wrapper2(true)");
fail("%PrepareFunctionForOptimization(wrapper2); "+
"%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)");
%PrepareFunctionForOptimization(wrapper2);
%DisableOptimizationFinalization();
%OptimizeFunctionOnNextCall(wrapper2, "concurrent");
wrapper2(false);
fail("%FinalizeOptimization();" +
"wrapper2(true);");
} catch (e) {
exception = e;
print(e, e.stack);
}
};
// Add the debug event listener.
Debug.setListener(listener);
function f() {
debugger;
};
f();
assertNull(exception);

View File

@ -0,0 +1,32 @@
// Copyright 2019 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.
Debug = debug.Debug
var exception = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
assertEquals("n", exec_state.frame(0).evaluate("n").value());
assertEquals("m", exec_state.frame(0).evaluate("m").value());
}
} catch(e) {
exception = e;
print(e, e.stack);
}
};
Debug.setListener(listener);
(function foo () {
var n = "n";
var m = "m";
(function bar() {
assertEquals("m", eval("m")); // force context-allocation.
debugger;
})();
})();
assertNull(exception);
Debug.setListener(null);

View File

@ -0,0 +1,10 @@
// Copyright 2020 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: --print-break-location
// Ensure that --print-break-location correctly collects source positions on
// breaking.
debug.Debug
debugger;

View File

@ -0,0 +1,44 @@
// Copyright 2019 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.
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
const Debug = new DebugWrapper();
Debug.enable();
// Record the ID of the first script reported. This is to ignore
// the (now deprecated) fake scripts that are generated for every
// Wasm module.
let scriptId;
Debug.setListener((eventType, execState, eventData, data) => {
assertEquals(Debug.DebugEvent.AfterCompile, eventType);
if (scriptId === undefined) scriptId = eventData.scriptId;
});
// Create a simple Wasm script, which will be caught by the event listener.
const builder = new WasmModuleBuilder();
builder.addFunction('sub', kSig_i_ii)
// input is 2 args of type int and output is int
.addBody([
kExprLocalGet, 0, // local.get i0
kExprLocalGet, 1, // local.get i1
kExprI32Sub]) // i32.sub i0 i1
.exportFunc();
const instance = builder.instantiate();
// By now we should have recorded the ID of the Wasm script above.
assertNotEquals(undefined, scriptId);
// Disable and re-enable the Debugger and collect the reported
// script IDs.
const scriptIds = new Set();
Debug.disable();
Debug.setListener((eventType, execState, eventData, data) => {
assertEquals(Debug.DebugEvent.AfterCompile, eventType);
scriptIds.add(eventData.scriptId);
});
Debug.enable();
// Make sure the Wasm script was reported.
assertTrue(scriptIds.has(scriptId));

View File

@ -0,0 +1,20 @@
// Copyright 2021 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;
Debug.setListener(function (event, exec_state, event_data, data) {
});
Debug.setBreakOnException();
function f(){
(() => {
var out = 42;
var needsOut = () => {return out}
var simp_class = class {
static var1 = unreferenced;
}
})();
}
assertThrows(f, ReferenceError);

View File

@ -0,0 +1,52 @@
// Copyright 2021 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: --sparkplug --allow-natives-syntax
function f() {
debugger;
return 1;
}
function g() {
return f(); // Break
}
function h() {
return g();
}
// Ensure FeedbackVector to consider f for inlining.
%EnsureFeedbackVectorForFunction(f);
%CompileBaseline(g);
%PrepareFunctionForOptimization(h);
h();
h();
var Debug = debug.Debug;
var step_count = 0;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (step_count == 0) {
exec_state.prepareStep(Debug.StepAction.StepOut);
} else {
assertTrue(exec_state.frame().sourceLineText().includes('Break'));
}
step_count++;
} catch (e) {
exception = e;
print(e);
}
}
Debug.setListener(listener);
%OptimizeFunctionOnNextCall(h);
h();
Debug.setListener(null);
assertNull(exception);
assertEquals(2, step_count);

View File

@ -0,0 +1,10 @@
// Copyright 2021 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: --enable-inspector --allow-natives-syntax
debug.Debug.setBreakPoint(f, 1);
function f() {
var C = class {};
}
f();

View File

@ -0,0 +1,13 @@
// Copyright 2022 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.
debug.Debug.setBreakPoint(f, 2);
function f() {
function id(x) { return x; } // Force context allocation of `f`.
new class tmp {
#foo = id(42);
};
}
f();

View File

@ -0,0 +1,20 @@
// Copyright 2015 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: --allow-natives-syntax --cache=code --no-debug-code
try { } catch(e) { }
try { try { } catch (e) { } } catch(e) { }
try {
var Debug = debug.Debug;
Debug.setListener(function(){});
} catch(e) { }
(function() {
Debug.setBreakPoint(function(){}, 0, 0);
})();
var a = 1;
a += a;
Debug.setListener(null);
assertEquals(2, a);

View File

@ -0,0 +1,36 @@
// 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 StepOver
with ({}) { // B1 StepOver
return x // B2 StepOver
; // B3 Continue
}
}
f(42);
assertNull(exception);
assertEquals(4, step_count);

View File

@ -0,0 +1,16 @@
// 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.
var Debug = debug.Debug;
function listener() {}
function f() { [1,2,3].forEach(g) }
function g() { debugger }
%PrepareFunctionForOptimization(f);
f();
f();
Debug.setListener(listener);
%OptimizeFunctionOnNextCall(f)
f();

View File

@ -0,0 +1,30 @@
// Copyright 2019 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.
Debug = debug.Debug
let thisValue;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
thisValue = exec_state.frame(0).evaluate('this').value();
}
};
Debug.setListener(listener);
class Foo {}
class Bar extends Foo {
constructor() {
super();
var b = () => this;
this.c = 'b'; // <-- Inspect 'this' (it will be undefined)
debugger;
}
}
new Bar();
Debug.setListener(null);
assertNotEquals(undefined, thisValue);

View File

@ -0,0 +1,18 @@
// Copyright 2018 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: --allow-natives-syntax --enable-inspector --ignore-unhandled-promises
const Debug = debug.Debug;
Debug.setListener(() => {});
Debug.setBreakOnUncaughtException()
function sleep() {
return new Promise(resolve => setTimeout(resolve, 1));
}
async function thrower() {
await sleep();
throw "a"; // Exception a
}
(async function() { thrower(); })();

View File

@ -0,0 +1,289 @@
// Copyright 2018 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.
// Test that stepping works correctly with bytecode scaling prefix.
class MyClass { f(p) { this.x += p; } };
let obj = new MyClass();
function foo() {
obj.f(0);
obj.f(1);
obj.f(2);
obj.f(3);
obj.f(4);
obj.f(5);
obj.f(6);
obj.f(7);
obj.f(8);
obj.f(9);
obj.f(10);
obj.f(11);
obj.f(12);
obj.f(13);
obj.f(14);
obj.f(15);
obj.f(16);
obj.f(17);
obj.f(18);
obj.f(19);
obj.f(20);
obj.f(21);
obj.f(22);
obj.f(23);
obj.f(24);
obj.f(25);
obj.f(26);
obj.f(27);
obj.f(28);
obj.f(29);
obj.f(30);
obj.f(31);
obj.f(32);
obj.f(33);
obj.f(34);
obj.f(35);
obj.f(36);
obj.f(37);
obj.f(38);
obj.f(39);
obj.f(40);
obj.f(41);
obj.f(42);
obj.f(43);
obj.f(44);
obj.f(45);
obj.f(46);
obj.f(47);
obj.f(48);
obj.f(49);
obj.f(50);
obj.f(51);
obj.f(52);
obj.f(53);
obj.f(54);
obj.f(55);
obj.f(56);
obj.f(57);
obj.f(58);
obj.f(59);
obj.f(60);
obj.f(61);
obj.f(62);
obj.f(63);
obj.f(64);
obj.f(65);
obj.f(66);
obj.f(67);
obj.f(68);
obj.f(69);
obj.f(70);
obj.f(71);
obj.f(72);
obj.f(73);
obj.f(74);
obj.f(75);
obj.f(76);
obj.f(77);
obj.f(78);
obj.f(79);
obj.f(80);
obj.f(81);
obj.f(82);
obj.f(83);
obj.f(84);
obj.f(85);
obj.f(86);
obj.f(87);
obj.f(88);
obj.f(89);
obj.f(90);
obj.f(91);
obj.f(92);
obj.f(93);
obj.f(94);
obj.f(95);
obj.f(96);
obj.f(97);
obj.f(98);
obj.f(99);
obj.f(100);
obj.f(101);
obj.f(102);
obj.f(103);
obj.f(104);
obj.f(105);
obj.f(106);
obj.f(107);
obj.f(108);
obj.f(109);
obj.f(110);
obj.f(111);
obj.f(112);
obj.f(113);
obj.f(114);
obj.f(115);
obj.f(116);
obj.f(117);
obj.f(118);
obj.f(119);
obj.f(120);
obj.f(121);
obj.f(122);
obj.f(123);
obj.f(124);
obj.f(125);
obj.f(126);
obj.f(127);
obj.f(128);
obj.f(129);
obj.f(130);
obj.f(131);
obj.f(132);
obj.f(133);
obj.f(134);
obj.f(135);
obj.f(136);
obj.f(137);
obj.f(138);
obj.f(139);
obj.f(140);
obj.f(141);
obj.f(142);
obj.f(143);
obj.f(144);
obj.f(145);
obj.f(146);
obj.f(147);
obj.f(148);
obj.f(149);
obj.f(150);
obj.f(151);
obj.f(152);
obj.f(153);
obj.f(154);
obj.f(155);
obj.f(156);
obj.f(157);
obj.f(158);
obj.f(159);
obj.f(160);
obj.f(161);
obj.f(162);
obj.f(163);
obj.f(164);
obj.f(165);
obj.f(166);
obj.f(167);
obj.f(168);
obj.f(169);
obj.f(170);
obj.f(171);
obj.f(172);
obj.f(173);
obj.f(174);
obj.f(175);
obj.f(176);
obj.f(177);
obj.f(178);
obj.f(179);
obj.f(180);
obj.f(181);
obj.f(182);
obj.f(183);
obj.f(184);
obj.f(185);
obj.f(186);
obj.f(187);
obj.f(188);
obj.f(189);
obj.f(190);
obj.f(191);
obj.f(192);
obj.f(193);
obj.f(194);
obj.f(195);
obj.f(196);
obj.f(197);
obj.f(198);
obj.f(199);
obj.f(200);
obj.f(201);
obj.f(202);
obj.f(203);
obj.f(204);
obj.f(205);
obj.f(206);
obj.f(207);
obj.f(208);
obj.f(209);
obj.f(210);
obj.f(211);
obj.f(212);
obj.f(213);
obj.f(214);
obj.f(215);
obj.f(216);
obj.f(217);
obj.f(218);
obj.f(219);
obj.f(220);
obj.f(221);
obj.f(222);
obj.f(223);
obj.f(224);
obj.f(225);
obj.f(226);
obj.f(227);
obj.f(228);
obj.f(229);
obj.f(230);
obj.f(231);
obj.f(232);
obj.f(233);
obj.f(234);
obj.f(235);
obj.f(236);
obj.f(237);
obj.f(238);
obj.f(239);
obj.f(240);
obj.f(241);
obj.f(242);
obj.f(243);
obj.f(244);
obj.f(245);
obj.f(246);
obj.f(247);
obj.f(248);
obj.f(249);
obj.f(250);
obj.f(251);
obj.f(252);
obj.f(253);
obj.f(254);
obj.f(255);
debugger;
obj.f(256);
obj.f(257);
obj.f(258);
obj.f(259);
}
let break_count = 0;
function listener(event, exec_state, event_data, data) {
if (event != debug.Debug.DebugEvent.Break) return;
try {
exec_state.prepareStep(debug.Debug.StepAction.StepOver);
break_count++;
} catch {
%AbortJS("unexpected exception");
}
}
debug.Debug.setListener(listener);
foo();
debug.Debug.setListener(null);
assertEquals(7, break_count);

View File

@ -0,0 +1,27 @@
// Copyright 2018 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.
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.AfterCompile) {
// The actual source doesn't matter, just don't crash.
var source = event_data.script().source();
// Source will be empty for the script representing the entire module,
// disassembly for the script representing just the function.
assertTrue(source == "func $main\nend\n" || source == "");
}
};
// Add the debug event listener.
Debug.setListener(listener);
var builder = new WasmModuleBuilder();
builder.addFunction('main', kSig_v_v).addBody([]).exportFunc();
var promise = WebAssembly.compile(builder.toBuffer());
// Clear the debug listener only after the event fired.
promise.then(() => Debug.setListener(null), assertUnreachable);

View File

@ -0,0 +1,41 @@
// Copyright 2018 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.
function provoke_scaling_prefix() {
var a = [0];
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++; a[0]++;
return a;
}
Debug = debug.Debug;
function success(expectation, source) {
const result = Debug.evaluateGlobal(source, true).value();
assertEquals(expectation, result);
}
success([216], "provoke_scaling_prefix()");