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

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

Issue 1394673002: Move reusable handles from isolate to thread. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix release build Created 5 years, 2 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/longjump.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) 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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/json.h" 10 #include "platform/json.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 tag_table_(GrowableObjectArray::null()), 787 tag_table_(GrowableObjectArray::null()),
788 collected_closures_(GrowableObjectArray::null()), 788 collected_closures_(GrowableObjectArray::null()),
789 deoptimized_code_array_(GrowableObjectArray::null()), 789 deoptimized_code_array_(GrowableObjectArray::null()),
790 background_compilation_queue_(GrowableObjectArray::null()), 790 background_compilation_queue_(GrowableObjectArray::null()),
791 pending_service_extension_calls_(GrowableObjectArray::null()), 791 pending_service_extension_calls_(GrowableObjectArray::null()),
792 registered_service_extension_handlers_(GrowableObjectArray::null()), 792 registered_service_extension_handlers_(GrowableObjectArray::null()),
793 metrics_list_head_(NULL), 793 metrics_list_head_(NULL),
794 compilation_allowed_(true), 794 compilation_allowed_(true),
795 cha_(NULL), 795 cha_(NULL),
796 next_(NULL), 796 next_(NULL),
797 pause_loop_monitor_(NULL), 797 pause_loop_monitor_(NULL) {
798 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
799 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
800 reusable_handles_() {
801 flags_.CopyFrom(api_flags); 798 flags_.CopyFrom(api_flags);
802 Thread::Current()->set_vm_tag(VMTag::kEmbedderTagId); 799 Thread::Current()->set_vm_tag(VMTag::kEmbedderTagId);
803 set_user_tag(UserTags::kDefaultUserTag); 800 set_user_tag(UserTags::kDefaultUserTag);
804 } 801 }
805 802
806 #undef REUSABLE_HANDLE_SCOPE_INIT 803 #undef REUSABLE_HANDLE_SCOPE_INIT
807 #undef REUSABLE_HANDLE_INITIALIZERS 804 #undef REUSABLE_HANDLE_INITIALIZERS
808 805
809 Isolate::~Isolate() { 806 Isolate::~Isolate() {
810 free(name_); 807 free(name_);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 is_vm_isolate 872 is_vm_isolate
876 ? 0 // New gen size 0; VM isolate should only allocate in old. 873 ? 0 // New gen size 0; VM isolate should only allocate in old.
877 : FLAG_new_gen_semi_max_size * MBInWords, 874 : FLAG_new_gen_semi_max_size * MBInWords,
878 FLAG_old_gen_heap_size * MBInWords, 875 FLAG_old_gen_heap_size * MBInWords,
879 FLAG_external_max_size * MBInWords); 876 FLAG_external_max_size * MBInWords);
880 877
881 // TODO(5411455): For now just set the recently created isolate as 878 // TODO(5411455): For now just set the recently created isolate as
882 // the current isolate. 879 // the current isolate.
883 Thread::EnterIsolate(result); 880 Thread::EnterIsolate(result);
884 881
885 // Setup the isolate specific resuable handles.
886 #define REUSABLE_HANDLE_ALLOCATION(object) \
887 result->object##_handle_ = result->AllocateReusableHandle<object>();
888 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION)
889 #undef REUSABLE_HANDLE_ALLOCATION
890
891 // Setup the isolate message handler. 882 // Setup the isolate message handler.
892 MessageHandler* handler = new IsolateMessageHandler(result); 883 MessageHandler* handler = new IsolateMessageHandler(result);
893 ASSERT(handler != NULL); 884 ASSERT(handler != NULL);
894 result->set_message_handler(handler); 885 result->set_message_handler(handler);
895 886
896 // Setup the Dart API state. 887 // Setup the Dart API state.
897 ApiState* state = new ApiState(); 888 ApiState* state = new ApiState();
898 ASSERT(state != NULL); 889 ASSERT(state != NULL);
899 result->set_api_state(state); 890 result->set_api_state(state);
900 891
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 for (int i = 0; i < invoked_functions.length(); i++) { 1564 for (int i = 0; i < invoked_functions.length(); i++) {
1574 OS::Print("%10" Pd " x %s\n", 1565 OS::Print("%10" Pd " x %s\n",
1575 invoked_functions[i]->usage_counter(), 1566 invoked_functions[i]->usage_counter(),
1576 invoked_functions[i]->ToFullyQualifiedCString()); 1567 invoked_functions[i]->ToFullyQualifiedCString());
1577 } 1568 }
1578 } 1569 }
1579 1570
1580 1571
1581 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor { 1572 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor {
1582 public: 1573 public:
1583 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Isolate::Current()) { 1574 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Thread::Current()) {
1584 } 1575 }
1585 1576
1586 void VisitHandle(uword addr) { 1577 void VisitHandle(uword addr) {
1587 FinalizablePersistentHandle* handle = 1578 FinalizablePersistentHandle* handle =
1588 reinterpret_cast<FinalizablePersistentHandle*>(addr); 1579 reinterpret_cast<FinalizablePersistentHandle*>(addr);
1589 handle->UpdateUnreachable(I); 1580 handle->UpdateUnreachable(thread()->isolate());
1590 } 1581 }
1591 1582
1592 private: 1583 private:
1593 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1584 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1594 }; 1585 };
1595 1586
1596 1587
1597 void Isolate::LowLevelShutdown() { 1588 void Isolate::LowLevelShutdown() {
1598 // Ensure we have a zone and handle scope so that we can call VM functions, 1589 // Ensure we have a zone and handle scope so that we can call VM functions,
1599 // but we no longer allocate new heap objects. 1590 // but we no longer allocate new heap objects.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 1755
1765 // Visit objects in the object store. 1756 // Visit objects in the object store.
1766 object_store()->VisitObjectPointers(visitor); 1757 object_store()->VisitObjectPointers(visitor);
1767 1758
1768 // Visit objects in the class table. 1759 // Visit objects in the class table.
1769 class_table()->VisitObjectPointers(visitor); 1760 class_table()->VisitObjectPointers(visitor);
1770 1761
1771 // Visit objects in per isolate stubs. 1762 // Visit objects in per isolate stubs.
1772 StubCode::VisitObjectPointers(visitor); 1763 StubCode::VisitObjectPointers(visitor);
1773 1764
1774 // Visit objects in isolate specific handles area.
1775 reusable_handles_.VisitObjectPointers(visitor);
1776
1777 // Visit the dart api state for all local and persistent handles. 1765 // Visit the dart api state for all local and persistent handles.
1778 if (api_state() != NULL) { 1766 if (api_state() != NULL) {
1779 api_state()->VisitObjectPointers(visitor, visit_prologue_weak_handles); 1767 api_state()->VisitObjectPointers(visitor, visit_prologue_weak_handles);
1780 } 1768 }
1781 1769
1782 // Visit the current tag which is stored in the isolate. 1770 // Visit the current tag which is stored in the isolate.
1783 visitor->VisitPointer(reinterpret_cast<RawObject**>(&current_tag_)); 1771 visitor->VisitPointer(reinterpret_cast<RawObject**>(&current_tag_));
1784 1772
1785 // Visit the default tag which is stored in the isolate. 1773 // Visit the default tag which is stored in the isolate.
1786 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); 1774 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_));
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 creation_enabled_ = false; 2294 creation_enabled_ = false;
2307 } 2295 }
2308 2296
2309 2297
2310 void Isolate::EnableIsolateCreation() { 2298 void Isolate::EnableIsolateCreation() {
2311 MonitorLocker ml(isolates_list_monitor_); 2299 MonitorLocker ml(isolates_list_monitor_);
2312 creation_enabled_ = true; 2300 creation_enabled_ = true;
2313 } 2301 }
2314 2302
2315 2303
2316 template<class C>
2317 C* Isolate::AllocateReusableHandle() {
2318 C* handle = reinterpret_cast<C*>(reusable_handles_.AllocateScopedHandle());
2319 C::initializeHandle(handle, C::null());
2320 return handle;
2321 }
2322
2323
2324 void Isolate::KillLocked(LibMsgId msg_id) { 2304 void Isolate::KillLocked(LibMsgId msg_id) {
2325 Dart_CObject kill_msg; 2305 Dart_CObject kill_msg;
2326 Dart_CObject* list_values[4]; 2306 Dart_CObject* list_values[4];
2327 kill_msg.type = Dart_CObject_kArray; 2307 kill_msg.type = Dart_CObject_kArray;
2328 kill_msg.value.as_array.length = 4; 2308 kill_msg.value.as_array.length = 4;
2329 kill_msg.value.as_array.values = list_values; 2309 kill_msg.value.as_array.values = list_values;
2330 2310
2331 Dart_CObject oob; 2311 Dart_CObject oob;
2332 oob.type = Dart_CObject_kInt32; 2312 oob.type = Dart_CObject_kInt32;
2333 oob.value.as_int32 = Message::kIsolateLibOOBMsg; 2313 oob.value.as_int32 = Message::kIsolateLibOOBMsg;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 serialized_message_, serialized_message_len_); 2585 serialized_message_, serialized_message_len_);
2606 } 2586 }
2607 2587
2608 2588
2609 void IsolateSpawnState::Cleanup() { 2589 void IsolateSpawnState::Cleanup() {
2610 SwitchIsolateScope switch_scope(I); 2590 SwitchIsolateScope switch_scope(I);
2611 Dart::ShutdownIsolate(); 2591 Dart::ShutdownIsolate();
2612 } 2592 }
2613 2593
2614 } // namespace dart 2594 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/longjump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698