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

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

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 #ifndef VM_REUSABLE_HANDLES_H_ 5 #ifndef VM_REUSABLE_HANDLES_H_
6 #define VM_REUSABLE_HANDLES_H_ 6 #define VM_REUSABLE_HANDLES_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/handles.h" 9 #include "vm/handles.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 12 matching lines...) Expand all
23 // { 23 // {
24 // REUSABLE_ARRAY_HANDLESCOPE(isolate); 24 // REUSABLE_ARRAY_HANDLESCOPE(isolate);
25 // .... 25 // ....
26 // .... 26 // ....
27 // Array& funcs = reused_array_handle.Handle(); 27 // Array& funcs = reused_array_handle.Handle();
28 // code that uses funcs 28 // code that uses funcs
29 // .... 29 // ....
30 // } 30 // }
31 // 31 //
32 32
33
33 #if defined(DEBUG) 34 #if defined(DEBUG)
34 #define REUSABLE_SCOPE(name) \ 35 #define REUSABLE_SCOPE(name) \
35 class Reusable##name##HandleScope : public ValueObject { \ 36 class Reusable##name##HandleScope : public ValueObject { \
36 public: \ 37 public: \
37 explicit Reusable##name##HandleScope(Isolate* isolate) \ 38 explicit Reusable##name##HandleScope(Thread* thread) \
38 : isolate_(isolate) { \ 39 : thread_(thread) { \
39 ASSERT(!isolate->reusable_##name##_handle_scope_active()); \ 40 ASSERT(!thread->reusable_##name##_handle_scope_active()); \
40 isolate->set_reusable_##name##_handle_scope_active(true); \ 41 thread->set_reusable_##name##_handle_scope_active(true); \
41 } \ 42 } \
42 Reusable##name##HandleScope() : isolate_(Isolate::Current()) { \ 43 Reusable##name##HandleScope() : thread_(Thread::Current()) { \
43 ASSERT(!isolate_->reusable_##name##_handle_scope_active()); \ 44 ASSERT(!thread_->reusable_##name##_handle_scope_active()); \
44 isolate_->set_reusable_##name##_handle_scope_active(true); \ 45 thread_->set_reusable_##name##_handle_scope_active(true); \
45 } \ 46 } \
46 ~Reusable##name##HandleScope() { \ 47 ~Reusable##name##HandleScope() { \
47 ASSERT(isolate_->reusable_##name##_handle_scope_active()); \ 48 ASSERT(thread_->reusable_##name##_handle_scope_active()); \
48 isolate_->set_reusable_##name##_handle_scope_active(false); \ 49 thread_->set_reusable_##name##_handle_scope_active(false); \
49 Handle().raw_ = name::null(); \ 50 Handle().raw_ = name::null(); \
50 } \ 51 } \
51 name& Handle() const { \ 52 name& Handle() const { \
52 ASSERT(isolate_->name##_handle_ != NULL); \ 53 ASSERT(thread_->name##_handle_ != NULL); \
53 return *isolate_->name##_handle_; \ 54 return *thread_->name##_handle_; \
54 } \ 55 } \
55 private: \ 56 private: \
56 Isolate* isolate_; \ 57 Thread* thread_; \
57 DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \ 58 DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \
58 }; 59 };
59 #else 60 #else
60 #define REUSABLE_SCOPE(name) \ 61 #define REUSABLE_SCOPE(name) \
61 class Reusable##name##HandleScope : public ValueObject { \ 62 class Reusable##name##HandleScope : public ValueObject { \
62 public: \ 63 public: \
63 explicit Reusable##name##HandleScope(Isolate* isolate) \ 64 explicit Reusable##name##HandleScope(Thread* thread) \
64 : handle_(isolate->name##_handle_) { \ 65 : handle_(thread->name##_handle_) { \
65 } \ 66 } \
66 Reusable##name##HandleScope() \ 67 Reusable##name##HandleScope() \
67 : handle_(Isolate::Current()->name##_handle_) { \ 68 : handle_(Thread::Current()->name##_handle_) { \
68 } \ 69 } \
69 ~Reusable##name##HandleScope() { \ 70 ~Reusable##name##HandleScope() { \
70 handle_->raw_ = name::null(); \ 71 handle_->raw_ = name::null(); \
71 } \ 72 } \
72 name& Handle() const { \ 73 name& Handle() const { \
73 ASSERT(handle_ != NULL); \ 74 ASSERT(handle_ != NULL); \
74 return *handle_; \ 75 return *handle_; \
75 } \ 76 } \
76 private: \ 77 private: \
77 name* handle_; \ 78 name* handle_; \
78 DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \ 79 DISALLOW_COPY_AND_ASSIGN(Reusable##name##HandleScope); \
79 }; 80 };
80 #endif // defined(DEBUG) 81 #endif // defined(DEBUG)
81 REUSABLE_HANDLE_LIST(REUSABLE_SCOPE) 82 REUSABLE_HANDLE_LIST(REUSABLE_SCOPE)
82 #undef REUSABLE_SCOPE 83 #undef REUSABLE_SCOPE
83 84
84 #define REUSABLE_ABSTRACT_TYPE_HANDLESCOPE(isolate) \ 85 #define REUSABLE_ABSTRACT_TYPE_HANDLESCOPE(isolate) \
85 ReusableAbstractTypeHandleScope reused_abstract_type(isolate); 86 ReusableAbstractTypeHandleScope reused_abstract_type(isolate);
86 #define REUSABLE_ARRAY_HANDLESCOPE(isolate) \ 87 #define REUSABLE_ARRAY_HANDLESCOPE(isolate) \
(...skipping 22 matching lines...) Expand all
109 ReusableObjectHandleScope reused_object_handle(isolate); 110 ReusableObjectHandleScope reused_object_handle(isolate);
110 #define REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate) \ 111 #define REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate) \
111 ReusablePcDescriptorsHandleScope reused_pc_descriptors_handle(isolate); 112 ReusablePcDescriptorsHandleScope reused_pc_descriptors_handle(isolate);
112 #define REUSABLE_STRING_HANDLESCOPE(isolate) \ 113 #define REUSABLE_STRING_HANDLESCOPE(isolate) \
113 ReusableStringHandleScope reused_string_handle(isolate); 114 ReusableStringHandleScope reused_string_handle(isolate);
114 #define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate) \ 115 #define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate) \
115 ReusableTypeArgumentsHandleScope reused_type_arguments_handle(isolate); 116 ReusableTypeArgumentsHandleScope reused_type_arguments_handle(isolate);
116 #define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(isolate) \ 117 #define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(isolate) \
117 ReusableTypeParameterHandleScope reused_type_parameter(isolate); 118 ReusableTypeParameterHandleScope reused_type_parameter(isolate);
118 119
119
120 } // namespace dart 120 } // namespace dart
121 121
122 #endif // VM_REUSABLE_HANDLES_H_ 122 #endif // VM_REUSABLE_HANDLES_H_
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/scavenger.cc » ('j') | runtime/vm/thread.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698