Chromium Code Reviews| 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_. |