Skip to content

Commit

Permalink
Allow SourceReport to have duplicate URL entries if the VM scripts does
Browse files Browse the repository at this point in the history
When using a concatenated dill file, several scripts with the same URL
can exist. They are not the same though, and should not be treated as
such.

Bug: #34841
Change-Id: Icd46357ffcf72ed35251b2a2793e1f83c02c4a8e
Reviewed-on: https://dart-review.googlesource.com/c/80821
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
  • Loading branch information
jensjoha authored and commit-bot@chromium.org committed Oct 29, 2018
1 parent 0fe448a commit db42713
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions runtime/vm/source_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ bool SourceReport::ShouldSkipFunction(const Function& func) {
}

intptr_t SourceReport::GetScriptIndex(const Script& script) {
ScriptTableEntry wrapper;
const String& url = String::Handle(zone(), script.url());
ScriptTableEntry* pair = script_table_.LookupValue(&url);
wrapper.key = &url;
wrapper.script = &Script::Handle(zone(), script.raw());
ScriptTableEntry* pair = script_table_.LookupValue(&wrapper);
if (pair != NULL) {
return pair->index;
}
ScriptTableEntry* tmp = new ScriptTableEntry();
tmp->key = &url;
tmp->index = next_script_index_++;
tmp->script = &Script::Handle(zone(), script.raw());
tmp->script = wrapper.script;
script_table_entries_.Add(tmp);
script_table_.Insert(tmp);
ASSERT(script_table_entries_.length() == next_script_index_);
Expand All @@ -139,7 +142,10 @@ void SourceReport::VerifyScriptTable() {
ASSERT(i == index);
const String& url2 = String::Handle(zone(), script->url());
ASSERT(url2.Equals(*url));
ScriptTableEntry* pair = script_table_.LookupValue(&url2);
ScriptTableEntry wrapper;
wrapper.key = &url2;
wrapper.script = &Script::Handle(zone(), script->raw());
ScriptTableEntry* pair = script_table_.LookupValue(&wrapper);
ASSERT(i == pair->index);
}
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/vm/source_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ class SourceReport {
// Needed for DirectChainedHashMap.
struct ScriptTableTrait {
typedef ScriptTableEntry* Value;
typedef const String* Key;
typedef const ScriptTableEntry* Key;
typedef ScriptTableEntry* Pair;

static Key KeyOf(Pair kv) { return kv->key; }
static Key KeyOf(Pair kv) { return kv; }

static Value ValueOf(Pair kv) { return kv; }

static inline intptr_t Hashcode(Key key) { return key->Hash(); }
static inline intptr_t Hashcode(Key key) { return key->key->Hash(); }

static inline bool IsKeyEqual(Pair kv, Key key) {
return kv->key->Equals(*key);
return kv->script->raw() == key->script->raw();
}
};

Expand Down

0 comments on commit db42713

Please sign in to comment.