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

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

Issue 2511883002: VM: [Kernel] Relax assertion in Script::GetTokenLocation(). (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // The bootstrapper will take care of creating the native wrapper classes, but 153 // The bootstrapper will take care of creating the native wrapper classes, but
154 // we will add the synthetic constructors to them here. 154 // we will add the synthetic constructors to them here.
155 if (library.name() == 155 if (library.name() ==
156 Symbols::Symbol(Symbols::kDartNativeWrappersLibNameId).raw()) { 156 Symbols::Symbol(Symbols::kDartNativeWrappersLibNameId).raw()) {
157 ASSERT(library.LoadInProgress()); 157 ASSERT(library.LoadInProgress());
158 } else { 158 } else {
159 library.SetLoadInProgress(); 159 library.SetLoadInProgress();
160 } 160 }
161 // Setup toplevel class (which contains library fields/procedures). 161 // Setup toplevel class (which contains library fields/procedures).
162 162
163 // TODO(27590): Figure out why we need this script stuff here. 163 // TODO(27590): Figure out why we need this script stuff here.
kustermann 2016/11/18 09:45:51 We need a valid [Script] for example because the [
Vyacheslav Egorov (Google) 2016/11/18 14:49:46 Done.
164 Script& script = Script::Handle( 164 Script& script =
165 Z, 165 Script::Handle(Z, Script::New(Symbols::KernelScriptUri(),
166 Script::New(H.DartString(""), H.DartString(""), RawScript::kScriptTag)); 166 H.DartString(""), RawScript::kScriptTag));
rmacnak 2016/11/17 20:13:31 There's a Symbols::Empty() btw.
Vyacheslav Egorov (Google) 2016/11/18 14:49:46 Done.
167 script.SetLocationOffset(0, 0); 167 script.SetLocationOffset(0, 0);
168 script.Tokenize(H.DartString("nop() {}")); 168 script.Tokenize(H.DartString("nop() {}"));
169 dart::Class& toplevel_class = dart::Class::Handle( 169 dart::Class& toplevel_class = dart::Class::Handle(
170 Z, dart::Class::New(library, Symbols::TopLevel(), script, 170 Z, dart::Class::New(library, Symbols::TopLevel(), script,
171 TokenPosition::kNoSource)); 171 TokenPosition::kNoSource));
172 toplevel_class.set_is_cycle_free(); 172 toplevel_class.set_is_cycle_free();
173 library.set_toplevel_class(toplevel_class); 173 library.set_toplevel_class(toplevel_class);
174 if (bootstrapping_) { 174 if (bootstrapping_) {
175 GrowableObjectArray::Handle(Z, I->object_store()->pending_classes()) 175 GrowableObjectArray::Handle(Z, I->object_store()->pending_classes())
176 .Add(toplevel_class, Heap::kOld); 176 .Add(toplevel_class, Heap::kOld);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // The class needs to have a script because all the functions in the class 620 // The class needs to have a script because all the functions in the class
621 // will inherit it. The predicate Function::IsOptimizable uses the 621 // will inherit it. The predicate Function::IsOptimizable uses the
622 // absence of a script to detect test functions that should not be 622 // absence of a script to detect test functions that should not be
623 // optimized. Use a dummy script. 623 // optimized. Use a dummy script.
624 // 624 //
625 // TODO(27590): We shouldn't need a dummy script per class. At the 625 // TODO(27590): We shouldn't need a dummy script per class. At the
626 // least we could have a singleton. At best, we'd change IsOptimizable to 626 // least we could have a singleton. At best, we'd change IsOptimizable to
627 // detect test functions some other way (like simply not setting the 627 // detect test functions some other way (like simply not setting the
628 // optimizable bit on those functions in the first place). 628 // optimizable bit on those functions in the first place).
629 TokenPosition pos(0); 629 TokenPosition pos(0);
630 Script& script = 630 Script& script = Script::Handle(
631 Script::Handle(Z, Script::New(H.DartString(""), H.DartString(""), 631 Z, Script::New(Symbols::KernelScriptUri(), H.DartString(""),
632 RawScript::kScriptTag)); 632 RawScript::kScriptTag));
633 handle = 633 handle =
634 &dart::Class::Handle(Z, dart::Class::New(library, name, script, pos)); 634 &dart::Class::Handle(Z, dart::Class::New(library, name, script, pos));
635 library.AddClass(*handle); 635 library.AddClass(*handle);
636 } else if (handle->script() == Script::null()) { 636 } else if (handle->script() == Script::null()) {
637 // When bootstrapping we can encounter classes that do not yet have a 637 // When bootstrapping we can encounter classes that do not yet have a
638 // dummy script. 638 // dummy script.
639 TokenPosition pos(0); 639 TokenPosition pos(0);
640 Script& script = 640 Script& script = Script::Handle(
641 Script::Handle(Z, Script::New(H.DartString(""), H.DartString(""), 641 Z, Script::New(Symbols::KernelScriptUri(), H.DartString(""),
642 RawScript::kScriptTag)); 642 RawScript::kScriptTag));
643 handle->set_script(script); 643 handle->set_script(script);
644 } 644 }
645 // Insert the class in the cache before calling ReadPreliminaryClass so 645 // Insert the class in the cache before calling ReadPreliminaryClass so
646 // we do not risk allocating the class again by calling LookupClass 646 // we do not risk allocating the class again by calling LookupClass
647 // recursively from ReadPreliminaryClass for the same class. 647 // recursively from ReadPreliminaryClass for the same class.
648 classes_.Insert(klass, handle); 648 classes_.Insert(klass, handle);
649 if (!handle->is_type_finalized()) { 649 if (!handle->is_type_finalized()) {
650 ReadPreliminaryClass(handle, klass); 650 ReadPreliminaryClass(handle, klass);
651 } 651 }
652 } 652 }
(...skipping 15 matching lines...) Expand all
668 } else { 668 } else {
669 ASSERT(0 <= kind && kind <= Procedure::kFactory); 669 ASSERT(0 <= kind && kind <= Procedure::kFactory);
670 return static_cast<RawFunction::Kind>(lookuptable[kind]); 670 return static_cast<RawFunction::Kind>(lookuptable[kind]);
671 } 671 }
672 } 672 }
673 673
674 674
675 } // namespace kernel 675 } // namespace kernel
676 } // namespace dart 676 } // namespace dart
677 #endif // !defined(DART_PRECOMPILED_RUNTIME) 677 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698