Files
sdk/pkg/vm/testcases/bytecode/optional_params.dart.expect
T
Alexander Markov 9f49b47823 [vm/bytecode] Revise representation of objects and strings in bytecode
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>
2018-12-03 19:08:42 +00:00

291 lines
7.8 KiB
Plaintext

library #lib;
import self as self;
import "dart:core" as core;
[@vm.bytecode=
Bytecode {
EntryOptional 1, 2, 0
LoadConstant r1, CP#0
LoadConstant r2, CP#1
Frame 1
CheckStack 0
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r3
Push r3
PushInt 0
PushConstant CP#2
StoreIndexedTOS
Push r3
PushInt 1
Push r0
StoreIndexedTOS
PushConstant CP#4
IndirectStaticCall 1, CP#3
PushConstant CP#5
IndirectStaticCall 1, CP#3
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r3
Push r3
PushInt 0
PushConstant CP#6
StoreIndexedTOS
Push r3
PushInt 1
Push r1
StoreIndexedTOS
PushConstant CP#7
IndirectStaticCall 1, CP#3
PushConstant CP#8
IndirectStaticCall 1, CP#3
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r3
Push r3
PushInt 0
PushConstant CP#9
StoreIndexedTOS
Push r3
PushInt 1
Push r2
StoreIndexedTOS
PushConstant CP#10
IndirectStaticCall 1, CP#3
PushConstant CP#11
IndirectStaticCall 1, CP#3
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = String 'default_a'
[1] = String 'default_b'
[2] = String 'x = '
[3] = ArgDesc num-args 1, num-type-args 0, names []
[4] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#3
[5] = StaticICData target 'dart:core::print', arg-desc CP#3
[6] = String 'a = '
[7] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#3
[8] = StaticICData target 'dart:core::print', arg-desc CP#3
[9] = String 'b = '
[10] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#3
[11] = StaticICData target 'dart:core::print', arg-desc CP#3
}
]static method foo1(dynamic x, [dynamic a = "default_a", dynamic b = "default_b"]) → void {
core::print("x = ${x}");
core::print("a = ${a}");
core::print("b = ${b}");
}
[@vm.bytecode=
Bytecode {
EntryOptional 2, 0, 3
LoadConstant r2, CP#0
LoadConstant r2, CP#1
LoadConstant r3, CP#2
LoadConstant r3, CP#4
LoadConstant r4, CP#5
LoadConstant r4, CP#6
Frame 1
CheckStack 0
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#7
StoreIndexedTOS
Push r5
PushInt 1
Push r0
StoreIndexedTOS
PushConstant CP#9
IndirectStaticCall 1, CP#8
PushConstant CP#10
IndirectStaticCall 1, CP#8
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#11
StoreIndexedTOS
Push r5
PushInt 1
Push r1
StoreIndexedTOS
PushConstant CP#12
IndirectStaticCall 1, CP#8
PushConstant CP#13
IndirectStaticCall 1, CP#8
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#14
StoreIndexedTOS
Push r5
PushInt 1
Push r2
StoreIndexedTOS
PushConstant CP#15
IndirectStaticCall 1, CP#8
PushConstant CP#16
IndirectStaticCall 1, CP#8
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#17
StoreIndexedTOS
Push r5
PushInt 1
Push r3
StoreIndexedTOS
PushConstant CP#18
IndirectStaticCall 1, CP#8
PushConstant CP#19
IndirectStaticCall 1, CP#8
Drop1
PushNull
PushInt 2
CreateArrayTOS
StoreLocal r5
Push r5
PushInt 0
PushConstant CP#20
StoreIndexedTOS
Push r5
PushInt 1
Push r4
StoreIndexedTOS
PushConstant CP#21
IndirectStaticCall 1, CP#8
PushConstant CP#22
IndirectStaticCall 1, CP#8
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = String 'a'
[1] = Int 42
[2] = String 'b'
[3] = String 'default_b'
[4] = List type-arg dart:core::String, entries CP# [3]
[5] = String 'c'
[6] = String 'default_c'
[7] = String 'y = '
[8] = ArgDesc num-args 1, num-type-args 0, names []
[9] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#8
[10] = StaticICData target 'dart:core::print', arg-desc CP#8
[11] = String 'z = '
[12] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#8
[13] = StaticICData target 'dart:core::print', arg-desc CP#8
[14] = String 'a = '
[15] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#8
[16] = StaticICData target 'dart:core::print', arg-desc CP#8
[17] = String 'b = '
[18] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#8
[19] = StaticICData target 'dart:core::print', arg-desc CP#8
[20] = String 'c = '
[21] = StaticICData target 'dart:core::_StringBase::_interpolate', arg-desc CP#8
[22] = StaticICData target 'dart:core::print', arg-desc CP#8
}
]static method foo2(dynamic y, dynamic z, {dynamic c = "default_c", dynamic a = 42, dynamic b = const <core::String>["default_b"]}) → void {
core::print("y = ${y}");
core::print("z = ${z}");
core::print("a = ${a}");
core::print("b = ${b}");
core::print("c = ${c}");
}
[@vm.bytecode=
Bytecode {
EntryOptional 2, 0, 2
LoadConstant r2, CP#0
LoadConstant r2, CP#1
LoadConstant r3, CP#2
LoadConstant r3, CP#3
Frame 1
CheckStack 0
CheckFunctionTypeArgs 2, r4
PushNull
Push r4
InstantiateType CP#4
PushConstant CP#6
IndirectStaticCall 1, CP#5
Drop1
Push r1
PushConstant CP#7
IndirectStaticCall 1, CP#5
Drop1
Push r3
PushConstant CP#8
IndirectStaticCall 1, CP#5
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = String 'a'
[1] = Bool false
[2] = String 'b'
[3] = Null
[4] = Type #lib::foo3::TypeParam/0
[5] = ArgDesc num-args 1, num-type-args 0, names []
[6] = StaticICData target 'dart:core::print', arg-desc CP#5
[7] = StaticICData target 'dart:core::print', arg-desc CP#5
[8] = StaticICData target 'dart:core::print', arg-desc CP#5
}
]static method foo3<P extends core::Object = dynamic, Q extends core::Object = dynamic>(dynamic z, dynamic y, {core::bool a = false, core::Map<self::foo3::P, self::foo3::Q> b = null}) → void {
core::print(self::foo3::P);
core::print(y);
core::print(b);
}
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
PushConstant CP#0
PushConstant CP#1
PushConstant CP#3
IndirectStaticCall 2, CP#2
Drop1
PushConstant CP#4
PushConstant CP#5
PushConstant CP#1
PushConstant CP#7
IndirectStaticCall 3, CP#6
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = String 'fixed_x'
[1] = String 'concrete_a'
[2] = ArgDesc num-args 2, num-type-args 0, names []
[3] = StaticICData target '#lib::foo1', arg-desc CP#2
[4] = String 'fixed_y'
[5] = String 'fixed_z'
[6] = ArgDesc num-args 3, num-type-args 0, names [a]
[7] = StaticICData target '#lib::foo2', arg-desc CP#6
}
]static method main() → dynamic {
self::foo1("fixed_x", "concrete_a");
self::foo2("fixed_y", "fixed_z", a: "concrete_a");
}