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/runtime/runtime.h" | 8 #include "src/runtime/runtime.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 RUNTIME_ASSERT(args[index]->IsSmi()); \ | 48 RUNTIME_ASSERT(args[index]->IsSmi()); \ |
49 int name = args.smi_at(index); | 49 int name = args.smi_at(index); |
50 | 50 |
51 // Cast the given argument to a double and store it in a variable with | 51 // Cast the given argument to a double and store it in a variable with |
52 // the given name. If the argument is not a number (as opposed to | 52 // the given name. If the argument is not a number (as opposed to |
53 // the number not-a-number) call IllegalOperation and return. | 53 // the number not-a-number) call IllegalOperation and return. |
54 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ | 54 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ |
55 RUNTIME_ASSERT(args[index]->IsNumber()); \ | 55 RUNTIME_ASSERT(args[index]->IsNumber()); \ |
56 double name = args.number_at(index); | 56 double name = args.number_at(index); |
57 | 57 |
| 58 |
| 59 // Cast the given argument to a size_t and store its value in a variable with |
| 60 // the given name. If the argument is not a size_t call IllegalOperation and |
| 61 // return. |
| 62 #define CONVERT_SIZE_ARG_CHECKED(name, index) \ |
| 63 RUNTIME_ASSERT(args[index]->IsNumber()); \ |
| 64 Handle<Object> name##_object = args.at<Object>(index); \ |
| 65 size_t name = 0; \ |
| 66 RUNTIME_ASSERT(TryNumberToSize(isolate, *name##_object, &name)); |
| 67 |
| 68 |
58 // Call the specified converter on the object *comand store the result in | 69 // Call the specified converter on the object *comand store the result in |
59 // a variable of the specified type with the given name. If the | 70 // a variable of the specified type with the given name. If the |
60 // object is not a Number call IllegalOperation and return. | 71 // object is not a Number call IllegalOperation and return. |
61 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ | 72 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ |
62 RUNTIME_ASSERT(obj->IsNumber()); \ | 73 RUNTIME_ASSERT(obj->IsNumber()); \ |
63 type name = NumberTo##Type(obj); | 74 type name = NumberTo##Type(obj); |
64 | 75 |
65 | 76 |
66 // Cast the given argument to PropertyDetails and store its value in a | 77 // Cast the given argument to PropertyDetails and store its value in a |
67 // variable with the given name. If the argument is not a Smi call | 78 // variable with the given name. If the argument is not a Smi call |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 #else | 159 #else |
149 #error Unknown endianness | 160 #error Unknown endianness |
150 #endif | 161 #endif |
151 } | 162 } |
152 #endif | 163 #endif |
153 | 164 |
154 } | 165 } |
155 } // namespace v8::internal | 166 } // namespace v8::internal |
156 | 167 |
157 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 168 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
OLD | NEW |