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

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

Issue 1807293002: - Fix for issue 25950 (add registration of a thread exit callback) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self-review-comments Created 4 years, 9 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/dart.h ('k') | runtime/vm/dart_api_impl.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/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 DEFINE_FLAG(bool, shutdown, true, "Do a clean shutdown of the VM"); 45 DEFINE_FLAG(bool, shutdown, true, "Do a clean shutdown of the VM");
46 DEFINE_FLAG(bool, trace_shutdown, false, "Trace VM shutdown on stderr"); 46 DEFINE_FLAG(bool, trace_shutdown, false, "Trace VM shutdown on stderr");
47 47
48 Isolate* Dart::vm_isolate_ = NULL; 48 Isolate* Dart::vm_isolate_ = NULL;
49 int64_t Dart::start_time_ = 0; 49 int64_t Dart::start_time_ = 0;
50 ThreadPool* Dart::thread_pool_ = NULL; 50 ThreadPool* Dart::thread_pool_ = NULL;
51 DebugInfo* Dart::pprof_symbol_generator_ = NULL; 51 DebugInfo* Dart::pprof_symbol_generator_ = NULL;
52 ReadOnlyHandles* Dart::predefined_handles_ = NULL; 52 ReadOnlyHandles* Dart::predefined_handles_ = NULL;
53 const uint8_t* Dart::instructions_snapshot_buffer_ = NULL; 53 const uint8_t* Dart::instructions_snapshot_buffer_ = NULL;
54 const uint8_t* Dart::data_snapshot_buffer_ = NULL; 54 const uint8_t* Dart::data_snapshot_buffer_ = NULL;
55 Dart_ThreadExitCallback Dart::thread_exit_callback_ = NULL;
56 Dart_FileOpenCallback Dart::file_open_callback_ = NULL;
57 Dart_FileReadCallback Dart::file_read_callback_ = NULL;
58 Dart_FileWriteCallback Dart::file_write_callback_ = NULL;
59 Dart_FileCloseCallback Dart::file_close_callback_ = NULL;
60 Dart_EntropySource Dart::entropy_source_callback_ = NULL;
55 61
56 // Structure for managing read-only global handles allocation used for 62 // Structure for managing read-only global handles allocation used for
57 // creating global read-only handles that are pre created and initialized 63 // creating global read-only handles that are pre created and initialized
58 // for use across all isolates. Having these global pre created handles 64 // for use across all isolates. Having these global pre created handles
59 // stored in the vm isolate ensures that we don't constantly create and 65 // stored in the vm isolate ensures that we don't constantly create and
60 // destroy handles for read-only objects referred in the VM code 66 // destroy handles for read-only objects referred in the VM code
61 // (e.g: symbols, null object, empty array etc.) 67 // (e.g: symbols, null object, empty array etc.)
62 // The ReadOnlyHandles C++ Wrapper around VMHandles which is a ValueObject is 68 // The ReadOnlyHandles C++ Wrapper around VMHandles which is a ValueObject is
63 // to ensure that the handles area is not trashed by automatic running of C++ 69 // to ensure that the handles area is not trashed by automatic running of C++
64 // static destructors when 'exit()" is called by any isolate. There might be 70 // static destructors when 'exit()" is called by any isolate. There might be
(...skipping 10 matching lines...) Expand all
75 friend class Dart; 81 friend class Dart;
76 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); 82 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles);
77 }; 83 };
78 84
79 85
80 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, 86 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
81 const uint8_t* instructions_snapshot, 87 const uint8_t* instructions_snapshot,
82 const uint8_t* data_snapshot, 88 const uint8_t* data_snapshot,
83 Dart_IsolateCreateCallback create, 89 Dart_IsolateCreateCallback create,
84 Dart_IsolateShutdownCallback shutdown, 90 Dart_IsolateShutdownCallback shutdown,
91 Dart_ThreadExitCallback thread_exit,
85 Dart_FileOpenCallback file_open, 92 Dart_FileOpenCallback file_open,
86 Dart_FileReadCallback file_read, 93 Dart_FileReadCallback file_read,
87 Dart_FileWriteCallback file_write, 94 Dart_FileWriteCallback file_write,
88 Dart_FileCloseCallback file_close, 95 Dart_FileCloseCallback file_close,
89 Dart_EntropySource entropy_source, 96 Dart_EntropySource entropy_source,
90 Dart_GetVMServiceAssetsArchive get_service_assets) { 97 Dart_GetVMServiceAssetsArchive get_service_assets) {
91 // TODO(iposva): Fix race condition here. 98 // TODO(iposva): Fix race condition here.
92 if (vm_isolate_ != NULL || !Flags::Initialized()) { 99 if (vm_isolate_ != NULL || !Flags::Initialized()) {
93 return "VM already initialized or flags not initialized."; 100 return "VM already initialized or flags not initialized.";
94 } 101 }
95 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); 102 set_thread_exit_callback(thread_exit);
96 Isolate::SetEntropySourceCallback(entropy_source); 103 SetFileCallbacks(file_open, file_read, file_write, file_close);
104 set_entropy_source_callback(entropy_source);
97 OS::InitOnce(); 105 OS::InitOnce();
98 VirtualMemory::InitOnce(); 106 VirtualMemory::InitOnce();
99 OSThread::InitOnce(); 107 OSThread::InitOnce();
100 if (FLAG_support_timeline) { 108 if (FLAG_support_timeline) {
101 Timeline::InitOnce(); 109 Timeline::InitOnce();
102 } 110 }
103 NOT_IN_PRODUCT(TimelineDurationScope tds(Timeline::GetVMStream(), 111 NOT_IN_PRODUCT(TimelineDurationScope tds(Timeline::GetVMStream(),
104 "Dart::InitOnce")); 112 "Dart::InitOnce"));
105 Isolate::InitOnce(); 113 Isolate::InitOnce();
106 PortMap::InitOnce(); 114 PortMap::InitOnce();
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 return predefined_handles_->handles_.IsValidScopedHandle(address); 570 return predefined_handles_->handles_.IsValidScopedHandle(address);
563 } 571 }
564 572
565 573
566 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 574 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
567 ASSERT(predefined_handles_ != NULL); 575 ASSERT(predefined_handles_ != NULL);
568 return predefined_handles_->api_handles_.IsValidHandle(handle); 576 return predefined_handles_->api_handles_.IsValidHandle(handle);
569 } 577 }
570 578
571 } // namespace dart 579 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698