| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_RUNTIME_RUNTIME_UTILS_H_ | 5 #ifndef V8_RUNTIME_RUNTIME_UTILS_H_ |
| 6 #define V8_RUNTIME_RUNTIME_UTILS_H_ | 6 #define V8_RUNTIME_RUNTIME_UTILS_H_ |
| 7 | 7 |
| 8 #include "src/base/logging.h" |
| 8 #include "src/runtime/runtime.h" | 9 #include "src/runtime/runtime.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 | 13 |
| 13 #define RUNTIME_ASSERT(value) \ | 14 #ifdef DEBUG |
| 14 if (!(value)) return isolate->ThrowIllegalOperation(); | 15 |
| 16 #define RUNTIME_ASSERT(value) \ |
| 17 do { \ |
| 18 if (!(value)) { \ |
| 19 V8_RuntimeError(__FILE__, __LINE__, #value); \ |
| 20 return isolate->ThrowIllegalOperation(); \ |
| 21 } \ |
| 22 } while (0) |
| 23 |
| 24 #define RUNTIME_ASSERT_HANDLIFIED(value, T) \ |
| 25 do { \ |
| 26 if (!(value)) { \ |
| 27 V8_RuntimeError(__FILE__, __LINE__, #value); \ |
| 28 isolate->ThrowIllegalOperation(); \ |
| 29 return MaybeHandle<T>(); \ |
| 30 } \ |
| 31 } while (0) |
| 32 |
| 33 #else |
| 34 |
| 35 #define RUNTIME_ASSERT(value) \ |
| 36 do { \ |
| 37 if (!(value)) { \ |
| 38 return isolate->ThrowIllegalOperation(); \ |
| 39 } \ |
| 40 } while (0) |
| 15 | 41 |
| 16 #define RUNTIME_ASSERT_HANDLIFIED(value, T) \ | 42 #define RUNTIME_ASSERT_HANDLIFIED(value, T) \ |
| 17 if (!(value)) { \ | 43 do { \ |
| 18 isolate->ThrowIllegalOperation(); \ | 44 if (!(value)) { \ |
| 19 return MaybeHandle<T>(); \ | 45 isolate->ThrowIllegalOperation(); \ |
| 20 } | 46 return MaybeHandle<T>(); \ |
| 47 } \ |
| 48 } while (0) |
| 49 |
| 50 #endif |
| 21 | 51 |
| 22 // Cast the given object to a value of the specified type and store | 52 // Cast the given object to a value of the specified type and store |
| 23 // it in a variable with the given name. If the object is not of the | 53 // it in a variable with the given name. If the object is not of the |
| 24 // expected type call IllegalOperation and return. | 54 // expected type call IllegalOperation and return. |
| 25 #define CONVERT_ARG_CHECKED(Type, name, index) \ | 55 #define CONVERT_ARG_CHECKED(Type, name, index) \ |
| 26 RUNTIME_ASSERT(args[index]->Is##Type()); \ | 56 RUNTIME_ASSERT(args[index]->Is##Type()); \ |
| 27 Type* name = Type::cast(args[index]); | 57 Type* name = Type::cast(args[index]); |
| 28 | 58 |
| 29 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \ | 59 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \ |
| 30 RUNTIME_ASSERT(args[index]->Is##Type()); \ | 60 RUNTIME_ASSERT(args[index]->Is##Type()); \ |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { | 205 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { |
| 176 ObjectTriple result = {x, y, z}; | 206 ObjectTriple result = {x, y, z}; |
| 177 // ObjectTriple is assigned to a hidden first argument. | 207 // ObjectTriple is assigned to a hidden first argument. |
| 178 return result; | 208 return result; |
| 179 } | 209 } |
| 180 | 210 |
| 181 } // namespace internal | 211 } // namespace internal |
| 182 } // namespace v8 | 212 } // namespace v8 |
| 183 | 213 |
| 184 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 214 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
| OLD | NEW |