OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_API_ARGUMENTS_H_ | 5 #ifndef V8_API_ARGUMENTS_H_ |
6 #define V8_API_ARGUMENTS_H_ | 6 #define V8_API_ARGUMENTS_H_ |
7 | 7 |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/tracing/trace-event.h" | 10 #include "src/tracing/trace-event.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 typedef FunctionCallbackInfo<Value> T; | 199 typedef FunctionCallbackInfo<Value> T; |
200 typedef CustomArguments<T> Super; | 200 typedef CustomArguments<T> Super; |
201 static const int kArgsLength = T::kArgsLength; | 201 static const int kArgsLength = T::kArgsLength; |
202 static const int kHolderIndex = T::kHolderIndex; | 202 static const int kHolderIndex = T::kHolderIndex; |
203 static const int kDataIndex = T::kDataIndex; | 203 static const int kDataIndex = T::kDataIndex; |
204 static const int kReturnValueDefaultValueIndex = | 204 static const int kReturnValueDefaultValueIndex = |
205 T::kReturnValueDefaultValueIndex; | 205 T::kReturnValueDefaultValueIndex; |
206 static const int kIsolateIndex = T::kIsolateIndex; | 206 static const int kIsolateIndex = T::kIsolateIndex; |
207 static const int kCalleeIndex = T::kCalleeIndex; | 207 static const int kCalleeIndex = T::kCalleeIndex; |
208 static const int kContextSaveIndex = T::kContextSaveIndex; | 208 static const int kContextSaveIndex = T::kContextSaveIndex; |
| 209 static const int kNewTargetIndex = T::kNewTargetIndex; |
209 | 210 |
210 FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data, | 211 FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data, |
211 internal::HeapObject* callee, | 212 internal::HeapObject* callee, |
212 internal::Object* holder, internal::Object** argv, | 213 internal::Object* holder, |
213 int argc, bool is_construct_call) | 214 internal::HeapObject* new_target, |
214 : Super(isolate), | 215 internal::Object** argv, int argc) |
215 argv_(argv), | 216 : Super(isolate), argv_(argv), argc_(argc) { |
216 argc_(argc), | |
217 is_construct_call_(is_construct_call) { | |
218 Object** values = begin(); | 217 Object** values = begin(); |
219 values[T::kDataIndex] = data; | 218 values[T::kDataIndex] = data; |
220 values[T::kCalleeIndex] = callee; | 219 values[T::kCalleeIndex] = callee; |
221 values[T::kHolderIndex] = holder; | 220 values[T::kHolderIndex] = holder; |
| 221 values[T::kNewTargetIndex] = new_target; |
222 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); | 222 values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); |
223 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); | 223 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate); |
224 // Here the hole is set as default value. | 224 // Here the hole is set as default value. |
225 // It cannot escape into js as it's remove in Call below. | 225 // It cannot escape into js as it's remove in Call below. |
226 values[T::kReturnValueDefaultValueIndex] = | 226 values[T::kReturnValueDefaultValueIndex] = |
227 isolate->heap()->the_hole_value(); | 227 isolate->heap()->the_hole_value(); |
228 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); | 228 values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); |
229 DCHECK(values[T::kCalleeIndex]->IsJSFunction() || | 229 DCHECK(values[T::kCalleeIndex]->IsJSFunction() || |
230 values[T::kCalleeIndex]->IsFunctionTemplateInfo()); | 230 values[T::kCalleeIndex]->IsFunctionTemplateInfo()); |
231 DCHECK(values[T::kHolderIndex]->IsHeapObject()); | 231 DCHECK(values[T::kHolderIndex]->IsHeapObject()); |
232 DCHECK(values[T::kIsolateIndex]->IsSmi()); | 232 DCHECK(values[T::kIsolateIndex]->IsSmi()); |
233 } | 233 } |
234 | 234 |
235 /* | 235 /* |
236 * The following Call function wraps the calling of all callbacks to handle | 236 * The following Call function wraps the calling of all callbacks to handle |
237 * calling either the old or the new style callbacks depending on which one | 237 * calling either the old or the new style callbacks depending on which one |
238 * has been registered. | 238 * has been registered. |
239 * For old callbacks which return an empty handle, the ReturnValue is checked | 239 * For old callbacks which return an empty handle, the ReturnValue is checked |
240 * and used if it's been set to anything inside the callback. | 240 * and used if it's been set to anything inside the callback. |
241 * New style callbacks always use the return value. | 241 * New style callbacks always use the return value. |
242 */ | 242 */ |
243 Handle<Object> Call(FunctionCallback f); | 243 Handle<Object> Call(FunctionCallback f); |
244 | 244 |
245 private: | 245 private: |
246 internal::Object** argv_; | 246 internal::Object** argv_; |
247 int argc_; | 247 int argc_; |
248 bool is_construct_call_; | |
249 }; | 248 }; |
250 | 249 |
251 } // namespace internal | 250 } // namespace internal |
252 } // namespace v8 | 251 } // namespace v8 |
253 | 252 |
254 #endif // V8_API_ARGUMENTS_H_ | 253 #endif // V8_API_ARGUMENTS_H_ |
OLD | NEW |