Remove writeOptionalReference

References can be null --- it's written as the byte [0].
Thus in the null case it would before be [0] and now be [0].
In the non-null case it would before be [1, xyz] (1 for Tag.Something
and xyz for the actual, now positive, uint30). Now it would be [xyz].

Change-Id: Ibc08d3afb7275b0429a4d6c5e667fbd381121489
Reviewed-on: https://dart-review.googlesource.com/c/85394
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen
2019-01-04 13:31:03 +00:00
committed by commit-bot@chromium.org
parent 5ed1c6132a
commit d53f02aa8a
7 changed files with 20 additions and 36 deletions
+4 -4
View File
@@ -131,7 +131,7 @@ type CanonicalName {
type ComponentFile {
UInt32 magic = 0x90ABCDEF;
UInt32 formatVersion = 14;
UInt32 formatVersion = 15;
Library[] libraries;
UriSource sourceMap;
List<CanonicalName> canonicalNames;
@@ -373,8 +373,8 @@ type Procedure extends Member {
Name name;
List<Expression> annotations;
// Only present if the 'isForwardingStub' flag is set.
Option<MemberReference> forwardingStubSuperTarget;
Option<MemberReference> forwardingStubInterfaceTarget;
MemberReference forwardingStubSuperTarget; // May be NullReference.
MemberReference forwardingStubInterfaceTarget; // May be NullReference.
// Can only be absent if abstract, but tag is there anyway.
Option<FunctionNode> function;
}
@@ -886,7 +886,7 @@ type StringConstant extends Constant {
type SymbolConstant extends Constant {
Byte tag = 5;
Option<LibraryReference> library;
LibraryReference library; // May be NullReference.
StringReference name;
}
+3 -6
View File
@@ -216,10 +216,7 @@ class BinaryBuilder {
case ConstantTag.StringConstant:
return new StringConstant(readStringReference());
case ConstantTag.SymbolConstant:
Reference libraryReference;
if (readAndCheckOptionTag()) {
libraryReference = readLibraryReference();
}
Reference libraryReference = readLibraryReference(allowNull: true);
return new SymbolConstant(readStringReference(), libraryReference);
case ConstantTag.MapConstant:
final DartType keyType = readDartType();
@@ -1113,9 +1110,9 @@ class BinaryBuilder {
(kind == ProcedureKind.Factory && functionNodeSize <= 50) ||
_disableLazyReading;
var forwardingStubSuperTargetReference =
readAndCheckOptionTag() ? readMemberReference() : null;
readMemberReference(allowNull: true);
var forwardingStubInterfaceTargetReference =
readAndCheckOptionTag() ? readMemberReference() : null;
readMemberReference(allowNull: true);
var function = readFunctionNodeOption(!readFunctionNodeNow, endOffset);
var transformerFlags = getAndResetTransformerFlags();
assert(((_) => true)(debugPath.removeLast()));
+3 -12
View File
@@ -203,7 +203,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
writeStringReference(constant.value);
} else if (constant is SymbolConstant) {
writeByte(ConstantTag.SymbolConstant);
writeOptionalReference(constant.libraryReference);
writeNullAllowedReference(constant.libraryReference);
writeStringReference(constant.name);
} else if (constant is MapConstant) {
writeByte(ConstantTag.MapConstant);
@@ -459,15 +459,6 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
}
}
void writeOptionalReference(Reference ref) {
if (ref == null) {
writeByte(Tag.Nothing);
} else {
writeByte(Tag.Something);
writeNonNullReference(ref);
}
}
void writeLinkTable(Component component) {
_binaryOffsetForLinkTable = getBufferOffset();
writeList(_canonicalNameList, writeCanonicalNameEntry);
@@ -1107,8 +1098,8 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
writeByte(node.flags);
writeName(node.name ?? _emptyName);
writeAnnotationList(node.annotations);
writeOptionalReference(node.forwardingStubSuperTargetReference);
writeOptionalReference(node.forwardingStubInterfaceTargetReference);
writeNullAllowedReference(node.forwardingStubSuperTargetReference);
writeNullAllowedReference(node.forwardingStubInterfaceTargetReference);
writeOptionalFunctionNode(node.function);
leaveScope(memberScope: true);
+1 -1
View File
@@ -136,7 +136,7 @@ class Tag {
/// Internal version of kernel binary format.
/// Bump it when making incompatible changes in kernel binaries.
/// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md.
static const int BinaryFormatVersion = 14;
static const int BinaryFormatVersion = 15;
}
abstract class ConstantTag {
@@ -1169,12 +1169,11 @@ const Array& ConstantHelper::ReadConstantTable() {
break;
}
case kSymbolConstant: {
Tag initializer_tag = helper_.ReadTag();
if (initializer_tag == kSomething) {
const NameIndex index = helper_.ReadCanonicalNameReference();
temp_library_ = H.LookupLibraryByKernelLibrary(index);
} else {
const NameIndex index = helper_.ReadCanonicalNameReference();
if (index == -1) {
temp_library_ = Library::null();
} else {
temp_library_ = H.LookupLibraryByKernelLibrary(index);
}
const String& symbol =
H.DartIdentifier(temp_library_, helper_.ReadStringReference());
@@ -1024,20 +1024,17 @@ void ProcedureHelper::ReadUntilExcluding(Field field) {
}
/* Falls through */
case kForwardingStubSuperTarget:
if (helper_->ReadTag() == kSomething) {
forwarding_stub_super_target_ = helper_->ReadCanonicalNameReference();
}
forwarding_stub_super_target_ = helper_->ReadCanonicalNameReference();
if (++next_read_ == field) return;
/* Falls through */
case kForwardingStubInterfaceTarget:
if (helper_->ReadTag() == kSomething) {
helper_->ReadCanonicalNameReference();
}
helper_->ReadCanonicalNameReference();
if (++next_read_ == field) return;
/* Falls through */
case kFunction:
if (helper_->ReadTag() == kSomething)
if (helper_->ReadTag() == kSomething) {
helper_->SkipFunctionNode(); // read function node.
}
if (++next_read_ == field) return;
/* Falls through */
case kEnd:
+1 -1
View File
@@ -17,7 +17,7 @@ namespace kernel {
// package:kernel/binary.md.
static const uint32_t kMagicProgramFile = 0x90ABCDEFu;
static const uint32_t kBinaryFormatVersion = 14;
static const uint32_t kBinaryFormatVersion = 15;
// Keep in sync with package:kernel/lib/binary/tag.dart
#define KERNEL_TAG_LIST(V) \