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

Side by Side Diff: src/isolate.h

Issue 2006673002: Reduce boilerplace for common pattern to return MaybeHandle. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 4 years, 7 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 | « src/ic/ic.cc ('k') | src/runtime/runtime-array.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ISOLATE_H_ 5 #ifndef V8_ISOLATE_H_
6 #define V8_ISOLATE_H_ 6 #define V8_ISOLATE_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Isolate* __isolate__ = (isolate); \ 117 Isolate* __isolate__ = (isolate); \
118 if (__isolate__->has_scheduled_exception()) { \ 118 if (__isolate__->has_scheduled_exception()) { \
119 __isolate__->PromoteScheduledException(); \ 119 __isolate__->PromoteScheduledException(); \
120 return value; \ 120 return value; \
121 } \ 121 } \
122 } while (false) 122 } while (false)
123 123
124 #define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, T) \ 124 #define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, T) \
125 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, MaybeHandle<T>()) 125 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, MaybeHandle<T>())
126 126
127 #define RETURN_RESULT_OR_FAILURE(isolate, call) \
128 do { \
129 Handle<Object> __result__; \
130 Isolate* __isolate__ = (isolate); \
131 if (!(call).ToHandle(&__result__)) { \
132 DCHECK(__isolate__->has_pending_exception()); \
133 return __isolate__->heap()->exception(); \
134 } \
135 return *__result__; \
136 } while (false)
137
127 #define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \ 138 #define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \
128 do { \ 139 do { \
129 if (!(call).ToHandle(&dst)) { \ 140 if (!(call).ToHandle(&dst)) { \
130 DCHECK((isolate)->has_pending_exception()); \ 141 DCHECK((isolate)->has_pending_exception()); \
131 return value; \ 142 return value; \
132 } \ 143 } \
133 } while (false) 144 } while (false)
134 145
135 #define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \ 146 #define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
136 ASSIGN_RETURN_ON_EXCEPTION_VALUE( \ 147 do { \
137 isolate, dst, call, isolate->heap()->exception()) 148 Isolate* __isolate__ = (isolate); \
149 ASSIGN_RETURN_ON_EXCEPTION_VALUE(__isolate__, dst, call, \
150 __isolate__->heap()->exception()); \
151 } while (false)
138 152
139 #define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T) \ 153 #define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T) \
140 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, MaybeHandle<T>()) 154 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, MaybeHandle<T>())
141 155
142 #define THROW_NEW_ERROR(isolate, call, T) \ 156 #define THROW_NEW_ERROR(isolate, call, T) \
143 do { \ 157 do { \
144 return isolate->Throw<T>(isolate->factory()->call); \ 158 Isolate* __isolate__ = (isolate); \
159 return __isolate__->Throw<T>(__isolate__->factory()->call); \
145 } while (false) 160 } while (false)
146 161
147 #define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call) \ 162 #define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call) \
148 do { \ 163 do { \
149 return isolate->Throw(*isolate->factory()->call); \ 164 Isolate* __isolate__ = (isolate); \
165 return __isolate__->Throw(*__isolate__->factory()->call); \
150 } while (false) 166 } while (false)
151 167
152 #define RETURN_ON_EXCEPTION_VALUE(isolate, call, value) \ 168 #define RETURN_ON_EXCEPTION_VALUE(isolate, call, value) \
153 do { \ 169 do { \
154 if ((call).is_null()) { \ 170 if ((call).is_null()) { \
155 DCHECK((isolate)->has_pending_exception()); \ 171 DCHECK((isolate)->has_pending_exception()); \
156 return value; \ 172 return value; \
157 } \ 173 } \
158 } while (false) 174 } while (false)
159 175
160 #define RETURN_FAILURE_ON_EXCEPTION(isolate, call) \ 176 #define RETURN_FAILURE_ON_EXCEPTION(isolate, call) \
161 RETURN_ON_EXCEPTION_VALUE(isolate, call, isolate->heap()->exception()) 177 do { \
178 Isolate* __isolate__ = (isolate); \
179 RETURN_ON_EXCEPTION_VALUE(__isolate__, call, \
180 __isolate__->heap()->exception()); \
181 } while (false);
162 182
163 #define RETURN_ON_EXCEPTION(isolate, call, T) \ 183 #define RETURN_ON_EXCEPTION(isolate, call, T) \
164 RETURN_ON_EXCEPTION_VALUE(isolate, call, MaybeHandle<T>()) 184 RETURN_ON_EXCEPTION_VALUE(isolate, call, MaybeHandle<T>())
165 185
166 186
167 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \ 187 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \
168 C(Handler, handler) \ 188 C(Handler, handler) \
169 C(CEntryFP, c_entry_fp) \ 189 C(CEntryFP, c_entry_fp) \
170 C(CFunction, c_function) \ 190 C(CFunction, c_function) \
171 C(Context, context) \ 191 C(Context, context) \
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 1634
1615 EmbeddedVector<char, 128> filename_; 1635 EmbeddedVector<char, 128> filename_;
1616 FILE* file_; 1636 FILE* file_;
1617 int scope_depth_; 1637 int scope_depth_;
1618 }; 1638 };
1619 1639
1620 } // namespace internal 1640 } // namespace internal
1621 } // namespace v8 1641 } // namespace v8
1622 1642
1623 #endif // V8_ISOLATE_H_ 1643 #endif // V8_ISOLATE_H_
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698