OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_ARGUMENTS_H_ | 5 #ifndef V8_ARGUMENTS_H_ |
6 #define V8_ARGUMENTS_H_ | 6 #define V8_ARGUMENTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 // | 25 // |
26 // Note that length_ (whose value is in the integer range) is defined | 26 // Note that length_ (whose value is in the integer range) is defined |
27 // as intptr_t to provide endian-neutrality on 64-bit archs. | 27 // as intptr_t to provide endian-neutrality on 64-bit archs. |
28 | 28 |
29 class Arguments BASE_EMBEDDED { | 29 class Arguments BASE_EMBEDDED { |
30 public: | 30 public: |
31 Arguments(int length, Object** arguments) | 31 Arguments(int length, Object** arguments) |
32 : length_(length), arguments_(arguments) { } | 32 : length_(length), arguments_(arguments) { } |
33 | 33 |
34 Object*& operator[] (int index) { | 34 Object*& operator[] (int index) { |
35 ASSERT(0 <= index && index < length_); | 35 DCHECK(0 <= index && index < length_); |
36 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) - | 36 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) - |
37 index * kPointerSize)); | 37 index * kPointerSize)); |
38 } | 38 } |
39 | 39 |
40 template <class S> Handle<S> at(int index) { | 40 template <class S> Handle<S> at(int index) { |
41 Object** value = &((*this)[index]); | 41 Object** value = &((*this)[index]); |
42 // This cast checks that the object we're accessing does indeed have the | 42 // This cast checks that the object we're accessing does indeed have the |
43 // expected type. | 43 // expected type. |
44 S::cast(*value); | 44 S::cast(*value); |
45 return Handle<S>(reinterpret_cast<S**>(value)); | 45 return Handle<S>(reinterpret_cast<S**>(value)); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 Object** values = this->begin(); | 169 Object** values = this->begin(); |
170 values[T::kThisIndex] = self; | 170 values[T::kThisIndex] = self; |
171 values[T::kHolderIndex] = holder; | 171 values[T::kHolderIndex] = holder; |
172 values[T::kDataIndex] = data; | 172 values[T::kDataIndex] = data; |
173 values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate); | 173 values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate); |
174 // Here the hole is set as default value. | 174 // Here the hole is set as default value. |
175 // It cannot escape into js as it's remove in Call below. | 175 // It cannot escape into js as it's remove in Call below. |
176 values[T::kReturnValueDefaultValueIndex] = | 176 values[T::kReturnValueDefaultValueIndex] = |
177 isolate->heap()->the_hole_value(); | 177 isolate->heap()->the_hole_value(); |
178 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); | 178 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); |
179 ASSERT(values[T::kHolderIndex]->IsHeapObject()); | 179 DCHECK(values[T::kHolderIndex]->IsHeapObject()); |
180 ASSERT(values[T::kIsolateIndex]->IsSmi()); | 180 DCHECK(values[T::kIsolateIndex]->IsSmi()); |
181 } | 181 } |
182 | 182 |
183 /* | 183 /* |
184 * The following Call functions wrap the calling of all callbacks to handle | 184 * The following Call functions wrap the calling of all callbacks to handle |
185 * calling either the old or the new style callbacks depending on which one | 185 * calling either the old or the new style callbacks depending on which one |
186 * has been registered. | 186 * has been registered. |
187 * For old callbacks which return an empty handle, the ReturnValue is checked | 187 * For old callbacks which return an empty handle, the ReturnValue is checked |
188 * and used if it's been set to anything inside the callback. | 188 * and used if it's been set to anything inside the callback. |
189 * New style callbacks always use the return value. | 189 * New style callbacks always use the return value. |
190 */ | 190 */ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 values[T::kDataIndex] = data; | 241 values[T::kDataIndex] = data; |
242 values[T::kCalleeIndex] = callee; | 242 values[T::kCalleeIndex] = callee; |
243 values[T::kHolderIndex] = holder; | 243 values[T::kHolderIndex] = holder; |
244 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); | 244 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); |
245 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); | 245 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); |
246 // Here the hole is set as default value. | 246 // Here the hole is set as default value. |
247 // It cannot escape into js as it's remove in Call below. | 247 // It cannot escape into js as it's remove in Call below. |
248 values[T::kReturnValueDefaultValueIndex] = | 248 values[T::kReturnValueDefaultValueIndex] = |
249 isolate->heap()->the_hole_value(); | 249 isolate->heap()->the_hole_value(); |
250 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); | 250 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); |
251 ASSERT(values[T::kCalleeIndex]->IsJSFunction()); | 251 DCHECK(values[T::kCalleeIndex]->IsJSFunction()); |
252 ASSERT(values[T::kHolderIndex]->IsHeapObject()); | 252 DCHECK(values[T::kHolderIndex]->IsHeapObject()); |
253 ASSERT(values[T::kIsolateIndex]->IsSmi()); | 253 DCHECK(values[T::kIsolateIndex]->IsSmi()); |
254 } | 254 } |
255 | 255 |
256 /* | 256 /* |
257 * The following Call function wraps the calling of all callbacks to handle | 257 * The following Call function wraps the calling of all callbacks to handle |
258 * calling either the old or the new style callbacks depending on which one | 258 * calling either the old or the new style callbacks depending on which one |
259 * has been registered. | 259 * has been registered. |
260 * For old callbacks which return an empty handle, the ReturnValue is checked | 260 * For old callbacks which return an empty handle, the ReturnValue is checked |
261 * and used if it's been set to anything inside the callback. | 261 * and used if it's been set to anything inside the callback. |
262 * New style callbacks always use the return value. | 262 * New style callbacks always use the return value. |
263 */ | 263 */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) | 296 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) |
297 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ | 297 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ |
298 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) | 298 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) |
299 | 299 |
300 #define RUNTIME_ARGUMENTS(isolate, args) \ | 300 #define RUNTIME_ARGUMENTS(isolate, args) \ |
301 args.length(), args.arguments(), isolate | 301 args.length(), args.arguments(), isolate |
302 | 302 |
303 } } // namespace v8::internal | 303 } } // namespace v8::internal |
304 | 304 |
305 #endif // V8_ARGUMENTS_H_ | 305 #endif // V8_ARGUMENTS_H_ |
OLD | NEW |