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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2632183002: Debugging in kernel shaping up. (Closed)
Patch Set: Changed to TokenPosition::kMaxSourcePos Created 3 years, 11 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_binary.cc ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_reader.cc
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index f0be6f6fb9b25b868359d98b11ba218fe52377a2..2e1fac9c104d883e6befb40971222439c9c9935a 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -450,6 +450,45 @@ const Object& KernelReader::ClassForScriptAt(const dart::Class& klass,
return klass;
}
+static int LowestFirst(const intptr_t* a, const intptr_t* b) {
+ return *a - *b;
+}
+
+/**
+ * If index exists as sublist in list, sort the sublist from lowest to highest,
+ * then copy it, as Smis and without duplicates,
+ * to a new Array in Heap::kOld which is returned.
+ * Note that the source list is both sorted and de-duplicated as well, but will
+ * possibly contain duplicate and unsorted data at the end.
+ * Otherwise (when sublist doesn't exist in list) return new empty array.
+ */
+static RawArray* AsSortedDuplicateFreeArray(
+ intptr_t index,
+ MallocGrowableArray<MallocGrowableArray<intptr_t>*>* list) {
+ if ((index < list->length()) && (list->At(index)->length() > 0)) {
+ MallocGrowableArray<intptr_t>* source = list->At(index);
+ source->Sort(LowestFirst);
+
+ intptr_t size = source->length();
+ intptr_t last = 0;
+ for (intptr_t current = 1; current < size; ++current) {
+ if (source->At(last) != source->At(current)) {
+ (*source)[++last] = source->At(current);
+ }
+ }
+ Array& array_object = Array::Handle();
+ array_object ^= Array::New(last + 1, Heap::kOld);
+ Smi& smi_value = Smi::Handle();
+ for (intptr_t i = 0; i <= last; ++i) {
+ smi_value = Smi::New(source->At(i));
+ array_object.SetAt(i, smi_value);
+ }
+ return array_object.raw();
+ } else {
+ return Array::New(0);
+ }
+}
+
Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) {
Script& script = Script::ZoneHandle(Z);
script ^= scripts_.At(source_uri_index);
@@ -477,6 +516,16 @@ Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) {
array_object.SetAt(i, value);
}
script.set_line_starts(array_object);
+
+ // Create tokens_seen array for the script.
+ array_object ^= AsSortedDuplicateFreeArray(
+ source_uri_index, &program_->valid_token_positions);
+ script.set_debug_positions(array_object);
+
+ // Create yield_positions array for the script.
+ array_object ^= AsSortedDuplicateFreeArray(
+ source_uri_index, &program_->yield_token_positions);
+ script.set_yield_positions(array_object);
}
return script;
}
« no previous file with comments | « runtime/vm/kernel_binary.cc ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698