Commit f1026c19 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[api] Add a check that FunctionTemplate getters have code

Attempting to set a FunctionTemplate without a code handler as an
accessor for a property will fail in the runtime, which expects to be
able to call the handler. Add an API check that guards against this.

Change-Id: I270f0ca3d20de507bc9bde2c4c8d23b2614313dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3879490Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83055}
parent 7cdd1ed3
......@@ -1188,6 +1188,15 @@ void Template::SetAccessorProperty(v8::Local<v8::Name> name,
v8::Local<FunctionTemplate> setter,
v8::PropertyAttribute attribute,
v8::AccessControl access_control) {
Utils::ApiCheck(
getter.IsEmpty() ||
!Utils::OpenHandle(*getter)->call_code(kAcquireLoad).IsUndefined(),
"v8::Template::SetAccessorProperty", "Getter must have a call handler");
Utils::ApiCheck(
setter.IsEmpty() ||
!Utils::OpenHandle(*setter)->call_code(kAcquireLoad).IsUndefined(),
"v8::Template::SetAccessorProperty", "Setter must have a call handler");
// TODO(verwaest): Remove |access_control|.
DCHECK_EQ(v8::DEFAULT, access_control);
auto templ = Utils::OpenHandle(this);
......
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