| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64e8646 commit f0134fa
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ namespace node { | |||
| 13 | 13 | using v8::FastApiCallbackOptions; | |
| 14 | 14 | using v8::FastApiTypedArray; | |
| 15 | 15 | using v8::FunctionCallbackInfo; | |
| 16 | + using v8::HandleScope; | ||
| 16 | 17 | using v8::Local; | |
| 17 | 18 | using v8::Object; | |
| 18 | 19 | using v8::Value; | |
@@ -59,7 +60,8 @@ bool FastTimingSafeEqual(Local<Value> receiver, | |||
| 59 | 60 | if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) || | |
| 60 | 61 | !b.getStorageIfAligned(&data_b)) { | |
| 61 | 62 | TRACK_V8_FAST_API_CALL("crypto.timingSafeEqual.error"); | |
| 62 | - options.fallback = true; | ||
| 63 | + HandleScope scope(options.isolate); | ||
| 64 | + THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(options.isolate); | ||
| 63 | 65 | return false; | |
| 64 | 66 | } | |
| 65 | 67 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ using v8::Context; | |||
| 14 | 14 | using v8::FastApiCallbackOptions; | |
| 15 | 15 | using v8::FunctionCallbackInfo; | |
| 16 | 16 | using v8::FunctionTemplate; | |
| 17 | + using v8::HandleScope; | ||
| 17 | 18 | using v8::Integer; | |
| 18 | 19 | using v8::Isolate; | |
| 19 | 20 | using v8::Local; | |
@@ -193,7 +194,8 @@ void HistogramBase::FastRecord(Local<Value> receiver, | |||
| 193 | 194 | const int64_t value, | |
| 194 | 195 | FastApiCallbackOptions& options) { | |
| 195 | 196 | if (value < 1) { | |
| 196 | - options.fallback = true; | ||
| 197 | + HandleScope scope(options.isolate); | ||
| 198 | + THROW_ERR_OUT_OF_RANGE(options.isolate, "value is out of range"); | ||
| 197 | 199 | return; | |
| 198 | 200 | } | |
| 199 | 201 | HistogramBase* histogram; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1057,14 +1057,12 @@ static int32_t FastInternalModuleStat( | |||
| 1057 | 1057 | const FastOneByteString& input, | |
| 1058 | 1058 | // NOLINTNEXTLINE(runtime/references) This is V8 api. | |
| 1059 | 1059 | FastApiCallbackOptions& options) { | |
| 1060 | - Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked()); | ||
| 1060 | + Environment* env = Environment::GetCurrent(options.isolate); | ||
| 1061 | + HandleScope scope(env->isolate()); | ||
| 1061 | 1062 | ||
| 1062 | 1063 | auto path = std::filesystem::path(input.data, input.data + input.length); | |
| 1063 | - if (UNLIKELY(!env->permission()->is_granted( | ||
| 1064 | - env, permission::PermissionScope::kFileSystemRead, path.string()))) { | ||
| 1065 | - options.fallback = true; | ||
| 1066 | - return -1; | ||
| 1067 | - } | ||
| 1064 | + THROW_IF_INSUFFICIENT_PERMISSIONS( | ||
| 1065 | + env, permission::PermissionScope::kFileSystemRead, path.string(), -1); | ||
| 1068 | 1066 | ||
| 1069 | 1067 | switch (std::filesystem::status(path).type()) { | |
| 1070 | 1068 | case std::filesystem::file_type::directory: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ using v8::Exception; | |||
| 35 | 35 | using v8::FastApiCallbackOptions; | |
| 36 | 36 | using v8::FunctionCallbackInfo; | |
| 37 | 37 | using v8::FunctionTemplate; | |
| 38 | + using v8::HandleScope; | ||
| 38 | 39 | using v8::Integer; | |
| 39 | 40 | using v8::Isolate; | |
| 40 | 41 | using v8::Local; | |
@@ -248,17 +249,18 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback( | |||
| 248 | 249 | WASI* wasi = reinterpret_cast<WASI*>(BaseObject::FromJSObject(receiver)); | |
| 249 | 250 | if (UNLIKELY(wasi == nullptr)) return EinvalError<R>(); | |
| 250 | 251 | ||
| 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; | ||
| 252 | + Isolate* isolate = receiver->GetIsolate(); | ||
| 253 | + HandleScope scope(isolate); | ||
| 254 | + if (wasi->memory_.IsEmpty()) { | ||
| 255 | + THROW_ERR_WASI_NOT_STARTED(isolate); | ||
| 254 | 256 | return EinvalError<R>(); | |
| 255 | 257 | } | |
| 256 | - uint8_t* memory = nullptr; | ||
| 257 | - CHECK(LIKELY(options.wasm_memory->getStorageIfAligned(&memory))); | ||
| 258 | + Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer(); | ||
| 259 | + size_t mem_size = ab->ByteLength(); | ||
| 260 | + char* mem_data = static_cast<char*>(ab->Data()); | ||
| 261 | + CHECK_NOT_NULL(mem_data); | ||
| 258 | 262 | ||
| 259 | - return F(*wasi, | ||
| 260 | - {reinterpret_cast<char*>(memory), options.wasm_memory->length()}, | ||
| 261 | - args...); | ||
| 263 | + return F(*wasi, {mem_data, mem_size}, args...); | ||
| 262 | 264 | } | |
| 263 | 265 | ||
| 264 | 266 | namespace { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments