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

Interop.Pointer int64 creation from NativeScript side #921

Closed
NathanaelA opened this issue Apr 26, 2018 · 3 comments
Closed

Interop.Pointer int64 creation from NativeScript side #921

NathanaelA opened this issue Apr 26, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@NathanaelA
Copy link
Contributor

NathanaelA commented Apr 26, 2018

Please, provide the following version numbers that your issue occurs with:

3.4.x (Probably 4.x also)

Please, tell us how to recreate the issue in as much detail as possible.

Is there any code involved?

var x = new Interop.Pointer(-1) = <Pointer: 0xffffffff>
However, returning a pointer from ObjC of -1 = <Pointer: 0xffffffffffffffff>

Is their some secret to create a Interop.Pointer on the Javascript side that is the full int64 size, as it is a special value in a plugin I'm working on. This is the only piece that I'm having to create a tiny OBJC wrapper for; and I would like to eliminate this wrapper if possible.

@charsleysa
Copy link

@NathanaelA looks like they are using 32bit transformations behind the scenes.
https://github.com/NativeScript/ios-runtime/blob/9d967a09370bee938b5f8a16f9b41bbc696555ab/src/NativeScript/Marshalling/Pointer/PointerPrototype.cpp

At this point I don't think you'll be able to create 64bit pointers from JS.

@NathanaelA

This comment was marked as abuse.

@mbektchiev
Copy link
Contributor

I tested and it seems that now you can create a pointer from a 64bit number.

console.log(new interop.Pointer(-2));
console.log(new interop.Pointer(-1));

Outputs:

CONSOLE LOG file:///app/index.js:5:12: <Pointer: 0xfffffffffffffffe>
CONSOLE LOG file:///app/index.js:6:12: <Pointer: 0xffffffffffffffff>

I found another issue, however -- -1 turned out to be a special value for deleted keys in the JSC::WeakGCMap that we're using and causes an assertion failure in debug builds of the runtime. Meaning that it still is not completely safe, regardless that it appears to work. I plan to fix it this week.

mbektchiev added a commit that referenced this issue Jan 30, 2019
The "deleted" value of WeakGCMap's hashing function is -1
and such pointer's cannot be added to the `_pointerToInstance` map.

refs #921
mbektchiev added a commit that referenced this issue Jan 30, 2019
This allows for correct serialization of pointers through strings. Which can be
used for passing native objects to workers as discussed in #620 (comment).
The need for these methods arises from the fact that `toNumber` can't
be used for negative pointer values, due to JavaScript's values
inability to represent very large and/or negative 64-bit integer values
as integers.

There is a real-world use-case for the value of `-1` shown in #921
mbektchiev added a commit that referenced this issue Jan 31, 2019
This allows for correct serialization of pointers through strings. Which can be
used for passing native objects to workers as discussed in #620 (comment).
The need for these methods arises from the fact that `toNumber` can't
be used for negative pointer values, due to JavaScript's values
inability to represent very large and/or negative 64-bit integer values
as integers.

There is a real-world use-case for the value of `-1` shown in #921
mbektchiev added a commit that referenced this issue Jan 31, 2019
This allows for correct serialization of pointers through strings. Which can be
used for passing native objects to workers as discussed in #620 (comment).
The need for these methods arises from the fact that `toNumber` can't
be used for negative pointer values, due to JavaScript's values
inability to represent very large and/or negative 64-bit integer values
as integers.

There is a real-world use-case for the value of `-1` shown in #921
@mbektchiev mbektchiev self-assigned this Feb 1, 2019
@mbektchiev mbektchiev added the bug label Feb 1, 2019
@mbektchiev mbektchiev added this to the 5.2.0 milestone Feb 1, 2019
@vhristov5555 vhristov5555 self-assigned this Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants