5#ifndef INCLUDE_V8_FUNCTION_CALLBACK_H_
6#define INCLUDE_V8_FUNCTION_CALLBACK_H_
18class BasicTracedReference;
25class FunctionCallbackArguments;
26class PropertyCallbackArguments;
31class ConsoleCallArguments;
39 static_assert(std::is_base_of<T, S>::value,
"type check");
83 template <
class F,
class G,
class H>
97 static constexpr int kIsolateValueIndex = -2;
131 "V8 will stop providing access to hidden prototype (i.e. "
132 "JSGlobalObject). Use This() instead. \n"
133 "DO NOT try to workaround this by accessing JSGlobalObject via "
134 "v8::Object::GetPrototype() - it'll be deprecated soon too. \n"
135 "See http://crbug.com/333672197. ")
158 static constexpr int kHolderIndex = 0;
159 static constexpr int kIsolateIndex = 1;
160 static constexpr int kUnusedIndex = 2;
161 static constexpr int kReturnValueIndex = 3;
162 static constexpr int kDataIndex = 4;
163 static constexpr int kNewTargetIndex = 5;
164 static constexpr int kArgsLength = 6;
166 static constexpr int kArgsLengthWithReceiver = kArgsLength + 1;
170 static constexpr int kImplicitArgsOffset = 0;
171 static constexpr int kValuesOffset =
173 static constexpr int kLengthOffset =
176 static constexpr int kThisValuesIndex = -1;
178 kIsolateIndex - kReturnValueIndex);
280 "This is a temporary workaround to ease migration of Chromium bindings "
281 "code to the new interceptors Api")
286 template <
typename U>
291 static constexpr int kShouldThrowOnErrorIndex = 0;
292 static constexpr int kHolderIndex = 1;
293 static constexpr int kIsolateIndex = 2;
294 static constexpr int kUnusedIndex = 3;
295 static constexpr int kReturnValueIndex = 4;
296 static constexpr int kDataIndex = 5;
297 static constexpr int kThisIndex = 6;
298 static constexpr int kArgsLength = 7;
316void ReturnValue<T>::SetInternal(internal::Address value) {
317#if V8_STATIC_ROOTS_BOOL
318 using I = internal::Internals;
323 *value_ = I::DecompressTaggedField(*value_, I::CompressTagged(value));
332 static_assert(std::is_base_of<T, S>::value,
"type check");
336 SetInternal(handle.
ptr());
343 static_assert(std::is_base_of<T, S>::value,
"type check");
344#ifdef V8_ENABLE_CHECKS
345 internal::VerifyHandleIsNonEmpty(handle.
IsEmpty());
347 SetInternal(handle.
ptr());
353 static_assert(std::is_base_of<T, S>::value,
"type check");
357 SetInternal(handle.
ptr());
364 static_assert(std::is_base_of<T, S>::value,
"type check");
365#ifdef V8_ENABLE_CHECKS
366 internal::VerifyHandleIsNonEmpty(handle.
IsEmpty());
368 SetInternal(handle.
ptr());
374 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
379 SetInternal(handle.
ptr());
386 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
388#ifdef V8_ENABLE_CHECKS
389 internal::VerifyHandleIsNonEmpty(handle.
IsEmpty());
391 SetInternal(handle.
ptr());
396 static_assert(std::is_base_of<T, Number>::value,
"type check");
397 SetNonEmpty(Number::New(GetIsolate(), i));
402 static_assert(std::is_base_of<T, Integer>::value,
"type check");
405 SetInternal(I::IntToSmi(i));
408 SetNonEmpty(Integer::New(GetIsolate(), i));
413 static_assert(std::is_base_of<T, Integer>::value,
"type check");
415 bool fits_into_int32_t = (i & (1U << 31)) == 0;
417 Set(
static_cast<int32_t
>(i));
420 SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i));
425 static_assert(std::is_base_of<T, Integer>::value,
"type check");
427 static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::min()));
428 static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::max()));
429 SetInternal(I::IntToSmi(i));
434 static_assert(std::is_base_of<T, Boolean>::value,
"type check");
436#if V8_STATIC_ROOTS_BOOL
437#ifdef V8_ENABLE_CHECKS
438 internal::PerformCastCheck(
439 internal::ValueHelper::SlotAsValue<Value, true>(value_));
441 SetInternal(value ? I::StaticReadOnlyRoot::kTrueValue
442 : I::StaticReadOnlyRoot::kFalseValue);
446 root_index = I::kTrueValueRootIndex;
448 root_index = I::kFalseValueRootIndex;
450 *value_ = I::GetRoot(GetIsolate(), root_index);
457#if V8_STATIC_ROOTS_BOOL
458 SetInternal(I::StaticReadOnlyRoot::kTheHoleValue);
460 *value_ = I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
466 static_assert(std::is_base_of<T, Primitive>::value,
"type check");
468#if V8_STATIC_ROOTS_BOOL
469#ifdef V8_ENABLE_CHECKS
470 internal::PerformCastCheck(
471 internal::ValueHelper::SlotAsValue<Value, true>(value_));
473 SetInternal(I::StaticReadOnlyRoot::kNullValue);
475 *value_ = I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
481 static_assert(std::is_base_of<T, Primitive>::value,
"type check");
483#if V8_STATIC_ROOTS_BOOL
484#ifdef V8_ENABLE_CHECKS
485 internal::PerformCastCheck(
486 internal::ValueHelper::SlotAsValue<Value, true>(value_));
488 SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
490 *value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
496 static_assert(std::is_base_of<T, String>::value,
"type check");
498#if V8_STATIC_ROOTS_BOOL
499#ifdef V8_ENABLE_CHECKS
500 internal::PerformCastCheck(
501 internal::ValueHelper::SlotAsValue<Value, true>(value_));
503 SetInternal(I::StaticReadOnlyRoot::kEmptyString);
505 *value_ = I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
511 return *
reinterpret_cast<Isolate**
>(&value_[kIsolateValueIndex]);
517#if V8_STATIC_ROOTS_BOOL
518 if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) {
520 if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) {
525 internal::ValueHelper::SlotAsValue<Value>(value_));
531 static_assert(
sizeof(S) < 0,
"incompilable to prevent inadvertent misuse");
538 : implicit_args_(implicit_args), values_(values), length_(length) {}
543 if (i < 0 || length_ <= i)
return Undefined(GetIsolate());
560 return HolderSoonToBeDeprecated();
575 return *
reinterpret_cast<Isolate**
>(&implicit_args_[kIsolateIndex]);
585 return !NewTarget()->IsUndefined();
595 return *
reinterpret_cast<Isolate**
>(&args_[kIsolateIndex]);
621 if (args_[kShouldThrowOnErrorIndex] !=
622 I::IntToSmi(I::kInferShouldThrowMode)) {
623 return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
626 reinterpret_cast<v8::internal::Isolate*
>(GetIsolate()));
Definition: v8-traced-handle.h:125
Definition: v8-function-callback.h:109
Local< Object > HolderSoonToBeDeprecated() const
Definition: v8-function-callback.h:554
ReturnValue< T > GetReturnValue() const
Definition: v8-function-callback.h:579
Local< Object > This() const
Definition: v8-function-callback.h:548
Local< Object > Holder() const
Definition: v8-function-callback.h:559
Local< Value > operator[](int i) const
Definition: v8-function-callback.h:541
Isolate * GetIsolate() const
Definition: v8-function-callback.h:574
Local< Value > NewTarget() const
Definition: v8-function-callback.h:564
friend class debug::ConsoleCallArguments
Definition: v8-function-callback.h:156
friend class internal::FunctionCallbackArguments
Definition: v8-function-callback.h:154
Local< Value > Data() const
Definition: v8-function-callback.h:569
bool IsConstructCall() const
Definition: v8-function-callback.h:584
int Length() const
Definition: v8-function-callback.h:589
Definition: v8-persistent-handle.h:351
Definition: v8-isolate.h:210
Definition: v8-local-handle.h:258
Definition: v8-util.h:166
Definition: v8-function-callback.h:192
Local< Value > Data() const
Definition: v8-function-callback.h:599
friend class internal::PropertyCallbackArguments
Definition: v8-function-callback.h:289
friend class PropertyCallbackInfo
Definition: v8-function-callback.h:287
Local< Object > Holder() const
Definition: v8-function-callback.h:609
bool ShouldThrowOnError() const
Definition: v8-function-callback.h:619
ReturnValue< T > GetReturnValue() const
Definition: v8-function-callback.h:614
friend class MacroAssembler
Definition: v8-function-callback.h:288
Local< Object > This() const
Definition: v8-function-callback.h:604
Isolate * GetIsolate() const
Definition: v8-function-callback.h:594
Definition: v8-function-callback.h:35
void SetEmptyString()
Definition: v8-function-callback.h:495
friend class ReturnValue
Definition: v8-function-callback.h:78
ReturnValue(const ReturnValue< S > &that)
Definition: v8-function-callback.h:38
void SetNonEmpty(const Global< S > &handle)
Definition: v8-function-callback.h:342
Local< Value > Get() const
Definition: v8-function-callback.h:515
void SetNull()
Definition: v8-function-callback.h:465
Isolate * GetIsolate() const
Definition: v8-function-callback.h:510
void SetUndefined()
Definition: v8-function-callback.h:480
Definition: v8-container.h:148
internal::Address ptr() const
Definition: v8-handle-base.h:76
bool IsEmpty() const
Definition: v8-handle-base.h:56
Definition: v8-local-handle.h:74
Definition: v8-internal.h:729
const int kApiSystemPointerSize
Definition: v8-internal.h:44
bool ShouldThrowOnError(internal::Isolate *isolate)
uintptr_t Address
Definition: v8-internal.h:31
Definition: libplatform.h:15
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:839
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
Definition: v8-function-callback.h:308
#define V8_INLINE
Definition: v8config.h:477
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:580
#define V8_LIKELY(condition)
Definition: v8config.h:627
#define V8_UNLIKELY(condition)
Definition: v8config.h:626