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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Cast the given argument to PropertyDetails and store its value in a | 63 // Cast the given argument to PropertyDetails and store its value in a |
64 // variable with the given name. If the argument is not a Smi we crash safely. | 64 // variable with the given name. If the argument is not a Smi we crash safely. |
65 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \ | 65 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \ |
66 CHECK(args[index]->IsSmi()); \ | 66 CHECK(args[index]->IsSmi()); \ |
67 PropertyDetails name = PropertyDetails(Smi::cast(args[index])); | 67 PropertyDetails name = PropertyDetails(Smi::cast(args[index])); |
68 | 68 |
69 // Assert that the given argument has a valid value for a LanguageMode | 69 // Assert that the given argument has a valid value for a LanguageMode |
70 // and store it in a LanguageMode variable with the given name. | 70 // and store it in a LanguageMode variable with the given name. |
71 #define CONVERT_LANGUAGE_MODE_ARG_CHECKED(name, index) \ | 71 #define CONVERT_LANGUAGE_MODE_ARG_CHECKED(name, index) \ |
72 CHECK(args[index]->IsNumber()); \ | 72 CHECK(args[index]->IsSmi()); \ |
73 int32_t __tmp_##name = 0; \ | 73 CHECK(is_valid_language_mode(args.smi_at(index))); \ |
74 CHECK(args[index]->ToInt32(&__tmp_##name)); \ | 74 LanguageMode name = static_cast<LanguageMode>(args.smi_at(index)); |
75 CHECK(is_valid_language_mode(__tmp_##name)); \ | |
76 LanguageMode name = static_cast<LanguageMode>(__tmp_##name); | |
77 | 75 |
78 // 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 |
79 // 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. |
80 #define CONVERT_INT32_ARG_CHECKED(name, index) \ | 78 #define CONVERT_INT32_ARG_CHECKED(name, index) \ |
81 CHECK(args[index]->IsNumber()); \ | 79 CHECK(args[index]->IsNumber()); \ |
82 int32_t name = 0; \ | 80 int32_t name = 0; \ |
83 CHECK(args[index]->ToInt32(&name)); | 81 CHECK(args[index]->ToInt32(&name)); |
84 | 82 |
85 // Assert that the given argument is a number within the Uint32 range | 83 // Assert that the given argument is a number within the Uint32 range |
86 // and convert it to uint32_t. If the argument is not an Uint32 call | 84 // and convert it to uint32_t. If the argument is not an Uint32 call |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { | 162 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { |
165 ObjectTriple result = {x, y, z}; | 163 ObjectTriple result = {x, y, z}; |
166 // ObjectTriple is assigned to a hidden first argument. | 164 // ObjectTriple is assigned to a hidden first argument. |
167 return result; | 165 return result; |
168 } | 166 } |
169 | 167 |
170 } // namespace internal | 168 } // namespace internal |
171 } // namespace v8 | 169 } // namespace v8 |
172 | 170 |
173 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 171 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
OLD | NEW |