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

Side by Side Diff: runtime/vm/kernel_reader.cc

Issue 2632183002: Debugging in kernel shaping up. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/kernel_reader.h" 5 #include "vm/kernel_reader.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 intptr_t source_uri_index) { 428 intptr_t source_uri_index) {
429 Script& correct_script = ScriptAt(source_uri_index); 429 Script& correct_script = ScriptAt(source_uri_index);
430 if (klass.script() != correct_script.raw()) { 430 if (klass.script() != correct_script.raw()) {
431 // TODO(jensj): We could probably cache this so we don't create 431 // TODO(jensj): We could probably cache this so we don't create
432 // new PatchClasses all the time 432 // new PatchClasses all the time
433 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script)); 433 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script));
434 } 434 }
435 return klass; 435 return klass;
436 } 436 }
437 437
438 static int LowestFirst(const intptr_t* a, const intptr_t* b) {
439 return *a - *b;
440 }
441
442 /**
443 * If index exists as sublist in list, sort the sublist from lowest to highest,
444 * then copy it, as Smis and without duplicates,
445 * to a new Array in Heap::kOld which is returned.
446 * Otherwise (when sublist doesn't exist in list) return new empty array.
447 */
448 static RawArray* AsSortedDuplicateFreeArray(
449 intptr_t index,
450 MallocGrowableArray<MallocGrowableArray<intptr_t>*>* list) {
451 if (index < list->length()) {
Kevin Millikin (Google) 2017/01/24 13:44:13 Since you've possibly got empty lists for yield po
jensj 2017/01/25 12:52:22 Done. Though it shouldn't really change anything (
452 MallocGrowableArray<intptr_t>* source = list->At(index);
453 Array& array_object = Array::Handle();
454 source->Sort(LowestFirst);
455
456 intptr_t different_values = 0;
457 intptr_t last_seen = 0;
458 intptr_t size = source->length();
459 for (intptr_t i = 0; i < size; ++i) {
Kevin Millikin (Google) 2017/01/24 13:44:13 It seems simpler to me to remove the duplicates fr
jensj 2017/01/25 12:52:22 Semi-done.
460 intptr_t value = source->At(i);
461 if (different_values == 0 || last_seen != value) {
462 last_seen = value;
463 ++different_values;
464 }
465 }
466
467 array_object ^= Array::New(different_values, Heap::kOld);
468 Smi& smi_value = Smi::Handle();
469 different_values = 0;
470 last_seen = 0;
471 for (intptr_t i = 0; i < size; ++i) {
472 intptr_t value = source->At(i);
473 if (different_values == 0 || last_seen != value) {
474 smi_value = Smi::New(value);
475 array_object.SetAt(different_values, smi_value);
476 last_seen = value;
477 ++different_values;
478 }
479 }
480 return array_object.raw();
481 } else {
482 return Array::New(0);
483 }
484 }
485
438 Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) { 486 Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) {
439 Script& script = Script::ZoneHandle(Z); 487 Script& script = Script::ZoneHandle(Z);
440 script ^= scripts_.At(source_uri_index); 488 script ^= scripts_.At(source_uri_index);
441 if (script.IsNull()) { 489 if (script.IsNull()) {
442 // Create script with correct uri(s). 490 // Create script with correct uri(s).
443 String* uri = program_->source_uri_table().strings()[source_uri_index]; 491 String* uri = program_->source_uri_table().strings()[source_uri_index];
444 dart::String& uri_string = H.DartString(uri, Heap::kOld); 492 dart::String& uri_string = H.DartString(uri, Heap::kOld);
445 dart::String& import_uri_string = 493 dart::String& import_uri_string =
446 import_uri == NULL ? uri_string : H.DartString(import_uri, Heap::kOld); 494 import_uri == NULL ? uri_string : H.DartString(import_uri, Heap::kOld);
447 dart::String& source_code = H.DartString( 495 dart::String& source_code = H.DartString(
448 program_->source_table().SourceFor(source_uri_index), Heap::kOld); 496 program_->source_table().SourceFor(source_uri_index), Heap::kOld);
449 script = Script::New(import_uri_string, uri_string, source_code, 497 script = Script::New(import_uri_string, uri_string, source_code,
450 RawScript::kKernelTag); 498 RawScript::kKernelTag);
451 scripts_.SetAt(source_uri_index, script); 499 scripts_.SetAt(source_uri_index, script);
452 500
453 // Create line_starts array for the script. 501 // Create line_starts array for the script.
454 intptr_t* line_starts = 502 intptr_t* line_starts =
455 program_->source_table().LineStartsFor(source_uri_index); 503 program_->source_table().LineStartsFor(source_uri_index);
456 intptr_t line_count = 504 intptr_t line_count =
457 program_->source_table().LineCountFor(source_uri_index); 505 program_->source_table().LineCountFor(source_uri_index);
458 Array& array_object = Array::Handle(Z, Array::New(line_count, Heap::kOld)); 506 Array& array_object = Array::Handle(Z, Array::New(line_count, Heap::kOld));
459 Smi& value = Smi::Handle(Z); 507 Smi& value = Smi::Handle(Z);
460 for (intptr_t i = 0; i < line_count; ++i) { 508 for (intptr_t i = 0; i < line_count; ++i) {
461 value = Smi::New(line_starts[i]); 509 value = Smi::New(line_starts[i]);
462 array_object.SetAt(i, value); 510 array_object.SetAt(i, value);
463 } 511 }
464 script.set_line_starts(array_object); 512 script.set_line_starts(array_object);
513
514 // Create tokens_seen array for the script.
515 array_object ^= AsSortedDuplicateFreeArray(
516 source_uri_index, &program_->valid_token_positions);
517 script.set_tokens_seen(array_object);
518
519 // Create yields_seen array for the script.
520 array_object ^= AsSortedDuplicateFreeArray(
521 source_uri_index, &program_->yield_token_positions);
522 script.set_yields_seen(array_object);
465 } 523 }
466 return script; 524 return script;
467 } 525 }
468 526
469 void KernelReader::GenerateFieldAccessors(const dart::Class& klass, 527 void KernelReader::GenerateFieldAccessors(const dart::Class& klass,
470 const dart::Field& field, 528 const dart::Field& field,
471 Field* kernel_field) { 529 Field* kernel_field) {
472 if (kernel_field->IsStatic() && kernel_field->initializer() != NULL) { 530 if (kernel_field->IsStatic() && kernel_field->initializer() != NULL) {
473 // Static fields with initializers either have the static value set to the 531 // Static fields with initializers either have the static value set to the
474 // initializer value if it is simple enough or else set to an uninitialized 532 // initializer value if it is simple enough or else set to an uninitialized
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 initializer_fun.set_is_debuggable(false); 783 initializer_fun.set_is_debuggable(false);
726 initializer_fun.set_is_reflectable(false); 784 initializer_fun.set_is_reflectable(false);
727 initializer_fun.set_is_inlinable(false); 785 initializer_fun.set_is_inlinable(false);
728 return new (zone) ParsedFunction(thread, initializer_fun); 786 return new (zone) ParsedFunction(thread, initializer_fun);
729 } 787 }
730 788
731 789
732 } // namespace kernel 790 } // namespace kernel
733 } // namespace dart 791 } // namespace dart
734 #endif // !defined(DART_PRECOMPILED_RUNTIME) 792 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698