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

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
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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 tag_table_(GrowableObjectArray::null()), 759 tag_table_(GrowableObjectArray::null()),
760 collected_closures_(GrowableObjectArray::null()), 760 collected_closures_(GrowableObjectArray::null()),
761 deoptimized_code_array_(GrowableObjectArray::null()), 761 deoptimized_code_array_(GrowableObjectArray::null()),
762 background_compilation_queue_(GrowableObjectArray::null()), 762 background_compilation_queue_(GrowableObjectArray::null()),
763 pending_service_extension_calls_(GrowableObjectArray::null()), 763 pending_service_extension_calls_(GrowableObjectArray::null()),
764 registered_service_extension_handlers_(GrowableObjectArray::null()), 764 registered_service_extension_handlers_(GrowableObjectArray::null()),
765 metrics_list_head_(NULL), 765 metrics_list_head_(NULL),
766 compilation_allowed_(true), 766 compilation_allowed_(true),
767 cha_(NULL), 767 cha_(NULL),
768 next_(NULL), 768 next_(NULL),
769 pause_loop_monitor_(NULL), 769 pause_loop_monitor_(NULL) {
770 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
771 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
772 reusable_handles_() {
773 flags_.CopyFrom(api_flags); 770 flags_.CopyFrom(api_flags);
774 Thread::Current()->set_vm_tag(VMTag::kEmbedderTagId); 771 Thread::Current()->set_vm_tag(VMTag::kEmbedderTagId);
775 set_user_tag(UserTags::kDefaultUserTag); 772 set_user_tag(UserTags::kDefaultUserTag);
776 } 773 }
777 774
778 #undef REUSABLE_HANDLE_SCOPE_INIT 775 #undef REUSABLE_HANDLE_SCOPE_INIT
779 #undef REUSABLE_HANDLE_INITIALIZERS 776 #undef REUSABLE_HANDLE_INITIALIZERS
780 777
781 Isolate::~Isolate() { 778 Isolate::~Isolate() {
782 free(name_); 779 free(name_);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 is_vm_isolate 844 is_vm_isolate
848 ? 0 // New gen size 0; VM isolate should only allocate in old. 845 ? 0 // New gen size 0; VM isolate should only allocate in old.
849 : FLAG_new_gen_semi_max_size * MBInWords, 846 : FLAG_new_gen_semi_max_size * MBInWords,
850 FLAG_old_gen_heap_size * MBInWords, 847 FLAG_old_gen_heap_size * MBInWords,
851 FLAG_external_max_size * MBInWords); 848 FLAG_external_max_size * MBInWords);
852 849
853 // TODO(5411455): For now just set the recently created isolate as 850 // TODO(5411455): For now just set the recently created isolate as
854 // the current isolate. 851 // the current isolate.
855 Thread::EnterIsolate(result); 852 Thread::EnterIsolate(result);
856 853
857 // Setup the isolate specific resuable handles.
858 #define REUSABLE_HANDLE_ALLOCATION(object) \
859 result->object##_handle_ = result->AllocateReusableHandle<object>();
860 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION)
861 #undef REUSABLE_HANDLE_ALLOCATION
862
863 // Setup the isolate message handler. 854 // Setup the isolate message handler.
864 MessageHandler* handler = new IsolateMessageHandler(result); 855 MessageHandler* handler = new IsolateMessageHandler(result);
865 ASSERT(handler != NULL); 856 ASSERT(handler != NULL);
866 result->set_message_handler(handler); 857 result->set_message_handler(handler);
867 858
868 // Setup the Dart API state. 859 // Setup the Dart API state.
869 ApiState* state = new ApiState(); 860 ApiState* state = new ApiState();
870 ASSERT(state != NULL); 861 ASSERT(state != NULL);
871 result->set_api_state(state); 862 result->set_api_state(state);
872 863
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 for (int i = 0; i < invoked_functions.length(); i++) { 1538 for (int i = 0; i < invoked_functions.length(); i++) {
1548 OS::Print("%10" Pd " x %s\n", 1539 OS::Print("%10" Pd " x %s\n",
1549 invoked_functions[i]->usage_counter(), 1540 invoked_functions[i]->usage_counter(),
1550 invoked_functions[i]->ToFullyQualifiedCString()); 1541 invoked_functions[i]->ToFullyQualifiedCString());
1551 } 1542 }
1552 } 1543 }
1553 1544
1554 1545
1555 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor { 1546 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor {
1556 public: 1547 public:
1557 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Isolate::Current()) { 1548 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Thread::Current()) {
1558 } 1549 }
1559 1550
1560 void VisitHandle(uword addr) { 1551 void VisitHandle(uword addr) {
1561 FinalizablePersistentHandle* handle = 1552 FinalizablePersistentHandle* handle =
1562 reinterpret_cast<FinalizablePersistentHandle*>(addr); 1553 reinterpret_cast<FinalizablePersistentHandle*>(addr);
1563 handle->UpdateUnreachable(I); 1554 handle->UpdateUnreachable(thread()->isolate());
1564 } 1555 }
1565 1556
1566 private: 1557 private:
1567 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1558 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1568 }; 1559 };
1569 1560
1570 1561
1571 void Isolate::LowLevelShutdown() { 1562 void Isolate::LowLevelShutdown() {
1572 // Ensure we have a zone and handle scope so that we can call VM functions, 1563 // Ensure we have a zone and handle scope so that we can call VM functions,
1573 // but we no longer allocate new heap objects. 1564 // but we no longer allocate new heap objects.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 1729
1739 // Visit objects in the object store. 1730 // Visit objects in the object store.
1740 object_store()->VisitObjectPointers(visitor); 1731 object_store()->VisitObjectPointers(visitor);
1741 1732
1742 // Visit objects in the class table. 1733 // Visit objects in the class table.
1743 class_table()->VisitObjectPointers(visitor); 1734 class_table()->VisitObjectPointers(visitor);
1744 1735
1745 // Visit objects in per isolate stubs. 1736 // Visit objects in per isolate stubs.
1746 StubCode::VisitObjectPointers(visitor); 1737 StubCode::VisitObjectPointers(visitor);
1747 1738
1748 // Visit objects in isolate specific handles area.
1749 reusable_handles_.VisitObjectPointers(visitor);
1750
1751 // Visit the dart api state for all local and persistent handles. 1739 // Visit the dart api state for all local and persistent handles.
1752 if (api_state() != NULL) { 1740 if (api_state() != NULL) {
1753 api_state()->VisitObjectPointers(visitor, visit_prologue_weak_handles); 1741 api_state()->VisitObjectPointers(visitor, visit_prologue_weak_handles);
1754 } 1742 }
1755 1743
1756 // Visit the current tag which is stored in the isolate. 1744 // Visit the current tag which is stored in the isolate.
1757 visitor->VisitPointer(reinterpret_cast<RawObject**>(&current_tag_)); 1745 visitor->VisitPointer(reinterpret_cast<RawObject**>(&current_tag_));
1758 1746
1759 // Visit the default tag which is stored in the isolate. 1747 // Visit the default tag which is stored in the isolate.
1760 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); 1748 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_));
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 creation_enabled_ = false; 2266 creation_enabled_ = false;
2279 } 2267 }
2280 2268
2281 2269
2282 void Isolate::EnableIsolateCreation() { 2270 void Isolate::EnableIsolateCreation() {
2283 MonitorLocker ml(isolates_list_monitor_); 2271 MonitorLocker ml(isolates_list_monitor_);
2284 creation_enabled_ = true; 2272 creation_enabled_ = true;
2285 } 2273 }
2286 2274
2287 2275
2288 template<class C>
2289 C* Isolate::AllocateReusableHandle() {
2290 C* handle = reinterpret_cast<C*>(reusable_handles_.AllocateScopedHandle());
2291 C::initializeHandle(handle, C::null());
2292 return handle;
2293 }
2294
2295
2296 void Isolate::KillLocked() { 2276 void Isolate::KillLocked() {
2297 Dart_CObject kill_msg; 2277 Dart_CObject kill_msg;
2298 Dart_CObject* list_values[4]; 2278 Dart_CObject* list_values[4];
2299 kill_msg.type = Dart_CObject_kArray; 2279 kill_msg.type = Dart_CObject_kArray;
2300 kill_msg.value.as_array.length = 4; 2280 kill_msg.value.as_array.length = 4;
2301 kill_msg.value.as_array.values = list_values; 2281 kill_msg.value.as_array.values = list_values;
2302 2282
2303 Dart_CObject oob; 2283 Dart_CObject oob;
2304 oob.type = Dart_CObject_kInt32; 2284 oob.type = Dart_CObject_kInt32;
2305 oob.value.as_int32 = Message::kIsolateLibOOBMsg; 2285 oob.value.as_int32 = Message::kIsolateLibOOBMsg;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 serialized_message_, serialized_message_len_); 2555 serialized_message_, serialized_message_len_);
2576 } 2556 }
2577 2557
2578 2558
2579 void IsolateSpawnState::Cleanup() { 2559 void IsolateSpawnState::Cleanup() {
2580 SwitchIsolateScope switch_scope(I); 2560 SwitchIsolateScope switch_scope(I);
2581 Dart::ShutdownIsolate(); 2561 Dart::ShutdownIsolate();
2582 } 2562 }
2583 2563
2584 } // namespace dart 2564 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/longjump.cc » ('j') | runtime/vm/thread.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698