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

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

Issue 1152833002: Add a runtime flag to control availability of dart:mirrors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/bootstrap.h" 5 #include "vm/bootstrap.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/bootstrap_natives.h" 9 #include "vm/bootstrap_natives.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/dart_api_impl.h" 12 #include "vm/dart_api_impl.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DECLARE_FLAG(bool, use_mirrors);
20
19 #define INIT_LIBRARY(index, name, source, patch) \ 21 #define INIT_LIBRARY(index, name, source, patch) \
20 { index, \ 22 { index, \
21 "dart:"#name, source, \ 23 "dart:"#name, source, \
22 "dart:"#name"-patch", patch } \ 24 "dart:"#name"-patch", patch } \
23 25
24 typedef struct { 26 typedef struct {
25 ObjectStore::BootstrapLibraryId index_; 27 ObjectStore::BootstrapLibraryId index_;
26 const char* uri_; 28 const char* uri_;
27 const char** source_paths_; 29 const char** source_paths_;
28 const char* patch_uri_; 30 const char* patch_uri_;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // library tag handler so that we can load all the bootstrap libraries. 268 // library tag handler so that we can load all the bootstrap libraries.
267 isolate->set_library_tag_handler(BootstrapLibraryTagHandler); 269 isolate->set_library_tag_handler(BootstrapLibraryTagHandler);
268 270
269 HANDLESCOPE(isolate); 271 HANDLESCOPE(isolate);
270 272
271 // Create library objects for all the bootstrap libraries. 273 // Create library objects for all the bootstrap libraries.
272 for (intptr_t i = 0; 274 for (intptr_t i = 0;
273 bootstrap_libraries[i].index_ != ObjectStore::kNone; 275 bootstrap_libraries[i].index_ != ObjectStore::kNone;
274 ++i) { 276 ++i) {
275 uri = Symbols::New(bootstrap_libraries[i].uri_); 277 uri = Symbols::New(bootstrap_libraries[i].uri_);
278
279 if (!FLAG_use_mirrors && (uri.raw() == Symbols::DartMirrors().raw())) {
280 continue;
281 }
282
276 lib = Library::LookupLibrary(uri); 283 lib = Library::LookupLibrary(uri);
277 if (lib.IsNull()) { 284 if (lib.IsNull()) {
278 lib = Library::NewLibraryHelper(uri, false); 285 lib = Library::NewLibraryHelper(uri, false);
279 lib.SetLoadRequested(); 286 lib.SetLoadRequested();
280 lib.Register(); 287 lib.Register();
281 } 288 }
282 isolate->object_store()->set_bootstrap_library( 289 isolate->object_store()->set_bootstrap_library(
283 bootstrap_libraries[i].index_, lib); 290 bootstrap_libraries[i].index_, lib);
284 } 291 }
285 292
286 // Load, compile and patch bootstrap libraries. 293 // Load, compile and patch bootstrap libraries.
287 for (intptr_t i = 0; 294 for (intptr_t i = 0;
288 bootstrap_libraries[i].index_ != ObjectStore::kNone; 295 bootstrap_libraries[i].index_ != ObjectStore::kNone;
289 ++i) { 296 ++i) {
290 uri = Symbols::New(bootstrap_libraries[i].uri_); 297 uri = Symbols::New(bootstrap_libraries[i].uri_);
298
299 if (!FLAG_use_mirrors && (uri.raw() == Symbols::DartMirrors().raw())) {
300 continue;
301 }
302
291 lib = Library::LookupLibrary(uri); 303 lib = Library::LookupLibrary(uri);
292 ASSERT(!lib.IsNull()); 304 ASSERT(!lib.IsNull());
293 source = GetLibrarySource(lib, uri, false); 305 source = GetLibrarySource(lib, uri, false);
294 if (source.IsNull()) { 306 if (source.IsNull()) {
295 const String& message = String::Handle( 307 const String& message = String::Handle(
296 String::NewFormatted("Unable to find dart source for %s", 308 String::NewFormatted("Unable to find dart source for %s",
297 uri.ToCString())); 309 uri.ToCString()));
298 error ^= ApiError::New(message); 310 error ^= ApiError::New(message);
299 break; 311 break;
300 } 312 }
(...skipping 28 matching lines...) Expand all
329 Compiler::CompileClass(cls); 341 Compiler::CompileClass(cls);
330 } 342 }
331 343
332 // Restore the library tag handler for the isolate. 344 // Restore the library tag handler for the isolate.
333 isolate->set_library_tag_handler(saved_tag_handler); 345 isolate->set_library_tag_handler(saved_tag_handler);
334 346
335 return error.raw(); 347 return error.raw();
336 } 348 }
337 349
338 } // namespace dart 350 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/vm/bootstrap_natives.cc » ('j') | runtime/vm/dart.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698