Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Han Jiang <jhcarl0814@gmail.com>
* Abdelrahman Teima <abdelrahmanteima@gmail.com>
* Jaap Aarts <jaap.aarts1@gmail.com>
* Dimokritos Kolitsos <dkolitsos@protonmail.com>
16 changes: 8 additions & 8 deletions src/lib/libembind.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ var LibraryEmbind = {

_embind_finalize_value_array__deps: [
'$tupleRegistrations', '$runDestructors',
'$readPointer', '$whenDependentTypesAreResolved', '$stackAlloc'],
'$readPointer', '$whenDependentTypesAreResolved', '$stackAlloc', '$zeroMemory'],
_embind_finalize_value_array: (rawTupleType) => {
var reg = tupleRegistrations[rawTupleType];
delete tupleRegistrations[rawTupleType];
Expand Down Expand Up @@ -1013,7 +1013,7 @@ var LibraryEmbind = {
throw new TypeError(`Incorrect number of tuple elements for ${reg.name}: expected=${elementsLength}, actual=${o.length}`);
}
var ptr;
if (isTrivial && destructors === null) {
if (isTrivial && !destructors) {
// Trivially constructible and destructible, and the invoker
// manages a stack frame around this call: the temporary lives on
// the wasm stack. No allocation, nothing to destruct. Callers
Expand All @@ -1022,10 +1022,10 @@ var LibraryEmbind = {
// Zero-fill so unregistered fields and padding match the
// value-initialization the heap path's `new T()` performs.
ptr = stackAlloc(valueSize);
HEAPU8.fill(0, ptr, ptr + valueSize);
zeroMemory(ptr, valueSize);
} else {
ptr = rawConstructor();
if (destructors !== null) {
if (destructors) {
destructors.push(rawDestructor, ptr);
}
}
Expand Down Expand Up @@ -1092,7 +1092,7 @@ var LibraryEmbind = {

_embind_finalize_value_object__deps: [
'$structRegistrations', '$runDestructors',
'$readPointer', '$whenDependentTypesAreResolved', '$stackAlloc'],
'$readPointer', '$whenDependentTypesAreResolved', '$stackAlloc', '$zeroMemory'],
_embind_finalize_value_object: (structType) => {
var reg = structRegistrations[structType];
delete structRegistrations[structType];
Expand Down Expand Up @@ -1150,16 +1150,16 @@ var LibraryEmbind = {
}
}
var ptr;
if (isTrivial && destructors === null) {
if (isTrivial && !destructors) {
// See the matching branch in _embind_finalize_value_array: the
// invoker manages a stack frame, so the temporary lives on the
// wasm stack with no allocation and no destructor bookkeeping;
// zero-filled to match the heap path's value-initialization.
ptr = stackAlloc(valueSize);
HEAPU8.fill(0, ptr, ptr + valueSize);
zeroMemory(ptr, valueSize);
} else {
ptr = rawConstructor();
if (destructors !== null) {
if (destructors) {
destructors.push(rawDestructor, ptr);
}
}
Expand Down
Loading