Commit 0c3b4220 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[compiler] Fix fast_c_api test object constructor

This CL fixes the behaviour of the d8.test.fast_c_api constructor when
the global object has been modified by not allowing calls to it without
the `new` keyword.

Bug: chromium:1196597
Change-Id: I49b4a412d501f5c9adaa72b63beec1483ab4c449
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2808943
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73831}
parent 22282cab
......@@ -167,7 +167,15 @@ class FastCApiObject {
thread_local FastCApiObject kFastCApiObject;
} // namespace
// TODO(mslekova): Rename the fast_c_api helper to FastCAPI.
void CreateObject(const FunctionCallbackInfo<Value>& info) {
if (!info.IsConstructCall()) {
info.GetIsolate()->ThrowException(
v8::Exception::Error(String::NewFromUtf8Literal(
info.GetIsolate(),
"FastCAPI helper must be constructed with new.")));
return;
}
Local<Object> api_object = info.Holder();
api_object->SetAlignedPointerInInternalField(
FastCApiObject::kV8WrapperObjectIndex,
......
......@@ -9,6 +9,8 @@
// --always-opt is disabled because we rely on particular feedback for
// optimizing to the fastest path.
// Flags: --no-always-opt
assertThrows(() => d8.test.fast_c_api());
const fast_c_api = new d8.test.fast_c_api();
// ----------- add_all -----------
......
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