OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 #define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T) \ | 128 #define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T) \ |
129 do { \ | 129 do { \ |
130 Isolate* __isolate__ = (isolate); \ | 130 Isolate* __isolate__ = (isolate); \ |
131 if (__isolate__->has_scheduled_exception()) { \ | 131 if (__isolate__->has_scheduled_exception()) { \ |
132 __isolate__->PromoteScheduledException(); \ | 132 __isolate__->PromoteScheduledException(); \ |
133 return Handle<T>::null(); \ | 133 return Handle<T>::null(); \ |
134 } \ | 134 } \ |
135 } while (false) | 135 } while (false) |
136 | 136 |
137 #define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value) \ | 137 #define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value) \ |
138 do { \ | 138 do { \ |
139 if ((call).is_null()) { \ | 139 if ((call).is_null()) { \ |
140 ASSERT((isolate)->has_pending_exception()); \ | 140 ASSERT((isolate)->has_pending_exception()); \ |
141 return (value); \ | 141 return (value); \ |
142 } \ | 142 } \ |
143 } while (false) | 143 } while (false) |
144 | 144 |
145 #define CHECK_NOT_EMPTY_HANDLE(isolate, call) \ | 145 #define CHECK_NOT_EMPTY_HANDLE(isolate, call) \ |
146 do { \ | 146 do { \ |
147 ASSERT(!(isolate)->has_pending_exception()); \ | 147 ASSERT(!(isolate)->has_pending_exception()); \ |
148 CHECK(!(call).is_null()); \ | 148 CHECK(!(call).is_null()); \ |
149 } while (false) | 149 } while (false) |
150 | 150 |
151 #define RETURN_IF_EMPTY_HANDLE(isolate, call) \ | 151 #define RETURN_IF_EMPTY_HANDLE(isolate, call) \ |
152 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception()) | 152 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception()) |
153 | 153 |
| 154 |
| 155 // Macros for MaybeHandle. |
| 156 |
| 157 #define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, T) \ |
| 158 do { \ |
| 159 Isolate* __isolate__ = (isolate); \ |
| 160 if (__isolate__->has_scheduled_exception()) { \ |
| 161 __isolate__->PromoteScheduledException(); \ |
| 162 return MaybeHandle<T>::Exception(); \ |
| 163 } \ |
| 164 } while (false) |
| 165 |
| 166 #define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \ |
| 167 do { \ |
| 168 if (!(call).ToHandle(&dst)) { \ |
| 169 ASSERT((isolate)->has_pending_exception()); \ |
| 170 return value; \ |
| 171 } \ |
| 172 } while (false) |
| 173 |
| 174 #define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \ |
| 175 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, Failure::Exception()) |
| 176 |
| 177 #define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T) \ |
| 178 ASSIGN_RETURN_ON_EXCEPTION_VALUE( \ |
| 179 isolate, dst, call, MaybeHandle<T>::Exception()) |
| 180 |
| 181 #define RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \ |
| 182 do { \ |
| 183 if (call.is_null()) { \ |
| 184 ASSERT((isolate)->has_pending_exception()); \ |
| 185 return value; \ |
| 186 } \ |
| 187 } while (false) |
| 188 |
| 189 #define RETURN_FAILURE_ON_EXCEPTION(isolate, call) \ |
| 190 RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, Failure::Exception()) |
| 191 |
| 192 #define RETURN_ON_EXCEPTION(isolate, call, T) \ |
| 193 RETURN_ON_EXCEPTION_VALUE( \ |
| 194 isolate, dst, call, MaybeHandle<T>::Exception()) |
| 195 |
| 196 |
154 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \ | 197 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \ |
155 C(Handler, handler) \ | 198 C(Handler, handler) \ |
156 C(CEntryFP, c_entry_fp) \ | 199 C(CEntryFP, c_entry_fp) \ |
157 C(Context, context) \ | 200 C(Context, context) \ |
158 C(PendingException, pending_exception) \ | 201 C(PendingException, pending_exception) \ |
159 C(ExternalCaughtException, external_caught_exception) \ | 202 C(ExternalCaughtException, external_caught_exception) \ |
160 C(JSEntrySP, js_entry_sp) | 203 C(JSEntrySP, js_entry_sp) |
161 | 204 |
162 | 205 |
163 // Platform-independent, reliable thread identifier. | 206 // Platform-independent, reliable thread identifier. |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 bool MayIndexedAccess(JSObject* receiver, | 803 bool MayIndexedAccess(JSObject* receiver, |
761 uint32_t index, | 804 uint32_t index, |
762 v8::AccessType type); | 805 v8::AccessType type); |
763 | 806 |
764 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); | 807 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); |
765 void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); | 808 void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); |
766 | 809 |
767 // Exception throwing support. The caller should use the result | 810 // Exception throwing support. The caller should use the result |
768 // of Throw() as its return value. | 811 // of Throw() as its return value. |
769 Failure* Throw(Object* exception, MessageLocation* location = NULL); | 812 Failure* Throw(Object* exception, MessageLocation* location = NULL); |
| 813 |
| 814 template <typename T> |
| 815 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, |
| 816 MessageLocation* location = NULL) { |
| 817 Throw(*exception, location); |
| 818 return MaybeHandle<T>::Exception(); |
| 819 } |
| 820 |
770 // Re-throw an exception. This involves no error reporting since | 821 // Re-throw an exception. This involves no error reporting since |
771 // error reporting was handled when the exception was thrown | 822 // error reporting was handled when the exception was thrown |
772 // originally. | 823 // originally. |
773 Failure* ReThrow(MaybeObject* exception); | 824 Failure* ReThrow(MaybeObject* exception); |
774 void ScheduleThrow(Object* exception); | 825 void ScheduleThrow(Object* exception); |
775 // Re-set pending message, script and positions reported to the TryCatch | 826 // Re-set pending message, script and positions reported to the TryCatch |
776 // back to the TLS for re-use when rethrowing. | 827 // back to the TLS for re-use when rethrowing. |
777 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); | 828 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); |
778 void ReportPendingMessages(); | 829 void ReportPendingMessages(); |
779 // Return pending location if any or unfilled structure. | 830 // Return pending location if any or unfilled structure. |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 } | 1583 } |
1533 | 1584 |
1534 EmbeddedVector<char, 128> filename_; | 1585 EmbeddedVector<char, 128> filename_; |
1535 FILE* file_; | 1586 FILE* file_; |
1536 int scope_depth_; | 1587 int scope_depth_; |
1537 }; | 1588 }; |
1538 | 1589 |
1539 } } // namespace v8::internal | 1590 } } // namespace v8::internal |
1540 | 1591 |
1541 #endif // V8_ISOLATE_H_ | 1592 #endif // V8_ISOLATE_H_ |
OLD | NEW |