Skip to content

Commit 9f72f10

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,dyn_modules] Support class modifiers in bytecode
TEST=ci Change-Id: I521b27c793269dc6076b353f50e2cdaa629002e9 Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441987 Reviewed-by: Tess Strickland <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 77556e8 commit 9f72f10

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

pkg/dart2bytecode/docs/bytecode.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ type ClassDeclaration {
478478
UInt flags = (isAbstract, isEnum,
479479
hasTypeParams, hasTypeArguments,
480480
isTransformedMixinApplication,
481-
hasSourcePositions, hasAnnotations, hasPragma);
481+
hasSourcePositions, hasAnnotations, hasPragma,
482+
hasConstConstructor, isSealed, isMixinClass,
483+
isBaseClass, isInterface, isFinal);
482484
PackedObject script;
483485
484486
if hasSourcePositions

pkg/dart2bytecode/lib/bytecode_generator.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ class BytecodeGenerator extends RecursiveVisitor {
266266
if (cls.isEnum) {
267267
flags |= ClassDeclaration.isEnumFlag;
268268
}
269+
if (cls.isSealed) {
270+
flags |= ClassDeclaration.isSealedFlag;
271+
}
272+
if (cls.isMixinClass) {
273+
flags |= ClassDeclaration.isMixinClassFlag;
274+
}
275+
if (cls.isBase) {
276+
flags |= ClassDeclaration.isBaseClassFlag;
277+
}
278+
if (cls.isInterface) {
279+
flags |= ClassDeclaration.isInterfaceFlag;
280+
}
281+
if (cls.isFinal) {
282+
flags |= ClassDeclaration.isFinalFlag;
283+
}
269284
int numTypeArguments = 0;
270285
TypeParametersDeclaration? typeParameters;
271286
if (hasInstantiatorTypeArguments(cls)) {
@@ -282,6 +297,10 @@ class BytecodeGenerator extends RecursiveVisitor {
282297
if (cls.isEliminatedMixin) {
283298
flags |= ClassDeclaration.isTransformedMixinApplicationFlag;
284299
}
300+
if (cls.hasConstConstructor) {
301+
flags |= ClassDeclaration.hasConstConstructorFlag;
302+
}
303+
285304
int position = TreeNode.noOffset;
286305
int endPosition = TreeNode.noOffset;
287306
if (options.emitSourcePositions && cls.fileOffset != TreeNode.noOffset) {

pkg/dart2bytecode/lib/declarations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ class ClassDeclaration extends BytecodeDeclaration {
9494
static const hasSourcePositionsFlag = 1 << 5;
9595
static const hasAnnotationsFlag = 1 << 6;
9696
static const hasPragmaFlag = 1 << 7;
97+
static const hasConstConstructorFlag = 1 << 8;
98+
static const isSealedFlag = 1 << 9;
99+
static const isMixinClassFlag = 1 << 10;
100+
static const isBaseClassFlag = 1 << 11;
101+
static const isInterfaceFlag = 1 << 12;
102+
static const isFinalFlag = 1 << 13;
97103

98104
ObjectHandle? name;
99105
final int flags;

runtime/vm/bytecode_reader.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,12 @@ void BytecodeReaderHelper::ReadClassDeclaration(const Class& cls) {
21342134
const int kHasSourcePositionsFlag = 1 << 5;
21352135
const int kHasAnnotationsFlag = 1 << 6;
21362136
const int kHasPragmaFlag = 1 << 7;
2137+
const int kHasConstConstructorFlag = 1 << 8;
2138+
const int kIsSealedFlag = 1 << 9;
2139+
const int kIsMixinClassFlag = 1 << 10;
2140+
const int kIsBaseClassFlag = 1 << 11;
2141+
const int kIsInterfaceFlag = 1 << 12;
2142+
const int kIsFinalFlag = 1 << 13;
21372143

21382144
// Class is allocated when reading library declaration in
21392145
// BytecodeReaderHelper::ReadLibraryDeclaration.
@@ -2175,6 +2181,24 @@ void BytecodeReaderHelper::ReadClassDeclaration(const Class& cls) {
21752181
if ((flags & kIsTransformedMixinApplicationFlag) != 0) {
21762182
cls.set_is_transformed_mixin_application();
21772183
}
2184+
if ((flags & kHasConstConstructorFlag) != 0) {
2185+
cls.set_is_const();
2186+
}
2187+
if ((flags & kIsSealedFlag) != 0) {
2188+
cls.set_is_sealed();
2189+
}
2190+
if ((flags & kIsMixinClassFlag) != 0) {
2191+
cls.set_is_mixin_class();
2192+
}
2193+
if ((flags & kIsBaseClassFlag) != 0) {
2194+
cls.set_is_base_class();
2195+
}
2196+
if ((flags & kIsInterfaceFlag) != 0) {
2197+
cls.set_is_interface_class();
2198+
}
2199+
if ((flags & kIsFinalFlag) != 0) {
2200+
cls.set_is_final();
2201+
}
21782202

21792203
intptr_t num_type_arguments = 0;
21802204
if ((flags & kHasTypeArgumentsFlag) != 0) {

0 commit comments

Comments
 (0)