mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
quic: fixup some v8:: qualifiers
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63267 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
5d1ea79a83
commit
f1fdf91560
6 files changed
+57
-35
No files matched your search
@@ -23,6 +23,7 @@ using mem::kReserveSizeAndAlign;
|
||||
using v8::Function;
|
||||
using v8::FunctionTemplate;
|
||||
using v8::HandleScope;
|
||||
using v8::Isolate;
|
||||
using v8::Local;
|
||||
using v8::Object;
|
||||
using v8::String;
|
||||
@@ -274,7 +275,7 @@ void BindingData::DecreaseAllocatedSize(size_t size) {
|
||||
// Forwards detailed(verbose) debugging information from nghttp3. Enabled using
|
||||
// the NODE_DEBUG_NATIVE=NGHTTP3 category.
|
||||
void nghttp3_debug_log(const char* fmt, va_list args) {
|
||||
auto isolate = v8::Isolate::GetCurrent();
|
||||
auto isolate = Isolate::GetCurrent();
|
||||
if (isolate == nullptr) return;
|
||||
auto env = Environment::GetCurrent(isolate);
|
||||
if (env->enabled_debug_list()->enabled(DebugCategory::NGHTTP3)) {
|
||||
|
||||
+23
-10
@@ -17,7 +17,10 @@ using v8::Array;
|
||||
using v8::ArrayBuffer;
|
||||
using v8::ArrayBufferView;
|
||||
using v8::BackingStore;
|
||||
using v8::BackingStoreInitializationMode;
|
||||
using v8::BackingStoreOnFailureMode;
|
||||
using v8::BigInt;
|
||||
using v8::Isolate;
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
@@ -89,14 +92,14 @@ Store::Store(std::unique_ptr<BackingStore> store, size_t length, size_t offset)
|
||||
}
|
||||
|
||||
Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
|
||||
auto length = buffer->ByteLength();
|
||||
auto dest = ArrayBuffer::NewBackingStore(
|
||||
isolate,
|
||||
length,
|
||||
v8::BackingStoreInitializationMode::kUninitialized,
|
||||
v8::BackingStoreOnFailureMode::kReturnNull);
|
||||
BackingStoreInitializationMode::kUninitialized,
|
||||
BackingStoreOnFailureMode::kReturnNull);
|
||||
if (!dest) {
|
||||
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
|
||||
return Nothing<Store>();
|
||||
@@ -108,15 +111,15 @@ Maybe<Store> Store::From(Local<ArrayBuffer> buffer) {
|
||||
}
|
||||
|
||||
Maybe<Store> Store::From(Local<ArrayBufferView> view) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
Environment* env = Environment::GetCurrent(isolate->GetCurrentContext());
|
||||
auto length = view->ByteLength();
|
||||
auto offset = view->ByteOffset();
|
||||
auto dest = ArrayBuffer::NewBackingStore(
|
||||
isolate,
|
||||
length,
|
||||
v8::BackingStoreInitializationMode::kUninitialized,
|
||||
v8::BackingStoreOnFailureMode::kReturnNull);
|
||||
BackingStoreInitializationMode::kUninitialized,
|
||||
BackingStoreOnFailureMode::kReturnNull);
|
||||
if (!dest) {
|
||||
THROW_ERR_MEMORY_ALLOCATION_FAILED(env);
|
||||
return Nothing<Store>();
|
||||
@@ -130,24 +133,34 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
|
||||
}
|
||||
|
||||
Store Store::CopyFrom(Local<ArrayBuffer> buffer) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
auto backing = buffer->GetBackingStore();
|
||||
auto length = buffer->ByteLength();
|
||||
auto dest = ArrayBuffer::NewBackingStore(
|
||||
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
|
||||
isolate, length, BackingStoreInitializationMode::kUninitialized,
|
||||
BackingStoreOnFailureMode::kReturnNull);
|
||||
if (!dest) {
|
||||
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
|
||||
return Store();
|
||||
}
|
||||
// copy content
|
||||
memcpy(dest->Data(), backing->Data(), length);
|
||||
return Store(std::move(dest), length, 0);
|
||||
}
|
||||
|
||||
Store Store::CopyFrom(Local<ArrayBufferView> view) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
auto backing = view->Buffer()->GetBackingStore();
|
||||
auto length = view->ByteLength();
|
||||
auto offset = view->ByteOffset();
|
||||
auto dest = ArrayBuffer::NewBackingStore(
|
||||
isolate, length, v8::BackingStoreInitializationMode::kUninitialized);
|
||||
isolate, length, BackingStoreInitializationMode::kUninitialized,
|
||||
BackingStoreOnFailureMode::kReturnNull);
|
||||
// copy content
|
||||
if (!dest) {
|
||||
THROW_ERR_MEMORY_ALLOCATION_FAILED(Environment::GetCurrent(isolate));
|
||||
return Store();
|
||||
}
|
||||
memcpy(dest->Data(), static_cast<char*>(backing->Data()) + offset, length);
|
||||
return Store(std::move(dest), length, 0);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace node {
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
using v8::Object;
|
||||
using v8::Value;
|
||||
|
||||
namespace quic {
|
||||
@@ -131,7 +132,7 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
|
||||
: Just(FromV8Value<Policy>(value));
|
||||
}
|
||||
|
||||
void PreferredAddress::Initialize(Environment* env, Local<v8::Object> target) {
|
||||
void PreferredAddress::Initialize(Environment* env, Local<Object> target) {
|
||||
// The QUIC_* constants are expected to be exported out to be used on
|
||||
// the JavaScript side of the API.
|
||||
static constexpr auto PREFERRED_ADDRESS_USE =
|
||||
|
||||
+12
-9
@@ -40,7 +40,9 @@ using v8::Array;
|
||||
using v8::ArrayBufferView;
|
||||
using v8::BigInt;
|
||||
using v8::Boolean;
|
||||
using v8::Function;
|
||||
using v8::FunctionCallbackInfo;
|
||||
using v8::Global;
|
||||
using v8::HandleScope;
|
||||
using v8::Int32;
|
||||
using v8::Integer;
|
||||
@@ -54,6 +56,7 @@ using v8::Number;
|
||||
using v8::Object;
|
||||
using v8::ObjectTemplate;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::Undefined;
|
||||
using v8::Value;
|
||||
|
||||
@@ -420,9 +423,9 @@ bool SetOption(Environment* env,
|
||||
template <typename Opt, uint8_t Opt::*member>
|
||||
bool SetOption(Environment* env,
|
||||
Opt* options,
|
||||
const v8::Local<v8::Object>& object,
|
||||
const v8::Local<v8::String>& name) {
|
||||
v8::Local<v8::Value> value;
|
||||
const Local<Object>& object,
|
||||
const Local<String>& name) {
|
||||
Local<Value> value;
|
||||
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
||||
if (!value->IsUndefined()) {
|
||||
if (!value->IsUint32()) {
|
||||
@@ -431,7 +434,7 @@ bool SetOption(Environment* env,
|
||||
env, "The %s option must be an uint8", *nameStr);
|
||||
return false;
|
||||
}
|
||||
uint32_t val = value.As<v8::Uint32>()->Value();
|
||||
uint32_t val = value.As<Uint32>()->Value();
|
||||
if (val > 255) {
|
||||
Utf8Value nameStr(env->isolate(), name);
|
||||
THROW_ERR_INVALID_ARG_VALUE(
|
||||
@@ -1718,7 +1721,7 @@ Session::Session(Endpoint* endpoint,
|
||||
Debug(this, "Session created.");
|
||||
|
||||
{
|
||||
const v8::HandleScope handle_scope(env()->isolate());
|
||||
const HandleScope handle_scope(env()->isolate());
|
||||
JS_DEFINE_READONLY_PROPERTY(
|
||||
env(),
|
||||
object,
|
||||
@@ -1728,7 +1731,7 @@ Session::Session(Endpoint* endpoint,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(impl_->state_slot_.GetByteOffset())));
|
||||
JS_DEFINE_READONLY_PROPERTY(
|
||||
@@ -1740,7 +1743,7 @@ Session::Session(Endpoint* endpoint,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(impl_->stats_slot_.GetByteOffset())));
|
||||
}
|
||||
@@ -2127,8 +2130,8 @@ void Session::EmitQlog(uint32_t flags, std::string_view data) {
|
||||
// ngtcp2_conn is mid-destruction. Defer the final chunk via SetImmediate.
|
||||
if (is_destroyed()) {
|
||||
auto isolate = env()->isolate();
|
||||
v8::Global<v8::Object> recv(isolate, object());
|
||||
v8::Global<v8::Function> cb(
|
||||
Global<Object> recv(isolate, object());
|
||||
Global<Function> cb(
|
||||
isolate, BindingData::Get(env()).session_qlog_callback());
|
||||
std::string buf(data);
|
||||
env()->SetImmediate([recv = std::move(recv),
|
||||
|
||||
+11
-10
@@ -26,6 +26,7 @@ using v8::BackingStore;
|
||||
using v8::BigInt;
|
||||
using v8::FunctionCallbackInfo;
|
||||
using v8::Global;
|
||||
using v8::HandleScope;
|
||||
using v8::Integer;
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
@@ -34,6 +35,7 @@ using v8::Nothing;
|
||||
using v8::Object;
|
||||
using v8::ObjectTemplate;
|
||||
using v8::SharedArrayBuffer;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::Uint8Array;
|
||||
using v8::Value;
|
||||
@@ -277,7 +279,7 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
|
||||
// object's constructor name is "FileHandle".
|
||||
if (value->IsObject()) {
|
||||
auto obj = value.As<Object>();
|
||||
Local<v8::String> ctor_name;
|
||||
Local<String> ctor_name;
|
||||
auto maybe_name = obj->GetConstructorName();
|
||||
if (!maybe_name.IsEmpty()) {
|
||||
ctor_name = maybe_name;
|
||||
@@ -287,9 +289,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
|
||||
ASSIGN_OR_RETURN_UNWRAP(
|
||||
&file_handle, value, Nothing<std::shared_ptr<DataQueue>>());
|
||||
Local<Value> path;
|
||||
if (!v8::String::NewFromUtf8(env->isolate(),
|
||||
file_handle->original_name().c_str())
|
||||
.ToLocal(&path)) {
|
||||
if (!ToV8Value(env->context(), file_handle->original_name())
|
||||
.ToLocal(&path)) {
|
||||
return Nothing<std::shared_ptr<DataQueue>>();
|
||||
}
|
||||
auto entry = DataQueue::CreateFdEntry(env, path);
|
||||
@@ -1048,7 +1049,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
inbound_->addBackpressureListener(this);
|
||||
|
||||
{
|
||||
const v8::HandleScope handle_scope(env()->isolate());
|
||||
const HandleScope handle_scope(env()->isolate());
|
||||
// Pass the page's shared views and this slot's byte offset. JS uses
|
||||
// the offset to index into the shared view — no per-stream V8 object
|
||||
// creation.
|
||||
@@ -1060,7 +1061,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(state_slot_.GetByteOffset())));
|
||||
JS_DEFINE_READONLY_PROPERTY(
|
||||
@@ -1072,7 +1073,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
|
||||
}
|
||||
@@ -1107,7 +1108,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
inbound_->addBackpressureListener(this);
|
||||
|
||||
{
|
||||
const v8::HandleScope handle_scope(env()->isolate());
|
||||
const HandleScope handle_scope(env()->isolate());
|
||||
JS_DEFINE_READONLY_PROPERTY(env(),
|
||||
object,
|
||||
env()->state_string(),
|
||||
@@ -1116,7 +1117,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "stateByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(state_slot_.GetByteOffset())));
|
||||
JS_DEFINE_READONLY_PROPERTY(
|
||||
@@ -1128,7 +1129,7 @@ Stream::Stream(BaseObjectWeakPtr<Session> session,
|
||||
env(),
|
||||
object,
|
||||
FIXED_ONE_BYTE_STRING(env()->isolate(), "statsByteOffset"),
|
||||
v8::Integer::NewFromUnsigned(
|
||||
Integer::NewFromUnsigned(
|
||||
env()->isolate(),
|
||||
static_cast<uint32_t>(stats_slot_.GetByteOffset())));
|
||||
}
|
||||
|
||||
@@ -30,13 +30,16 @@ using ncrypto::SSLCtxPointer;
|
||||
using ncrypto::SSLPointer;
|
||||
using ncrypto::SSLSessionPointer;
|
||||
using ncrypto::X509Pointer;
|
||||
using v8::Array;
|
||||
using v8::ArrayBuffer;
|
||||
using v8::ArrayBufferView;
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
using v8::MaybeLocal;
|
||||
using v8::Nothing;
|
||||
using v8::Object;
|
||||
using v8::String;
|
||||
using v8::Undefined;
|
||||
using v8::Value;
|
||||
|
||||
@@ -95,7 +98,7 @@ template <typename T, typename Opt, std::vector<T> Opt::*member>
|
||||
bool SetOption(Environment* env,
|
||||
Opt* options,
|
||||
const Local<Object>& object,
|
||||
const Local<v8::String>& name) {
|
||||
const Local<String>& name) {
|
||||
Local<Value> value;
|
||||
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
||||
|
||||
@@ -105,7 +108,7 @@ bool SetOption(Environment* env,
|
||||
|
||||
if (value->IsArray()) {
|
||||
auto context = env->context();
|
||||
auto values = value.As<v8::Array>();
|
||||
auto values = value.As<Array>();
|
||||
uint32_t count = values->Length();
|
||||
for (uint32_t n = 0; n < count; n++) {
|
||||
Local<Value> item;
|
||||
@@ -125,7 +128,7 @@ bool SetOption(Environment* env,
|
||||
}
|
||||
} else if constexpr (std::is_same<T, Store>::value) {
|
||||
if (item->IsArrayBufferView()) {
|
||||
Store store = Store::CopyFrom(item.As<v8::ArrayBufferView>());
|
||||
Store store = Store::CopyFrom(item.As<ArrayBufferView>());
|
||||
(options->*member).push_back(std::move(store));
|
||||
} else if (item->IsArrayBuffer()) {
|
||||
Store store = Store::CopyFrom(item.As<ArrayBuffer>());
|
||||
@@ -154,7 +157,7 @@ bool SetOption(Environment* env,
|
||||
}
|
||||
} else if constexpr (std::is_same<T, Store>::value) {
|
||||
if (value->IsArrayBufferView()) {
|
||||
Store store = Store::CopyFrom(value.As<v8::ArrayBufferView>());
|
||||
Store store = Store::CopyFrom(value.As<ArrayBufferView>());
|
||||
(options->*member).push_back(std::move(store));
|
||||
} else if (value->IsArrayBuffer()) {
|
||||
Store store = Store::CopyFrom(value.As<ArrayBuffer>());
|
||||
|
||||
Reference in new issue
Block a user