Commit b63d4841 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[fastcall] Turn the options pointer to a reference

Refactor the {options} output parameter of the fast callback to a
reference, since it can never be nullptr for functions created with
MakeWithFallbackSupport. This allows embedders to spare the nullptr
check.

Bug: chromium:1052746
Change-Id: I3e22f07af4740ebe8522691da51b6addbc980f24
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2491026Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Auto-Submit: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70706}
parent 71df56fd
......@@ -37,12 +37,12 @@
* declare their method like:
*
* \code
* void FastMethodWithFallback(int param, FastApiCallbackOptions* options);
* void FastMethodWithFallback(int param, FastApiCallbackOptions& options);
* \endcode
*
* If the callback wants to signal an error condition or to perform an
* allocation, it must set options->fallback to true and do an early return from
* the fast method. Then V8 checks the value of options->fallback and if it's
* allocation, it must set options.fallback to true and do an early return from
* the fast method. Then V8 checks the value of options.fallback and if it's
* true, falls back to executing the SlowCallback, which is capable of reporting
* the error (either by throwing a JS exception or logging to the console) or
* doing the allocation. It's the embedder's responsibility to ensure that the
......
......@@ -27568,11 +27568,12 @@ DEFINE_OPERATORS_FOR_FLAGS(ApiCheckerResultFlags)
template <typename Value, typename Impl>
struct BasicApiChecker {
static void FastCallback(v8::ApiObject receiver, Value argument,
v8::FastApiCallbackOptions* options) {
v8::FastApiCallbackOptions& options) {
Impl::FastCallback(receiver, argument, options);
}
static void FastCallbackNoFallback(v8::ApiObject receiver, Value argument) {
Impl::FastCallback(receiver, argument, nullptr);
v8::FastApiCallbackOptions options;
Impl::FastCallback(receiver, argument, options);
}
static void SlowCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
Impl::SlowCallback(info);
......@@ -27622,10 +27623,10 @@ struct ApiNumberChecker : BasicApiChecker<T, ApiNumberChecker<T>> {
args_count_(args_count) {}
static void FastCallback(v8::ApiObject receiver, T argument,
v8::FastApiCallbackOptions* options) {
v8::FastApiCallbackOptions& options) {
v8::Object* receiver_obj = reinterpret_cast<v8::Object*>(&receiver);
if (!IsValidUnwrapObject(receiver_obj)) {
options->fallback = 1;
options.fallback = 1;
return;
}
ApiNumberChecker<T>* receiver_ptr =
......@@ -27638,8 +27639,8 @@ struct ApiNumberChecker : BasicApiChecker<T, ApiNumberChecker<T>> {
// the default behavior expected from the embedder. The value is checked
// against after loading it from a stack slot, as defined in
// EffectControlLinearizer::LowerFastApiCall.
CHECK_EQ(options->fallback, 0);
options->fallback = 1;
CHECK_EQ(options.fallback, 0);
options.fallback = 1;
}
}
......@@ -27674,7 +27675,7 @@ struct ApiNumberChecker : BasicApiChecker<T, ApiNumberChecker<T>> {
struct UnexpectedObjectChecker
: BasicApiChecker<v8::ApiObject, UnexpectedObjectChecker> {
static void FastCallback(v8::ApiObject receiver, v8::ApiObject argument,
v8::FastApiCallbackOptions* options) {
v8::FastApiCallbackOptions& options) {
v8::Object* receiver_obj = reinterpret_cast<v8::Object*>(&receiver);
UnexpectedObjectChecker* receiver_ptr =
GetInternalField<UnexpectedObjectChecker, kV8WrapperObjectIndex>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment