deps: V8: backport f3d4d458fe59

Original commit message:

    [cleanup] Remove --js-float16array

    Remove the --js-float16array flag and incorporate Float16Array into the
    standard typed array macros and baseline snapshot unconditionally.
    Float16Array has been shipping by default since M138.

    Bug: 548385945
    TAG=agy
    CONV=052f499d-4ee5-4a10-8afd-900ba4a338db

    Change-Id: I2c0012158febf422fdc1b866b9414f3f040e83ad
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8264275
    Reviewed-by: Nikolaos Papaspyrou <nikolaos@chromium.org>
    Auto-Submit: Olivier Flückiger <olivf@chromium.org>
    Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#109335}

Refs: https://github.com/v8/v8/commit/f3d4d458fe597b7c949c78f192a87f9d804c9520
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65702
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
Olivier FlückigerandAntoine du Hamel authored and Antoine du Hamel committed 2026-09-15 10:49:28 +02:00
1 parent b4b89c08c1
commit 82715158b8
12 files changed
+16 -140

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.28',
'v8_embedder_string': '-node.29',
##### V8 defaults for Node.js #####
-56
View File
@@ -3741,14 +3741,6 @@ bool Value::IsTypedArray() const {
TYPED_ARRAYS_BASE(VALUE_IS_TYPED_ARRAY)
#undef VALUE_IS_TYPED_ARRAY
bool Value::IsFloat16Array() const {
auto obj = *Utils::OpenDirectHandle(this);
return i::IsJSTypedArray(obj) &&
i::Cast<i::JSTypedArray>(obj)->type() == i::kExternalFloat16Array &&
Utils::ApiCheck(i::v8_flags.js_float16array, "Value::IsFloat16Array",
"Float16Array is not supported");
}
bool Value::IsDataView() const {
auto obj = *Utils::OpenDirectHandle(this);
return IsJSDataView(obj) || IsJSRabGsabDataView(obj);
@@ -4292,16 +4284,6 @@ void v8::TypedArray::CheckCast(Value* that) {
TYPED_ARRAYS_BASE(CHECK_TYPED_ARRAY_CAST)
#undef CHECK_TYPED_ARRAY_CAST
void v8::Float16Array::CheckCast(Value* that) {
Utils::ApiCheck(i::v8_flags.js_float16array, "v8::Float16Array::Cast",
"Float16Array is not supported");
auto obj = *Utils::OpenDirectHandle(that);
Utils::ApiCheck(
i::IsJSTypedArray(obj) &&
i::Cast<i::JSTypedArray>(obj)->type() == i::kExternalFloat16Array,
"v8::Float16Array::Cast()", "Value is not a Float16Array");
}
void v8::DataView::CheckCast(Value* that) {
auto obj = *Utils::OpenDirectHandle(that);
Utils::ApiCheck(i::IsJSDataView(obj) || IsJSRabGsabDataView(obj),
@@ -9347,44 +9329,6 @@ static_assert(v8::TypedArray::kMaxByteLength == i::JSTypedArray::kMaxByteLength,
TYPED_ARRAYS_BASE(TYPED_ARRAY_NEW)
#undef TYPED_ARRAY_NEW
Local<Float16Array> Float16Array::New(Local<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length) {
Utils::ApiCheck(i::v8_flags.js_float16array, "v8::Float16Array::New",
"Float16Array is not supported");
i::Isolate* i_isolate = i::Isolate::Current();
ApiRuntimeCallStatsScope rcs_scope(i_isolate, RCCId::kAPI_Float16Array_New);
EnterV8NoScriptNoExceptionScope api_scope(i_isolate);
if (!Utils::ApiCheck(
length <= kMaxLength,
"v8::Float16Array::New(Local<ArrayBuffer>, size_t, size_t)",
"length exceeds max allowed value")) {
return {};
}
auto buffer = Utils::OpenDirectHandle(*array_buffer);
i::DirectHandle<i::JSTypedArray> obj = i_isolate->factory()->NewJSTypedArray(
i::kExternalFloat16Array, buffer, byte_offset, length);
return Utils::ToLocalFloat16Array(obj);
}
Local<Float16Array> Float16Array::New(
Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
size_t length) {
Utils::ApiCheck(i::v8_flags.js_float16array, "v8::Float16Array::New",
"Float16Array is not supported");
i::Isolate* i_isolate = i::Isolate::Current();
ApiRuntimeCallStatsScope rcs_scope(i_isolate, RCCId::kAPI_Float16Array_New);
EnterV8NoScriptNoExceptionScope api_scope(i_isolate);
if (!Utils::ApiCheck(
length <= kMaxLength,
"v8::Float16Array::New(Local<SharedArrayBuffer>, size_t, size_t)",
"length exceeds max allowed value")) {
return {};
}
auto buffer = Utils::OpenDirectHandle(*shared_array_buffer);
i::DirectHandle<i::JSTypedArray> obj = i_isolate->factory()->NewJSTypedArray(
i::kExternalFloat16Array, buffer, byte_offset, length);
return Utils::ToLocalFloat16Array(obj);
}
// TODO(v8:11111): Support creating length tracking DataViews via the API.
Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer,
size_t byte_offset, size_t byte_length) {
-6
View File
@@ -863,12 +863,6 @@ Builtins::JSBuiltinStateFlags Builtins::GetJSBuiltinState(Builtin builtin) {
RETURN_FLAG_DEPENDENT_BUILTIN_STATE(
v8_flags.js_explicit_resource_management);
// --js-float16array
case Builtin::kMathF16round:
case Builtin::kDataViewPrototypeGetFloat16:
case Builtin::kDataViewPrototypeSetFloat16:
RETURN_FLAG_DEPENDENT_BUILTIN_STATE(v8_flags.js_float16array);
// --js-base-64
case Builtin::kUint8ArrayFromBase64:
case Builtin::kUint8ArrayFromHex:
-2
View File
@@ -344,8 +344,6 @@ DEFINE_BOOL(js_shipping, true, "enable all shipped JavaScript features")
V(js_error_iserror, "Error.isError") \
V(js_regexp_escape, "RegExp.escape") \
V(js_explicit_resource_management, "explicit resource management") \
V(js_float16array, \
"Float16Array, Math.f16round, DataView.getFloat16, DataView.setFloat16") \
V(js_base_64, "Uint8Array to/from base64 and hex") \
V(js_esm_ns_reexport, \
"Support diamond-importing re-expored namespaces " \
+6 -33
View File
@@ -3483,6 +3483,8 @@ void Genesis::InitializeGlobal(DirectHandle<JSGlobalObject> global_object,
SimpleInstallFunction(isolate_, math, "exp", Builtin::kMathExp, 1, kAdapt);
SimpleInstallFunction(isolate_, math, "floor", Builtin::kMathFloor, 1,
kAdapt);
SimpleInstallFunction(isolate_, math, "f16round", Builtin::kMathF16round, 1,
kAdapt);
SimpleInstallFunction(isolate_, math, "fround", Builtin::kMathFround, 1,
kAdapt);
SimpleInstallFunction(isolate_, math, "hypot", Builtin::kMathHypot, 2,
@@ -4330,6 +4332,10 @@ void Genesis::InitializeGlobal(DirectHandle<JSGlobalObject> global_object,
Builtin::kDataViewPrototypeGetUint32, 1, kDontAdapt);
SimpleInstallFunction(isolate_, prototype, "setUint32",
Builtin::kDataViewPrototypeSetUint32, 2, kDontAdapt);
SimpleInstallFunction(isolate_, prototype, "getFloat16",
Builtin::kDataViewPrototypeGetFloat16, 1, kDontAdapt);
SimpleInstallFunction(isolate_, prototype, "setFloat16",
Builtin::kDataViewPrototypeSetFloat16, 2, kDontAdapt);
SimpleInstallFunction(isolate_, prototype, "getFloat32",
Builtin::kDataViewPrototypeGetFloat32, 1, kDontAdapt);
SimpleInstallFunction(isolate_, prototype, "setFloat32",
@@ -5084,11 +5090,6 @@ DirectHandle<JSFunction> Genesis::InstallTypedArray(
GetCorrespondingRabGsabElementsKind(elements_kind), 0);
rab_gsab_initial_map->SetConstructor(*result);
if (rab_gsab_initial_map_index == Context::RAB_GSAB_FLOAT16_ARRAY_MAP_INDEX &&
v8_flags.js_float16array) {
LOG(isolate(), MapDetails(*rab_gsab_initial_map));
}
native_context()->set(rab_gsab_initial_map_index, *rab_gsab_initial_map,
UPDATE_WRITE_BARRIER, kReleaseStore);
Map::SetPrototype(isolate(), rab_gsab_initial_map, prototype);
@@ -5869,34 +5870,6 @@ void Genesis::InitializeGlobal_js_explicit_resource_management() {
kAdapt);
}
void Genesis::InitializeGlobal_js_float16array() {
if (!v8_flags.js_float16array) return;
DirectHandle<JSGlobalObject> global(native_context()->global_object(),
isolate());
DirectHandle<JSObject> math = Cast<JSObject>(
JSReceiver::GetProperty(isolate(), global, "Math").ToHandleChecked());
SimpleInstallFunction(isolate_, math, "f16round", Builtin::kMathF16round, 1,
kAdapt);
DirectHandle<JSObject> dataview_prototype(
Cast<JSObject>(native_context()->data_view_fun()->instance_prototype()),
isolate());
SimpleInstallFunction(isolate_, dataview_prototype, "getFloat16",
Builtin::kDataViewPrototypeGetFloat16, 1, kDontAdapt);
SimpleInstallFunction(isolate_, dataview_prototype, "setFloat16",
Builtin::kDataViewPrototypeSetFloat16, 2, kDontAdapt);
DirectHandle<JSFunction> fun = InstallTypedArray(
"Float16Array", FLOAT16_ELEMENTS, FLOAT16_TYPED_ARRAY_CONSTRUCTOR_TYPE,
Context::RAB_GSAB_FLOAT16_ARRAY_MAP_INDEX);
InstallWithIntrinsicDefaultProto(isolate_, fun,
Context::FLOAT16_ARRAY_FUN_INDEX);
}
void Genesis::InitializeGlobal_js_regexp_escape() {
if (!v8_flags.js_regexp_escape) return;
+9 -22
View File
@@ -26,13 +26,10 @@ namespace internal {
V(BigInt64, bigint64, BIGINT64, int64_t) \
V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t) \
V(Float32, float32, FLOAT32, float) \
V(Float64, float64, FLOAT64, double)
V(Float64, float64, FLOAT64, double) \
V(Float16, float16, FLOAT16, uint16_t)
#define TYPED_ARRAYS_FLOAT16(V) V(Float16, float16, FLOAT16, uint16_t)
#define TYPED_ARRAYS(V) \
TYPED_ARRAYS_BASE(V) \
TYPED_ARRAYS_FLOAT16(V)
#define TYPED_ARRAYS(V) TYPED_ARRAYS_BASE(V)
#define RAB_GSAB_TYPED_ARRAYS_BASE(V) \
V(RabGsabUint8, rab_gsab_uint8, RAB_GSAB_UINT8, uint8_t) \
@@ -46,14 +43,10 @@ namespace internal {
V(RabGsabUint8Clamped, rab_gsab_uint8_clamped, RAB_GSAB_UINT8_CLAMPED, \
uint8_t) \
V(RabGsabFloat32, rab_gsab_float32, RAB_GSAB_FLOAT32, float) \
V(RabGsabFloat64, rab_gsab_float64, RAB_GSAB_FLOAT64, double)
#define RAB_GSAB_TYPED_ARRAYS_FLOAT16(V) \
V(RabGsabFloat64, rab_gsab_float64, RAB_GSAB_FLOAT64, double) \
V(RabGsabFloat16, rab_gsab_float16, RAB_GSAB_FLOAT16, uint16_t)
#define RAB_GSAB_TYPED_ARRAYS(V) \
RAB_GSAB_TYPED_ARRAYS_BASE(V) \
RAB_GSAB_TYPED_ARRAYS_FLOAT16(V)
#define RAB_GSAB_TYPED_ARRAYS(V) RAB_GSAB_TYPED_ARRAYS_BASE(V)
// The TypedArrays backed by RAB / GSAB are called Uint8Array, Uint16Array etc,
// and not RabGsabUint8Array, RabGsabUint16Array etc. This macro is used for
@@ -69,14 +62,11 @@ namespace internal {
V(BigInt64, rab_gsab_bigint64, RAB_GSAB_BIGINT64, int64_t) \
V(Uint8Clamped, rab_gsab_uint8_clamped, RAB_GSAB_UINT8_CLAMPED, uint8_t) \
V(Float32, rab_gsab_float32, RAB_GSAB_FLOAT32, float) \
V(Float64, rab_gsab_float64, RAB_GSAB_FLOAT64, double)
#define RAB_GSAB_TYPED_ARRAYS_WITH_TYPED_ARRAY_TYPE_FLOAT16(V) \
V(Float64, rab_gsab_float64, RAB_GSAB_FLOAT64, double) \
V(Float16, rab_gsab_float16, RAB_GSAB_FLOAT16, uint16_t)
#define RAB_GSAB_TYPED_ARRAYS_WITH_TYPED_ARRAY_TYPE(V) \
RAB_GSAB_TYPED_ARRAYS_WITH_TYPED_ARRAY_TYPE_BASE(V) \
RAB_GSAB_TYPED_ARRAYS_WITH_TYPED_ARRAY_TYPE_FLOAT16(V)
RAB_GSAB_TYPED_ARRAYS_WITH_TYPED_ARRAY_TYPE_BASE(V)
// Like RAB_GSAB_TYPED_ARRAYS but has an additional parameter for
// for the corresponding non-RAB/GSAB ElementsKind.
@@ -93,14 +83,11 @@ namespace internal {
V(RabGsabUint8Clamped, rab_gsab_uint8_clamped, RAB_GSAB_UINT8_CLAMPED, \
uint8_t, UINT8_CLAMPED) \
V(RabGsabFloat32, rab_gsab_float32, RAB_GSAB_FLOAT32, float, FLOAT32) \
V(RabGsabFloat64, rab_gsab_float64, RAB_GSAB_FLOAT64, double, FLOAT64)
#define RAB_GSAB_TYPED_ARRAYS_WITH_NON_RAB_GSAB_ELEMENTS_KIND_FLOAT16(V) \
V(RabGsabFloat64, rab_gsab_float64, RAB_GSAB_FLOAT64, double, FLOAT64) \
V(RabGsabFloat16, rab_gsab_float16, RAB_GSAB_FLOAT16, uint16_t, FLOAT16)
#define RAB_GSAB_TYPED_ARRAYS_WITH_NON_RAB_GSAB_ELEMENTS_KIND(V) \
RAB_GSAB_TYPED_ARRAYS_WITH_NON_RAB_GSAB_ELEMENTS_KIND_BASE(V) \
RAB_GSAB_TYPED_ARRAYS_WITH_NON_RAB_GSAB_ELEMENTS_KIND_FLOAT16(V)
RAB_GSAB_TYPED_ARRAYS_WITH_NON_RAB_GSAB_ELEMENTS_KIND_BASE(V)
enum ElementsKind : uint8_t {
// The "fast" kind for elements that only contain SMI values. Must be first
-7
View File
@@ -2301,13 +2301,6 @@ MaybeDirectHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView(
break;
TYPED_ARRAYS_BASE(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case ArrayBufferViewTag::kFloat16Array: {
if (i::v8_flags.js_float16array) {
external_array_type = kExternalFloat16Array;
element_size = sizeof(uint16_t);
}
break;
}
}
if (element_size == 0 || byte_offset % element_size != 0 ||
byte_length % element_size != 0) {
-1
View File
@@ -1100,7 +1100,6 @@ TEST(SubclassArrayBuiltinNoInlineNew) {
TEST(SubclassTypedArrayBuiltin) {
v8_flags.js_float16array = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
-4
View File
@@ -115,20 +115,17 @@ void TestSpeciesProtector(char* code,
}
UNINITIALIZED_TEST(SpeciesConstructor) {
v8_flags.js_float16array = true;
char code[] = "x.constructor = MyTypedArray";
TestSpeciesProtector(code);
}
UNINITIALIZED_TEST(SpeciesConstructorAccessor) {
v8_flags.js_float16array = true;
char code[] =
"Object.defineProperty(x, 'constructor',{get() {return MyTypedArray;}})";
TestSpeciesProtector(code);
}
UNINITIALIZED_TEST(SpeciesModified) {
v8_flags.js_float16array = true;
char code[] =
"Object.defineProperty(constructor, Symbol.species, "
"{value:MyTypedArray})";
@@ -136,7 +133,6 @@ UNINITIALIZED_TEST(SpeciesModified) {
}
UNINITIALIZED_TEST(SpeciesParentConstructor) {
v8_flags.js_float16array = true;
char code[] = "constructor.prototype.constructor = MyTypedArray";
TestSpeciesProtector(code);
}
-1
View File
@@ -59,7 +59,6 @@ FEATURE_FLAGS = {
'import-attributes': '--harmony-import-attributes',
'regexp-duplicate-named-groups': '--js-regexp-duplicate-named-groups',
'regexp-modifiers': '--js-regexp-modifiers',
'Float16Array': '--js-float16array',
'explicit-resource-management': '--js-explicit-resource-management',
'decorators': '--js-decorators',
'promise-try': '--js-promise-try',
-3
View File
@@ -683,8 +683,6 @@ TEST_FUNCTION_KIND(IsStrictFunctionWithoutPrototype)
#undef TEST_FUNCTION_KIND
TEST_F(ObjectTest, ConstructorInstanceTypes) {
bool flag_was_enabled = i::v8_flags.js_float16array;
i::v8_flags.js_float16array = true;
v8::HandleScope scope(isolate());
DirectHandle<NativeContext> context = i_isolate()->native_context();
@@ -720,7 +718,6 @@ TEST_F(ObjectTest, ConstructorInstanceTypes) {
break;
}
}
i::v8_flags.js_float16array = flag_was_enabled;
}
TEST_F(ObjectTest, AddDataPropertyNameCollision) {
@@ -48,7 +48,6 @@ class ValueSerializerTest : public TestWithIsolate {
protected:
ValueSerializerTest() {
FLAG_SCOPE(js_float16array);
Local<Context> serialization_context = Context::New(isolate());
Local<Context> deserialization_context = Context::New(isolate());
serialization_context_.Reset(isolate(), serialization_context);
@@ -2083,7 +2082,6 @@ TEST_F(ValueSerializerTestWithArrayBufferTransfer,
}
TEST_F(ValueSerializerTest, RoundTripTypedArray) {
FLAG_SCOPE(js_float16array);
// Check that the right type comes out the other side for every kind of typed
// array.
// TODO(v8:11111): Use API functions for testing is_length_tracking and
@@ -2133,7 +2131,6 @@ TEST_F(ValueSerializerTest, RoundTripTypedArray) {
}
TEST_F(ValueSerializerTest, RoundTripRabBackedLengthTrackingTypedArray) {
FLAG_SCOPE(js_float16array);
// Check that the right type comes out the other side for every kind of typed
// array.
// TODO(v8:11111): Use API functions for testing is_length_tracking and
@@ -2158,7 +2155,6 @@ TEST_F(ValueSerializerTest, RoundTripRabBackedLengthTrackingTypedArray) {
}
TEST_F(ValueSerializerTest, RoundTripRabBackedNonLengthTrackingTypedArray) {
FLAG_SCOPE(js_float16array);
// Check that the right type comes out the other side for every kind of typed
// array.
// TODO(v8:11111): Use API functions for testing is_length_tracking and