Commit 6229eee3 authored by snek's avatar snek Committed by V8 LUCI CQ

[fastcall] fix options.data representation

The representation of `options.data` was previously refactored to
`v8::Value` when removing `v8::ApiObject`, but this is invalid for a
number of reasons (SMIs, v8::Value being a ZST, etc). To fix this, it
has been changed to `Local<Value>`, which also matches the
representation used for other fastcall parameters.

Bug: chromium:1052746
Change-Id: Ia4450bf3d908d4e1b7a85d6bd7ab45ea5f5f08f4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3844662Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: snek <snek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82843}
parent ad6b1249
......@@ -569,7 +569,7 @@ struct FastApiCallbackOptions {
*/
union {
uintptr_t data_ptr;
v8::Value data;
v8::Local<v8::Value> data;
};
/**
......
......@@ -309,11 +309,18 @@ Node* FastApiCallBuilder::Build(const FastApiCallFunctionVector& c_functions,
stack_slot,
static_cast<int>(offsetof(v8::FastApiCallbackOptions, fallback)),
__ Int32Constant(0));
Node* data_stack_slot = __ StackSlot(sizeof(uintptr_t), alignof(uintptr_t));
__ Store(
StoreRepresentation(MachineType::PointerRepresentation(),
kNoWriteBarrier),
data_stack_slot, 0, data_argument);
__ Store(StoreRepresentation(MachineType::PointerRepresentation(),
kNoWriteBarrier),
stack_slot,
static_cast<int>(offsetof(v8::FastApiCallbackOptions, data)),
data_argument);
data_stack_slot);
initialize_options_(stack_slot);
......
......@@ -27625,9 +27625,8 @@ struct BasicApiChecker {
static Ret FastCallback(v8::Local<v8::Object> receiver, Value argument,
v8::FastApiCallbackOptions& options) {
// TODO(mslekova): Refactor the data checking.
v8::Value* data = &(options.data);
CHECK(data->IsNumber());
CHECK_EQ(v8::Number::Cast(data)->Value(), 42.0);
CHECK(options.data->IsNumber());
CHECK_EQ(Local<v8::Number>::Cast(options.data)->Value(), 42.5);
return Impl::FastCallback(receiver, argument, options);
}
static Ret FastCallbackNoFallback(v8::Local<v8::Object> receiver,
......@@ -27859,7 +27858,7 @@ bool SetupTest(v8::Local<v8::Value> initial_value, LocalContext* env,
Local<v8::FunctionTemplate> checker_templ = v8::FunctionTemplate::New(
isolate, BasicApiChecker<Value, Impl, Ret>::SlowCallback,
v8::Number::New(isolate, 42), v8::Local<v8::Signature>(), 1,
v8::Number::New(isolate, 42.5), v8::Local<v8::Signature>(), 1,
v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasSideEffect,
&c_func);
if (!accept_any_receiver) {
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