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

Unified Diff: pkg/kernel/binary.md

Issue 2790073004: Restructure the Kernel string table. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/binary.md
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index aae1e3008d2e4707f340c23737a3355a52f7ca1d..7d426ea92f9430d9a32ca4f5d53af43807270a9b 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -46,29 +46,37 @@ type List<T> {
UInt length;
T[length] items;
}
+```
-type String {
- List<Byte> utf8Bytes;
-}
+A string table consists of an array of end offsets and a payload array of
+strings encoded as UTF-8. The array of end offsets maps a string index to the
+offset of the _next_ string in the table or the offset of the end of the array
+for the last string. These offsets are relative to the string payload array.
+Thus, string number 0 consists of the UTF-8 encoded string stretching from
+offset 0 (inclusive) to endOffset[0] (exclusive); and string number N for N > 0
+consists of the UTF-8 encoded string stretching from offset endOffset[N-1]
+(inclusive) to endOffset[N] (exclusive).
+``` scala
type StringTable {
- List<String> strings;
+ List<UInt> endOffsets;
+ Byte[endOffsets.last] utf8Bytes;
}
type StringReference {
- UInt index; // Index into the StringTable strings.
+ UInt index; // Index into the Program's .strings.
asgerf 2017/04/04 09:33:36 The '.' looks out of place. It looks like it shou
Kevin Millikin (Google) 2017/04/04 11:02:58 I'll just say Program's strings. I was going for
}
type Source {
- String source;
+ List<Byte> utf8Bytes;
// Line starts are delta-encoded (they are encoded as line lengths). The list
// [0, 10, 25, 32, 42] is encoded as [0, 10, 15, 7, 10].
List<Uint> lineStarts;
}
type UriSource {
- List<String> uris;
- Source[uris.length] source;
+ StringTable uris;
+ Source[uris.endOffsets.length] source;
}
type UriReference {
« no previous file with comments | « no previous file | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | pkg/kernel/lib/binary/ast_from_binary.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698