9f49b47823
This is a major revamp of bytecode metadata format. Now bytecode has its own serialization mechanisms. This CL adds 'bytecode component' metadata, which contains bytecode object table and string table. All references from bytecode (constant pools) to libraries, classes, members, types and strings now have a new format. References to frequently used objects are represented as indices in object table, while rarely used objects are written inline. This allows VM to cache frequently used objects while reading bytecode. Representation of strings is aligned with VM - string characters are stored in separate pools of one-byte and two-byte strings. This allows VM to avoid UTF-8 decoding and extra copying. Closure declarations are now explicit. Type parameters no longer require enslosing scopes when reading/writing them. Benchmarks: GenKernelKernelReadAllBytecode (Intel Core i5) +29.84% GenKernelKernelReadAllBytecode (Intel Xeon) +28.74% Change-Id: I4b80009733a8f8c038264af74f97c4e094b9e311 Reviewed-on: https://dart-review.googlesource.com/c/85469 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Régis Crelier <regis@google.com> Reviewed-by: Zach Anderson <zra@google.com>
252 lines
5.1 KiB
Plaintext
252 lines
5.1 KiB
Plaintext
library #lib;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
[@vm.bytecode=
|
|
Bytecode {
|
|
Entry 2
|
|
CheckStack 0
|
|
PushNull
|
|
PopLocal r0
|
|
Push FP[-5]
|
|
PopLocal r1
|
|
Push r1
|
|
PushInt 1
|
|
InstanceCall 2, CP#1
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 2
|
|
InstanceCall 2, CP#2
|
|
JumpIfTrue L2
|
|
Push r1
|
|
PushInt 3
|
|
InstanceCall 2, CP#3
|
|
JumpIfTrue L3
|
|
Jump L4
|
|
L1:
|
|
PushInt 11
|
|
PopLocal r0
|
|
Jump L4
|
|
L2:
|
|
PushInt 22
|
|
PopLocal r0
|
|
Jump L4
|
|
L3:
|
|
PushInt 33
|
|
PopLocal r0
|
|
Jump L4
|
|
L4:
|
|
Push r0
|
|
ReturnTOS
|
|
}
|
|
ConstantPool {
|
|
[0] = ArgDesc num-args 2, num-type-args 0, names []
|
|
[1] = ICData target-name '==', arg-desc CP#0
|
|
[2] = ICData target-name '==', arg-desc CP#0
|
|
[3] = ICData target-name '==', arg-desc CP#0
|
|
}
|
|
]static method foo1(core::int x) → core::int {
|
|
core::int y;
|
|
#L1:
|
|
switch(x) {
|
|
#L2:
|
|
case 1:
|
|
{
|
|
y = 11;
|
|
break #L1;
|
|
}
|
|
#L3:
|
|
case 2:
|
|
{
|
|
y = 22;
|
|
break #L1;
|
|
}
|
|
#L4:
|
|
case 3:
|
|
{
|
|
y = 33;
|
|
break #L1;
|
|
}
|
|
}
|
|
return y;
|
|
}
|
|
[@vm.bytecode=
|
|
Bytecode {
|
|
Entry 2
|
|
CheckStack 0
|
|
PushNull
|
|
PopLocal r0
|
|
Push FP[-5]
|
|
PopLocal r1
|
|
Push r1
|
|
PushInt 1
|
|
InstanceCall 2, CP#1
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 2
|
|
InstanceCall 2, CP#2
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 3
|
|
InstanceCall 2, CP#3
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 4
|
|
InstanceCall 2, CP#4
|
|
JumpIfTrue L2
|
|
Push r1
|
|
PushInt 5
|
|
InstanceCall 2, CP#5
|
|
JumpIfTrue L2
|
|
Push r1
|
|
PushInt 6
|
|
InstanceCall 2, CP#6
|
|
JumpIfTrue L2
|
|
Jump L3
|
|
L1:
|
|
PushInt 11
|
|
PopLocal r0
|
|
Jump L4
|
|
L2:
|
|
PushInt 22
|
|
PopLocal r0
|
|
Jump L4
|
|
L3:
|
|
PushInt 33
|
|
PopLocal r0
|
|
L4:
|
|
Push r0
|
|
ReturnTOS
|
|
}
|
|
ConstantPool {
|
|
[0] = ArgDesc num-args 2, num-type-args 0, names []
|
|
[1] = ICData target-name '==', arg-desc CP#0
|
|
[2] = ICData target-name '==', arg-desc CP#0
|
|
[3] = ICData target-name '==', arg-desc CP#0
|
|
[4] = ICData target-name '==', arg-desc CP#0
|
|
[5] = ICData target-name '==', arg-desc CP#0
|
|
[6] = ICData target-name '==', arg-desc CP#0
|
|
}
|
|
]static method foo2(core::int x) → core::int {
|
|
core::int y;
|
|
#L5:
|
|
switch(x) {
|
|
#L6:
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
{
|
|
y = 11;
|
|
break #L5;
|
|
}
|
|
#L7:
|
|
case 4:
|
|
case 5:
|
|
case 6:
|
|
{
|
|
y = 22;
|
|
break #L5;
|
|
}
|
|
#L8:
|
|
default:
|
|
{
|
|
y = 33;
|
|
}
|
|
}
|
|
return y;
|
|
}
|
|
[@vm.bytecode=
|
|
Bytecode {
|
|
Entry 2
|
|
CheckStack 0
|
|
PushNull
|
|
PopLocal r0
|
|
Push FP[-5]
|
|
PopLocal r1
|
|
Push r1
|
|
PushInt 1
|
|
InstanceCall 2, CP#1
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 2
|
|
InstanceCall 2, CP#2
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 3
|
|
InstanceCall 2, CP#3
|
|
JumpIfTrue L1
|
|
Push r1
|
|
PushInt 4
|
|
InstanceCall 2, CP#4
|
|
JumpIfTrue L2
|
|
Push r1
|
|
PushInt 5
|
|
InstanceCall 2, CP#5
|
|
JumpIfTrue L2
|
|
Push r1
|
|
PushInt 6
|
|
InstanceCall 2, CP#6
|
|
JumpIfTrue L2
|
|
Jump L3
|
|
L1:
|
|
PushInt 11
|
|
PopLocal r0
|
|
Jump L2
|
|
L2:
|
|
PushInt 22
|
|
PopLocal r0
|
|
PushInt 42
|
|
ReturnTOS
|
|
L3:
|
|
PushInt 33
|
|
PopLocal r0
|
|
Push r0
|
|
ReturnTOS
|
|
}
|
|
ConstantPool {
|
|
[0] = ArgDesc num-args 2, num-type-args 0, names []
|
|
[1] = ICData target-name '==', arg-desc CP#0
|
|
[2] = ICData target-name '==', arg-desc CP#0
|
|
[3] = ICData target-name '==', arg-desc CP#0
|
|
[4] = ICData target-name '==', arg-desc CP#0
|
|
[5] = ICData target-name '==', arg-desc CP#0
|
|
[6] = ICData target-name '==', arg-desc CP#0
|
|
}
|
|
]static method foo3(core::int x) → core::int {
|
|
core::int y;
|
|
switch(x) {
|
|
#L9:
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
{
|
|
y = 11;
|
|
continue #L10;
|
|
}
|
|
#L10:
|
|
case 4:
|
|
case 5:
|
|
case 6:
|
|
{
|
|
y = 22;
|
|
return 42;
|
|
}
|
|
#L11:
|
|
default:
|
|
{
|
|
y = 33;
|
|
}
|
|
}
|
|
return y;
|
|
}
|
|
[@vm.bytecode=
|
|
Bytecode {
|
|
Entry 0
|
|
CheckStack 0
|
|
PushNull
|
|
ReturnTOS
|
|
}
|
|
ConstantPool {
|
|
}
|
|
]static method main() → dynamic {}
|