OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // Custom arguments replicate a small segment of stack that can be | 130 // Custom arguments replicate a small segment of stack that can be |
131 // accessed through an Arguments object the same way the actual stack | 131 // accessed through an Arguments object the same way the actual stack |
132 // can. | 132 // can. |
133 template<int kArrayLength> | 133 template<int kArrayLength> |
134 class CustomArgumentsBase : public Relocatable { | 134 class CustomArgumentsBase : public Relocatable { |
135 public: | 135 public: |
136 virtual inline void IterateInstance(ObjectVisitor* v) { | 136 virtual inline void IterateInstance(ObjectVisitor* v) { |
137 v->VisitPointers(values_, values_ + kArrayLength); | 137 v->VisitPointers(values_, values_ + kArrayLength); |
138 } | 138 } |
139 protected: | 139 protected: |
140 inline Object** begin() { return values_; } | 140 inline Object** end() { return values_ + kArrayLength - 1; } |
141 explicit inline CustomArgumentsBase(Isolate* isolate) | 141 explicit inline CustomArgumentsBase(Isolate* isolate) |
142 : Relocatable(isolate) {} | 142 : Relocatable(isolate) {} |
143 Object* values_[kArrayLength]; | 143 Object* values_[kArrayLength]; |
144 }; | 144 }; |
145 | 145 |
146 | 146 |
147 template<typename T> | 147 template<typename T> |
148 class CustomArguments : public CustomArgumentsBase<T::kArgsLength> { | 148 class CustomArguments : public CustomArgumentsBase<T::kArgsLength> { |
149 public: | 149 public: |
150 static const int kReturnValueOffset = T::kReturnValueIndex; | 150 static const int kReturnValueOffset = T::kReturnValueIndex; |
151 | 151 |
152 typedef CustomArgumentsBase<T::kArgsLength> Super; | 152 typedef CustomArgumentsBase<T::kArgsLength> Super; |
153 ~CustomArguments() { | 153 ~CustomArguments() { |
154 this->begin()[kReturnValueOffset] = | 154 this->end()[kReturnValueOffset] = |
155 reinterpret_cast<Object*>(kHandleZapValue); | 155 reinterpret_cast<Object*>(kHandleZapValue); |
156 } | 156 } |
157 | 157 |
158 protected: | 158 protected: |
159 explicit inline CustomArguments(Isolate* isolate) : Super(isolate) {} | 159 explicit inline CustomArguments(Isolate* isolate) : Super(isolate) {} |
160 | 160 |
161 template<typename V> | 161 template<typename V> |
162 v8::Handle<V> GetReturnValue(Isolate* isolate); | 162 v8::Handle<V> GetReturnValue(Isolate* isolate); |
163 | 163 |
164 inline Isolate* isolate() { | 164 inline Isolate* isolate() { |
165 return reinterpret_cast<Isolate*>(this->begin()[T::kIsolateIndex]); | 165 return reinterpret_cast<Isolate*>(this->end()[T::kIsolateIndex]); |
166 } | 166 } |
167 }; | 167 }; |
168 | 168 |
169 | 169 |
170 class PropertyCallbackArguments | 170 class PropertyCallbackArguments |
171 : public CustomArguments<PropertyCallbackInfo<Value> > { | 171 : public CustomArguments<PropertyCallbackInfo<Value> > { |
172 public: | 172 public: |
173 typedef PropertyCallbackInfo<Value> T; | 173 typedef PropertyCallbackInfo<Value> T; |
174 typedef CustomArguments<T> Super; | 174 typedef CustomArguments<T> Super; |
175 static const int kArgsLength = T::kArgsLength; | 175 static const int kArgsLength = T::kArgsLength; |
176 static const int kThisIndex = T::kThisIndex; | 176 static const int kThisIndex = T::kThisIndex; |
177 static const int kHolderIndex = T::kHolderIndex; | 177 static const int kHolderIndex = T::kHolderIndex; |
178 static const int kDataIndex = T::kDataIndex; | 178 static const int kDataIndex = T::kDataIndex; |
179 static const int kReturnValueDefaultValueIndex = | 179 static const int kReturnValueDefaultValueIndex = |
180 T::kReturnValueDefaultValueIndex; | 180 T::kReturnValueDefaultValueIndex; |
181 static const int kIsolateIndex = T::kIsolateIndex; | 181 static const int kIsolateIndex = T::kIsolateIndex; |
182 | 182 |
183 PropertyCallbackArguments(Isolate* isolate, | 183 PropertyCallbackArguments(Isolate* isolate, |
184 Object* data, | 184 Object* data, |
185 Object* self, | 185 Object* self, |
186 JSObject* holder) | 186 JSObject* holder) |
187 : Super(isolate) { | 187 : Super(isolate) { |
188 Object** values = this->begin(); | 188 Object** values = this->end(); |
189 values[T::kThisIndex] = self; | 189 values[T::kThisIndex] = self; |
190 values[T::kHolderIndex] = holder; | 190 values[T::kHolderIndex] = holder; |
191 values[T::kDataIndex] = data; | 191 values[T::kDataIndex] = data; |
192 values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate); | 192 values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate); |
193 // Here the hole is set as default value. | 193 // Here the hole is set as default value. |
194 // It cannot escape into js as it's remove in Call below. | 194 // It cannot escape into js as it's remove in Call below. |
195 values[T::kReturnValueDefaultValueIndex] = | 195 values[T::kReturnValueDefaultValueIndex] = |
196 isolate->heap()->the_hole_value(); | 196 isolate->heap()->the_hole_value(); |
197 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); | 197 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); |
198 ASSERT(values[T::kHolderIndex]->IsHeapObject()); | 198 ASSERT(values[T::kHolderIndex]->IsHeapObject()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 internal::Object* data, | 249 internal::Object* data, |
250 internal::JSFunction* callee, | 250 internal::JSFunction* callee, |
251 internal::Object* holder, | 251 internal::Object* holder, |
252 internal::Object** argv, | 252 internal::Object** argv, |
253 int argc, | 253 int argc, |
254 bool is_construct_call) | 254 bool is_construct_call) |
255 : Super(isolate), | 255 : Super(isolate), |
256 argv_(argv), | 256 argv_(argv), |
257 argc_(argc), | 257 argc_(argc), |
258 is_construct_call_(is_construct_call) { | 258 is_construct_call_(is_construct_call) { |
259 Object** values = begin(); | 259 Object** values = end(); |
260 values[T::kDataIndex] = data; | 260 values[T::kDataIndex] = data; |
261 values[T::kCalleeIndex] = callee; | 261 values[T::kCalleeIndex] = callee; |
262 values[T::kHolderIndex] = holder; | 262 values[T::kHolderIndex] = holder; |
263 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); | 263 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); |
264 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); | 264 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); |
265 // Here the hole is set as default value. | 265 // Here the hole is set as default value. |
266 // It cannot escape into js as it's remove in Call below. | 266 // It cannot escape into js as it's remove in Call below. |
267 values[T::kReturnValueDefaultValueIndex] = | 267 values[T::kReturnValueDefaultValueIndex] = |
268 isolate->heap()->the_hole_value(); | 268 isolate->heap()->the_hole_value(); |
269 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); | 269 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); |
(...skipping 29 matching lines...) Expand all Loading... |
299 return __RT_impl_##Name(args, isolate); \ | 299 return __RT_impl_##Name(args, isolate); \ |
300 } \ | 300 } \ |
301 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) | 301 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) |
302 | 302 |
303 #define RUNTIME_ARGUMENTS(isolate, args) \ | 303 #define RUNTIME_ARGUMENTS(isolate, args) \ |
304 args.length(), args.arguments(), isolate | 304 args.length(), args.arguments(), isolate |
305 | 305 |
306 } } // namespace v8::internal | 306 } } // namespace v8::internal |
307 | 307 |
308 #endif // V8_ARGUMENTS_H_ | 308 #endif // V8_ARGUMENTS_H_ |
OLD | NEW |