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

Side by Side Diff: pkg/kernel/lib/binary/ast_to_binary.dart

Issue 2972343002: [kernel] Insert kernel bodies into VM heap (Closed)
Patch Set: Review comments Created 3 years, 4 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 | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | runtime/vm/class_finalizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.ast_to_binary; 4 library kernel.ast_to_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import 'tag.dart'; 8 import 'tag.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 isSyntheticMixinImplementationFlag | 389 isSyntheticMixinImplementationFlag |
390 levelFlags; 390 levelFlags;
391 } 391 }
392 392
393 visitClass(Class node) { 393 visitClass(Class node) {
394 int flags = _encodeClassFlags(node.isAbstract, node.isEnum, 394 int flags = _encodeClassFlags(node.isAbstract, node.isEnum,
395 node.isSyntheticMixinImplementation, node.level); 395 node.isSyntheticMixinImplementation, node.level);
396 if (node.canonicalName == null) { 396 if (node.canonicalName == null) {
397 throw 'Missing canonical name for $node'; 397 throw 'Missing canonical name for $node';
398 } 398 }
399 node.binaryOffset = _sink.flushedLength + _sink.length;
400 writeByte(Tag.Class); 399 writeByte(Tag.Class);
401 writeCanonicalNameReference(getCanonicalNameOfClass(node)); 400 writeCanonicalNameReference(getCanonicalNameOfClass(node));
402 writeOffset(node.fileOffset); 401 writeOffset(node.fileOffset);
403 writeOffset(node.fileEndOffset); 402 writeOffset(node.fileEndOffset);
404 writeByte(flags); 403 writeByte(flags);
405 writeStringReference(node.name ?? ''); 404 writeStringReference(node.name ?? '');
406 writeUriReference(node.fileUri ?? ''); 405 writeUriReference(node.fileUri ?? '');
407 writeStringReference(node.documentationComment ?? ''); 406 writeStringReference(node.documentationComment ?? '');
408 writeAnnotationList(node.annotations); 407 writeAnnotationList(node.annotations);
409 _typeParameterIndexer.enter(node.typeParameters); 408 _typeParameterIndexer.enter(node.typeParameters);
(...skipping 12 matching lines...) Expand all
422 visitConstructor(Constructor node) { 421 visitConstructor(Constructor node) {
423 if (node.canonicalName == null) { 422 if (node.canonicalName == null) {
424 throw 'Missing canonical name for $node'; 423 throw 'Missing canonical name for $node';
425 } 424 }
426 _variableIndexer = new VariableIndexer(); 425 _variableIndexer = new VariableIndexer();
427 writeByte(Tag.Constructor); 426 writeByte(Tag.Constructor);
428 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 427 writeCanonicalNameReference(getCanonicalNameOfMember(node));
429 writeOffset(node.fileOffset); 428 writeOffset(node.fileOffset);
430 writeOffset(node.fileEndOffset); 429 writeOffset(node.fileEndOffset);
431 writeByte(node.flags); 430 writeByte(node.flags);
432 assert(node.parent is Class);
433 Class parent = node.parent;
434 writeUInt30(parent.binaryOffset);
435 writeName(node.name ?? _emptyName); 431 writeName(node.name ?? _emptyName);
436 writeStringReference(node.documentationComment ?? ''); 432 writeStringReference(node.documentationComment ?? '');
437 writeAnnotationList(node.annotations); 433 writeAnnotationList(node.annotations);
438 assert(node.function.typeParameters.isEmpty); 434 assert(node.function.typeParameters.isEmpty);
439 writeNode(node.function); 435 writeNode(node.function);
440 // Parameters are in scope in the initializers. 436 // Parameters are in scope in the initializers.
441 _variableIndexer.restoreScope(node.function.positionalParameters.length + 437 _variableIndexer.restoreScope(node.function.positionalParameters.length +
442 node.function.namedParameters.length); 438 node.function.namedParameters.length);
443 writeNodeList(node.initializers); 439 writeNodeList(node.initializers);
444 _variableIndexer = null; 440 _variableIndexer = null;
445 } 441 }
446 442
447 visitProcedure(Procedure node) { 443 visitProcedure(Procedure node) {
448 if (node.canonicalName == null) { 444 if (node.canonicalName == null) {
449 throw 'Missing canonical name for $node'; 445 throw 'Missing canonical name for $node';
450 } 446 }
451 _variableIndexer = new VariableIndexer(); 447 _variableIndexer = new VariableIndexer();
452 writeByte(Tag.Procedure); 448 writeByte(Tag.Procedure);
453 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 449 writeCanonicalNameReference(getCanonicalNameOfMember(node));
454 writeOffset(node.fileOffset); 450 writeOffset(node.fileOffset);
455 writeOffset(node.fileEndOffset); 451 writeOffset(node.fileEndOffset);
456 writeByte(node.kind.index); 452 writeByte(node.kind.index);
457 writeByte(node.flags); 453 writeByte(node.flags);
458 if (node.parent is Class) {
459 Class parent = node.parent;
460 writeUInt30(parent.binaryOffset);
461 } else {
462 writeUInt30(0); // 0 is a valid offset, but not for a class.
463 }
464 writeName(node.name ?? ''); 454 writeName(node.name ?? '');
465 writeUriReference(node.fileUri ?? ''); 455 writeUriReference(node.fileUri ?? '');
466 writeStringReference(node.documentationComment ?? ''); 456 writeStringReference(node.documentationComment ?? '');
467 writeAnnotationList(node.annotations); 457 writeAnnotationList(node.annotations);
468 writeOptionalNode(node.function); 458 writeOptionalNode(node.function);
469 _variableIndexer = null; 459 _variableIndexer = null;
470 } 460 }
471 461
472 visitField(Field node) { 462 visitField(Field node) {
473 if (node.canonicalName == null) { 463 if (node.canonicalName == null) {
474 throw 'Missing canonical name for $node'; 464 throw 'Missing canonical name for $node';
475 } 465 }
476 _variableIndexer = new VariableIndexer(); 466 _variableIndexer = new VariableIndexer();
477 writeByte(Tag.Field); 467 writeByte(Tag.Field);
478 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 468 writeCanonicalNameReference(getCanonicalNameOfMember(node));
479 writeOffset(node.fileOffset); 469 writeOffset(node.fileOffset);
480 writeOffset(node.fileEndOffset); 470 writeOffset(node.fileEndOffset);
481 writeByte(node.flags); 471 writeByte(node.flags);
482 if (node.parent is Class) {
483 Class parent = node.parent;
484 writeUInt30(parent.binaryOffset);
485 } else {
486 writeUInt30(0); // 0 is a valid offset, but not for a class.
487 }
488 writeName(node.name); 472 writeName(node.name);
489 writeUriReference(node.fileUri ?? ''); 473 writeUriReference(node.fileUri ?? '');
490 writeStringReference(node.documentationComment ?? ''); 474 writeStringReference(node.documentationComment ?? '');
491 writeAnnotationList(node.annotations); 475 writeAnnotationList(node.annotations);
492 writeNode(node.type); 476 writeNode(node.type);
493 writeOptionalNode(node.initializer); 477 writeOptionalNode(node.initializer);
494 _variableIndexer = null; 478 _variableIndexer = null;
495 } 479 }
496 480
497 visitInvalidInitializer(InvalidInitializer node) { 481 visitInvalidInitializer(InvalidInitializer node) {
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 writeByte(Tag.VectorType); 1155 writeByte(Tag.VectorType);
1172 } 1156 }
1173 1157
1174 visitTypedefType(TypedefType node) { 1158 visitTypedefType(TypedefType node) {
1175 writeByte(Tag.TypedefType); 1159 writeByte(Tag.TypedefType);
1176 writeReference(node.typedefReference); 1160 writeReference(node.typedefReference);
1177 writeNodeList(node.typeArguments); 1161 writeNodeList(node.typeArguments);
1178 } 1162 }
1179 1163
1180 visitTypeParameter(TypeParameter node) { 1164 visitTypeParameter(TypeParameter node) {
1181 node.binaryOffset = _sink.flushedLength + _sink.length;
1182 writeStringReference(node.name ?? ''); 1165 writeStringReference(node.name ?? '');
1183 writeNode(node.bound); 1166 writeNode(node.bound);
1184 } 1167 }
1185 1168
1186 defaultNode(Node node) { 1169 defaultNode(Node node) {
1187 throw 'Unsupported node: $node'; 1170 throw 'Unsupported node: $node';
1188 } 1171 }
1189 } 1172 }
1190 1173
1191 typedef bool LibraryFilter(Library _); 1174 typedef bool LibraryFilter(Library _);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 _sink.add(_buffer.sublist(0, length)); 1550 _sink.add(_buffer.sublist(0, length));
1568 _buffer = new Uint8List(SIZE); 1551 _buffer = new Uint8List(SIZE);
1569 flushedLength += length; 1552 flushedLength += length;
1570 length = 0; 1553 length = 0;
1571 } 1554 }
1572 1555
1573 void flushAndDestroy() { 1556 void flushAndDestroy() {
1574 _sink.add(_buffer.sublist(0, length)); 1557 _sink.add(_buffer.sublist(0, length));
1575 } 1558 }
1576 } 1559 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | runtime/vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698