mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Each finally scope gets two registers (completion_type and completion_value) that form an explicit completion record. Every path into the finally body sets these before jumping, and a dispatch chain after the finally body routes to the correct continuation. This replaces the old implicit protocol that relied on the exception register, a saved_return_value register, and a scheduled_jump field on ExecutionContext, allowing us to remove: - 5 opcodes (ContinuePendingUnwind, ScheduleJump, LeaveFinally, RestoreScheduledJump, PrepareYield) - 1 reserved register (saved_return_value) - 2 ExecutionContext fields (scheduled_jump, previously_scheduled_jumps)
35 lines
650 B
JavaScript
35 lines
650 B
JavaScript
function basicTryFinally() {
|
|
try {
|
|
return 1;
|
|
} finally {
|
|
console.log("finally");
|
|
}
|
|
}
|
|
basicTryFinally();
|
|
|
|
function breakThroughFinally() {
|
|
for (let i = 0; i < 10; i++) {
|
|
try {
|
|
if (i === 5) break;
|
|
} finally {
|
|
console.log(i);
|
|
}
|
|
}
|
|
}
|
|
breakThroughFinally();
|
|
|
|
function nestedTryFinallyWithBreak() {
|
|
outer: for (let i = 0; ; i++) {
|
|
try {
|
|
try {
|
|
break outer;
|
|
} finally {
|
|
console.log("inner");
|
|
}
|
|
} finally {
|
|
console.log("outer");
|
|
}
|
|
}
|
|
}
|
|
nestedTryFinallyWithBreak();
|