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 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 CHECK(is_valid_language_mode(args.smi_at(index))); \ | 73 CHECK(is_valid_language_mode(args.smi_at(index))); \ |
74 LanguageMode name = static_cast<LanguageMode>(args.smi_at(index)); | 74 LanguageMode name = static_cast<LanguageMode>(args.smi_at(index)); |
75 | 75 |
76 // Assert that the given argument is a number within the Int32 range | 76 // Assert that the given argument is a number within the Int32 range |
77 // and convert it to int32_t. If the argument is not an Int32 we crash safely. | 77 // and convert it to int32_t. If the argument is not an Int32 we crash safely. |
78 #define CONVERT_INT32_ARG_CHECKED(name, index) \ | 78 #define CONVERT_INT32_ARG_CHECKED(name, index) \ |
79 CHECK(args[index]->IsNumber()); \ | 79 CHECK(args[index]->IsNumber()); \ |
80 int32_t name = 0; \ | 80 int32_t name = 0; \ |
81 CHECK(args[index]->ToInt32(&name)); | 81 CHECK(args[index]->ToInt32(&name)); |
82 | 82 |
| 83 // Assert that the given argument is a number within the Uint32 range |
| 84 // and convert it to uint32_t. If the argument is not an Uint32 call |
| 85 // IllegalOperation and return. |
| 86 #define CONVERT_UINT32_ARG_CHECKED(name, index) \ |
| 87 CHECK(args[index]->IsNumber()); \ |
| 88 uint32_t name = 0; \ |
| 89 CHECK(args[index]->ToUint32(&name)); |
| 90 |
83 // Cast the given argument to PropertyAttributes and store its value in a | 91 // Cast the given argument to PropertyAttributes and store its value in a |
84 // variable with the given name. If the argument is not a Smi or the | 92 // variable with the given name. If the argument is not a Smi or the |
85 // enum value is out of range, we crash safely. | 93 // enum value is out of range, we crash safely. |
86 #define CONVERT_PROPERTY_ATTRIBUTES_CHECKED(name, index) \ | 94 #define CONVERT_PROPERTY_ATTRIBUTES_CHECKED(name, index) \ |
87 CHECK(args[index]->IsSmi()); \ | 95 CHECK(args[index]->IsSmi()); \ |
88 CHECK((args.smi_at(index) & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); \ | 96 CHECK((args.smi_at(index) & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); \ |
89 PropertyAttributes name = static_cast<PropertyAttributes>(args.smi_at(index)); | 97 PropertyAttributes name = static_cast<PropertyAttributes>(args.smi_at(index)); |
90 | 98 |
91 // A mechanism to return a pair of Object pointers in registers (if possible). | 99 // A mechanism to return a pair of Object pointers in registers (if possible). |
92 // How this is achieved is calling convention-dependent. | 100 // How this is achieved is calling convention-dependent. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { | 162 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { |
155 ObjectTriple result = {x, y, z}; | 163 ObjectTriple result = {x, y, z}; |
156 // ObjectTriple is assigned to a hidden first argument. | 164 // ObjectTriple is assigned to a hidden first argument. |
157 return result; | 165 return result; |
158 } | 166 } |
159 | 167 |
160 } // namespace internal | 168 } // namespace internal |
161 } // namespace v8 | 169 } // namespace v8 |
162 | 170 |
163 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 171 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
OLD | NEW |