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

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

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

Powered by Google App Engine
This is Rietveld 408576698