Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/crypto/crypto_timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ bool FastTimingSafeEqual(Local<Value> receiver,
return CRYPTO_memcmp(a.data(), b.data(), a.length()) == 0;
}

static CFunction fast_equal(CFunction::Make(FastTimingSafeEqual));
static CFunction fast_timing_safe_equal(CFunction::Make(FastTimingSafeEqual));

void Initialize(Environment* env, Local<Object> target) {
SetFastMethodNoSideEffect(
env->context(), target, "timingSafeEqual", TimingSafeEqual, &fast_equal);
SetFastMethodNoSideEffect(env->context(),
target,
"timingSafeEqual",
TimingSafeEqual,
&fast_timing_safe_equal);
}
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(TimingSafeEqual);
registry->Register(FastTimingSafeEqual);
registry->Register(fast_equal.GetTypeInfo());
registry->Register(fast_timing_safe_equal);
}
} // namespace Timing

Expand Down
36 changes: 12 additions & 24 deletions src/histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,14 @@ void HistogramImpl::RegisterExternalReferences(
registry->Register(GetPercentiles);
registry->Register(GetPercentilesBigInt);
registry->Register(DoReset);
registry->Register(fast_reset_.GetTypeInfo());
registry->Register(fast_get_count_.GetTypeInfo());
registry->Register(fast_get_min_.GetTypeInfo());
registry->Register(fast_get_max_.GetTypeInfo());
registry->Register(fast_get_mean_.GetTypeInfo());
registry->Register(fast_get_exceeds_.GetTypeInfo());
registry->Register(fast_get_stddev_.GetTypeInfo());
registry->Register(fast_get_percentile_.GetTypeInfo());
registry->Register(FastReset);
registry->Register(FastGetCount);
registry->Register(FastGetMin);
registry->Register(FastGetMax);
registry->Register(FastGetMean);
registry->Register(FastGetExceeds);
registry->Register(FastGetStddev);
registry->Register(FastGetPercentile);
registry->Register(fast_reset_);
registry->Register(fast_get_count_);
registry->Register(fast_get_min_);
registry->Register(fast_get_max_);
registry->Register(fast_get_mean_);
registry->Register(fast_get_exceeds_);
registry->Register(fast_get_stddev_);
registry->Register(fast_get_percentile_);
is_registered = true;
}

Expand Down Expand Up @@ -302,10 +294,8 @@ void HistogramBase::RegisterExternalReferences(
registry->Register(Add);
registry->Register(Record);
registry->Register(RecordDelta);
registry->Register(fast_record_.GetTypeInfo());
registry->Register(fast_record_delta_.GetTypeInfo());
registry->Register(FastRecord);
registry->Register(FastRecordDelta);
registry->Register(fast_record_);
registry->Register(fast_record_delta_);
HistogramImpl::RegisterExternalReferences(registry);
}

Expand Down Expand Up @@ -356,10 +346,8 @@ void IntervalHistogram::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
registry->Register(Start);
registry->Register(Stop);
registry->Register(fast_start_.GetTypeInfo());
registry->Register(fast_stop_.GetTypeInfo());
registry->Register(FastStart);
registry->Register(FastStop);
registry->Register(fast_start_);
registry->Register(fast_stop_);
HistogramImpl::RegisterExternalReferences(registry);
}

Expand Down
21 changes: 7 additions & 14 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1634,20 +1634,16 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(SetBufferPrototype);

registry->Register(SlowByteLengthUtf8);
registry->Register(fast_byte_length_utf8.GetTypeInfo());
registry->Register(FastByteLengthUtf8);
registry->Register(fast_byte_length_utf8);
registry->Register(SlowCopy);
registry->Register(fast_copy.GetTypeInfo());
registry->Register(FastCopy);
registry->Register(fast_copy);
registry->Register(Compare);
registry->Register(FastCompare);
registry->Register(fast_compare.GetTypeInfo());
registry->Register(fast_compare);
registry->Register(CompareOffset);
registry->Register(Fill);
registry->Register(IndexOfBuffer);
registry->Register(SlowIndexOfNumber);
registry->Register(FastIndexOfNumber);
registry->Register(fast_index_of_number.GetTypeInfo());
registry->Register(fast_index_of_number);
registry->Register(IndexOfString);

registry->Register(Swap16);
Expand All @@ -1668,12 +1664,9 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(SlowWriteString<ASCII>);
registry->Register(SlowWriteString<LATIN1>);
registry->Register(SlowWriteString<UTF8>);
registry->Register(FastWriteString<ASCII>);
registry->Register(fast_write_string_ascii.GetTypeInfo());
registry->Register(FastWriteString<LATIN1>);
registry->Register(fast_write_string_latin1.GetTypeInfo());
registry->Register(FastWriteString<UTF8>);
registry->Register(fast_write_string_utf8.GetTypeInfo());
registry->Register(fast_write_string_ascii);
registry->Register(fast_write_string_latin1);
registry->Register(fast_write_string_utf8);
registry->Register(StringWrite<ASCII>);
registry->Register(StringWrite<BASE64>);
registry->Register(StringWrite<BASE64URL>);
Expand Down
115 changes: 7 additions & 108 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,121 +10,13 @@

namespace node {

using CFunctionCallbackWithalueAndOptions = bool (*)(
v8::Local<v8::Value>, v8::Local<v8::Value>, v8::FastApiCallbackOptions&);
using CFunctionCallbackWithMultipleValueAndOptions =
bool (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
v8::Local<v8::Value>,
v8::FastApiCallbackOptions&);
using CFunctionA =
uint32_t (*)(v8::Local<v8::Value> receiver,
v8::Local<v8::Value> sourceValue,
// NOLINTNEXTLINE(runtime/references) This is V8 api.
v8::FastApiCallbackOptions& options);
using CFunctionCallbackWithOneByteString =
uint32_t (*)(v8::Local<v8::Value>, const v8::FastOneByteString&);

using CFunctionCallbackReturnBool = bool (*)(v8::Local<v8::Value> unused,
v8::Local<v8::Value> receiver);
using CFunctionCallback = void (*)(v8::Local<v8::Value> unused,
v8::Local<v8::Value> receiver);
using CFunctionCallbackReturnDouble =
double (*)(v8::Local<v8::Object> unused, v8::Local<v8::Object> receiver);
using CFunctionCallbackReturnInt32 =
int32_t (*)(v8::Local<v8::Value> receiver,
v8::Local<v8::Value> input,
// NOLINTNEXTLINE(runtime/references) This is V8 api.
v8::FastApiCallbackOptions& options);
using CFunctionCallbackValueReturnDouble =
double (*)(v8::Local<v8::Value> receiver);
using CFunctionCallbackValueReturnDoubleUnusedReceiver =
double (*)(v8::Local<v8::Value> unused, v8::Local<v8::Value> receiver);
using CFunctionCallbackWithInt64 = void (*)(v8::Local<v8::Object> unused,
v8::Local<v8::Object> receiver,
int64_t);
using CFunctionCallbackWithBool = void (*)(v8::Local<v8::Object> unused,
v8::Local<v8::Object> receiver,
bool);
using CFunctionCallbackWithString =
bool (*)(v8::Local<v8::Value>, const v8::FastOneByteString& input);
using CFunctionCallbackWithStrings =
bool (*)(v8::Local<v8::Value>,
const v8::FastOneByteString& input,
const v8::FastOneByteString& base);
using CFunctionCallbackWithTwoUint8Arrays =
int32_t (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
v8::Local<v8::Value>,
v8::FastApiCallbackOptions&);
using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
int32_t (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
uint32_t,
int64_t,
bool,
v8::FastApiCallbackOptions&);
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
const uint32_t input);
using CFunctionWithReturnUint32 = uint32_t (*)(v8::Local<v8::Value>);
using CFunctionWithReturnDouble = double (*)(v8::Local<v8::Value>);
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
const double);
using CFunctionWithInt64Fallback = void (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
const int64_t,
v8::FastApiCallbackOptions&);
using CFunctionWithBool = void (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
bool);

using CFunctionWriteString = uint32_t (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
const v8::FastOneByteString&,
uint32_t,
uint32_t,
v8::FastApiCallbackOptions&);

using CFunctionBufferCopy = uint32_t (*)(v8::Local<v8::Value>,
v8::Local<v8::Value>,
v8::Local<v8::Value>,
uint32_t,
uint32_t,
uint32_t,
v8::FastApiCallbackOptions&);

