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

Unified Diff: runtime/vm/kernel_binary.cc

Issue 2782913003: Revert "Remove definitions from Kernel canonical names." (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
« no previous file with comments | « runtime/vm/kernel.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_binary.cc
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc
index 44980724fba3ac957b4b70827f9e7852f2ab0e22..a1cad8377e2c09b8d4a288acc9e78b0380914b6b 100644
--- a/runtime/vm/kernel_binary.cc
+++ b/runtime/vm/kernel_binary.cc
@@ -494,6 +494,13 @@ class Reader {
return name;
}
+ CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) {
+ CanonicalName* name = ReadCanonicalNameReference();
+ ASSERT(name != NULL);
+ name->BindTo(node_to_link);
+ return name;
+ }
+
intptr_t offset() { return offset_; }
private:
@@ -680,9 +687,11 @@ Library* Library::ReadFrom(Reader* reader) {
int flags = reader->ReadFlags();
ASSERT(flags == 0); // external libraries not supported
- canonical_name_ = reader->ReadCanonicalNameReference();
+ CanonicalName* canonical_name =
+ reader->ReadDefiningCanonicalNameReference(this);
+
name_ = Reference::ReadStringFrom(reader);
- import_uri_ = canonical_name_->name();
+ import_uri_ = canonical_name->name();
source_uri_index_ = reader->ReadUInt();
reader->set_current_script_id(source_uri_index_);
@@ -708,7 +717,7 @@ Library* Library::ReadFrom(Reader* reader) {
Class* Class::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
- canonical_name_ = reader->ReadCanonicalNameReference();
+ reader->ReadDefiningCanonicalNameReference(this);
position_ = reader->ReadPosition(false);
is_abstract_ = reader->ReadBool();
name_ = Reference::ReadStringFrom(reader);
@@ -800,7 +809,7 @@ Field* Field::ReadFrom(Reader* reader) {
Tag tag = reader->ReadTag();
ASSERT(tag == kField);
- canonical_name_ = reader->ReadCanonicalNameReference();
+ reader->ReadDefiningCanonicalNameReference(this);
position_ = reader->ReadPosition(false);
end_position_ = reader->ReadPosition(false);
flags_ = reader->ReadFlags();
@@ -821,7 +830,7 @@ Constructor* Constructor::ReadFrom(Reader* reader) {
Tag tag = reader->ReadTag();
ASSERT(tag == kConstructor);
- canonical_name_ = reader->ReadCanonicalNameReference();
+ reader->ReadDefiningCanonicalNameReference(this);
VariableScope<ReaderHelper> parameters(reader->helper());
position_ = reader->ReadPosition();
end_position_ = reader->ReadPosition();
@@ -839,7 +848,7 @@ Procedure* Procedure::ReadFrom(Reader* reader) {
Tag tag = reader->ReadTag();
ASSERT(tag == kProcedure);
- canonical_name_ = reader->ReadCanonicalNameReference();
+ reader->ReadDefiningCanonicalNameReference(this);
VariableScope<ReaderHelper> parameters(reader->helper());
position_ = reader->ReadPosition(false);
end_position_ = reader->ReadPosition(false);
@@ -1881,6 +1890,15 @@ Program* Program::ReadFrom(Reader* reader) {
program->main_method_reference_ = Reference::ReadMemberFrom(reader);
+#ifdef DEBUG
+ for (intptr_t i = 0; i < canonical_names; ++i) {
+ CanonicalName* name = reader->helper()->GetCanonicalName(i);
+ if (name->is_referenced() && name->definition() == NULL) {
+ FATAL("Missing definition for canonical name");
+ }
+ }
+#endif
+
return program;
}
« no previous file with comments | « runtime/vm/kernel.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698