-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS: make hash float support IE/Safari(follow up #16863) #16872
Conversation
It seems that safari begins to support BigUint64Array |
else: | ||
let z = newUint32Array(x) | ||
y[0] = num | ||
big(z[0]) + big(z[1]) shl big(32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big(z[0]) + big(z[1]) shl big(32) | |
big(z[0]) + big(z[1]) shl big(32) # xxx support `bigEndian` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endians
is totally wrong in nodejs backend. For Nim JS, endians is always bigEndian
.
echo cpuEndian
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we could check endians by means of typed array
{.emit: """
let endianNess = () => {
let uInt32 = new Uint32Array([0x11223344]);
let uInt8 = new Uint8Array(uInt32.buffer);
if(uInt8[0] === 0x44) {
return 'Little Endian';
} else if (uInt8[0] === 0x11) {
return 'Big Endian';
} else {
return 'Maybe mixed-endian?';
}
};
console.log(endianNess());
"""
.}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Nim JS, endians is always bigEndian.
endianness for js (say in browser or on node) depends on the host machine where the code runs
see also timotheecour#515
endians is totally wrong in nodejs backend.
possibly
EDIT: yikes, indeed:
nim r -b:js --eval:'echo cpuEndian'
# both with or without -d:nodejs
bigEndian
=> we should file/fix
this possibly also impacts js non-nodejs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO for starters we should fix these:
(name: "js", intSize: 32, endian: bigEndian,floatSize: 64,bit: 32),
(name: "nimvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
to littleEndian
in platform.nim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> #16886
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timotheecour
in platform.nim
there is vm
and nimvm
, I don't whether they are different?
Ref #16549 (comment)