// This class manages the external references from the V8 heap
// to the C++ addresses in Node.js.
class ExternalReferenceRegistry {
public:
ExternalReferenceRegistry();

#define ALLOWED_EXTERNAL_REFERENCE_TYPES(V) \
V(CFunctionA) \
V(CFunctionCallback) \
V(CFunctionCallbackWithalueAndOptions) \
V(CFunctionCallbackWithMultipleValueAndOptions) \
V(CFunctionCallbackWithOneByteString) \
V(CFunctionCallbackReturnBool) \
V(CFunctionCallbackReturnDouble) \
V(CFunctionCallbackReturnInt32) \
V(CFunctionWithReturnUint32) \
V(CFunctionCallbackValueReturnDouble) \
V(CFunctionCallbackValueReturnDoubleUnusedReceiver) \
V(CFunctionCallbackWithInt64) \
V(CFunctionCallbackWithBool) \
V(CFunctionCallbackWithString) \
V(CFunctionCallbackWithStrings) \
V(CFunctionCallbackWithTwoUint8Arrays) \
V(CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
V(CFunctionWithUint32) \
V(CFunctionWithDoubleReturnDouble) \
V(CFunctionWithInt64Fallback) \
V(CFunctionWithBool) \
V(CFunctionBufferCopy) \
V(CFunctionWriteString) \
V(const v8::CFunctionInfo*) \
V(v8::FunctionCallback) \
V(v8::AccessorNameGetterCallback) \
V(v8::AccessorNameSetterCallback) \
Expand All @@ -146,6 +38,13 @@ class ExternalReferenceRegistry {
ALLOWED_EXTERNAL_REFERENCE_TYPES(V)
#undef V

// Registers both the underlying function pointer
// and the corresponding CFunctionInfo.
void Register(const v8::CFunction& c_func) {
RegisterT(c_func.GetAddress());
RegisterT(c_func.GetTypeInfo());
}

// This can be called only once.
const std::vector<intptr_t>& external_references();

Expand Down
9 changes: 3 additions & 6 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,17 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(GetLoadAvg);
registry->Register(GetUptime);
registry->Register(GetTotalMemory);
registry->Register(FastGetTotalMemory);
registry->Register(fast_get_total_memory.GetTypeInfo());
registry->Register(fast_get_total_memory);
registry->Register(GetFreeMemory);
registry->Register(FastGetFreeMemory);
registry->Register(fast_get_free_memory.GetTypeInfo());
registry->Register(fast_get_free_memory);
registry->Register(GetCPUInfo);
registry->Register(GetInterfaceAddresses);
registry->Register(GetHomeDirectory);
registry->Register(GetUserInfo);
registry->Register(SetPriority);
registry->Register(GetPriority);
registry->Register(GetAvailableParallelism);
registry->Register(FastGetAvailableParallelism);
registry->Register(fast_get_available_parallelism.GetTypeInfo());
registry->Register(fast_get_available_parallelism);
registry->Register(GetOSInformation);
}

Expand Down
3 changes: 1 addition & 2 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(MarkBootstrapComplete);
registry->Register(UvMetricsInfo);
registry->Register(SlowPerformanceNow);
registry->Register(FastPerformanceNow);
registry->Register(fast_performance_now.GetTypeInfo());
registry->Register(fast_performance_now);
HistogramBase::RegisterExternalReferences(registry);
IntervalHistogram::RegisterExternalReferences(registry);
}
Expand Down
6 changes: 2 additions & 4 deletions src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,8 @@ void BindingData::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
registry->Register(SlowNumber);
registry->Register(SlowBigInt);
registry->Register(FastNumber);
registry->Register(FastBigInt);
registry->Register(fast_number_.GetTypeInfo());
registry->Register(fast_bigint_.GetTypeInfo());
registry->Register(fast_number_);
registry->Register(fast_bigint_);
}

BindingData* BindingData::FromV8Value(Local<Value> value) {
Expand Down
9 changes: 3 additions & 6 deletions src/node_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,15 @@ void InitializeTypes(Local<Object> target,
void RegisterTypesExternalReferences(ExternalReferenceRegistry* registry) {
#define V(type) \
registry->Register(Is##type); \
registry->Register(Is##type##FastApi); \
registry->Register(fast_is_##type##_.GetTypeInfo());
registry->Register(fast_is_##type##_);

VALUE_METHOD_MAP(V)
#undef V

registry->Register(IsAnyArrayBuffer);
registry->Register(IsAnyArrayBufferFastApi);
registry->Register(fast_is_any_array_buffer_.GetTypeInfo());
registry->Register(fast_is_any_array_buffer_);
registry->Register(IsBoxedPrimitive);
registry->Register(IsBoxedPrimitiveFastApi);
registry->Register(fast_is_boxed_primitive_.GetTypeInfo());
registry->Register(fast_is_boxed_primitive_);
}
} // namespace node

Expand Down
5 changes: 1 addition & 4 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,8 @@ void BindingData::RegisterExternalReferences(
registry->Register(PathToFileURL);
registry->Register(Update);
registry->Register(CanParse);
registry->Register(FastCanParse);
registry->Register(FastCanParseWithBase);

for (const CFunction& method : fast_can_parse_methods_) {
registry->Register(method.GetTypeInfo());
registry->Register(method);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(Sleep);
registry->Register(ArrayBufferViewHasBuffer);
registry->Register(GuessHandleType);
registry->Register(FastGuessHandleType);
registry->Register(fast_guess_handle_type_.GetTypeInfo());
registry->Register(fast_guess_handle_type_);
registry->Register(ParseEnv);
registry->Register(IsInsideNodeModules);
registry->Register(DefineLazyProperties);
Expand Down
3 changes: 1 addition & 2 deletions src/node_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(GCProfiler::Stop);
registry->Register(GetCppHeapStatistics);
registry->Register(IsStringOneByteRepresentation);
registry->Register(FastIsStringOneByteRepresentation);
registry->Register(fast_is_string_one_byte_representation_.GetTypeInfo());
registry->Register(fast_is_string_one_byte_representation_);
}

} // namespace v8_utils
Expand Down
Loading
Loading