| OLD | NEW | 
|---|
| 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/isolate.h" | 5 #include "vm/isolate.h" | 
| 6 | 6 | 
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" | 
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" | 
| 9 #include "platform/json.h" | 9 #include "platform/json.h" | 
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" | 
| 11 #include "vm/compiler_stats.h" | 11 #include "vm/compiler_stats.h" | 
| 12 #include "vm/coverage.h" | 12 #include "vm/coverage.h" | 
| 13 #include "vm/dart_api_state.h" | 13 #include "vm/dart_api_state.h" | 
| 14 #include "vm/dart_entry.h" | 14 #include "vm/dart_entry.h" | 
| 15 #include "vm/debugger.h" | 15 #include "vm/debugger.h" | 
| 16 #include "vm/deopt_instructions.h" | 16 #include "vm/deopt_instructions.h" | 
| 17 #include "vm/heap.h" | 17 #include "vm/heap.h" | 
| 18 #include "vm/lockers.h" | 18 #include "vm/lockers.h" | 
| 19 #include "vm/log.h" | 19 #include "vm/log.h" | 
| 20 #include "vm/message_handler.h" | 20 #include "vm/message_handler.h" | 
| 21 #include "vm/object_id_ring.h" | 21 #include "vm/object_id_ring.h" | 
| 22 #include "vm/object_store.h" | 22 #include "vm/object_store.h" | 
|  | 23 #include "vm/object.h" | 
|  | 24 #include "vm/os_thread.h" | 
| 23 #include "vm/parser.h" | 25 #include "vm/parser.h" | 
| 24 #include "vm/port.h" | 26 #include "vm/port.h" | 
| 25 #include "vm/profiler.h" | 27 #include "vm/profiler.h" | 
| 26 #include "vm/reusable_handles.h" | 28 #include "vm/reusable_handles.h" | 
| 27 #include "vm/service.h" | 29 #include "vm/service.h" | 
| 28 #include "vm/service_isolate.h" | 30 #include "vm/service_isolate.h" | 
| 29 #include "vm/simulator.h" | 31 #include "vm/simulator.h" | 
| 30 #include "vm/stack_frame.h" | 32 #include "vm/stack_frame.h" | 
| 31 #include "vm/stub_code.h" | 33 #include "vm/stub_code.h" | 
| 32 #include "vm/symbols.h" | 34 #include "vm/symbols.h" | 
| 33 #include "vm/tags.h" | 35 #include "vm/tags.h" | 
| 34 #include "vm/os_thread.h" |  | 
| 35 #include "vm/thread_interrupter.h" | 36 #include "vm/thread_interrupter.h" | 
| 36 #include "vm/timer.h" | 37 #include "vm/timer.h" | 
| 37 #include "vm/visitor.h" | 38 #include "vm/visitor.h" | 
| 38 | 39 | 
| 39 | 40 | 
| 40 namespace dart { | 41 namespace dart { | 
| 41 | 42 | 
| 42 DEFINE_FLAG(bool, trace_isolates, false, | 43 DEFINE_FLAG(bool, trace_isolates, false, | 
| 43             "Trace isolate creation and shut down."); | 44             "Trace isolate creation and shut down."); | 
| 44 DEFINE_FLAG(bool, pause_isolates_on_start, false, | 45 DEFINE_FLAG(bool, pause_isolates_on_start, false, | 
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 486       last_allocationprofile_accumulator_reset_timestamp_(0), | 487       last_allocationprofile_accumulator_reset_timestamp_(0), | 
| 487       last_allocationprofile_gc_timestamp_(0), | 488       last_allocationprofile_gc_timestamp_(0), | 
| 488       cha_(NULL), | 489       cha_(NULL), | 
| 489       object_id_ring_(NULL), | 490       object_id_ring_(NULL), | 
| 490       trace_buffer_(NULL), | 491       trace_buffer_(NULL), | 
| 491       profiler_data_(NULL), | 492       profiler_data_(NULL), | 
| 492       thread_state_(NULL), | 493       thread_state_(NULL), | 
| 493       tag_table_(GrowableObjectArray::null()), | 494       tag_table_(GrowableObjectArray::null()), | 
| 494       current_tag_(UserTag::null()), | 495       current_tag_(UserTag::null()), | 
| 495       default_tag_(UserTag::null()), | 496       default_tag_(UserTag::null()), | 
|  | 497       deoptimized_code_array_(GrowableObjectArray::null()), | 
| 496       metrics_list_head_(NULL), | 498       metrics_list_head_(NULL), | 
| 497       next_(NULL), | 499       next_(NULL), | 
| 498       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 500       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 
| 499       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 501       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 
| 500       reusable_handles_() { | 502       reusable_handles_() { | 
| 501   set_vm_tag(VMTag::kIdleTagId); | 503   set_vm_tag(VMTag::kIdleTagId); | 
| 502   set_user_tag(UserTags::kDefaultUserTag); | 504   set_user_tag(UserTags::kDefaultUserTag); | 
| 503 } | 505 } | 
| 504 | 506 | 
| 505 Isolate::Isolate(Isolate* original) | 507 Isolate::Isolate(Isolate* original) | 
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1244 | 1246 | 
| 1245   // Visit the current tag which is stored in the isolate. | 1247   // Visit the current tag which is stored in the isolate. | 
| 1246   visitor->VisitPointer(reinterpret_cast<RawObject**>(¤t_tag_)); | 1248   visitor->VisitPointer(reinterpret_cast<RawObject**>(¤t_tag_)); | 
| 1247 | 1249 | 
| 1248   // Visit the default tag which is stored in the isolate. | 1250   // Visit the default tag which is stored in the isolate. | 
| 1249   visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); | 1251   visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); | 
| 1250 | 1252 | 
| 1251   // Visit the tag table which is stored in the isolate. | 1253   // Visit the tag table which is stored in the isolate. | 
| 1252   visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); | 1254   visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); | 
| 1253 | 1255 | 
|  | 1256   // Visit the deoptimized code array which is stored in the isolate. | 
|  | 1257   visitor->VisitPointer( | 
|  | 1258       reinterpret_cast<RawObject**>(&deoptimized_code_array_)); | 
|  | 1259 | 
| 1254   // Visit objects in the debugger. | 1260   // Visit objects in the debugger. | 
| 1255   debugger()->VisitObjectPointers(visitor); | 1261   debugger()->VisitObjectPointers(visitor); | 
| 1256 | 1262 | 
| 1257   // Visit objects that are being used for deoptimization. | 1263   // Visit objects that are being used for deoptimization. | 
| 1258   if (deopt_context() != NULL) { | 1264   if (deopt_context() != NULL) { | 
| 1259     deopt_context()->VisitObjectPointers(visitor); | 1265     deopt_context()->VisitObjectPointers(visitor); | 
| 1260   } | 1266   } | 
| 1261 } | 1267 } | 
| 1262 | 1268 | 
| 1263 | 1269 | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1441   set_user_tag(user_tag); | 1447   set_user_tag(user_tag); | 
| 1442   current_tag_ = tag.raw(); | 1448   current_tag_ = tag.raw(); | 
| 1443 } | 1449 } | 
| 1444 | 1450 | 
| 1445 | 1451 | 
| 1446 void Isolate::set_default_tag(const UserTag& tag) { | 1452 void Isolate::set_default_tag(const UserTag& tag) { | 
| 1447   default_tag_ = tag.raw(); | 1453   default_tag_ = tag.raw(); | 
| 1448 } | 1454 } | 
| 1449 | 1455 | 
| 1450 | 1456 | 
|  | 1457 void Isolate::set_deoptimized_code_array(const GrowableObjectArray& value) { | 
|  | 1458   deoptimized_code_array_ = value.raw(); | 
|  | 1459 } | 
|  | 1460 | 
|  | 1461 | 
|  | 1462 void Isolate::TrackDeoptimizedCode(const Code& code) { | 
|  | 1463   ASSERT(!code.IsNull()); | 
|  | 1464   const GrowableObjectArray& deoptimized_code = | 
|  | 1465       GrowableObjectArray::Handle(deoptimized_code_array()); | 
|  | 1466   if (deoptimized_code.IsNull()) { | 
|  | 1467     // Not tracking deoptimized code. | 
|  | 1468     return; | 
|  | 1469   } | 
|  | 1470   // TODO(johnmccutchan): Scan this array and the isolate's profile before | 
|  | 1471   // old space GC and remove the keep_code flag. | 
|  | 1472   deoptimized_code.Add(code); | 
|  | 1473 } | 
|  | 1474 | 
|  | 1475 | 
| 1451 void Isolate::VisitIsolates(IsolateVisitor* visitor) { | 1476 void Isolate::VisitIsolates(IsolateVisitor* visitor) { | 
| 1452   if (visitor == NULL) { | 1477   if (visitor == NULL) { | 
| 1453     return; | 1478     return; | 
| 1454   } | 1479   } | 
| 1455   MonitorLocker ml(isolates_list_monitor_); | 1480   MonitorLocker ml(isolates_list_monitor_); | 
| 1456   Isolate* current = isolates_list_head_; | 1481   Isolate* current = isolates_list_head_; | 
| 1457   while (current) { | 1482   while (current) { | 
| 1458     visitor->VisitIsolate(current); | 1483     visitor->VisitIsolate(current); | 
| 1459     current = current->next_; | 1484     current = current->next_; | 
| 1460   } | 1485   } | 
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1700                            serialized_message_, serialized_message_len_); | 1725                            serialized_message_, serialized_message_len_); | 
| 1701 } | 1726 } | 
| 1702 | 1727 | 
| 1703 | 1728 | 
| 1704 void IsolateSpawnState::Cleanup() { | 1729 void IsolateSpawnState::Cleanup() { | 
| 1705   SwitchIsolateScope switch_scope(I); | 1730   SwitchIsolateScope switch_scope(I); | 
| 1706   Dart::ShutdownIsolate(); | 1731   Dart::ShutdownIsolate(); | 
| 1707 } | 1732 } | 
| 1708 | 1733 | 
| 1709 }  // namespace dart | 1734 }  // namespace dart | 
| OLD | NEW | 
|---|