| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/source_report.h" | 5 #include "vm/source_report.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // before we have compiled its enclosing function or if the enclosing | 106 // before we have compiled its enclosing function or if the enclosing |
| 107 // function failed to compile. | 107 // function failed to compile. |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 intptr_t SourceReport::GetScriptIndex(const Script& script) { | 114 intptr_t SourceReport::GetScriptIndex(const Script& script) { |
| 115 const String& url = String::Handle(zone(), script.url()); | 115 const String& url = String::Handle(zone(), script.url()); |
| 116 ScriptTableEntry* pair = script_table_.Lookup(&url); | 116 ScriptTableEntry* pair = script_table_.LookupValue(&url); |
| 117 if (pair != NULL) { | 117 if (pair != NULL) { |
| 118 return pair->index; | 118 return pair->index; |
| 119 } | 119 } |
| 120 ScriptTableEntry* tmp = new ScriptTableEntry(); | 120 ScriptTableEntry* tmp = new ScriptTableEntry(); |
| 121 tmp->key = &url; | 121 tmp->key = &url; |
| 122 tmp->index = next_script_index_++; | 122 tmp->index = next_script_index_++; |
| 123 tmp->script = &Script::Handle(zone(), script.raw()); | 123 tmp->script = &Script::Handle(zone(), script.raw()); |
| 124 script_table_entries_.Add(tmp); | 124 script_table_entries_.Add(tmp); |
| 125 script_table_.Insert(tmp); | 125 script_table_.Insert(tmp); |
| 126 ASSERT(script_table_entries_.length() == next_script_index_); | 126 ASSERT(script_table_entries_.length() == next_script_index_); |
| 127 #if defined(DEBUG) | 127 #if defined(DEBUG) |
| 128 VerifyScriptTable(); | 128 VerifyScriptTable(); |
| 129 #endif | 129 #endif |
| 130 return tmp->index; | 130 return tmp->index; |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 #if defined(DEBUG) | 134 #if defined(DEBUG) |
| 135 void SourceReport::VerifyScriptTable() { | 135 void SourceReport::VerifyScriptTable() { |
| 136 for (intptr_t i = 0; i < script_table_entries_.length(); i++) { | 136 for (intptr_t i = 0; i < script_table_entries_.length(); i++) { |
| 137 const String* url = script_table_entries_[i]->key; | 137 const String* url = script_table_entries_[i]->key; |
| 138 const Script* script = script_table_entries_[i]->script; | 138 const Script* script = script_table_entries_[i]->script; |
| 139 intptr_t index = script_table_entries_[i]->index; | 139 intptr_t index = script_table_entries_[i]->index; |
| 140 ASSERT(i == index); | 140 ASSERT(i == index); |
| 141 const String& url2 = String::Handle(zone(), script->url()); | 141 const String& url2 = String::Handle(zone(), script->url()); |
| 142 ASSERT(url2.Equals(*url)); | 142 ASSERT(url2.Equals(*url)); |
| 143 ScriptTableEntry* pair = script_table_.Lookup(&url2); | 143 ScriptTableEntry* pair = script_table_.LookupValue(&url2); |
| 144 ASSERT(i == pair->index); | 144 ASSERT(i == pair->index); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 #endif | 147 #endif |
| 148 | 148 |
| 149 | 149 |
| 150 bool SourceReport::ScriptIsLoadedByLibrary(const Script& script, | 150 bool SourceReport::ScriptIsLoadedByLibrary(const Script& script, |
| 151 const Library& lib) { | 151 const Library& lib) { |
| 152 const Array& scripts = Array::Handle(zone(), lib.LoadedScripts()); | 152 const Array& scripts = Array::Handle(zone(), lib.LoadedScripts()); |
| 153 for (intptr_t j = 0; j < scripts.Length(); j++) { | 153 for (intptr_t j = 0; j < scripts.Length(); j++) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 // Visit all closures for this isolate. | 531 // Visit all closures for this isolate. |
| 532 VisitClosures(&ranges); | 532 VisitClosures(&ranges); |
| 533 } | 533 } |
| 534 | 534 |
| 535 // Print the script table. | 535 // Print the script table. |
| 536 JSONArray scripts(&report, "scripts"); | 536 JSONArray scripts(&report, "scripts"); |
| 537 PrintScriptTable(&scripts); | 537 PrintScriptTable(&scripts); |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace dart | 540 } // namespace dart |
| OLD | NEW |