Skip to content

Commit 346dbbe

Browse files
gahaasvictorgomes
authored andcommitted
Reverts v8#192 (nodejs#193)
* [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 (nodejs#192)" This reverts commit 286ed38.
1 parent 167b455 commit 346dbbe

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/crypto/crypto_timing.cc

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

src/histogram.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ void HistogramBase::FastRecord(Local<Value> receiver,
193193
const int64_t value,
194194
FastApiCallbackOptions& options) {
195195
if (value < 1) {
196-
Environment* env = Environment::GetCurrent(options.isolate);
197-
THROW_ERR_OUT_OF_RANGE(env, "value is out of range");
196+
options.fallback = true;
198197
return;
199198
}
200199
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-
v8::Isolate* isolate = receiver->GetIsolate();
252-
if (wasi->memory_.IsEmpty()) {
253-
THROW_ERR_WASI_NOT_STARTED(isolate);
254-
return;
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>();
255255
}
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);
256+
uint8_t* memory = nullptr;
257+
CHECK(LIKELY(options.wasm_memory->getStorageIfAligned(&memory)));
260258

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

264264
namespace {

0 commit comments

Comments
 (0)