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

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
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/scavenger.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 #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(thread) \
85 ReusableAbstractTypeHandleScope reused_abstract_type(isolate); 86 ReusableAbstractTypeHandleScope reused_abstract_type(thread);
86 #define REUSABLE_ARRAY_HANDLESCOPE(isolate) \ 87 #define REUSABLE_ARRAY_HANDLESCOPE(thread) \
87 ReusableArrayHandleScope reused_array_handle(isolate); 88 ReusableArrayHandleScope reused_array_handle(thread);
88 #define REUSABLE_CLASS_HANDLESCOPE(isolate) \ 89 #define REUSABLE_CLASS_HANDLESCOPE(thread) \
89 ReusableClassHandleScope reused_class_handle(isolate); 90 ReusableClassHandleScope reused_class_handle(thread);
90 #define REUSABLE_CODE_HANDLESCOPE(isolate) \ 91 #define REUSABLE_CODE_HANDLESCOPE(thread) \
91 ReusableCodeHandleScope reused_code_handle(isolate); 92 ReusableCodeHandleScope reused_code_handle(thread);
92 #define REUSABLE_ERROR_HANDLESCOPE(isolate) \ 93 #define REUSABLE_ERROR_HANDLESCOPE(thread) \
93 ReusableErrorHandleScope reused_error_handle(isolate); 94 ReusableErrorHandleScope reused_error_handle(thread);
94 #define REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(isolate) \ 95 #define REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(thread) \
95 ReusableExceptionHandlersHandleScope \ 96 ReusableExceptionHandlersHandleScope \
96 reused_exception_handlers_handle(isolate); 97 reused_exception_handlers_handle(thread);
97 #define REUSABLE_FIELD_HANDLESCOPE(isolate) \ 98 #define REUSABLE_FIELD_HANDLESCOPE(thread) \
98 ReusableFieldHandleScope reused_field_handle(isolate); 99 ReusableFieldHandleScope reused_field_handle(thread);
99 #define REUSABLE_FUNCTION_HANDLESCOPE(isolate) \ 100 #define REUSABLE_FUNCTION_HANDLESCOPE(thread) \
100 ReusableFunctionHandleScope reused_function_handle(isolate); 101 ReusableFunctionHandleScope reused_function_handle(thread);
101 #define REUSABLE_GROWABLE_OBJECT_ARRAY_HANDLESCOPE(isolate) \ 102 #define REUSABLE_GROWABLE_OBJECT_ARRAY_HANDLESCOPE(thread) \
102 ReusableGrowableObjectArrayHandleScope \ 103 ReusableGrowableObjectArrayHandleScope \
103 reused_growable_object_array_handle(isolate) 104 reused_growable_object_array_handle(thread)
104 #define REUSABLE_INSTANCE_HANDLESCOPE(isolate) \ 105 #define REUSABLE_INSTANCE_HANDLESCOPE(thread) \
105 ReusableInstanceHandleScope reused_instance_handle(isolate); 106 ReusableInstanceHandleScope reused_instance_handle(thread);
106 #define REUSABLE_LIBRARY_HANDLESCOPE(isolate) \ 107 #define REUSABLE_LIBRARY_HANDLESCOPE(thread) \
107 ReusableLibraryHandleScope reused_library_handle(isolate); 108 ReusableLibraryHandleScope reused_library_handle(thread);
108 #define REUSABLE_OBJECT_HANDLESCOPE(isolate) \ 109 #define REUSABLE_OBJECT_HANDLESCOPE(thread) \
109 ReusableObjectHandleScope reused_object_handle(isolate); 110 ReusableObjectHandleScope reused_object_handle(thread);
110 #define REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate) \ 111 #define REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(thread) \
111 ReusablePcDescriptorsHandleScope reused_pc_descriptors_handle(isolate); 112 ReusablePcDescriptorsHandleScope reused_pc_descriptors_handle(thread);
112 #define REUSABLE_STRING_HANDLESCOPE(isolate) \ 113 #define REUSABLE_STRING_HANDLESCOPE(thread) \
113 ReusableStringHandleScope reused_string_handle(isolate); 114 ReusableStringHandleScope reused_string_handle(thread);
114 #define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate) \ 115 #define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread) \
115 ReusableTypeArgumentsHandleScope reused_type_arguments_handle(isolate); 116 ReusableTypeArgumentsHandleScope reused_type_arguments_handle(thread);
116 #define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(isolate) \ 117 #define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread) \
117 ReusableTypeParameterHandleScope reused_type_parameter(isolate); 118 ReusableTypeParameterHandleScope reused_type_parameter(thread);
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698