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