Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Side by Side Diff: pkg/kernel/binary.md

Issue 2854393002: [kernel] [partial] Streaming of kernel binary without AST nodes (Closed)
Patch Set: Address comments; small fixes; rebased. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 This file describes the binary format of Dart Kernel. 1 This file describes the binary format of Dart Kernel.
2 2
3 Notation 3 Notation
4 -------- 4 --------
5 Bitmasks are described with the syntax: 5 Bitmasks are described with the syntax:
6 ```scala 6 ```scala
7 Byte flags (flag1, flag2, ..., flagN) 7 Byte flags (flag1, flag2, ..., flagN)
8 ``` 8 ```
9 where 'flag<N>' is the N-th least significant bit, 9 where 'flag<N>' is the N-th least significant bit,
10 (so flag1 is the least significant bit). 10 (so flag1 is the least significant bit).
(...skipping 28 matching lines...) Expand all
39 Byte byte3(xxxxxxxx); 39 Byte byte3(xxxxxxxx);
40 Byte byte4(xxxxxxxx); // least significant byte 40 Byte byte4(xxxxxxxx); // least significant byte
41 } 41 }
42 42
43 type MagicWord = big endian 32-bit unsigned integer 43 type MagicWord = big endian 32-bit unsigned integer
44 44
45 type List<T> { 45 type List<T> {
46 UInt length; 46 UInt length;
47 T[length] items; 47 T[length] items;
48 } 48 }
49
50 // Untagged pairs.
51 type Pair<T0, T1> {
52 T0 first;
53 T1 second;
54 }
49 ``` 55 ```
50 56
51 A string table consists of an array of end offsets and a payload array of 57 A string table consists of an array of end offsets and a payload array of
52 strings encoded as UTF-8. The array of end offsets maps a string index to the 58 strings encoded as UTF-8. The array of end offsets maps a string index to the
53 offset of the _next_ string in the table or the offset of the end of the array 59 offset of the _next_ string in the table or the offset of the end of the array
54 for the last string. These offsets are relative to the string payload array. 60 for the last string. These offsets are relative to the string payload array.
55 Thus, string number 0 consists of the UTF-8 encoded string stretching from 61 Thus, string number 0 consists of the UTF-8 encoded string stretching from
56 offset 0 (inclusive) to endOffset[0] (exclusive); and string number N for N > 0 62 offset 0 (inclusive) to endOffset[0] (exclusive); and string number N for N > 0
57 consists of the UTF-8 encoded string stretching from offset endOffset[N-1] 63 consists of the UTF-8 encoded string stretching from offset endOffset[N-1]
58 (inclusive) to endOffset[N] (exclusive). 64 (inclusive) to endOffset[N] (exclusive).
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 345
340 abstract type Expression extends Node {} 346 abstract type Expression extends Node {}
341 347
342 type InvalidExpression extends Expression { 348 type InvalidExpression extends Expression {
343 Byte tag = 19; 349 Byte tag = 19;
344 } 350 }
345 351
346 type VariableGet extends Expression { 352 type VariableGet extends Expression {
347 Byte tag = 20; 353 Byte tag = 20;
348 FileOffset fileOffset; 354 FileOffset fileOffset;
355 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration.
349 VariableReference variable; 356 VariableReference variable;
350 } 357 }
351 358
352 type SpecializedVariableGet extends Expression { 359 type SpecializedVariableGet extends Expression {
353 Byte tag = 128 + N; // Where 0 <= N < 8. 360 Byte tag = 128 + N; // Where 0 <= N < 8.
354 // Equivalent to a VariableGet with index N. 361 // Equivalent to a VariableGet with index N.
355 FileOffset fileOffset; 362 FileOffset fileOffset;
363 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration.
356 } 364 }
357 365
358 type VariableSet extends Expression { 366 type VariableSet extends Expression {
359 Byte tag = 21; 367 Byte tag = 21;
360 FileOffset fileOffset; 368 FileOffset fileOffset;
369 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration.
361 VariableReference variable; 370 VariableReference variable;
362 Expression value; 371 Expression value;
363 } 372 }
364 373
365 type SpecializedVariableSet extends Expression { 374 type SpecializedVariableSet extends Expression {
366 Byte tag = 136 + N; // Where 0 <= N < 8. 375 Byte tag = 136 + N; // Where 0 <= N < 8.
367 FileOffset fileOffset; 376 FileOffset fileOffset;
377 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration.
368 Expression value; 378 Expression value;
369 // Equivalent to VariableSet with index N. 379 // Equivalent to VariableSet with index N.
370 } 380 }
371 381
372 type PropertyGet extends Expression { 382 type PropertyGet extends Expression {
373 Byte tag = 22; 383 Byte tag = 22;
374 FileOffset fileOffset; 384 FileOffset fileOffset;
375 Expression receiver; 385 Expression receiver;
376 Name name; 386 Name name;
377 MemberReference interfaceTarget; // May be NullReference. 387 MemberReference interfaceTarget; // May be NullReference.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 432
423 type StaticSet extends Expression { 433 type StaticSet extends Expression {
424 Byte tag = 27; 434 Byte tag = 27;
425 FileOffset fileOffset; 435 FileOffset fileOffset;
426 MemberReference target; 436 MemberReference target;
427 Expression value; 437 Expression value;
428 } 438 }
429 439
430 type Arguments { 440 type Arguments {
431 // Note: there is no tag on Arguments. 441 // Note: there is no tag on Arguments.
442 UInt numArguments; // equals positional.length + named.length
432 List<DartType> types; 443 List<DartType> types;
433 List<Expression> positional; 444 List<Expression> positional;
434 List<NamedExpression> named; 445 List<NamedExpression> named;
435 } 446 }
436 447
437 type NamedExpression { 448 type NamedExpression {
438 // Note: there is no tag on NamedExpression. 449 // Note: there is no tag on NamedExpression.
439 StringReference name; 450 StringReference name;
440 Expression value; 451 Expression value;
441 } 452 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 786 }
776 787
777 type SwitchStatement extends Statement { 788 type SwitchStatement extends Statement {
778 Byte tag = 71; 789 Byte tag = 71;
779 Expression expression; 790 Expression expression;
780 List<SwitchCase> cases; 791 List<SwitchCase> cases;
781 } 792 }
782 793
783 type SwitchCase { 794 type SwitchCase {
784 // Note: there is no tag on SwitchCase 795 // Note: there is no tag on SwitchCase
785 List<Expression> expressions; 796 List<Pair<FileOffset, Expression>> expressions;
786 FileOffset[expressions.length] expressionOffsets; // 1-to-1 with expressions.
787 Byte isDefault; // 1 if default, 0 is not default. 797 Byte isDefault; // 1 if default, 0 is not default.
788 Statement body; 798 Statement body;
789 } 799 }
790 800
791 type ContinueSwitchStatement extends Statement { 801 type ContinueSwitchStatement extends Statement {
792 Byte tag = 72; 802 Byte tag = 72;
793 803
794 // Reference to the Nth SwitchCase in scope. 804 // Reference to the Nth SwitchCase in scope.
795 // 805 //
796 // A SwitchCase is in scope everywhere within its enclosing switch, 806 // A SwitchCase is in scope everywhere within its enclosing switch,
(...skipping 15 matching lines...) Expand all
812 822
813 type ReturnStatement extends Statement { 823 type ReturnStatement extends Statement {
814 Byte tag = 74; 824 Byte tag = 74;
815 FileOffset fileOffset; 825 FileOffset fileOffset;
816 Option<Expression> expression; 826 Option<Expression> expression;
817 } 827 }
818 828
819 type TryCatch extends Statement { 829 type TryCatch extends Statement {
820 Byte tag = 75; 830 Byte tag = 75;
821 Statement body; 831 Statement body;
832 Byte anyCatchNeedsStackTrace; // 1 if any catch needs a stacktrace (have a sta cktrace variable).
822 List<Catch> catches; 833 List<Catch> catches;
823 } 834 }
824 835
825 type Catch { 836 type Catch {
826 DartType guard; 837 DartType guard;
827 Option<VariableDeclaration> exception; 838 Option<VariableDeclaration> exception;
828 Option<VariableDeclaration> stackTrace; 839 Option<VariableDeclaration> stackTrace;
829 Statement body; 840 Statement body;
830 } 841 }
831 842
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 type SimpleInterfaceType extends DartType { 914 type SimpleInterfaceType extends DartType {
904 Byte tag = 96; // Note: tag is out of order. 915 Byte tag = 96; // Note: tag is out of order.
905 ClassReference class; 916 ClassReference class;
906 // Equivalent to InterfaceType with empty list of type arguments. 917 // Equivalent to InterfaceType with empty list of type arguments.
907 } 918 }
908 919
909 type FunctionType extends DartType { 920 type FunctionType extends DartType {
910 Byte tag = 94; 921 Byte tag = 94;
911 List<TypeParameter> typeParameters; 922 List<TypeParameter> typeParameters;
912 UInt requiredParameterCount; 923 UInt requiredParameterCount;
924 UInt totalParameterCount; // positionalParameters.length + namedParameters.len gth
913 List<DartType> positionalParameters; 925 List<DartType> positionalParameters;
914 List<NamedDartType> namedParameters; 926 List<NamedDartType> namedParameters;
915 DartType returnType; 927 DartType returnType;
916 } 928 }
917 929
918 type SimpleFunctionType extends DartType { 930 type SimpleFunctionType extends DartType {
919 Byte tag = 97; // Note: tag is out of order. 931 Byte tag = 97; // Note: tag is out of order.
920 List<DartType> positionalParameters; 932 List<DartType> positionalParameters;
921 DartType returnType; 933 DartType returnType;
922 // Equivalent to a FunctionType with no type parameters or named parameters, 934 // Equivalent to a FunctionType with no type parameters or named parameters,
(...skipping 19 matching lines...) Expand all
942 // from the definition of scoping, since type parameter N+1 is not "in scope" 954 // from the definition of scoping, since type parameter N+1 is not "in scope"
943 // in the bound of type parameter N, but it takes up an index as if it was in 955 // in the bound of type parameter N, but it takes up an index as if it was in
944 // scope there. 956 // scope there.
945 // 957 //
946 // The type parameter can be bound by a Class, FunctionNode, or FunctionType. 958 // The type parameter can be bound by a Class, FunctionNode, or FunctionType.
947 // 959 //
948 // Note that constructors currently do not declare type parameters. Uses of 960 // Note that constructors currently do not declare type parameters. Uses of
949 // the class type parameters in a constructor refer to those declared on the 961 // the class type parameters in a constructor refer to those declared on the
950 // class. 962 // class.
951 UInt index; 963 UInt index;
952 964
965 // Byte offset in the binary for the type declaration.
966 // Note: This can also be 0, which is a 'forward reference' and is not to be u sed.
967 UInt typeParameterPosition;
953 Option<DartType> bound; 968 Option<DartType> bound;
954 } 969 }
955 970
956 type VectorType extends DartType { 971 type VectorType extends DartType {
957 Byte tag = 88; 972 Byte tag = 88;
958 } 973 }
959 974
960 type TypeParameter { 975 type TypeParameter {
961 // Note: there is no tag on TypeParameter 976 // Note: there is no tag on TypeParameter
962 StringReference name; // Cosmetic, may be empty, not unique. 977 StringReference name; // Cosmetic, may be empty, not unique.
963 DartType bound; // 'dynamic' if no explicit bound was given. 978 DartType bound; // 'dynamic' if no explicit bound was given.
964 } 979 }
965 980
966 ``` 981 ```
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698