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

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

Issue 2790073004: Restructure the Kernel string table. (Closed)
Patch Set: Incorporate review comments. Created 3 years, 8 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/binary/ast_from_binary.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 ```
49 50
50 type String { 51 A string table consists of an array of end offsets and a payload array of
51 List<Byte> utf8Bytes; 52 strings encoded as UTF-8. The array of end offsets maps a string index to the
52 } 53 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.
55 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
57 consists of the UTF-8 encoded string stretching from offset endOffset[N-1]
58 (inclusive) to endOffset[N] (exclusive).
53 59
60 ``` scala
54 type StringTable { 61 type StringTable {
55 List<String> strings; 62 List<UInt> endOffsets;
63 Byte[endOffsets.last] utf8Bytes;
56 } 64 }
57 65
58 type StringReference { 66 type StringReference {
59 UInt index; // Index into the StringTable strings. 67 UInt index; // Index into the Program's .strings.
60 } 68 }
61 69
62 type Source { 70 type Source {
63 String source; 71 List<Byte> utf8Bytes;
64 // Line starts are delta-encoded (they are encoded as line lengths). The list 72 // Line starts are delta-encoded (they are encoded as line lengths). The list
65 // [0, 10, 25, 32, 42] is encoded as [0, 10, 15, 7, 10]. 73 // [0, 10, 25, 32, 42] is encoded as [0, 10, 15, 7, 10].
66 List<Uint> lineStarts; 74 List<Uint> lineStarts;
67 } 75 }
68 76
69 type UriSource { 77 type UriSource {
70 List<String> uris; 78 StringTable uris;
71 Source[uris.length] source; 79 Source[uris.endOffsets.length] source;
72 } 80 }
73 81
74 type UriReference { 82 type UriReference {
75 UInt index; // Index into the UriSource uris. 83 UInt index; // Index into the UriSource uris.
76 } 84 }
77 85
78 type FileOffset { 86 type FileOffset {
79 // Encoded as offset + 1 to accommodate -1 indicating no offset. 87 // Encoded as offset + 1 to accommodate -1 indicating no offset.
80 UInt fileOffset; 88 UInt fileOffset;
81 } 89 }
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 Byte tag = 88; 955 Byte tag = 88;
948 } 956 }
949 957
950 type TypeParameter { 958 type TypeParameter {
951 // Note: there is no tag on TypeParameter 959 // Note: there is no tag on TypeParameter
952 StringReference name; // Cosmetic, may be empty, not unique. 960 StringReference name; // Cosmetic, may be empty, not unique.
953 DartType bound; // 'dynamic' if no explicit bound was given. 961 DartType bound; // 'dynamic' if no explicit bound was given.
954 } 962 }
955 963
956 ``` 964 ```
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698