| 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/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 #include "src/tracing/trace-event.h" | 10 #include "src/tracing/trace-event.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 DCHECK_GE(length_, 0); | 34 DCHECK_GE(length_, 0); |
| 35 } | 35 } |
| 36 | 36 |
| 37 Object*& operator[] (int index) { | 37 Object*& operator[] (int index) { |
| 38 DCHECK_GE(index, 0); | 38 DCHECK_GE(index, 0); |
| 39 DCHECK_LT(static_cast<uint32_t>(index), static_cast<uint32_t>(length_)); | 39 DCHECK_LT(static_cast<uint32_t>(index), static_cast<uint32_t>(length_)); |
| 40 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) - | 40 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) - |
| 41 index * kPointerSize)); | 41 index * kPointerSize)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 template <class S> Handle<S> at(int index) { | 44 template <class S = Object> |
| 45 Handle<S> at(int index) { |
| 45 Object** value = &((*this)[index]); | 46 Object** value = &((*this)[index]); |
| 46 // This cast checks that the object we're accessing does indeed have the | 47 // This cast checks that the object we're accessing does indeed have the |
| 47 // expected type. | 48 // expected type. |
| 48 S::cast(*value); | 49 S::cast(*value); |
| 49 return Handle<S>(reinterpret_cast<S**>(value)); | 50 return Handle<S>(reinterpret_cast<S**>(value)); |
| 50 } | 51 } |
| 51 | 52 |
| 52 int smi_at(int index) { | 53 int smi_at(int index) { |
| 53 return Smi::cast((*this)[index])->value(); | 54 return Smi::cast((*this)[index])->value(); |
| 54 } | 55 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) | 109 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) |
| 109 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ | 110 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ |
| 110 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) | 111 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) |
| 111 #define RUNTIME_FUNCTION_RETURN_TRIPLE(Name) \ | 112 #define RUNTIME_FUNCTION_RETURN_TRIPLE(Name) \ |
| 112 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectTriple, Name) | 113 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectTriple, Name) |
| 113 | 114 |
| 114 } // namespace internal | 115 } // namespace internal |
| 115 } // namespace v8 | 116 } // namespace v8 |
| 116 | 117 |
| 117 #endif // V8_ARGUMENTS_H_ | 118 #endif // V8_ARGUMENTS_H_ |
| OLD | NEW |