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

Side by Side Diff: runtime/vm/dart.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/code_observers.h" 7 #include "vm/code_observers.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 28 matching lines...) Expand all
39 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap"); 39 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap");
40 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024, 40 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024,
41 "Max total size of external allocations in MB, or 0 for unlimited," 41 "Max total size of external allocations in MB, or 0 for unlimited,"
42 "e.g: --external_max_size=1024 allows up to 1024MB of externals"); 42 "e.g: --external_max_size=1024 allows up to 1024MB of externals");
43 43
44 DEFINE_FLAG(bool, keep_code, false, 44 DEFINE_FLAG(bool, keep_code, false,
45 "Keep deoptimized code for profiling."); 45 "Keep deoptimized code for profiling.");
46 46
47 DECLARE_FLAG(bool, print_class_table); 47 DECLARE_FLAG(bool, print_class_table);
48 DECLARE_FLAG(bool, trace_isolates); 48 DECLARE_FLAG(bool, trace_isolates);
49 DECLARE_FLAG(bool, use_mirrors);
49 50
50 Isolate* Dart::vm_isolate_ = NULL; 51 Isolate* Dart::vm_isolate_ = NULL;
51 ThreadPool* Dart::thread_pool_ = NULL; 52 ThreadPool* Dart::thread_pool_ = NULL;
52 DebugInfo* Dart::pprof_symbol_generator_ = NULL; 53 DebugInfo* Dart::pprof_symbol_generator_ = NULL;
53 ReadOnlyHandles* Dart::predefined_handles_ = NULL; 54 ReadOnlyHandles* Dart::predefined_handles_ = NULL;
54 55
55 // Structure for managing read-only global handles allocation used for 56 // Structure for managing read-only global handles allocation used for
56 // creating global read-only handles that are pre created and initialized 57 // creating global read-only handles that are pre created and initialized
57 // for use across all isolates. Having these global pre created handles 58 // for use across all isolates. Having these global pre created handles
58 // stored in the vm isolate ensures that we don't constantly create and 59 // stored in the vm isolate ensures that we don't constantly create and
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); 271 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length());
271 } 272 }
272 IsolateSnapshotReader reader(snapshot->content(), 273 IsolateSnapshotReader reader(snapshot->content(),
273 snapshot->length(), 274 snapshot->length(),
274 isolate, 275 isolate,
275 zone.GetZone()); 276 zone.GetZone());
276 const Error& error = Error::Handle(reader.ReadFullSnapshot()); 277 const Error& error = Error::Handle(reader.ReadFullSnapshot());
277 if (!error.IsNull()) { 278 if (!error.IsNull()) {
278 return error.raw(); 279 return error.raw();
279 } 280 }
281
282 if (!FLAG_use_mirrors) {
283 const Object& libmirrors =
284 Object::Handle(isolate->object_store()->mirrors_library());
Ivan Posva 2015/05/29 06:02:24 Should we at this point set the value in the objec
rmacnak 2015/06/13 00:11:09 Actually, this is unsafe. We sometimes lookup libr
285 if (!libmirrors.IsNull()) {
286 // Mirrors were enabled when the snapshot was taken. Retroactively
287 // remove them.
288 const GrowableObjectArray& old_libs =
Ivan Posva 2015/05/29 06:02:24 Instead of creating a new array, you could find th
289 GrowableObjectArray::Handle(isolate->object_store()->libraries());
290 const GrowableObjectArray& new_libs = GrowableObjectArray::Handle(
291 GrowableObjectArray::New(old_libs.Length(), Heap::kOld));
292 Object& lib = Object::Handle();
293 for (intptr_t i = 0; i < old_libs.Length(); i++) {
294 lib = old_libs.At(i);
295 if (lib.raw() != libmirrors.raw()) {
296 new_libs.Add(lib);
297 }
298 }
299 isolate->object_store()->set_libraries(new_libs);
300 }
301 }
302
280 if (FLAG_trace_isolates) { 303 if (FLAG_trace_isolates) {
281 isolate->heap()->PrintSizes(); 304 isolate->heap()->PrintSizes();
282 isolate->megamorphic_cache_table()->PrintSizes(); 305 isolate->megamorphic_cache_table()->PrintSizes();
283 } 306 }
284 } else { 307 } else {
285 // Populate the isolate's symbol table with all symbols from the 308 // Populate the isolate's symbol table with all symbols from the
286 // VM isolate. We do this so that when we generate a full snapshot 309 // VM isolate. We do this so that when we generate a full snapshot
287 // for the isolate we have a unified symbol table that we can then 310 // for the isolate we have a unified symbol table that we can then
288 // read into the VM isolate. 311 // read into the VM isolate.
289 Symbols::AddPredefinedSymbolsToIsolate(); 312 Symbols::AddPredefinedSymbolsToIsolate();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return predefined_handles_->handles_.AllocateScopedHandle(); 373 return predefined_handles_->handles_.AllocateScopedHandle();
351 } 374 }
352 375
353 376
354 bool Dart::IsReadOnlyHandle(uword address) { 377 bool Dart::IsReadOnlyHandle(uword address) {
355 ASSERT(predefined_handles_ != NULL); 378 ASSERT(predefined_handles_ != NULL);
356 return predefined_handles_->handles_.IsValidScopedHandle(address); 379 return predefined_handles_->handles_.IsValidScopedHandle(address);
357 } 380 }
358 381
359 } // namespace dart 382 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698