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

Unified Diff: runtime/vm/object.cc

Issue 23982002: Fix bug where Script files that only contained patches were lost from the list of LoadedScripts() T… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index d1037bf718a2bc995ded5aa67c706f6a95449b8b..b67da40ab9cf4b3d2a673c214e47cd5a649ce8cc 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6780,6 +6780,18 @@ void Library::AddClass(const Class& cls) const {
cls.set_library(*this);
}
+void AddScriptIfUnique(const GrowableObjectArray& scripts, Script& candidate) {
hausner 2013/09/05 21:23:51 static
Jacob 2013/09/06 00:56:58 Done.
+ Script& script_obj = Script::Handle();
+ for (int i = 0; i < scripts.Length(); i++) {
+ script_obj ^= scripts.At(i);
+ if (script_obj.raw() == candidate.raw()) {
+ // We already have a reference to this script.
+ return;
+ }
+ }
+ // Add script to the list of scripts.
+ scripts.Add(candidate);
+}
RawArray* Library::LoadedScripts() const {
// We compute the list of loaded scripts lazily. The result is
@@ -6791,12 +6803,23 @@ RawArray* Library::LoadedScripts() const {
Object& entry = Object::Handle();
Class& cls = Class::Handle();
Script& owner_script = Script::Handle();
+ Script& function_script = Script::Handle();
siva 2013/09/05 18:35:11 Class& patch_cls = Class::Handle(); Script& patch_
Jacob 2013/09/05 23:58:24 Done.
+ Function& function = Function::Handle();
DictionaryIterator it(*this);
- Script& script_obj = Script::Handle();
while (it.HasNext()) {
entry = it.GetNext();
if (entry.IsClass()) {
owner_script = Class::Cast(entry).script();
+ Array& functions_list = Array::Handle(Class::Cast(entry).functions());
+ intptr_t functions_len = functions_list.Length();
+ for (intptr_t i = 0; i < functions_len; i++) {
+ function ^= functions_list.At(i);
+ function_script = function.script();
+ if (!(function_script.raw() == owner_script.raw())) {
+ // The function was patched in.
+ AddScriptIfUnique(scripts, function_script);
+ }
+ }
siva 2013/09/05 18:35:11 I don't think it is necessary to go over all the f
Jacob 2013/09/05 23:58:24 That is simpler. Done.
} else if (entry.IsFunction()) {
owner_script = Function::Cast(entry).script();
} else if (entry.IsField()) {
@@ -6805,22 +6828,7 @@ RawArray* Library::LoadedScripts() const {
} else {
continue;
}
- if (owner_script.IsNull()) {
- continue;
- }
- bool is_unique = true;
- for (int i = 0; i < scripts.Length(); i++) {
- script_obj ^= scripts.At(i);
- if (script_obj.raw() == owner_script.raw()) {
- // We already have a reference to this script.
- is_unique = false;
- break;
- }
- }
- if (is_unique) {
- // Add script to the list of scripts.
- scripts.Add(owner_script);
- }
+ AddScriptIfUnique(scripts, owner_script);
}
// Create the array of scripts and cache it in loaded_scripts_.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698