chore: bump chromium to 127.0.6521.0 (main) (#42118)

* chore: bump chromium in DEPS to 126.0.6470.0

* 5492605: Migrate TODOs referencing old crbug IDs to the new issue tracker IDs | 5492605

* 5513277: Move subresource-filter-ruleset to GCS | 5513277

* 5512656: Remove CustomizeChromeSupportsChromeRefresh2023 | 5512656

* 5516009: Accept mouse events in inactive window for Top Chrome WebUIs | 5516009

* 5376861: Change references to RWHVB in RWHIER and RenderWidgetTargeter to RWHVI. | 5376861

* 5490530: Use partition_alloc PA_BUILDFLAG(...) outside PA. #cleanup | 5490530

* 5296870: network: Allow trusted loaders to learn the sent request cookies. | 5296870

* 5453438: Delegate delegated ink trails to RWHI from RWHIER. | 5453438

* chore: update patches

* chore: bump chromium in DEPS to 126.0.6472.0

* chore: bump chromium in DEPS to 126.0.6474.0

* chore: update patches

* chore: bump chromium in DEPS to 126.0.6476.0

* chore: bump chromium in DEPS to 126.0.6478.0

* chore: bump chromium in DEPS to 126.0.6478.3

* chore: bump chromium in DEPS to 126.0.6478.8

* update patches

* only disable enterprise_cloud_content_analysis

* 5403888: [api] support v8::Data in v8::TracedReference and v8::EmbedderGraph

5403888

* chore: bump chromium in DEPS to 127.0.6484.0

* chore: bump chromium in DEPS to 127.0.6485.0

* 5539004: Use NOTREACHED_IN_MIGRATION() in remaining chrome/ | 5539004

* src: cast to v8::Value before using v8::EmbedderGraph::V8Node | https://github.com/nodejs/node/pull/52638/files

* chore: update patches

* chore: update v8 patches

* chore: bump chromium in DEPS to 127.0.6486.0

* chore: bump chromium in DEPS to 127.0.6488.0

* chore: bump chromium in DEPS to 127.0.6490.0

* chore: bump chromium in DEPS to 127.0.6492.0

* chore: update patches

For some reason, `feat_expose_raw_response_headers_from_urlloader.patch` got messed up in an earlier commit.

* chore: update patches

printing.patch was updated due to 5535938

* 5527572: Move Connectors prefs files to components/enterprise/connectors/

5527572

* chore: bump chromium in DEPS to 127.0.6494.0

* chore: bump chromium in DEPS to 127.0.6495.0

* chore: bump chromium in DEPS to 127.0.6496.0

* 5465511: [api] Mark v8::ObjectTemplate::SetAccessor(..) for deprecation
5465511

* chore: revert v8 deprecation

See patch message for more details.

5526611

* chore: update patches

* 5538771: Remove srcdoc else-if block in CalculateOrigin()
5538771

* 5522321: [devtools] Support saving base64 encoded files via host bindings
5522321

* 5376861: Change references to RWHVB in RWHIER and RenderWidgetTargeter to RWHVI.
5376861

* 5530163: [media] Use VideoFrame::Plane typed enum instead of nameless enum
5530163

* 5463431: iwa: Only create IsolatedWebAppURLLoaderFactory for subresources in IWAs
5463431

* fixup! 5465511: [api] Mark v8::ObjectTemplate::SetAccessor(..) for deprecation 5465511

* 5512176: Remove OnEnvironmentEstimationComplete()
5512176

* 5528282: Move Web Speech API .mojom files to //media/mojo/mojom
5528282

* 5513740: Reland "[Extensions] Restructure extensions::ProcessMap"
5513740

* 5483406: [PEPC] Make PEPC permission subscription take into account device status
5483406

* 5526034: [DoH] Remove kDnsOverHttps feature flag
5526034

The title is a bit misleading. They removed handling for the feature flag and generally intend to remove it but haven't yet.

I only changed our code to address the flag that was removed. A quick search on GitHub for `DnsOverHttpsFallback` yielded a few results, but they were all C++ chromium code or patches, 0 app code or discussion results. Since I couldn't find any evidence of this flag being used in developer applications, I've chosen to exclude this change from the breaking changes docs.

* chore: revert v8 removal

5497515

See patch message for more details.

* chore: cherry-pick Node.js patch for V8 API removal fix

Node.js PR: https://github.com/nodejs/node/pull/52996
V8 API Removal CL: 5539888

See the patch description for more details.

* 5492183: Extensions: CodeHealth: Give enums some class
5492183

* fixup! 5528282: Move Web Speech API .mojom files to //media/mojo/mojom 5528282

* 5514687: Reland "Add a secret handshake to the base::Feature constructor"
5514687

* fixup! 5530163: [media] Use VideoFrame::Plane typed enum instead of nameless enum 5530163

* 5466238: PDF Viewer: add metrics to record if PDF is opened with a11y
5466238

* 5502081: Migrate OnDisplayRemoved to OnDisplaysRemoved
5502081

* 5539888: [api] Remove several APIs deprecated in version 12.6
5539888

This commit essentially only removes the `only_terminate_in_safe_scope` isolate creation parameter. This undoes some work that was originally done in #35766.

* 5498236: Make browser_tests force full async initialization for OSCrypt Async
5498236

* fixup! 5528282: Move Web Speech API .mojom files to //media/mojo/mojom 5528282

* 5545807: Migrate most remaining NOTREACHED()
5545807

I took a systematic approach to modifying all of our uses of `NOTREACHED` that were causing errors:
* If there was a `return` or `break` (etc.) immediately after `NOTREACHED`, I removed the control flow instruction and left the `NOTREACHED` unmodified
* All other instances were migrated to `NOTREACHED_IN_MIGRATION`

We should revisit pretty much all usage of `NOTREACHED` as an upgrade follow-up item.

* fixup! 5526034: [DoH] Remove kDnsOverHttps feature flag 5526034

Turns out the feature flags were removed in the `.cc` file, but not the
`.h` feature list file. This means that the feature flags are pretty
much officially gone. (The leftover symbols in the header are likely an
oversight from what I can gather.)

We may potentially decide to put this in the breaking changes doc if we
decide this feature flag is important enough to highlight.

* chore: bump chromium in DEPS to 127.0.6498.3

* chore: bump chromium in DEPS to 127.0.6500.0

* chore: bump chromium in DEPS to 127.0.6502.0

* chore: bump chromium in DEPS to 127.0.6504.0

* chore: bump chromium in DEPS to 127.0.6505.0

* chore: bump chromium in DEPS to 127.0.6508.0

* build: use Sha256Sum in script/sysroots.json

Xref: 5506275

* chore: update chore_add_electron_deps_to_gitignores.patch

Xref: no manual changes; patch applied with fuzz 2

* chore: update feat_allow_code_cache_in_custom_schemes.patch

Xref: no manual changes; patch applied with fuzz 1

* chore: e patches all

* fixup! build: use Sha256Sum in script/sysroots.json

`sync` succeeds now

* chore: replace absl::optional with std::optional

Xref: 5253843

* chore: update CalculatePreferredSize() to new upstream semantics

Xref: 5459174
Xref: 5541220
Xref: 5514708
Xref: 5504212
Xref: https://chromium-review.googlesource.com/516542

* chore: replace absl::optional with std::optional

Xref: 5296147

* chore: add kPip to enumeration as a no-op

5546257

* [Autofill] Remove RenderFrame::ElementBoundsInWindow()

Xref: 5553982

* chore: fix feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch

need new header to pick up definition of BLINK_PLATFORM_EXPORT macro

Xref: 5463143

* chore: bump chromium in DEPS to 127.0.6510.0

* chore: update patches

* chore: fix include path for native_web_keyboard_event.h

Xref: 5541976

* chore: add currently-unused should_include_device_status arg to GetPermissionStatusForCurrentDocument()

Xref: 5545382

* chore: bump chromium in DEPS to 127.0.6512.0

* chore: update mas_avoid_private_macos_api_usage.patch.patch

No manual changes; patch applied with fuzz 1

* chore: update feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch

No manual changes; patch applied with fuzz 1

* chore: update webview_fullscreen.patch

No manual changes; patch applied with fuzz 1

* chore=: remove cherry-pick-22db6918bac9.patch

already present upstream

* chore: remove nonexistent patchfiles from .patches

* chore: remove cherry-pick-3e037e195e50.patch

no longer needed; merged upstream

* Update namespace for files moved to //components/input

Xref: 5563251

* Require client for InitParams to always specify an ownership mode.

Xref: 5532482

Xref: 5578714

* chore: e patches all

* fixup! Update namespace for files moved to //components/input

* chore: remove profile_keyed_service_factory, profile_selections from chromium_src

already being linked in via chrome browser for printing

* chore: bump chromium in DEPS to 127.0.6515.0

* chore: bump chromium in DEPS to 127.0.6516.0

* chore: update render_widget_host_view_base.patch

Xref: 5547803

patch applied manually due to simple upstream shear

* chore: update feat_allow_code_cache_in_custom_schemes.patch

No manual changes; patch applied with fuzz 1

* chore: e patches all

* Pull RWHIER and RWT to //content/common/input.

Xref: 5397681

* chore: bump chromium in DEPS to 127.0.6517.0

* chore: update patches

* fixup: Update namespace for files moved to //components/input

* Remove 0-arg (default) constructor for views::Widget::InitParams.

5578714

* fixup: only disable enterprise_cloud_content_analysis

The original commit a5480accc2, was due to this CL 5527572: Move Connectors prefs files to components/enterprise/connectors/ | 5527572

* chore: bump chromium in DEPS to 127.0.6519.0

* chore: update patches

* src: do not use deprecated V8 API

https://github.com/nodejs/node/pull/53084

* src: remove dependency on wrapper-descriptor-based cpp heap

https://github.com/nodejs/node/pull/53086

* 5344413: [DevTools] Add `getHostConfig` UI binding for sending status of `base::Features` to DevTools

5344413

* 5585788: Extensions: ManifestHandler: Separate Registry like ExtensionRegistry

5585788

* chore: update filenames.libcxx.gni

* 5506857: Reland "Migrate clang-format to gcs first class deps"

5506857

* fixup: 5539888: [api] Remove several APIs deprecated in version 12.6

* fixup:  5506857: Reland Migrate clang-format to gcs first class deps

* chore: bump chromium in DEPS to 127.0.6521.0

* chore: update patches

* spec: update navigator.keyboard should lock the keyboard

* Block or allow all MIDI using the existing SysEx permission

Refs 5154368
Refs 5499157

* spec: update test/parallel/test-v8-stats

* views: remove CalculatePreferredSize()

Refs 5504212

* chore: update patches after rebase

* 5560288: Re-enable ChromeOS XNNPack on Intel only

5560288

* chore: add nan patches for v8 changes

Refs
5539888: [api] Remove several APIs deprecated in version 12.6 | 5539888
and
5539852: [heap][api] Remove deprecated v8::Isolate::IdleNotificationDeadline | 5539852

* 5573603: Modularize //chrome/browser/themes

5573603

* 5539888: [api] Remove several APIs deprecated in version 12.6

5539888

* chore: update patches

* test: fixup navigator.keyboard.lock on Windows

* chore: remove unneeded profile target

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
electron-roller[bot] 2024-06-07 17:18:35 -04:00 committed by GitHub
parent 84e15e2d04
commit c3b4cd987c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
202 changed files with 1843 additions and 1127 deletions

View file

@ -34,7 +34,6 @@ fix_add_trusted_space_and_trusted_lo_space_to_the_v8_heap.patch
win_process_avoid_assert_after_spawning_store_app_4152.patch
chore_remove_use_of_deprecated_kmaxlength.patch
feat_optionally_prevent_calling_v8_enablewebassemblytraphandler.patch
build_only_create_cppgc_heap_on_non-32_bit_platforms.patch
src_update_default_v8_platform_to_override_functions_with_location.patch
fix_capture_embedder_exceptions_before_entering_v8.patch
spec_add_iterator_to_global_intrinsics.patch
@ -46,3 +45,8 @@ deprecate_vector_v8_local_in_v8.patch
fix_remove_deprecated_errno_constants.patch
build_enable_perfetto.patch
fix_add_source_location_for_v8_task_runner.patch
cherry-pick_src_remove_calls_to_recently_deprecated_v8_apis.patch
src_do_not_use_deprecated_v8_api.patch
src_use_new_v8_api_to_define_stream_accessor.patch
src_remove_dependency_on_wrapper-descriptor-based_cppheap.patch
test_update_v8-stats_test_for_v8_12_6.patch

View file

@ -1,56 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 27 Nov 2023 17:23:29 +0100
Subject: build: only create cppgc heap on non-32 bit platforms
Node.js crashes during heap marking when using cppgc on 32 bit platforms. Disable for now.
Crash occurs in the following stack:
* MarkingVisitorBase<ConcreteVisitor>::VisitEmbedderTracingSubClassWithEmbedderTracing
* MarkingWorklists::Local::PushExtractedWrapper
* CppMarkingState::MarkAndPush
* CppMarkingState::MarkAndPush
* WrappableInfo::From
* Crash
See https://gist.github.com/codebytere/275ec8923253fd6559b3d36115f7b31b for more.
This should be fixed and re-enabled on all platforms.
diff --git a/BUILD.gn b/BUILD.gn
index 2ce1e8a7dcca2ba153d387d11970c72b5f43c167..590303d1b78e2c28d7c3338196b12fcf14f65b28 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -181,6 +181,10 @@ config("node_internal_config") {
}
defines += [ "NODE_ARCH=\"$node_arch\"" ]
+ if (target_cpu == "x86" || target_cpu == "arm") {
+ defines += [ "NODE_RUNNING_32_BIT" ]
+ }
+
if (target_os == "win") {
node_platform = "win32"
} else if (target_os == "mac") {
diff --git a/src/env.cc b/src/env.cc
index 5c75e5b99d9415163640ab90f5891c0fee067a88..5f8bb37d117d82123b81f5f4b32735150184fa74 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -557,7 +557,8 @@ IsolateData::IsolateData(Isolate* isolate,
// for embedder ID, V8 could accidentally enable cppgc on them. So
// safe guard against this.
DCHECK_NE(descriptor.wrappable_type_index, BaseObject::kSlot);
- } else {
+ } else {
+#if !defined(NODE_RUNNING_32_BIT)
cpp_heap_ = CppHeap::Create(
platform,
CppHeapCreateParams{
@@ -565,6 +566,7 @@ IsolateData::IsolateData(Isolate* isolate,
WrapperDescriptor(
BaseObject::kEmbedderType, BaseObject::kSlot, cppgc_id)});
isolate->AttachCppHeap(cpp_heap_.get());
+#endif
}
// We do not care about overflow since we just want this to be different
// from the cppgc id.

View file

@ -0,0 +1,182 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Adam Klein <adamk@chromium.org>
Date: Wed, 15 May 2024 09:16:00 +0200
Subject: cherry-pick: src: remove calls to recently deprecated V8 APIs
Node.js Commit: a6d54f179d997497a95c18456bef6bc3ee15e2c4
Node.js PR: https://github.com/nodejs/node/pull/52996
V8 API Removal CL: https://chromium-review.googlesource.com/c/v8/v8/+/5539888
This patch is slightly modified from the original commit in order to
resolve conflicts due to the base commit difference between the Node.js
PR and the current upgrade roll.
This patch is expected to be deleted once we catch up with a Node.js
upgrade that includes the original Node.js commit above.
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 9ad67e0993da4c3e3f8a14681edbf941cf14e2e6..29ed378d32d452518dc929e60e6038ba4ca38a5c 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -186,8 +186,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
}
Local<String> source_text = args[2].As<String>();
- ScriptOrigin origin(isolate,
- url,
+ ScriptOrigin origin(url,
line_offset,
column_offset,
true, // is cross origin
@@ -394,7 +393,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
ShouldNotAbortOnUncaughtScope no_abort_scope(realm->env());
TryCatchScope try_catch(realm->env());
- Isolate::SafeForTerminationScope safe_for_termination(isolate);
bool timed_out = false;
bool received_signal = false;
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index f9a090f5c3e04403602ba383032e7f3230669a92..3f82db324d406e342abee23ab0d7f7c9807ff652 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -267,7 +267,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
std::string filename_s = std::string("node:") + id;
Local<String> filename =
OneByteString(isolate, filename_s.c_str(), filename_s.size());
- ScriptOrigin origin(isolate, filename, 0, 0, true);
+ ScriptOrigin origin(filename, 0, 0, true);
BuiltinCodeCacheData cached_data{};
{
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index df1d9cb4fd0442ec6ce6164a136b7a5fbcbe5b67..f6969e635f692b17b4efca1dfbee086a0199db6e 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -850,16 +850,15 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
host_defined_options->Set(
isolate, loader::HostDefinedOptions::kID, id_symbol);
- ScriptOrigin origin(isolate,
- filename,
- line_offset, // line offset
- column_offset, // column offset
- true, // is cross origin
- -1, // script id
- Local<Value>(), // source map URL
- false, // is opaque (?)
- false, // is WASM
- false, // is ES Module
+ ScriptOrigin origin(filename,
+ line_offset, // line offset
+ column_offset, // column offset
+ true, // is cross origin
+ -1, // script id
+ Local<Value>(), // source map URL
+ false, // is opaque (?)
+ false, // is WASM
+ false, // is ES Module
host_defined_options);
ScriptCompiler::Source source(code, origin, cached_data);
ScriptCompiler::CompileOptions compile_options =
@@ -971,7 +970,7 @@ MaybeLocal<Function> CompileFunction(Local<Context> context,
Local<String> filename,
Local<String> content,
std::vector<Local<String>>* parameters) {
- ScriptOrigin script_origin(context->GetIsolate(), filename, 0, 0, true);
+ ScriptOrigin script_origin(filename, 0, 0, true);
ScriptCompiler::Source script_source(content, script_origin);
return ScriptCompiler::CompileFunction(context,
@@ -1081,7 +1080,6 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
}
TryCatchScope try_catch(env);
- Isolate::SafeForTerminationScope safe_for_termination(env->isolate());
ContextifyScript* wrapped_script;
ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder(), false);
Local<UnboundScript> unbound_script =
@@ -1244,8 +1242,7 @@ void ContextifyContext::CompileFunction(
Local<PrimitiveArray> host_defined_options =
GetHostDefinedOptions(isolate, id_symbol);
ScriptCompiler::Source source =
- GetCommonJSSourceInstance(isolate,
- code,
+ GetCommonJSSourceInstance(code,
filename,
line_offset,
column_offset,
@@ -1300,15 +1297,13 @@ void ContextifyContext::CompileFunction(
}
ScriptCompiler::Source ContextifyContext::GetCommonJSSourceInstance(
- Isolate* isolate,
Local<String> code,
Local<String> filename,
int line_offset,
int column_offset,
Local<PrimitiveArray> host_defined_options,
ScriptCompiler::CachedData* cached_data) {
- ScriptOrigin origin(isolate,
- filename,
+ ScriptOrigin origin(filename,
line_offset, // line offset
column_offset, // column offset
true, // is cross origin
@@ -1486,7 +1481,7 @@ void ContextifyContext::ContainsModuleSyntax(
Local<PrimitiveArray> host_defined_options =
GetHostDefinedOptions(isolate, id_symbol);
ScriptCompiler::Source source = GetCommonJSSourceInstance(
- isolate, code, filename, 0, 0, host_defined_options, nullptr);
+ code, filename, 0, 0, host_defined_options, nullptr);
ScriptCompiler::CompileOptions options = GetCompileOptions(source);
std::vector<Local<String>> params = GetCJSParameters(env->isolate_data());
@@ -1534,7 +1529,7 @@ void ContextifyContext::ContainsModuleSyntax(
code,
String::NewFromUtf8(isolate, "})();").ToLocalChecked());
ScriptCompiler::Source wrapped_source = GetCommonJSSourceInstance(
- isolate, code, filename, 0, 0, host_defined_options, nullptr);
+ code, filename, 0, 0, host_defined_options, nullptr);
std::ignore = ScriptCompiler::CompileFunction(
context,
&wrapped_source,
@@ -1587,8 +1582,7 @@ static void CompileFunctionForCJSLoader(
Local<Symbol> symbol = env->vm_dynamic_import_default_internal();
Local<PrimitiveArray> hdo = GetHostDefinedOptions(isolate, symbol);
- ScriptOrigin origin(isolate,
- filename,
+ ScriptOrigin origin(filename,
0, // line offset
0, // column offset
true, // is cross origin
diff --git a/src/node_contextify.h b/src/node_contextify.h
index e96df803b7ec2aa1231d4ab5d4ae0fe863ceb672..d42b5e0c544e726fc3f6d8392a554df9aa480fe9 100644
--- a/src/node_contextify.h
+++ b/src/node_contextify.h
@@ -95,7 +95,6 @@ class ContextifyContext : public BaseObject {
v8::Local<v8::Symbol> id_symbol,
const errors::TryCatchScope& try_catch);
static v8::ScriptCompiler::Source GetCommonJSSourceInstance(
- v8::Isolate* isolate,
v8::Local<v8::String> code,
v8::Local<v8::String> filename,
int line_offset,
diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
index 64e38c83006a004ebc3519a5e9f8b04263244514..14e82cc80ff73084fb43b2ef07febfd2667a0abc 100644
--- a/test/cctest/test_environment.cc
+++ b/test/cctest/test_environment.cc
@@ -620,12 +620,9 @@ TEST_F(EnvironmentTest, SetImmediateMicrotasks) {
#ifndef _WIN32 // No SIGINT on Windows.
TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
- // We need to go through the whole setup dance here because we want to
- // set only_terminate_in_safe_scope.
// Allocate and initialize Isolate.
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = allocator.get();
- create_params.only_terminate_in_safe_scope = true;
v8::Isolate* isolate = v8::Isolate::Allocate();
CHECK_NOT_NULL(isolate);
platform->RegisterIsolate(isolate, &current_loop);

View file

@ -0,0 +1,118 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ishell <isheludko@gmail.com>
Date: Mon, 25 Mar 2024 15:45:41 +0100
Subject: src: do not use deprecated V8 API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Namely:
- `v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>, ...);`
- `v8::ObjectTemplate::SetNativeDataProperty` with `AccessControl`
Refs: https://github.com/v8/v8/commit/46c241eb99557fe8205acac5c526650c3847d180
Refs: https://github.com/v8/v8/commit/6ec883986bd417e2a42ddb960bd9449deb7e4639
Co-authored-by: Michaël Zasso <targos@protonmail.com>
PR-URL: https://github.com/nodejs/node/pull/53084
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
(cherry picked from commit 26d5cafff76d3a096ebfd7d7a6279d4b5b190230)
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index da8fed7b3013df10ae02be2070545c74d9a978f0..518b22dabef0974c2e7ecb466669925338524059 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -132,14 +132,14 @@ v8::EmbedderGraph::Node::Detachedness BaseObject::GetDetachedness() const {
template <int Field>
void BaseObject::InternalFieldGet(
- v8::Local<v8::String> property,
+ v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(
info.This()->GetInternalField(Field).As<v8::Value>());
}
-template <int Field, bool (v8::Value::* typecheck)() const>
-void BaseObject::InternalFieldSet(v8::Local<v8::String> property,
+template <int Field, bool (v8::Value::*typecheck)() const>
+void BaseObject::InternalFieldSet(v8::Local<v8::Name> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
// This could be e.g. value->IsFunction().
diff --git a/src/base_object.h b/src/base_object.h
index 5968694e8393d8434fb2ffee411dfac4c93aff29..5c16d0d1b32e2d056f4fcfa0e01781292932a0fa 100644
--- a/src/base_object.h
+++ b/src/base_object.h
@@ -111,10 +111,10 @@ class BaseObject : public MemoryRetainer {
// Setter/Getter pair for internal fields that can be passed to SetAccessor.
template <int Field>
- static void InternalFieldGet(v8::Local<v8::String> property,
+ static void InternalFieldGet(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info);
template <int Field, bool (v8::Value::*typecheck)() const>
- static void InternalFieldSet(v8::Local<v8::String> property,
+ static void InternalFieldSet(v8::Local<v8::Name> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info);
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 3f82db324d406e342abee23ab0d7f7c9807ff652..91ee97c0d1308e650730b9977facb924ab361bf5 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -11,7 +11,6 @@ namespace node {
namespace builtins {
using v8::Context;
-using v8::DEFAULT;
using v8::EscapableHandleScope;
using v8::Function;
using v8::FunctionCallbackInfo;
@@ -724,7 +723,6 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
nullptr,
Local<Value>(),
None,
- DEFAULT,
SideEffectType::kHasNoSideEffect);
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
@@ -732,7 +730,6 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
nullptr,
Local<Value>(),
None,
- DEFAULT,
SideEffectType::kHasNoSideEffect);
target->SetNativeDataProperty(
@@ -741,7 +738,6 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
nullptr,
Local<Value>(),
None,
- DEFAULT,
SideEffectType::kHasNoSideEffect);
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "natives"),
@@ -749,7 +745,6 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
nullptr,
Local<Value>(),
None,
- DEFAULT,
SideEffectType::kHasNoSideEffect);
SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage);
diff --git a/src/node_external_reference.h b/src/node_external_reference.h
index 17c0b2d7e1a440b5280a090ad043858faf99f009..24f0c6771720d8a6cdb684a0d562d01564d433f7 100644
--- a/src/node_external_reference.h
+++ b/src/node_external_reference.h
@@ -63,8 +63,6 @@ class ExternalReferenceRegistry {
V(CFunctionWithBool) \
V(const v8::CFunctionInfo*) \
V(v8::FunctionCallback) \
- V(v8::AccessorGetterCallback) \
- V(v8::AccessorSetterCallback) \
V(v8::AccessorNameGetterCallback) \
V(v8::AccessorNameSetterCallback) \
V(v8::GenericNamedPropertyDefinerCallback) \

View file

@ -0,0 +1,308 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Joyee Cheung <joyeec9h3@gmail.com>
Date: Wed, 29 May 2024 19:59:19 +0200
Subject: src: remove dependency on wrapper-descriptor-based CppHeap
As V8 has moved away from wrapper-descriptor-based CppHeap, this
patch:
1. Create the CppHeap without using wrapper descirptors.
2. Deprecates node::SetCppgcReference() in favor of
v8::Object::Wrap() since the wrapper descriptor is no longer
relevant. It is still kept as a compatibility layer for addons
that need to also work on Node.js versions without
v8::Object::Wrap().
(cherry picked from commit 30329d06235a9f9733b1d4da479b403462d1b326)
diff --git a/src/env-inl.h b/src/env-inl.h
index 63ce35ba68b48a55d8150395304bf86c2bf23aae..c6fc53d1666ae51e69257c9bbcaf4cbff36cbad3 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -62,31 +62,6 @@ inline uv_loop_t* IsolateData::event_loop() const {
return event_loop_;
}
-inline void IsolateData::SetCppgcReference(v8::Isolate* isolate,
- v8::Local<v8::Object> object,
- void* wrappable) {
- v8::CppHeap* heap = isolate->GetCppHeap();
- CHECK_NOT_NULL(heap);
- v8::WrapperDescriptor descriptor = heap->wrapper_descriptor();
- uint16_t required_size = std::max(descriptor.wrappable_instance_index,
- descriptor.wrappable_type_index);
- CHECK_GT(object->InternalFieldCount(), required_size);
-
- uint16_t* id_ptr = nullptr;
- {
- Mutex::ScopedLock lock(isolate_data_mutex_);
- auto it =
- wrapper_data_map_.find(descriptor.embedder_id_for_garbage_collected);
- CHECK_NE(it, wrapper_data_map_.end());
- id_ptr = &(it->second->cppgc_id);
- }
-
- object->SetAlignedPointerInInternalField(descriptor.wrappable_type_index,
- id_ptr);
- object->SetAlignedPointerInInternalField(descriptor.wrappable_instance_index,
- wrappable);
-}
-
inline uint16_t* IsolateData::embedder_id_for_cppgc() const {
return &(wrapper_data_->cppgc_id);
}
diff --git a/src/env.cc b/src/env.cc
index 5c75e5b99d9415163640ab90f5891c0fee067a88..17b389ae3e1eea52d02b3f3ffdf67fd489e6bf42 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -22,6 +22,7 @@
#include "util-inl.h"
#include "v8-cppgc.h"
#include "v8-profiler.h"
+#include "v8-sandbox.h" // v8::Object::Wrap(), v8::Object::Unwrap()
#include <algorithm>
#include <atomic>
@@ -68,7 +69,6 @@ using v8::TryCatch;
using v8::Uint32;
using v8::Undefined;
using v8::Value;
-using v8::WrapperDescriptor;
using worker::Worker;
int const ContextEmbedderTag::kNodeContextTag = 0x6e6f64;
@@ -518,6 +518,14 @@ void IsolateData::CreateProperties() {
CreateEnvProxyTemplate(this);
}
+// Previously, the general convention of the wrappable layout for cppgc in
+// the ecosystem is:
+// [ 0 ] -> embedder id
+// [ 1 ] -> wrappable instance
+// Now V8 has deprecated this layout-based tracing enablement, embedders
+// should simply use v8::Object::Wrap() and v8::Object::Unwrap(). We preserve
+// this layout only to distinguish internally how the memory of a Node.js
+// wrapper is managed or whether a wrapper is managed by Node.js.
constexpr uint16_t kDefaultCppGCEmebdderID = 0x90de;
Mutex IsolateData::isolate_data_mutex_;
std::unordered_map<uint16_t, std::unique_ptr<PerIsolateWrapperData>>
@@ -539,36 +547,16 @@ IsolateData::IsolateData(Isolate* isolate,
v8::CppHeap* cpp_heap = isolate->GetCppHeap();
uint16_t cppgc_id = kDefaultCppGCEmebdderID;
- if (cpp_heap != nullptr) {
- // The general convention of the wrappable layout for cppgc in the
- // ecosystem is:
- // [ 0 ] -> embedder id
- // [ 1 ] -> wrappable instance
- // If the Isolate includes a CppHeap attached by another embedder,
- // And if they also use the field 0 for the ID, we DCHECK that
- // the layout matches our layout, and record the embedder ID for cppgc
- // to avoid accidentally enabling cppgc on non-cppgc-managed wrappers .
- v8::WrapperDescriptor descriptor = cpp_heap->wrapper_descriptor();
- if (descriptor.wrappable_type_index == BaseObject::kEmbedderType) {
- cppgc_id = descriptor.embedder_id_for_garbage_collected;
- DCHECK_EQ(descriptor.wrappable_instance_index, BaseObject::kSlot);
- }
- // If the CppHeap uses the slot we use to put non-cppgc-traced BaseObject
- // for embedder ID, V8 could accidentally enable cppgc on them. So
- // safe guard against this.
- DCHECK_NE(descriptor.wrappable_type_index, BaseObject::kSlot);
- } else {
- cpp_heap_ = CppHeap::Create(
- platform,
- CppHeapCreateParams{
- {},
- WrapperDescriptor(
- BaseObject::kEmbedderType, BaseObject::kSlot, cppgc_id)});
- isolate->AttachCppHeap(cpp_heap_.get());
- }
// We do not care about overflow since we just want this to be different
// from the cppgc id.
uint16_t non_cppgc_id = cppgc_id + 1;
+ if (cpp_heap == nullptr) {
+ cpp_heap_ = CppHeap::Create(platform, v8::CppHeapCreateParams{{}});
+ // TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8
+ // own it when we can keep the isolate registered/task runner discoverable
+ // during isolate disposal.
+ isolate->AttachCppHeap(cpp_heap_.get());
+ }
{
// GC could still be run after the IsolateData is destroyed, so we store
@@ -600,11 +588,12 @@ IsolateData::~IsolateData() {
}
}
-// Public API
+// Deprecated API, embedders should use v8::Object::Wrap() directly instead.
void SetCppgcReference(Isolate* isolate,
Local<Object> object,
void* wrappable) {
- IsolateData::SetCppgcReference(isolate, object, wrappable);
+ v8::Object::Wrap<v8::CppHeapPointerTag::kDefaultTag>(
+ isolate, object, wrappable);
}
void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
diff --git a/src/env.h b/src/env.h
index 910c69b6d1d17ef25201dbb39d3d074f4f3f011f..5fd375f143dd529c83aca59348182cce47d3abf8 100644
--- a/src/env.h
+++ b/src/env.h
@@ -164,10 +164,6 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
uint16_t* embedder_id_for_cppgc() const;
uint16_t* embedder_id_for_non_cppgc() const;
- static inline void SetCppgcReference(v8::Isolate* isolate,
- v8::Local<v8::Object> object,
- void* wrappable);
-
inline uv_loop_t* event_loop() const;
inline MultiIsolatePlatform* platform() const;
inline const SnapshotData* snapshot_data() const;
diff --git a/src/node.h b/src/node.h
index 76e2459eceed127e69c686f26fd5bd369b81f1af..37f310cbda4b69857ff505ea25c99e43790deeb6 100644
--- a/src/node.h
+++ b/src/node.h
@@ -1561,24 +1561,14 @@ void RegisterSignalHandler(int signal,
bool reset_handler = false);
#endif // _WIN32
-// Configure the layout of the JavaScript object with a cppgc::GarbageCollected
-// instance so that when the JavaScript object is reachable, the garbage
-// collected instance would have its Trace() method invoked per the cppgc
-// contract. To make it work, the process must have called
-// cppgc::InitializeProcess() before, which is usually the case for addons
-// loaded by the stand-alone Node.js executable. Embedders of Node.js can use
-// either need to call it themselves or make sure that
-// ProcessInitializationFlags::kNoInitializeCppgc is *not* set for cppgc to
-// work.
-// If the CppHeap is owned by Node.js, which is usually the case for addon,
-// the object must be created with at least two internal fields available,
-// and the first two internal fields would be configured by Node.js.
-// This may be superseded by a V8 API in the future, see
-// https://bugs.chromium.org/p/v8/issues/detail?id=13960. Until then this
-// serves as a helper for Node.js isolates.
-NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate,
- v8::Local<v8::Object> object,
- void* wrappable);
+// This is kept as a compatibility layer for addons to wrap cppgc-managed
+// objects on Node.js versions without v8::Object::Wrap(). Addons created to
+// work with only Node.js versions with v8::Object::Wrap() should use that
+// instead.
+NODE_DEPRECATED("Use v8::Object::Wrap()",
+ NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate,
+ v8::Local<v8::Object> object,
+ void* wrappable));
} // namespace node
diff --git a/test/addons/cppgc-object/binding.cc b/test/addons/cppgc-object/binding.cc
index 1b70ff11dc561abdc5ac794f6280557d5c428239..7fc16a87b843ce0626ee137a07c3ccb7f4cc6493 100644
--- a/test/addons/cppgc-object/binding.cc
+++ b/test/addons/cppgc-object/binding.cc
@@ -1,8 +1,10 @@
+#include <assert.h>
#include <cppgc/allocation.h>
#include <cppgc/garbage-collected.h>
#include <cppgc/heap.h>
#include <node.h>
#include <v8-cppgc.h>
+#include <v8-sandbox.h>
#include <v8.h>
#include <algorithm>
@@ -15,8 +17,10 @@ class CppGCed : public cppgc::GarbageCollected<CppGCed> {
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> js_object = args.This();
- CppGCed* gc_object = cppgc::MakeGarbageCollected<CppGCed>(
- isolate->GetCppHeap()->GetAllocationHandle());
+ auto* heap = isolate->GetCppHeap();
+ assert(heap != nullptr);
+ CppGCed* gc_object =
+ cppgc::MakeGarbageCollected<CppGCed>(heap->GetAllocationHandle());
node::SetCppgcReference(isolate, js_object, gc_object);
args.GetReturnValue().Set(js_object);
}
@@ -24,12 +28,6 @@ class CppGCed : public cppgc::GarbageCollected<CppGCed> {
static v8::Local<v8::Function> GetConstructor(
v8::Local<v8::Context> context) {
auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New);
- auto ot = ft->InstanceTemplate();
- v8::WrapperDescriptor descriptor =
- context->GetIsolate()->GetCppHeap()->wrapper_descriptor();
- uint16_t required_size = std::max(descriptor.wrappable_instance_index,
- descriptor.wrappable_type_index);
- ot->SetInternalFieldCount(required_size + 1);
return ft->GetFunction(context).ToLocalChecked();
}
diff --git a/test/cctest/test_cppgc.cc b/test/cctest/test_cppgc.cc
index 49665174615870b4f70529b1d548e593846140a1..edd413ae9b956b2e59e8166785adef6a8ff06d51 100644
--- a/test/cctest/test_cppgc.cc
+++ b/test/cctest/test_cppgc.cc
@@ -3,16 +3,12 @@
#include <cppgc/heap.h>
#include <node.h>
#include <v8-cppgc.h>
+#include <v8-sandbox.h>
#include <v8.h>
#include "node_test_fixture.h"
// This tests that Node.js can work with an existing CppHeap.
-// Mimic the Blink layout.
-static int kWrappableTypeIndex = 0;
-static int kWrappableInstanceIndex = 1;
-static uint16_t kEmbedderID = 0x1;
-
// Mimic a class that does not know about Node.js.
class CppGCed : public cppgc::GarbageCollected<CppGCed> {
public:
@@ -23,12 +19,11 @@ class CppGCed : public cppgc::GarbageCollected<CppGCed> {
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> js_object = args.This();
- CppGCed* gc_object = cppgc::MakeGarbageCollected<CppGCed>(
- isolate->GetCppHeap()->GetAllocationHandle());
- js_object->SetAlignedPointerInInternalField(kWrappableTypeIndex,
- &kEmbedderID);
- js_object->SetAlignedPointerInInternalField(kWrappableInstanceIndex,
- gc_object);
+ auto* heap = isolate->GetCppHeap();
+ CHECK_NOT_NULL(heap);
+ CppGCed* gc_object =
+ cppgc::MakeGarbageCollected<CppGCed>(heap->GetAllocationHandle());
+ node::SetCppgcReference(isolate, js_object, gc_object);
kConstructCount++;
args.GetReturnValue().Set(js_object);
}
@@ -36,8 +31,6 @@ class CppGCed : public cppgc::GarbageCollected<CppGCed> {
static v8::Local<v8::Function> GetConstructor(
v8::Local<v8::Context> context) {
auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New);
- auto ot = ft->InstanceTemplate();
- ot->SetInternalFieldCount(2);
return ft->GetFunction(context).ToLocalChecked();
}
@@ -58,12 +51,12 @@ TEST_F(NodeZeroIsolateTestFixture, ExistingCppHeapTest) {
// Create and attach the CppHeap before we set up the IsolateData so that
// it recognizes the existing heap.
- std::unique_ptr<v8::CppHeap> cpp_heap = v8::CppHeap::Create(
- platform.get(),
- v8::CppHeapCreateParams(
- {},
- v8::WrapperDescriptor(
- kWrappableTypeIndex, kWrappableInstanceIndex, kEmbedderID)));
+ std::unique_ptr<v8::CppHeap> cpp_heap =
+ v8::CppHeap::Create(platform.get(), v8::CppHeapCreateParams{{}});
+
+ // TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8
+ // own it when we can keep the isolate registered/task runner discoverable
+ // during isolate disposal.
isolate->AttachCppHeap(cpp_heap.get());
// Try creating Context + IsolateData + Environment.

View file

@ -0,0 +1,153 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Igor Sheludko <isheludko@gmail.com>
Date: Tue, 30 Apr 2024 15:22:06 +0200
Subject: src: use new V8 API to define stream accessor
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Define XxxStream.prototype.onread as an accessor in JavaScript sense.
Previously it was defined via soon-to-be-deprecated
`v8::ObjectTemplate::SetAccessor(..)` which used to call setter even
for property stores via stream object.
The replacement V8 API `v8::ObjectTemplate::SetNativeDataProperty(..)`
defines a properly behaving data property and thus a store to a stream
object will not trigger the "onread" setter callback.
In order to preserve the desired behavior of storing the value in the
receiver's internal field the "onread" property should be defined as
a proper JavaScript accessor.
PR-URL: https://github.com/nodejs/node/pull/53084
Refs: https://github.com/v8/v8/commit/46c241eb99557fe8205acac5c526650c3847d180
Refs: https://github.com/v8/v8/commit/6ec883986bd417e2a42ddb960bd9449deb7e4639
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
(cherry picked from commit bd151552ef35b0eed415eb1c50d30dafd341cee8)
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index 518b22dabef0974c2e7ecb466669925338524059..61f30b3cfbdb0f3d21fe8e93dc97c55162b69a69 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -132,19 +132,18 @@ v8::EmbedderGraph::Node::Detachedness BaseObject::GetDetachedness() const {
template <int Field>
void BaseObject::InternalFieldGet(
- v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(
- info.This()->GetInternalField(Field).As<v8::Value>());
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ args.GetReturnValue().Set(
+ args.This()->GetInternalField(Field).As<v8::Value>());
}
template <int Field, bool (v8::Value::*typecheck)() const>
-void BaseObject::InternalFieldSet(v8::Local<v8::Name> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info) {
+void BaseObject::InternalFieldSet(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Local<v8::Value> value = args[0];
// This could be e.g. value->IsFunction().
CHECK(((*value)->*typecheck)());
- info.This()->SetInternalField(Field, value);
+ args.This()->SetInternalField(Field, value);
}
bool BaseObject::has_pointer_data() const {
diff --git a/src/base_object.h b/src/base_object.h
index 5c16d0d1b32e2d056f4fcfa0e01781292932a0fa..ce6277dec5a2b9313ecd3699b39ec17585d5adc5 100644
--- a/src/base_object.h
+++ b/src/base_object.h
@@ -111,12 +111,9 @@ class BaseObject : public MemoryRetainer {
// Setter/Getter pair for internal fields that can be passed to SetAccessor.
template <int Field>
- static void InternalFieldGet(v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
+ static void InternalFieldGet(const v8::FunctionCallbackInfo<v8::Value>& args);
template <int Field, bool (v8::Value::*typecheck)() const>
- static void InternalFieldSet(v8::Local<v8::Name> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info);
+ static void InternalFieldSet(const v8::FunctionCallbackInfo<v8::Value>& args);
// This is a bit of a hack. See the override in async_wrap.cc for details.
virtual bool IsDoneInitializing() const;
diff --git a/src/stream_base.cc b/src/stream_base.cc
index af714734f49b836de79ebb25e61f1376b757d5ed..a8f9f98d413c8573eb22960a4cefb47408215469 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -492,6 +492,29 @@ Local<Object> StreamBase::GetObject() {
return GetAsyncWrap()->object();
}
+void StreamBase::AddAccessor(v8::Isolate* isolate,
+ v8::Local<v8::Signature> signature,
+ enum v8::PropertyAttribute attributes,
+ v8::Local<v8::FunctionTemplate> t,
+ JSMethodFunction* getter,
+ JSMethodFunction* setter,
+ v8::Local<v8::String> string) {
+ Local<FunctionTemplate> getter_templ =
+ NewFunctionTemplate(isolate,
+ getter,
+ signature,
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect);
+ Local<FunctionTemplate> setter_templ =
+ NewFunctionTemplate(isolate,
+ setter,
+ signature,
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
+ t->PrototypeTemplate()->SetAccessorProperty(
+ string, getter_templ, setter_templ, attributes);
+}
+
void StreamBase::AddMethod(Isolate* isolate,
Local<Signature> signature,
enum PropertyAttribute attributes,
@@ -561,11 +584,14 @@ void StreamBase::AddMethods(IsolateData* isolate_data,
JSMethod<&StreamBase::WriteString<LATIN1>>);
t->PrototypeTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "isStreamBase"),
True(isolate));
- t->PrototypeTemplate()->SetAccessor(
- FIXED_ONE_BYTE_STRING(isolate, "onread"),
- BaseObject::InternalFieldGet<StreamBase::kOnReadFunctionField>,
- BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField,
- &Value::IsFunction>);
+ AddAccessor(isolate,
+ sig,
+ static_cast<PropertyAttribute>(DontDelete | DontEnum),
+ t,
+ BaseObject::InternalFieldGet<StreamBase::kOnReadFunctionField>,
+ BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField,
+ &Value::IsFunction>,
+ FIXED_ONE_BYTE_STRING(isolate, "onread"));
}
void StreamBase::RegisterExternalReferences(
diff --git a/src/stream_base.h b/src/stream_base.h
index 62a8928e144ad6aa67eeccdbc46d44da22887fb8..ccbd769ceaf3c1e024defb3104e601d037c98b6a 100644
--- a/src/stream_base.h
+++ b/src/stream_base.h
@@ -413,6 +413,13 @@ class StreamBase : public StreamResource {
EmitToJSStreamListener default_listener_;
void SetWriteResult(const StreamWriteResult& res);
+ static void AddAccessor(v8::Isolate* isolate,
+ v8::Local<v8::Signature> sig,
+ enum v8::PropertyAttribute attributes,
+ v8::Local<v8::FunctionTemplate> t,
+ JSMethodFunction* getter,
+ JSMethodFunction* setter,
+ v8::Local<v8::String> str);
static void AddMethod(v8::Isolate* isolate,
v8::Local<v8::Signature> sig,
enum v8::PropertyAttribute attributes,

View file

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "targos@protonmail.com" <targos@protonmail.com>
Date: Thu, 9 May 2024 12:00:39 +0200
Subject: test: update v8-stats test for V8 12.6
Refs: https://github.com/v8/v8/commit/e30e228ee6e034de49a40af0173113198a19b497
diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js
index 2366cbf716c11851bb3a759dce5db47d616516dc..9d2971ba9411bb98107f6a9acc8a07ec438b76e5 100644
--- a/test/parallel/test-v8-stats.js
+++ b/test/parallel/test-v8-stats.js
@@ -48,6 +48,8 @@ const expectedHeapSpaces = [
'read_only_space',
'shared_large_object_space',
'shared_space',
+ 'shared_trusted_large_object_space',
+ 'shared_trusted_space',
'trusted_large_object_space',
'trusted_space'
];