Skip to content

Commit 286ed38

Browse files
authored
[v8] Stop using deprecated fields of v8::FastApiCallbackOptions (v8#192)
1 parent cce9437 commit 286ed38

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/crypto/crypto_timing.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ bool FastTimingSafeEqual(Local<Value> receiver,
5757
uint8_t* data_b;
5858
if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) ||
5959
!b.getStorageIfAligned(&data_b)) {
60-
options.fallback = true;
60+
Environment* env = Environment::GetCurrent(options.isolate);
61+
THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(env);
6162
return false;
6263
}
6364

src/histogram.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ void HistogramBase::FastRecord(Local<Value> receiver,
193193
const int64_t value,
194194
FastApiCallbackOptions& options) {
195195
if (value < 1) {
196-
options.fallback = true;
196+
Environment* env = Environment::GetCurrent(options.isolate);
197+
THROW_ERR_OUT_OF_RANGE(env, "value is out of range");
197198
return;
198199
}
199200
HistogramBase* histogram;

src/node_wasi.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,17 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
248248
WASI* wasi = reinterpret_cast<WASI*>(BaseObject::FromJSObject(receiver));
249249
if (UNLIKELY(wasi == nullptr)) return EinvalError<R>();
250250

251-
if (UNLIKELY(options.wasm_memory == nullptr || wasi->memory_.IsEmpty())) {
252-
// fallback to slow path which to throw an error about missing memory.
253-
options.fallback = true;
254-
return EinvalError<R>();
251+
v8::Isolate* isolate = receiver->GetIsolate();
252+
if (wasi->memory_.IsEmpty()) {
253+
THROW_ERR_WASI_NOT_STARTED(isolate);
254+
return;
255255
}
256-
uint8_t* memory = nullptr;
257-
CHECK(LIKELY(options.wasm_memory->getStorageIfAligned(&memory)));
256+
Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer();
257+
size_t mem_size = ab->ByteLength();
258+
char* mem_data = static_cast<char*>(ab->Data());
259+
CHECK_NOT_NULL(mem_data);
258260

259-
return F(*wasi,
260-
{reinterpret_cast<char*>(memory), options.wasm_memory->length()},
261-
args...);
261+
return F(*wasi, {mem_data, mem_size}, args...);
262262
}
263263

264264
namespace {

0 commit comments

Comments
 (0)