Skip to content

Commit f09d022

Browse files
gahaastargos
authored andcommitted
src: remove use of deprecated type v8::FastApiTypedArray
In the examples where `v8::FastApiTypedArray` was used, there is actually no advantage of using V8's fast API calls instead of regular API calls. Therefore this CL just removes the fast API call targets instead of adjusting them.
1 parent 256200e commit f09d022

File tree

3 files changed

+3
-86
lines changed

3 files changed

+3
-86
lines changed

src/crypto/crypto_timing.cc

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace node {
1111

12-
using v8::FastApiCallbackOptions;
13-
using v8::FastApiTypedArray;
1412
using v8::FunctionCallbackInfo;
1513
using v8::Local;
1614
using v8::Object;
@@ -48,33 +46,11 @@ void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) {
4846
CRYPTO_memcmp(buf1.data(), buf2.data(), buf1.size()) == 0);
4947
}
5048

51-
bool FastTimingSafeEqual(Local<Value> receiver,
52-
const FastApiTypedArray<uint8_t>& a,
53-
const FastApiTypedArray<uint8_t>& b,
54-
// NOLINTNEXTLINE(runtime/references)
55-
FastApiCallbackOptions& options) {
56-
uint8_t* data_a;
57-
uint8_t* data_b;
58-
if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) ||
59-
!b.getStorageIfAligned(&data_b)) {
60-
Environment* env = Environment::GetCurrent(options.isolate);
61-
THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(env);
62-
return false;
63-
}
64-
65-
return CRYPTO_memcmp(data_a, data_b, a.length()) == 0;
66-
}
67-
68-
static v8::CFunction fast_equal(v8::CFunction::Make(FastTimingSafeEqual));
69-
7049
void Initialize(Environment* env, Local<Object> target) {
71-
SetFastMethodNoSideEffect(
72-
env->context(), target, "timingSafeEqual", TimingSafeEqual, &fast_equal);
50+
SetMethod(env->context(), target, "timingSafeEqual", TimingSafeEqual);
7351
}
7452
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
7553
registry->Register(TimingSafeEqual);
76-
registry->Register(FastTimingSafeEqual);
77-
registry->Register(fast_equal.GetTypeInfo());
7854
}
7955
} // namespace Timing
8056

src/node_buffer.cc

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ using v8::ArrayBufferView;
5858
using v8::BackingStore;
5959
using v8::Context;
6060
using v8::EscapableHandleScope;
61-
using v8::FastApiTypedArray;
6261
using v8::FunctionCallbackInfo;
6362
using v8::Global;
6463
using v8::HandleScope;
@@ -845,24 +844,6 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
845844
args.GetReturnValue().Set(val);
846845
}
847846

848-
int32_t FastCompare(v8::Local<v8::Value>,
849-
const FastApiTypedArray<uint8_t>& a,
850-
const FastApiTypedArray<uint8_t>& b) {
851-
uint8_t* data_a;
852-
uint8_t* data_b;
853-
CHECK(a.getStorageIfAligned(&data_a));
854-
CHECK(b.getStorageIfAligned(&data_b));
855-
856-
size_t cmp_length = std::min(a.length(), b.length());
857-
858-
return normalizeCompareVal(
859-
cmp_length > 0 ? memcmp(data_a, data_b, cmp_length) : 0,
860-
a.length(),
861-
b.length());
862-
}
863-
864-
static v8::CFunction fast_compare(v8::CFunction::Make(FastCompare));
865-
866847
// Computes the offset for starting an indexOf or lastIndexOf search.
867848
// Returns either a valid offset in [0...<length - 1>], ie inside the Buffer,
868849
// or -1 to signal that there is no possible match.
@@ -1128,20 +1109,6 @@ void SlowIndexOfNumber(const FunctionCallbackInfo<Value>& args) {
11281109
buffer.data(), buffer.length(), needle, offset_i64, is_forward));
11291110
}
11301111

1131-
int32_t FastIndexOfNumber(v8::Local<v8::Value>,
1132-
const FastApiTypedArray<uint8_t>& buffer,
1133-
uint32_t needle,
1134-
int64_t offset_i64,
1135-
bool is_forward) {
1136-
uint8_t* buffer_data;
1137-
CHECK(buffer.getStorageIfAligned(&buffer_data));
1138-
return IndexOfNumber(
1139-
buffer_data, buffer.length(), needle, offset_i64, is_forward);
1140-
}
1141-
1142-
static v8::CFunction fast_index_of_number(
1143-
v8::CFunction::Make(FastIndexOfNumber));
1144-
11451112
void Swap16(const FunctionCallbackInfo<Value>& args) {
11461113
Environment* env = Environment::GetCurrent(args);
11471114
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
@@ -1448,15 +1415,11 @@ void Initialize(Local<Object> target,
14481415
SlowByteLengthUtf8,
14491416
&fast_byte_length_utf8);
14501417
SetMethod(context, target, "copy", Copy);
1451-
SetFastMethodNoSideEffect(context, target, "compare", Compare, &fast_compare);
1418+
SetMethod(context, target, "compare", Compare);
14521419
SetMethodNoSideEffect(context, target, "compareOffset", CompareOffset);
14531420
SetMethod(context, target, "fill", Fill);
14541421
SetMethodNoSideEffect(context, target, "indexOfBuffer", IndexOfBuffer);
1455-
SetFastMethodNoSideEffect(context,
1456-
target,
1457-
"indexOfNumber",
1458-
SlowIndexOfNumber,
1459-
&fast_index_of_number);
1422+
SetMethod(context, target, "indexOfNumber", SlowIndexOfNumber);
14601423
SetMethodNoSideEffect(context, target, "indexOfString", IndexOfString);
14611424

14621425
SetMethod(context, target, "detachArrayBuffer", DetachArrayBuffer);
@@ -1512,14 +1475,10 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
15121475
registry->Register(FastByteLengthUtf8);
15131476
registry->Register(Copy);
15141477
registry->Register(Compare);
1515-
registry->Register(FastCompare);
1516-
registry->Register(fast_compare.GetTypeInfo());
15171478
registry->Register(CompareOffset);
15181479
registry->Register(Fill);
15191480
registry->Register(IndexOfBuffer);
15201481
registry->Register(SlowIndexOfNumber);
1521-
registry->Register(FastIndexOfNumber);
1522-
registry->Register(fast_index_of_number.GetTypeInfo());
15231482
registry->Register(IndexOfString);
15241483

15251484
registry->Register(Swap16);

src/node_external_reference.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@ using CFunctionCallbackWithStrings =
3232
bool (*)(v8::Local<v8::Value>,
3333
const v8::FastOneByteString& input,
3434
const v8::FastOneByteString& base);
35-
using CFunctionCallbackWithTwoUint8Arrays =
36-
int32_t (*)(v8::Local<v8::Value>,
37-
const v8::FastApiTypedArray<uint8_t>&,
38-
const v8::FastApiTypedArray<uint8_t>&);
39-
using CFunctionCallbackWithTwoUint8ArraysFallback =
40-
bool (*)(v8::Local<v8::Value>,
41-
const v8::FastApiTypedArray<uint8_t>&,
42-
const v8::FastApiTypedArray<uint8_t>&,
43-
v8::FastApiCallbackOptions&);
44-
using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
45-
int32_t (*)(v8::Local<v8::Value>,
46-
const v8::FastApiTypedArray<uint8_t>&,
47-
uint32_t,
48-
int64_t,
49-
bool);
5035
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
5136
const uint32_t input);
5237
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
@@ -72,9 +57,6 @@ class ExternalReferenceRegistry {
7257
V(CFunctionCallbackWithBool) \
7358
V(CFunctionCallbackWithString) \
7459
V(CFunctionCallbackWithStrings) \
75-
V(CFunctionCallbackWithTwoUint8Arrays) \
76-
V(CFunctionCallbackWithTwoUint8ArraysFallback) \
77-
V(CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
7860
V(CFunctionWithUint32) \
7961
V(CFunctionWithDoubleReturnDouble) \
8062
V(CFunctionWithInt64Fallback) \

0 commit comments

Comments
 (0)