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

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

Issue 1955453002: - Use a map to lookup libraries by URL. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix precompiler handling. Created 4 years, 7 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 5904 matching lines...) Expand 10 before | Expand all | Expand 10 after
5915 hide_names = Array::MakeArray(hide_list); 5915 hide_names = Array::MakeArray(hide_list);
5916 } 5916 }
5917 } 5917 }
5918 ExpectSemicolon(); 5918 ExpectSemicolon();
5919 5919
5920 // Canonicalize library URL. 5920 // Canonicalize library URL.
5921 const String& canon_url = String::CheckedHandle( 5921 const String& canon_url = String::CheckedHandle(
5922 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url)); 5922 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url));
5923 5923
5924 // Create a new library if it does not exist yet. 5924 // Create a new library if it does not exist yet.
5925 Library& library = Library::Handle(Z, Library::LookupLibrary(canon_url)); 5925 Library& library = Library::Handle(Z, Library::LookupLibrary(T, canon_url));
5926 if (library.IsNull()) { 5926 if (library.IsNull()) {
5927 library = Library::New(canon_url); 5927 library = Library::New(canon_url);
5928 library.Register(); 5928 library.Register(T);
5929 } 5929 }
5930 5930
5931 // If loading hasn't been requested yet, and if this is not a deferred 5931 // If loading hasn't been requested yet, and if this is not a deferred
5932 // library import, call the library tag handler to request loading 5932 // library import, call the library tag handler to request loading
5933 // the library. 5933 // the library.
5934 if (library.LoadNotStarted() && 5934 if (library.LoadNotStarted() &&
5935 (!is_deferred_import || FLAG_load_deferred_eagerly)) { 5935 (!is_deferred_import || FLAG_load_deferred_eagerly)) {
5936 library.SetLoadRequested(); 5936 library.SetLoadRequested();
5937 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); 5937 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url);
5938 } 5938 }
(...skipping 6052 matching lines...) Expand 10 before | Expand all | Expand 10 after
11991 static uword Hash(const Object& obj) { 11991 static uword Hash(const Object& obj) {
11992 const Array& key = Array::Cast(obj); 11992 const Array& key = Array::Cast(obj);
11993 intptr_t url_hash = String::HashRawSymbol(String::RawCast(key.At(0))); 11993 intptr_t url_hash = String::HashRawSymbol(String::RawCast(key.At(0)));
11994 intptr_t pos = Smi::Value(Smi::RawCast(key.At(1))); 11994 intptr_t pos = Smi::Value(Smi::RawCast(key.At(1)));
11995 return HashValue(url_hash, pos); 11995 return HashValue(url_hash, pos);
11996 } 11996 }
11997 static uword Hash(const ConstantPosKey& key) { 11997 static uword Hash(const ConstantPosKey& key) {
11998 return HashValue(String::HashRawSymbol(key.script_url.raw()), 11998 return HashValue(String::HashRawSymbol(key.script_url.raw()),
11999 key.token_pos.value()); 11999 key.token_pos.value());
12000 } 12000 }
12001 // Used by CachConstantValue if a new constant is added to the map. 12001 // Used by CacheConstantValue if a new constant is added to the map.
12002 static RawObject* NewKey(const ConstantPosKey& key) { 12002 static RawObject* NewKey(const ConstantPosKey& key) {
12003 const Array& key_obj = Array::Handle(Array::New(2)); 12003 const Array& key_obj = Array::Handle(Array::New(2));
12004 key_obj.SetAt(0, key.script_url); 12004 key_obj.SetAt(0, key.script_url);
12005 key_obj.SetAt(1, Smi::Handle(Smi::New(key.token_pos.value()))); 12005 key_obj.SetAt(1, Smi::Handle(Smi::New(key.token_pos.value())));
12006 return key_obj.raw();; 12006 return key_obj.raw();;
12007 } 12007 }
12008 12008
12009 private: 12009 private:
12010 static uword HashValue(intptr_t url_hash, intptr_t pos) { 12010 static uword HashValue(intptr_t url_hash, intptr_t pos) {
12011 return url_hash * pos % (Smi::kMaxValue - 13); 12011 return url_hash * pos % (Smi::kMaxValue - 13);
(...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after
14483 const ArgumentListNode& function_args, 14483 const ArgumentListNode& function_args,
14484 const LocalVariable* temp_for_last_arg, 14484 const LocalVariable* temp_for_last_arg,
14485 bool is_super_invocation) { 14485 bool is_super_invocation) {
14486 UNREACHABLE(); 14486 UNREACHABLE();
14487 return NULL; 14487 return NULL;
14488 } 14488 }
14489 14489
14490 } // namespace dart 14490 } // namespace dart
14491 14491
14492 #endif // DART_PRECOMPILED_RUNTIME 14492 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object_test.cc ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698