Files
sdk/pkg/dart2bytecode/testcases/try_blocks.dart.expect
T
Tess Strickland a02596b28f [vm,dyn_modules] Source position cleanups and fewer temp uses.
Reduces the usage of temps in the following cases to remove unneeded
StoreLocal/Push instructions:

Refactors visitVariableSet so that a temporary is used only if the
variable is captured and the result is not ignored. (That is,
sets of uncaptured late final fields no longer need a temporary.)

Only allocate a temp for FunctionDeclarations and FunctionExpressions
if there are function type arguments to capture or if the function
is generic (in which case the delayed type arguments field must be
empty-initialized, not null initialized).

-----

Clean up how source positions are emitted to both be more consistent
and to also move some source position emissions closer to the actual
instruction that performs the operation:

Move emission of debugging information for FunctionDeclaration,
and VariableSet to when the variable is actually set. The emission
in VariableDeclaration stays before the initializer as that's when
debugger tests expect to pause at it.

Change the implementation of _genConditionAndJumpIf to use if/else
chaining instead of early returns so that the condition's source
position can be recorded once before the if/then chain and then the
previous source position restored afterward the chain. This means
that _emitDebuggerInformation can be used.

_generateNonLocalControlTransfer is only called during visit methods
where the parent call to _generateNode has already recorded the from
node's position, so there's no need to record it during that call.
Instead, move the emission of the source position to the jump within the
passed continuation.

Remove _emitLocalSourcePosition, since it is no longer used.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Id7722146769c57713ae466d67401258c010cee37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473380
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-19 04:04:43 -08:00

927 lines
22 KiB
Plaintext

