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

Side by Side Diff: runtime/vm/thread.h

Issue 1210033007: Cache some global constants in Thread, to allow access via THR register. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unused define. Created 5 years, 5 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/stub_code_ia32.cc ('k') | runtime/vm/thread.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 #ifndef VM_THREAD_H_ 5 #ifndef VM_THREAD_H_
6 #define VM_THREAD_H_ 6 #define VM_THREAD_H_
7 7
8 #include "vm/base_isolate.h" 8 #include "vm/base_isolate.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
11 #include "vm/store_buffer.h" 11 #include "vm/store_buffer.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 class CHA; 15 class CHA;
16 class Isolate; 16 class Isolate;
17 class RawBool;
18 class RawObject;
19
17 20
18 // A VM thread; may be executing Dart code or performing helper tasks like 21 // A VM thread; may be executing Dart code or performing helper tasks like
19 // garbage collection or compilation. The Thread structure associated with 22 // garbage collection or compilation. The Thread structure associated with
20 // a thread is allocated by EnsureInit before entering an isolate, and destroyed 23 // a thread is allocated by EnsureInit before entering an isolate, and destroyed
21 // automatically when the underlying OS thread exits. NOTE: On Windows, CleanUp 24 // automatically when the underlying OS thread exits. NOTE: On Windows, CleanUp
22 // must currently be called manually (issue 23474). 25 // must currently be called manually (issue 23474).
23 class Thread { 26 class Thread {
24 public: 27 public:
25 // The currently executing thread, or NULL if not yet initialized. 28 // The currently executing thread, or NULL if not yet initialized.
26 static Thread* Current() { 29 static Thread* Current() {
(...skipping 19 matching lines...) Expand all
46 // Empties the store buffer block into the isolate. 49 // Empties the store buffer block into the isolate.
47 // TODO(koda): Always run GC in separate thread. 50 // TODO(koda): Always run GC in separate thread.
48 static void PrepareForGC(); 51 static void PrepareForGC();
49 52
50 #if defined(TARGET_OS_WINDOWS) 53 #if defined(TARGET_OS_WINDOWS)
51 // Clears the state of the current thread and frees the allocation. 54 // Clears the state of the current thread and frees the allocation.
52 static void CleanUp(); 55 static void CleanUp();
53 #endif 56 #endif
54 57
55 // Called at VM startup. 58 // Called at VM startup.
56 static void InitOnce(); 59 static void InitOnceBeforeIsolate();
60 static void InitOnceAfterObjectAndStubCode();
57 61
58 // The topmost zone used for allocation in this thread. 62 // The topmost zone used for allocation in this thread.
59 Zone* zone() { 63 Zone* zone() {
60 return reinterpret_cast<BaseIsolate*>(isolate())->current_zone(); 64 return reinterpret_cast<BaseIsolate*>(isolate())->current_zone();
61 } 65 }
62 66
63 // The isolate that this thread is operating on, or NULL if none. 67 // The isolate that this thread is operating on, or NULL if none.
64 Isolate* isolate() const { return isolate_; } 68 Isolate* isolate() const { return isolate_; }
65 static intptr_t isolate_offset() { 69 static intptr_t isolate_offset() {
66 return OFFSET_OF(Thread, isolate_); 70 return OFFSET_OF(Thread, isolate_);
67 } 71 }
68 72
69 // The (topmost) CHA for the compilation in the isolate of this thread. 73 // The (topmost) CHA for the compilation in the isolate of this thread.
70 // TODO(23153): Move this out of Isolate/Thread. 74 // TODO(23153): Move this out of Isolate/Thread.
71 CHA* cha() const; 75 CHA* cha() const;
72 void set_cha(CHA* value); 76 void set_cha(CHA* value);
73 77
74 void StoreBufferAddObject(RawObject* obj); 78 void StoreBufferAddObject(RawObject* obj);
75 void StoreBufferAddObjectGC(RawObject* obj); 79 void StoreBufferAddObjectGC(RawObject* obj);
76 #if defined(TESTING) 80 #if defined(TESTING)
77 bool StoreBufferContains(RawObject* obj) const { 81 bool StoreBufferContains(RawObject* obj) const {
78 return store_buffer_block_->Contains(obj); 82 return store_buffer_block_->Contains(obj);
79 } 83 }
80 #endif 84 #endif
81 void StoreBufferBlockProcess(bool check_threshold); 85 void StoreBufferBlockProcess(bool check_threshold);
82 static intptr_t store_buffer_block_offset() { 86 static intptr_t store_buffer_block_offset() {
83 return OFFSET_OF(Thread, store_buffer_block_); 87 return OFFSET_OF(Thread, store_buffer_block_);
84 } 88 }
85 89
90 static intptr_t object_null_offset() {
91 return OFFSET_OF(Thread, object_null_);
92 }
93
94 static intptr_t bool_true_offset() {
95 return OFFSET_OF(Thread, bool_true_);
96 }
97
98 static intptr_t bool_false_offset() {
99 return OFFSET_OF(Thread, bool_false_);
100 }
101
102 static intptr_t update_store_buffer_entry_point_offset() {
103 return OFFSET_OF(Thread, update_store_buffer_entry_point_);
104 }
105
86 private: 106 private:
87 static ThreadLocalKey thread_key_; 107 static ThreadLocalKey thread_key_;
88 108
89 Isolate* isolate_; 109 Isolate* isolate_;
90 StoreBufferBlock* store_buffer_block_; 110 StoreBufferBlock* store_buffer_block_;
111 RawObject* object_null_;
112 RawBool* bool_true_;
113 RawBool* bool_false_;
114 uword update_store_buffer_entry_point_;
91 115
92 Thread() 116 explicit Thread(bool init_vm_constants = true);
93 : isolate_(NULL), store_buffer_block_(NULL) {} 117
118 void InitVMConstants();
94 119
95 static void SetCurrent(Thread* current); 120 static void SetCurrent(Thread* current);
96 121
97 DISALLOW_COPY_AND_ASSIGN(Thread); 122 DISALLOW_COPY_AND_ASSIGN(Thread);
98 }; 123 };
99 124
100 } // namespace dart 125 } // namespace dart
101 126
102 #endif // VM_THREAD_H_ 127 #endif // VM_THREAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698