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,148 @@
// 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.
// Test debug event catch prediction for thrown exceptions. We distinguish
// between "caught" and "uncaught" based on the following assumptions:
// 1) try-catch : Will always catch the exception.
// 2) try-finally : Will always re-throw the exception.
Debug = debug.Debug;
var log = [];
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Exception) {
log.push([event_data.exception(), event_data.uncaught()]);
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
Debug.setBreakOnException();
Debug.setListener(listener);
(function TryCatch() {
log = []; // Clear log.
function f(a) {
try {
throw "boom" + a;
} catch(e) {
return e;
}
}
%PrepareFunctionForOptimization(f);
assertEquals("boom1", f(1));
assertEquals("boom2", f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals("boom3", f(3));
print("Collect log:", log);
assertEquals([["boom1",false], ["boom2",false], ["boom3",false]], log);
})();
(function TryFinally() {
log = []; // Clear log.
function f(a) {
try {
throw "baem" + a;
} finally {
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals(13, f(3));
print("Collect log:", log);
assertEquals([["baem1",true], ["baem2",true], ["baem3",true]], log);
})();
(function TryCatchFinally() {
log = []; // Clear log.
function f(a) {
try {
throw "wosh" + a;
} catch(e) {
return e + a;
} finally {
// Nothing.
}
}
%PrepareFunctionForOptimization(f);
assertEquals("wosh11", f(1));
assertEquals("wosh22", f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals("wosh33", f(3));
print("Collect log:", log);
assertEquals([["wosh1",false], ["wosh2",false], ["wosh3",false]], log);
})();
(function TryCatchNestedFinally() {
log = []; // Clear log.
function f(a) {
try {
try {
throw "bang" + a;
} finally {
// Nothing.
}
} catch(e) {
return e + a;
}
}
%PrepareFunctionForOptimization(f);
assertEquals("bang11", f(1));
assertEquals("bang22", f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals("bang33", f(3));
print("Collect log:", log);
assertEquals([["bang1",false], ["bang2",false], ["bang3",false]], log);
})();
(function TryFinallyNestedCatch() {
log = []; // Clear log.
function f(a) {
try {
try {
throw "peng" + a;
} catch(e) {
return e
}
} finally {
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals(13, f(3));
print("Collect log:", log);
assertEquals([["peng1",false], ["peng2",false], ["peng3",false]], log);
})();
(function TryFinallyNestedFinally() {
log = []; // Clear log.
function f(a) {
try {
try {
throw "oops" + a;
} finally {
// Nothing.
}
} finally {
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);
assertEquals(13, f(3));
print("Collect log:", log);
assertEquals([["oops1",true], ["oops2",true], ["oops3",true]], log);
})();

View File

@ -0,0 +1,58 @@
// 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: --allow-natives-syntax --turbolev --turbofan
// Flags: --no-maglev --no-stress-concurrent-inlining
// Flags: --invocation-count-for-turbofan=3000
// This test checks that loop interrupt stack checks are properly detected are
// processed.
// Note that interrupt requests are not handled at the same time in Maglev and
// Turbofan: in Maglev, they are not directly checked but we instead rely on the
// fact budget interrupt will perform stack check interrupt, which in Turbofan,
// they are checked at every loop iteration.
var Debug = debug.Debug;
var trigger_count = 0;
var called_from;
Debug.setListener(function (event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
called_from = exec_state.frames[0].functionName;
trigger_count += 1;
}
});
function g(x) {
if (x == 0) {
%ScheduleBreak();
}
return 7;
}
function loop_interrupt_check_f(x) {
let r = 0;
for (let i = 0; i < 10; i++) {
if (i == 0) {
// Schedules an interrupt if {x} is 0.
r += g(x);
} else {
r += g(1);
}
}
return r;
}
%PrepareFunctionForOptimization(loop_interrupt_check_f);
assertEquals(70, loop_interrupt_check_f(1));
%OptimizeFunctionOnNextCall(loop_interrupt_check_f);
assertEquals(70, loop_interrupt_check_f(1));
assertOptimized(loop_interrupt_check_f);
assertEquals(0, trigger_count);
assertEquals(70, loop_interrupt_check_f(0));
assertEquals(1, trigger_count);
assertEquals("loop_interrupt_check_f", called_from);
assertOptimized(loop_interrupt_check_f);

View File

@ -0,0 +1,118 @@
// 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 changed = false;
function listenerSetJToResult(
event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
var scope = exec_state.frame(1).scope(0);
var newval = "result";
try {
scope.setVariableValue("j", newval);
changed = true;
} catch(e) {
changed = false;
}
}
}
Debug.setListener(listenerSetJToResult);
function g() { debugger; }
%NeverOptimizeFunction(g);
function ChangeSmiConstantAndOsr() {
var j = 1;
for (var i = 0; i < 4; i++) {
if (i == 2) {
%OptimizeOsr();
g();
}
}
return j;
}
%PrepareFunctionForOptimization(ChangeSmiConstantAndOsr);
var r1 = ChangeSmiConstantAndOsr();
if (changed) {
assertEquals("result", r1);
} else {
assertEquals(1, r1);
}
function ChangeFloatConstantAndOsr() {
var j = 0.1;
for (var i = 0; i < 4; i++) {
if (i == 2) {
%OptimizeOsr();
g();
}
}
return j;
}
%PrepareFunctionForOptimization(ChangeFloatConstantAndOsr);
var r2 = ChangeFloatConstantAndOsr();
if (changed) {
assertEquals("result", r2);
} else {
assertEquals(0.1, r2);
}
function ChangeFloatVarAndOsr() {
var j = 0.1;
for (var i = 0; i < 4; i++) {
j = j + 0.1;
if (i == 2) {
%OptimizeOsr();
g();
}
}
return j;
}
%PrepareFunctionForOptimization(ChangeFloatVarAndOsr);
var r3 = ChangeFloatVarAndOsr();
if (changed) {
assertEquals("result0.1", r3);
} else {
assertEquals(0.5, r3);
}
function listenerSetJToObject(
event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
var scope = exec_state.frame(1).scope(0);
try {
scope.setVariableValue("j", 100);
changed = true;
} catch(e) {
changed = false;
}
}
}
Debug.setListener(listenerSetJToObject);
function ChangeIntVarAndOsr() {
var j = 1;
for (var i = 0; i < 4; i++) {
j = j + 1|0;
if (i == 2) {
%OptimizeOsr();
g();
}
}
return j;
}
%PrepareFunctionForOptimization(ChangeIntVarAndOsr);
var r4 = ChangeIntVarAndOsr();
if (changed) {
assertEquals(101, r4);
} else {
assertEquals(5, r4);
}

View File

@ -0,0 +1,38 @@
// 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: --allow-natives-syntax --turbolev --turbofan
// Flags: --no-turboshaft-loop-unrolling --expose-gc --enable-inspector
var Debug = debug.Debug;
Debug.setListener(function (event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
gc();
}
});
function foo(b) {
%ScheduleBreak();
// Allocating a first object.
let o1 = { x : 42 };
// Inserting a loop, in order to get a JSStackCheck.
let v = 0;
for (; v < 42; v = (v + 2) * 2) {}
// Allocating a second object. This should not get allocation-folded with the
// first allocation, because of the JSStackCheck's GC in the middle.
let o2 = { x : o1, y : v };
return o2;
}
%PrepareFunctionForOptimization(foo);
assertEquals({ x : { x : 42 }, y : 60 }, foo());
assertEquals({ x : { x : 42 }, y : 60 }, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals({ x : { x : 42 }, y : 60 }, foo());