Bytecode
Dynamic Module Entry Point: DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart::main
Library 'DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart'
name '#lib'
script 'DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart'
Class '', script = 'DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart'
Function 'testTryCatch1', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 4
CheckStack 0
Try #0 start:
PushConstant CP#0
DirectCall CP#1, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 4
MoveSpecial exception, r0
MoveSpecial stackTrace, r1
Push r0
PopLocal r2
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r3
Push r3
PushInt 0
PushConstant CP#4
StoreIndexedTOS
Push r3
PushInt 1
Push r2
StoreIndexedTOS
DirectCall CP#5, 1
DirectCall CP#1, 1
Drop1
Jump L1
L1:
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 4, end 14, handler 14, types [CP#3]
}
ConstantPool {
[0] = ObjectRef 'danger!'
[1] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[2] = Reserved
[3] = Type dart:core::Object
[4] = ObjectRef 'caught '
[5] = DirectCall 'dart:core::_StringBase::_interpolate', ArgDesc num-args 1, num-type-args 0, names []
[6] = Reserved
}
Function 'testTryCatch2', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 5
CheckStack 0
Try #0 start:
PushConstant CP#0
DirectCall CP#1, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 5
MoveSpecial exception, r0
MoveSpecial stackTrace, r1
Push r0
PushConstant CP#3
InterfaceCall CP#4, 2
JumpIfFalse L2
PushConstant CP#6
DirectCall CP#1, 1
Drop1
Jump L1
L2:
Push r0
PushConstant CP#7
InterfaceCall CP#4, 2
JumpIfFalse L3
Push r0
PopLocal r2
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r3
Push r3
PushInt 0
PushConstant CP#8
StoreIndexedTOS
Push r3
PushInt 1
Push r2
StoreIndexedTOS
DirectCall CP#9, 1
DirectCall CP#1, 1
Drop1
Jump L1
L3:
Push r0
PushConstant CP#11
InterfaceCall CP#4, 2
JumpIfFalse L4
Push r0
PopLocal r2
Push r1
PopLocal r3
PushNull
PushInt 4
CreateArrayTOS
StoreLocal r4
Push r4
PushInt 0
PushConstant CP#12
StoreIndexedTOS
Push r4
PushInt 1
Push r2
StoreIndexedTOS
Push r4
PushInt 2
PushConstant CP#13
StoreIndexedTOS
Push r4
PushInt 3
Push r3
StoreIndexedTOS
DirectCall CP#9, 1
DirectCall CP#1, 1
Drop1
Jump L1
L4:
Push r0
PopLocal r2
Push r1
PopLocal r3
PushNull
PushInt 4
CreateArrayTOS
StoreLocal r4
Push r4
PushInt 0
PushConstant CP#15
StoreIndexedTOS
Push r4
PushInt 1
Push r2
StoreIndexedTOS
Push r4
PushInt 2
PushConstant CP#13
StoreIndexedTOS
Push r4
PushInt 3
Push r3
StoreIndexedTOS
DirectCall CP#9, 1
DirectCall CP#1, 1
Drop1
Jump L1
L1:
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 4, end 14, handler 14, needs-stack-trace, types [CP#3, CP#7, CP#11, CP#14]
}
ConstantPool {
[0] = ObjectRef 'danger!'
[1] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[2] = Reserved
[3] = Type dart:core::TypeError
[4] = InterfaceCall 'dart:core::Object::_simpleInstanceOf', ArgDesc num-args 2, num-type-args 0, names []
[5] = Reserved
[6] = ObjectRef 'caught type error'
[7] = Type dart:core::AssertionError
[8] = ObjectRef 'caught assertion error '
[9] = DirectCall 'dart:core::_StringBase::_interpolate', ArgDesc num-args 1, num-type-args 0, names []
[10] = Reserved
[11] = Type dart:core::Error
[12] = ObjectRef 'caught error '
[13] = ObjectRef ' '
[14] = Type dart:core::Object
[15] = ObjectRef 'caught something '
}
Function 'testTryCatch3', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 7
CheckStack 0
AllocateContext 0, 3
PopLocal r0
Push r0
PushInt 1
StoreContextVar 0, 0
Push r0
PopLocal r2
Try #0 start:
Push r0
PushInt 2
StoreContextVar 0, 1
PushConstant CP#0
Push r0
PushNull
AllocateClosure
PopLocal r4
Push r4
Push r4
UncheckedClosureCall CP#8, 1
Drop1
Push r0
LoadContextVar 0, 1
DirectCall CP#4, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 7
Push r2
PopLocal r0
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r2
PopLocal r4
Push r0
Push r3
StoreContextVar 0, 2
PushNull
PushInt 4
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#9
StoreIndexedTOS
Push r5
PushInt 1
Push r4
StoreIndexedTOS
Push r5
PushInt 2
PushConstant CP#10
StoreIndexedTOS
Push r5
PushInt 3
Push r0
LoadContextVar 0, 2
StoreIndexedTOS
DirectCall CP#11, 1
DirectCall CP#4, 1
Drop1
PushConstant CP#13
Push r0
PushNull
AllocateClosure
PopLocal r6
Push r6
ReturnTOS
L1:
Push r0
LoadContextParent
PopLocal r0
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 20, end 56, handler 56, needs-stack-trace, types [CP#6]
}
ConstantPool {
[0] = ClosureFunction 0
[1] = InstanceField dart:core::_Closure::_context (field)
[2] = Reserved
[3] = ObjectRef 'danger foo'
[4] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[5] = Reserved
[6] = Type dart:core::Object
[7] = EndClosureFunctionScope
[8] = ObjectRef ArgDesc num-args 1, num-type-args 0, names []
[9] = ObjectRef 'caught '
[10] = ObjectRef ' '
[11] = DirectCall 'dart:core::_StringBase::_interpolate', ArgDesc num-args 1, num-type-args 0, names []
[12] = Reserved
[13] = ClosureFunction 1
[14] = ObjectRef 'danger bar'
[15] = Type dart:core::Error
[16] = InterfaceCall 'dart:core::Object::_simpleInstanceOf', ArgDesc num-args 2, num-type-args 0, names []
[17] = Reserved
[18] = ObjectRef 'error '
[19] = ObjectRef ', captured stack trace: '
[20] = EndClosureFunctionScope
}
Closure DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart::testTryCatch3::'foo' () -> void
ClosureCode {
Entry 5
Push FP[-5]
LoadFieldTOS CP#1
PopLocal r0
CheckStack 0
Push r0
PopLocal r2
Try #0 start:
PushConstant CP#3
DirectCall CP#4, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 5
Push r2
PopLocal r0
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r2
PopLocal r4
Push r0
LoadContextVar 0, 0
DirectCall CP#4, 1
Drop1
Push r0
PushInt 3
StoreContextVar 0, 1
Jump L1
L1:
PushNull
ReturnTOS
}
Closure DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart::testTryCatch3::'bar' () -> void
ClosureCode {
Entry 6
Push FP[-5]
LoadFieldTOS CP#1
PopLocal r0
CheckStack 0
Push r0
PopLocal r2
Try #0 start:
PushConstant CP#14
DirectCall CP#4, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 6
Push r2
PopLocal r0
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r2
PushConstant CP#15
InterfaceCall CP#16, 2
JumpIfFalse L2
Push r2
PopLocal r4
PushNull
PushInt 4
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#18
StoreIndexedTOS
Push r5
PushInt 1
Push r4
StoreIndexedTOS
Push r5
PushInt 2
PushConstant CP#19
StoreIndexedTOS
Push r5
PushInt 3
Push r0
LoadContextVar 0, 2
StoreIndexedTOS
DirectCall CP#11, 1
DirectCall CP#4, 1
Drop1
Jump L1
L2:
Push r2
Push r3
Throw 1
L1:
PushNull
ReturnTOS
}
Function 'testRethrow', static, reflectable, debuggable
parameters [dart:core::bool 'cond'] (required: 1)
return-type dynamic
Bytecode {
Entry 8
CheckStack 0
Try #0 start:
Try #1 start:
PushConstant CP#0
DirectCall CP#1, 1
Drop1
Jump L1
Try #1 end:
Try #1 handler:
SetFrame 8
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r2
PopLocal r4
Try #2 start:
PushConstant CP#4
DirectCall CP#1, 1
Drop1
Push FP[-5]
JumpIfFalse L2
Push r2
Push r3
Throw 1
L2:
Jump L3
Try #2 end:
Try #2 handler:
SetFrame 8
MoveSpecial exception, r5
MoveSpecial stackTrace, r6
Push r5
PopLocal r7
PushConstant CP#5
DirectCall CP#1, 1
Drop1
Jump L3
L3:
Jump L1
L1:
Jump L4
Try #0 end:
Try #0 handler:
SetFrame 8
MoveSpecial exception, r0
MoveSpecial stackTrace, r1
Push r0
PopLocal r2
Push r1
PopLocal r3
PushConstant CP#6
DirectCall CP#1, 1
Drop1
Push r3
DirectCall CP#1, 1
Drop1
Jump L4
L4:
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 4, end 78, handler 78, needs-stack-trace, types [CP#3]
try-index 1, outer 0, start 4, end 14, handler 14, needs-stack-trace, types [CP#3]
try-index 2, outer 0, start 26, end 48, handler 48, types [CP#3]
}
ConstantPool {
[0] = ObjectRef 'try 1 > try 2'
[1] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[2] = Reserved
[3] = Type dart:core::Object
[4] = ObjectRef 'try 1 > catch 2 > try 3'
[5] = ObjectRef 'try 1 > catch 2 > catch 3'
[6] = ObjectRef 'catch 1'
}
Function 'testTryFinally1', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 3
CheckStack 0
PushInt 0
PopLocal r0
L5:
CheckStack 1
Push r0
PushInt 10
CompareIntLt
JumpIfFalse L1
Try #0 start:
Push r0
PushInt 5
CompareIntGt
JumpIfFalse L2
Jump L3
L2:
Jump L4
Try #0 end:
Try #0 handler:
SetFrame 3
MoveSpecial exception, r1
MoveSpecial stackTrace, r2
Push r0
DirectCall CP#1, 1
Drop1
Push r1
Push r2
Throw 1
L3:
Push r0
DirectCall CP#1, 1
Drop1
Jump L1
L4:
Push r0
DirectCall CP#1, 1
Drop1
Push r0
PushInt 1
AddInt
StoreLocal r0
Drop1
Jump L5
L1:
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 19, end 36, handler 36, needs-stack-trace, synthetic, types [CP#0]
}
ConstantPool {
[0] = Type dynamic
[1] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[2] = Reserved
}
Function 'testTryFinally2', static, reflectable, debuggable
parameters [dart:core::int 'x'] (required: 1)
return-type dynamic
Bytecode {
Entry 9
CheckStack 0
AllocateContext 0, 2
PopLocal r0
Push r0
Push FP[-5]
StoreContextVar 0, 0
Push r0
LoadContextVar 0, 0
PopLocal r2
PushInt 1
Push r2
InterfaceCall CP#0, 2
JumpIfTrue L1
PushInt 2
Push r2
InterfaceCall CP#0, 2
JumpIfTrue L2
Jump L3
L1:
Push r0
PopLocal r3
Try #0 start:
PushConstant CP#2
DirectCall CP#3, 1
Drop1
Push r0
PushInt 3
StoreContextVar 0, 1
Push r0
PopLocal r5
Try #1 start:
PushConstant CP#5
DirectCall CP#3, 1
Drop1
PushConstant CP#6
Push r0
PushNull
AllocateClosure
PopLocal r7
Push r7
Push r7
UncheckedClosureCall CP#10, 1
Drop1
Jump L4
Try #1 end:
Try #1 handler:
SetFrame 9
Push r5
PopLocal r0
MoveSpecial exception, r5
MoveSpecial stackTrace, r6
PushConstant CP#12
DirectCall CP#3, 1
Drop1
Push r5
Push r6
Throw 1
L4:
Push r5
PopLocal r0
PushConstant CP#12
DirectCall CP#3, 1
Drop1
Jump L5
Try #0 end:
Try #0 handler:
SetFrame 9
Push r3
PopLocal r0
MoveSpecial exception, r3
MoveSpecial stackTrace, r4
PushConstant CP#14
DirectCall CP#3, 1
Drop1
Push r3
Push r4
Throw 1
L5:
Push r3
PopLocal r0
PushConstant CP#14
DirectCall CP#3, 1
Drop1
Jump L2
L2:
PushConstant CP#15
DirectCall CP#3, 1
Drop1
Jump L3
L3:
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 53, end 134, handler 134, needs-stack-trace, synthetic, types [CP#11]
try-index 1, outer 0, start 70, end 96, handler 96, needs-stack-trace, synthetic, types [CP#11]
}
ConstantPool {
[0] = InterfaceCall 'dart:core::Object::==', ArgDesc num-args 2, num-type-args 0, names []
[1] = Reserved
[2] = ObjectRef 'before try 1'
[3] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[4] = Reserved
[5] = ObjectRef 'try'
[6] = ClosureFunction 0
[7] = InstanceField dart:core::_Closure::_context (field)
[8] = Reserved
[9] = EndClosureFunctionScope
[10] = ObjectRef ArgDesc num-args 1, num-type-args 0, names []
[11] = Type dynamic
[12] = ObjectRef 'finally 1'
[13] = ObjectRef 'after try 1'
[14] = ObjectRef 'finally 2'
[15] = ObjectRef 'case 2'
}
Closure DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart::testTryFinally2::'foo' () -> void
ClosureCode {
Entry 2
Push FP[-5]
LoadFieldTOS CP#7
PopLocal r0
CheckStack 0
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r0
LoadContextVar 0, 1
DirectCall CP#3, 1
Drop1
PushNull
ReturnTOS
}
Function 'testTryFinally3', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 5
CheckStack 0
AllocateContext 0, 1
PopLocal r0
Push r0
PushInt 11
StoreContextVar 0, 0
PushNull
PopLocal r2
Push r0
PopLocal r3
Try #0 start:
PushConstant CP#0
Push r0
PushNull
AllocateClosure
PopLocal r2
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 5
Push r3
PopLocal r0
MoveSpecial exception, r3
MoveSpecial stackTrace, r4
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r2
DynamicCall CP#9, 1
Drop1
Push r3
Push r4
Throw 1
L1:
Push r3
PopLocal r0
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r2
DynamicCall CP#9, 1
Drop1
Push r0
LoadContextParent
PopLocal r0
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 23, end 35, handler 35, needs-stack-trace, synthetic, types [CP#6]
}
ConstantPool {
[0] = ClosureFunction 0
[1] = InstanceField dart:core::_Closure::_context (field)
[2] = Reserved
[3] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[4] = Reserved
[5] = ObjectRef 'try 1'
[6] = Type dynamic
[7] = ObjectRef 'try 2'
[8] = EndClosureFunctionScope
[9] = DynamicCall 'implicit:call', ArgDesc num-args 1, num-type-args 0, names []
[10] = Reserved
}
Closure DART_SDK/pkg/dart2bytecode/testcases/try_blocks.dart::testTryFinally3::'<anonymous closure>' () -> dart:core::int
ClosureCode {
Entry 6
Push FP[-5]
LoadFieldTOS CP#1
PopLocal r0
CheckStack 0
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r0
PopLocal r2
Try #0 start:
PushConstant CP#5
DirectCall CP#3, 1
Drop1
Jump L1
Try #0 end:
Try #0 handler:
SetFrame 6
Push r2
PopLocal r0
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r0
PopLocal r4
Try #1 start:
PushConstant CP#7
DirectCall CP#3, 1
Drop1
Jump L2
Try #1 end:
Try #1 handler:
SetFrame 6
Push r4
PopLocal r0
MoveSpecial exception, r4
MoveSpecial stackTrace, r5
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r4
Push r5
Throw 1
L2:
Push r4
PopLocal r0
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
PushInt 43
ReturnTOS
L1:
Push r2
PopLocal r0
Push r0
PopLocal r4
Try #2 start:
PushConstant CP#7
DirectCall CP#3, 1
Drop1
Jump L3
Try #2 end:
Try #2 handler:
SetFrame 6
Push r4
PopLocal r0
MoveSpecial exception, r4
MoveSpecial stackTrace, r5
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
Push r4
Push r5
Throw 1
L3:
Push r4
PopLocal r0
Push r0
LoadContextVar 0, 0
DirectCall CP#3, 1
Drop1
PushInt 43
ReturnTOS
}
Function 'testTryCatchFinally', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 5
CheckStack 0
Try #0 start:
Try #1 start:
PushConstant CP#0
DirectCall CP#1, 1
Drop1
Jump L1
Try #1 end:
Try #1 handler:
SetFrame 5
MoveSpecial exception, r2
MoveSpecial stackTrace, r3
Push r2
PopLocal r4
PushConstant CP#4
DirectCall CP#1, 1
Drop1
Jump L1
L1:
Jump L2
Try #0 end:
Try #0 handler:
SetFrame 5
MoveSpecial exception, r0
MoveSpecial stackTrace, r1
PushConstant CP#6
DirectCall CP#1, 1
Drop1
Push r0
Push r1
Throw 1
L2:
PushConstant CP#6
DirectCall CP#1, 1
Drop1
PushNull
ReturnTOS
}
ExceptionsTable {
try-index 0, outer -1, start 4, end 40, handler 40, needs-stack-trace, synthetic, types [CP#5]
try-index 1, outer 0, start 4, end 14, handler 14, types [CP#3]
}
ConstantPool {
[0] = ObjectRef 'try'
[1] = DirectCall 'dart:core::print', ArgDesc num-args 1, num-type-args 0, names []
[2] = Reserved
[3] = Type dart:core::Object
[4] = ObjectRef 'catch'
[5] = Type dynamic
[6] = ObjectRef 'finally'
}
Function 'main', static, reflectable, debuggable
parameters [] (required: 0)
return-type dynamic
Bytecode {
Entry 0
CheckStack 0
PushNull
ReturnTOS
}
ConstantPool {
}