diff --git a/include/v8-fast-api-calls.h b/include/v8-fast-api-calls.h index f7b4469adc..cdf67decf6 100644 --- a/include/v8-fast-api-calls.h +++ b/include/v8-fast-api-calls.h @@ -70,8 +70,7 @@ * return GetInternalField(wrapper); * } - * static void FastMethod(v8::Value* receiver_obj, int param) { - * v8::Object* v8_object = v8::Object::Cast(receiver_obj); + * static void FastMethod(v8::Local receiver_obj, int param) { * CustomEmbedderType* receiver = static_cast( * receiver_obj->GetAlignedPointerFromInternalField( * kV8EmbedderWrapperObjectIndex)); @@ -210,7 +209,7 @@ class CTypeInfo { kFloat64, kV8Value, kApiObject, // This will be deprecated once all users have - // migrated from v8::ApiObject to v8::Value*. + // migrated from v8::ApiObject to v8::Local. }; // kCallbackOptionsType is not part of the Type enum @@ -315,7 +314,7 @@ class V8_EXPORT CFunction { }; }; -struct V8_DEPRECATE_SOON("Use v8::Value* instead.") ApiObject { +struct V8_DEPRECATE_SOON("Use v8::Local instead.") ApiObject { uintptr_t address; }; @@ -415,20 +414,22 @@ struct TypeInfoHelper { static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \ }; -#define BASIC_C_TYPES(V) \ - V(void, kVoid) \ - V(bool, kBool) \ - V(int32_t, kInt32) \ - V(uint32_t, kUint32) \ - V(int64_t, kInt64) \ - V(uint64_t, kUint64) \ - V(float, kFloat32) \ - V(double, kFloat64) \ - V(ApiObject, kApiObject) \ - V(v8::Local, kV8Value) +#define BASIC_C_TYPES(V) \ + V(void, kVoid) \ + V(bool, kBool) \ + V(int32_t, kInt32) \ + V(uint32_t, kUint32) \ + V(int64_t, kInt64) \ + V(uint64_t, kUint64) \ + V(float, kFloat32) \ + V(double, kFloat64) \ + V(ApiObject, kApiObject) \ + V(v8::Local, kV8Value) \ + V(v8::Local, kV8Value) // ApiObject was a temporary solution to wrap the pointer to the v8::Value. -// Please use v8::Value* in new code, as ApiObject will be deprecated soon. +// Please use v8::Local in new code for the arguments and +// v8::Local for the receiver, as ApiObject will be deprecated. BASIC_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR) diff --git a/src/d8/d8-test.cc b/src/d8/d8-test.cc index aa1cdfb9f1..21838002a2 100644 --- a/src/d8/d8-test.cc +++ b/src/d8/d8-test.cc @@ -37,13 +37,12 @@ namespace { class FastCApiObject { public: - static double AddAllFastCallback(Local receiver, bool should_fallback, + static double AddAllFastCallback(Local receiver, bool should_fallback, int32_t arg_i32, uint32_t arg_u32, int64_t arg_i64, uint64_t arg_u64, float arg_f32, double arg_f64, FastApiCallbackOptions& options) { - CHECK(receiver->IsObject()); - FastCApiObject* self = UnwrapObject(receiver.As()); + FastCApiObject* self = UnwrapObject(receiver); CHECK_SELF_OR_FALLBACK(0); self->fast_call_count_++; @@ -92,12 +91,11 @@ class FastCApiObject { args.GetReturnValue().Set(Number::New(isolate, sum)); } - static int Add32BitIntFastCallback(v8::Local receiver, + static int Add32BitIntFastCallback(v8::Local receiver, bool should_fallback, int32_t arg_i32, uint32_t arg_u32, FastApiCallbackOptions& options) { - CHECK(receiver->IsObject()); - FastCApiObject* self = UnwrapObject(receiver.As()); + FastCApiObject* self = UnwrapObject(receiver); CHECK_SELF_OR_FALLBACK(0); self->fast_call_count_++; @@ -128,12 +126,11 @@ class FastCApiObject { args.GetReturnValue().Set(Number::New(isolate, sum)); } - static bool IsFastCApiObjectFastCallback(v8::Local receiver, + static bool IsFastCApiObjectFastCallback(v8::Local receiver, bool should_fallback, v8::Local arg, FastApiCallbackOptions& options) { - CHECK(receiver->IsObject()); - FastCApiObject* self = UnwrapObject(receiver.As()); + FastCApiObject* self = UnwrapObject(receiver); CHECK_SELF_OR_FALLBACK(false); self->fast_call_count_++; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 10a0f1ef07..13a9704279 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -27680,7 +27680,7 @@ namespace { template struct BasicApiChecker { - static Ret FastCallback(v8::Local receiver, Value argument, + static Ret FastCallback(v8::Local receiver, Value argument, v8::FastApiCallbackOptions& options) { // TODO(mslekova): Refactor the data checking. v8::Value* data = &(options.data); @@ -27688,7 +27688,7 @@ struct BasicApiChecker { CHECK_EQ(v8::Number::Cast(data)->Value(), 42.0); return Impl::FastCallback(receiver, argument, options); } - static Ret FastCallbackNoFallback(v8::Local receiver, + static Ret FastCallbackNoFallback(v8::Local receiver, Value argument) { v8::FastApiCallbackOptions options = {false, {0}}; return Impl::FastCallback(receiver, argument, options); @@ -27730,9 +27730,9 @@ struct ApiNumberChecker : BasicApiChecker, void> { write_to_fallback_(write_to_fallback), args_count_(args_count) {} - static void FastCallback(v8::Local receiver, T argument, + static void FastCallback(v8::Local receiver, T argument, v8::FastApiCallbackOptions& options) { - v8::Object* receiver_obj = v8::Object::Cast(*receiver); + v8::Object* receiver_obj = *receiver; if (!IsValidUnwrapObject(receiver_obj)) { options.fallback = 1; return; @@ -27781,12 +27781,11 @@ struct ApiNumberChecker : BasicApiChecker, void> { struct UnexpectedObjectChecker : BasicApiChecker, UnexpectedObjectChecker, void> { - static void FastCallback(v8::Local receiver, + static void FastCallback(v8::Local receiver, v8::Local argument, v8::FastApiCallbackOptions& options) { - v8::Object* receiver_obj = v8::Object::Cast(*receiver); UnexpectedObjectChecker* receiver_ptr = - GetInternalField(receiver_obj); + GetInternalField(*receiver); receiver_ptr->SetCallFast(); if (argument->IsObject()) { v8::Object* argument_obj = v8::Object::Cast(*argument); @@ -27815,12 +27814,11 @@ struct ApiObjectChecker ApiObjectChecker(v8::FunctionTemplate* ctor, int data) : ctor_(ctor), initial_data_(data) {} - static void FastCallback(v8::Local receiver, + static void FastCallback(v8::Local receiver, v8::Local argument, v8::FastApiCallbackOptions& options) { - v8::Object* receiver_obj = v8::Object::Cast(*receiver); ApiObjectChecker* receiver_ptr = - GetInternalField(receiver_obj); + GetInternalField(*receiver); receiver_ptr->SetCallFast(); v8::Object* argument_obj = v8::Object::Cast(*argument); @@ -28003,11 +28001,10 @@ void CheckApiObjectArg() { template struct ReturnValueChecker : BasicApiChecker, T> { - static T FastCallback(v8::Local receiver, T arg, + static T FastCallback(v8::Local receiver, T arg, v8::FastApiCallbackOptions& options) { - v8::Object* receiver_obj = v8::Object::Cast(*receiver); ReturnValueChecker* receiver_ptr = - GetInternalField>(receiver_obj); + GetInternalField>(*receiver); receiver_ptr->SetCallFast(); return arg; } diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 27cd5643cb..2373fd2f3a 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -4071,17 +4071,16 @@ UNINITIALIZED_TEST(DetailedSourcePositionAPI_Inlining) { namespace { struct FastApiReceiver { - static void FastCallback(v8::Local receiver, int argument, + static void FastCallback(v8::Local receiver, int argument, v8::FastApiCallbackOptions& options) { // TODO(mslekova): The fallback is not used by the test. Replace this // with a CHECK. - v8::Object* receiver_obj = v8::Object::Cast(*receiver); - if (!IsValidUnwrapObject(receiver_obj)) { + if (!IsValidUnwrapObject(*receiver)) { options.fallback = 1; return; } FastApiReceiver* receiver_ptr = - GetInternalField(receiver_obj); + GetInternalField(*receiver); receiver_ptr->result_ |= ApiCheckerResult::kFastCalled;