Files
sdk/pkg/vm/testcases/bytecode/field_initializers.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

197 lines
5.0 KiB
Plaintext

library #lib;
import self as self;
import "dart:core" as core;
class A extends core::Object {
field core::int foo1;
field core::int foo2 = null;
field core::int foo3 = 42;
field core::int foo4;
field core::int foo5 = 43;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-6]
PushInt 42
StoreFieldTOS CP#0
Push FP[-6]
PushInt 43
StoreFieldTOS CP#2
Push FP[-6]
Push FP[-5]
StoreFieldTOS CP#4
Push FP[-6]
PushInt 44
StoreFieldTOS CP#2
Push FP[-6]
PushConstant CP#7
IndirectStaticCall 1, CP#6
Drop1
PushNull
ReturnTOS
}
Nullable fields: [#lib::A::foo1 (field), #lib::A::foo2 (field)]}
ConstantPool {
[0] = InstanceField #lib::A::foo3 (field)
[1] = Reserved
[2] = InstanceField #lib::A::foo5 (field)
[3] = Reserved
[4] = InstanceField #lib::A::foo4 (field)
[5] = Reserved
[6] = ArgDesc num-args 1, num-type-args 0, names []
[7] = StaticICData target 'dart:core::Object::'' (constructor)', arg-desc CP#6
}
] constructor •(core::int foo4) → self::A
: self::A::foo1 = null, self::A::foo4 = foo4, self::A::foo5 = 44, super core::Object::•()
;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-7]
PushInt 42
StoreFieldTOS CP#0
Push FP[-7]
PushInt 43
StoreFieldTOS CP#2
Push FP[-7]
Push FP[-6]
StoreFieldTOS CP#4
Push FP[-7]
Push FP[-5]
PushInt 1
AddInt
StoreFieldTOS CP#2
Push FP[-7]
PushConstant CP#7
IndirectStaticCall 1, CP#6
Drop1
PushNull
ReturnTOS
}
Nullable fields: [#lib::A::foo2 (field), #lib::A::foo4 (field)]}
ConstantPool {
[0] = InstanceField #lib::A::foo3 (field)
[1] = Reserved
[2] = InstanceField #lib::A::foo5 (field)
[3] = Reserved
[4] = InstanceField #lib::A::foo1 (field)
[5] = Reserved
[6] = ArgDesc num-args 1, num-type-args 0, names []
[7] = StaticICData target 'dart:core::Object::'' (constructor)', arg-desc CP#6
}
] constructor constr2(core::int x, core::int y) → self::A
: self::A::foo4 = null, self::A::foo1 = x, self::A::foo5 = y.{core::num::+}(1), super core::Object::•()
;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-5]
PushInt 45
PushConstant CP#1
IndirectStaticCall 2, CP#0
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = ArgDesc num-args 2, num-type-args 0, names []
[1] = StaticICData target '#lib::A::'' (constructor)', arg-desc CP#0
}
] constructor redirecting1() → self::A
: this self::A::•(45)
;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-8]
Push FP[-7]
Push FP[-6]
Push FP[-5]
MulInt
PushConstant CP#1
IndirectStaticCall 3, CP#0
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = ArgDesc num-args 3, num-type-args 0, names []
[1] = StaticICData target '#lib::A::constr2 (constructor)', arg-desc CP#0
}
] constructor redirecting2(core::int a, core::int b, core::int c) → self::A
: this self::A::constr2(a, b.{core::num::*}(c))
;
}
class B extends self::A {
field core::int foo6 = 46;
static field core::int foo7 = 47;
static const field core::int foo8 = 48;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-5]
PushInt 46
StoreFieldTOS CP#0
Push FP[-5]
PushInt 49
PushConstant CP#3
IndirectStaticCall 2, CP#2
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = InstanceField #lib::B::foo6 (field)
[1] = Reserved
[2] = ArgDesc num-args 2, num-type-args 0, names []
[3] = StaticICData target '#lib::A::'' (constructor)', arg-desc CP#2
}
] constructor •() → self::B
: super self::A::•(49)
;
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
Push FP[-7]
PushInt 46
StoreFieldTOS CP#0
Push FP[-7]
PushInt 50
StoreFieldTOS CP#0
Push FP[-7]
Push FP[-6]
Push FP[-5]
PushInt 51
PushConstant CP#3
IndirectStaticCall 4, CP#2
Drop1
PushNull
ReturnTOS
}
ConstantPool {
[0] = InstanceField #lib::B::foo6 (field)
[1] = Reserved
[2] = ArgDesc num-args 4, num-type-args 0, names []
[3] = StaticICData target '#lib::A::redirecting2 (constructor)', arg-desc CP#2
}
] constructor c2(core::int i, core::int j) → self::B
: self::B::foo6 = 50, super self::A::redirecting2(i, j, 51)
;
}
[@vm.bytecode=
Bytecode {
Entry 0
CheckStack 0
PushNull
ReturnTOS
}
ConstantPool {
}
]static method main() → dynamic {}