Skip to content

Commit

Permalink
Reverts #192 (#193)
Browse files Browse the repository at this point in the history
* [wasi] Stop using V8 fast API

* Revert "[wasi] Stop using V8 fast API"

This reverts commit 0d5d171.

* Revert "[v8] Stop using deprecated fields of v8::FastApiCallbackOptions (#192)"

This reverts commit 286ed38.
  • Loading branch information
gahaas authored and pthier committed Jul 15, 2024
1 parent 4ec9e96 commit ed7f0da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/crypto/crypto_timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ bool FastTimingSafeEqual(Local<Value> 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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ void HistogramBase::FastRecord(Local<Value> 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;
Expand Down
18 changes: 9 additions & 9 deletions src/node_wasi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,17 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
WASI* wasi = reinterpret_cast<WASI*>(BaseObject::FromJSObject(receiver));
if (UNLIKELY(wasi == nullptr)) return EinvalError<R>();

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<R>();
}
Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer();
size_t mem_size = ab->ByteLength();
char* mem_data = static_cast<char*>(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<char*>(memory), options.wasm_memory->length()},
args...);
}

namespace {
Expand Down

0 comments on commit ed7f0da

Please sign in to comment.