Skip to content
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

Merged
merged 1 commit into from
Feb 1, 2021

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Jan 30, 2021

Ref #16549 (comment)

@ringabout ringabout changed the title JS: make hash float support IE/Safari(Ref #16863) JS: make hash float support IE/Safari(follow up #16863) Jan 30, 2021
@ringabout
Copy link
Member Author

It seems that safari begins to support BigUint64Array
https://bugs.webkit.org/show_bug.cgi?id=190800

else:
let z = newUint32Array(x)
y[0] = num
big(z[0]) + big(z[1]) shl big(32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
big(z[0]) + big(z[1]) shl big(32)
big(z[0]) + big(z[1]) shl big(32) # xxx support `bigEndian`

Copy link
Member Author

@ringabout ringabout Jan 31, 2021

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.

Copy link
Member Author

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());
"""
.}

Copy link
Member

@timotheecour timotheecour Jan 31, 2021

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

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> #16886

Copy link
Member Author

@ringabout ringabout Feb 1, 2021

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?

@Araq Araq merged commit a2855b6 into nim-lang:devel Feb 1, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants