From 346dbbe308c8b13ba4a76ff512c475cc648f0ef0 Mon Sep 17 00:00:00 2001 From: gahaas Date: Mon, 24 Jun 2024 12:16:04 +0200 Subject: [PATCH] Reverts https://github.com/v8/node/pull/192 (#193) * [wasi] Stop using V8 fast API * Revert "[wasi] Stop using V8 fast API" This reverts commit 0d5d171017e857712093189f3a357cee862635e0. * Revert "[v8] Stop using deprecated fields of v8::FastApiCallbackOptions (#192)" This reverts commit 286ed38fb55e183f20e4d51d30e8ffb844cd5864. --- src/crypto/crypto_timing.cc | 3 +-- src/histogram.cc | 3 +-- src/node_wasi.cc | 18 +++++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/crypto/crypto_timing.cc b/src/crypto/crypto_timing.cc index 7772ff875d855d..03fe60c9e2a154 100644 --- a/src/crypto/crypto_timing.cc +++ b/src/crypto/crypto_timing.cc @@ -58,8 +58,7 @@ bool FastTimingSafeEqual(Local receiver, uint8_t* data_b; if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) || !b.getStorageIfAligned(&data_b)) { - Environment* env = Environment::GetCurrent(options.isolate); - THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(env); + options.fallback = true; return false; } diff --git a/src/histogram.cc b/src/histogram.cc index 4aacaa2a5d1253..4dbdea9be57214 100644 --- a/src/histogram.cc +++ b/src/histogram.cc @@ -193,8 +193,7 @@ void HistogramBase::FastRecord(Local receiver, const int64_t value, FastApiCallbackOptions& options) { if (value < 1) { - Environment* env = Environment::GetCurrent(options.isolate); - THROW_ERR_OUT_OF_RANGE(env, "value is out of range"); + options.fallback = true; return; } HistogramBase* histogram; diff --git a/src/node_wasi.cc b/src/node_wasi.cc index b77a1f57854261..ad1da44a01f437 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -248,17 +248,17 @@ R WASI::WasiFunction::FastCallback( WASI* wasi = reinterpret_cast(BaseObject::FromJSObject(receiver)); if (UNLIKELY(wasi == nullptr)) return EinvalError(); - v8::Isolate* isolate = receiver->GetIsolate(); - if (wasi->memory_.IsEmpty()) { - THROW_ERR_WASI_NOT_STARTED(isolate); - return; + if (UNLIKELY(options.wasm_memory == nullptr || wasi->memory_.IsEmpty())) { + // fallback to slow path which to throw an error about missing memory. + options.fallback = true; + return EinvalError(); } - Local ab = wasi->memory_.Get(isolate)->Buffer(); - size_t mem_size = ab->ByteLength(); - char* mem_data = static_cast(ab->Data()); - CHECK_NOT_NULL(mem_data); + uint8_t* memory = nullptr; + CHECK(LIKELY(options.wasm_memory->getStorageIfAligned(&memory))); - return F(*wasi, {mem_data, mem_size}, args...); + return F(*wasi, + {reinterpret_cast(memory), options.wasm_memory->length()}, + args...); } namespace {