aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/javascript/jsc/bindings/napi.cpp27
2 files changed, 22 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 3a3675a44..1b4af8247 100644
--- a/Makefile
+++ b/Makefile
@@ -1127,7 +1127,7 @@ wasm-return1:
-EMIT_LLVM_FOR_RELEASE=
+EMIT_LLVM_FOR_RELEASE= -emit-llvm
# We do this outside of build.zig for performance reasons
# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest
diff --git a/src/javascript/jsc/bindings/napi.cpp b/src/javascript/jsc/bindings/napi.cpp
index 13ec61a53..027609ec7 100644
--- a/src/javascript/jsc/bindings/napi.cpp
+++ b/src/javascript/jsc/bindings/napi.cpp
@@ -118,16 +118,31 @@ extern "C" napi_status napi_get_cb_info(
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(env);
JSC::VM& vm = globalObject->vm();
JSC::CallFrame* callFrame = reinterpret_cast<JSC::CallFrame*>(cbinfo);
- JSC::JSValue thisValue = callFrame->thisValue();
- *argc = callFrame->argumentCount();
- **reinterpret_cast<JSC::EncodedJSValue***>(argv) = reinterpret_cast<JSC::EncodedJSValue*>(callFrame->addressOfArgumentsStart());
- if (thisValue && this_arg != nullptr) {
+
+ auto inputArgsCount = argc == nullptr ? 0 : *argc;
+
+ if (inputArgsCount > 0) {
+ auto outputArgsCount = callFrame->argumentCount();
+ auto argsToCopy = inputArgsCount < outputArgsCount ? inputArgsCount : outputArgsCount;
+ *argc = argsToCopy;
+
+ memcpy(argv, callFrame->addressOfArgumentsStart(), argsToCopy * sizeof(JSC::JSValue));
+ auto argv_ptr = argv[outputArgsCount];
+ for (size_t i = outputArgsCount; i < inputArgsCount; i++) {
+ argv[i] = reinterpret_cast<napi_value>(JSC::JSValue::encode(JSC::jsUndefined()));
+ }
+ }
+
+ if (this_arg != nullptr) {
+ JSC::JSValue thisValue = callFrame->thisValue();
*this_arg = reinterpret_cast<napi_value>(JSC::JSValue::encode(thisValue));
}
- Zig::JSFFIFunction* ffiFunction = JSC::jsDynamicCast<Zig::JSFFIFunction*>(vm, JSC::JSValue(callFrame->jsCallee()));
- if (data != nullptr)
+ if (data != nullptr) {
+ Zig::JSFFIFunction* ffiFunction = JSC::jsDynamicCast<Zig::JSFFIFunction*>(vm, JSC::JSValue(callFrame->jsCallee()));
*data = reinterpret_cast<void*>(ffiFunction->dataPtr);
+ }
+
return napi_ok;
}