-
Notifications
You must be signed in to change notification settings - Fork 340
Merge N-API JSRT implementation from abi-stable-node #238
Conversation
LGTM 👍 |
Are these changes in Microsoft/chakracore's 2.0 branch? If yes, can you just sync Microsoft/Chakracore branch 2.0 instead? |
@@ -74,7 +74,8 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol && | |||
compareToNative(x, MySubClass); | |||
compareToNative(y, MySubClass); | |||
compareToNative(x, MyClass); | |||
compareToNative(y, MyClass); | |||
// TODO: https://github.com/nodejs/abi-stable-node/issues/236 |
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.
TODO [](start = 5, length = 4)
nit: Should we open/port these issues to nodejs/node?
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.
Probably not, because these issues are specific to N-API on Node-ChakraCore. The tests pass with N-API on Node-V8.
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.
Maybe they could be moved to nodejs/node-chakracore/issues. I think sometime soon we will stop using the abi-stable-node fork, now that all the code has been merged from it. But then we'll review all the remaining open issues there.
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.
Does it make sense to add the ChakraCore check rather than commenting these out?
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.
@kfarnung I'm not sure about that. These are issues that we want to fix in Node-ChakraCore, not engine-specific behavior that we want to allow indefinitely.
These JSRT APIs were added specifically to support N-API. Would it be better to add them to ChakraCore first, or do changes sometimes flow back from Node-ChakraCore? |
@jasongin I've been making my ChakraCore changes in release/2.0 and then flowing them into node-chakracore. I don't believe we have a two-way sync, we just clone ChakraCore into node-chakracore. |
I created a PR for the weak-reference APIs at chakra-core/ChakraCore#2948 I guess this PR should wait for that change to merge into ChakraCore and Node-ChakraCore. |
That's correct. |
node.gyp
Outdated
'src/node_api.h', | ||
'src/node_api_types.h', | ||
# 'src/node_api.cc', | ||
'src/node_api_jsrt.cc', |
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.
Can we just add a "conditions" block which checked the engine type and then removes node_api.cc and adds in node_api_jsrt.cc?
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.
OK, I'll do that.
src/node_api_jsrt.cc
Outdated
JsValueRef target; | ||
CHECK_JSRT(JsGetWeakReferenceValue(weakRef, &target)); | ||
|
||
if (target == nullptr) { |
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.
Should we be comparing against JS_INVALID_REFERENCE
?
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.
Yes. (Though actually they are the same thing.)
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.
Fixed.
Merge pull request #2948 from jasongin:weakref - Add a new typedef: `JsWeakRef` - Add two new APIs: `JsCreateWeakReference()`, `JsGetWeakReferenceValue()` - Add a native test for the new APIs The weak reference APIs are required for N-API in Node-ChakraCore. See nodejs/node-chakracore#238
Merge pull request #2948 from jasongin:weakref - Add a new typedef: `JsWeakRef` - Add two new APIs: `JsCreateWeakReference()`, `JsGetWeakReferenceValue()` - Add a native test for the new APIs The weak reference APIs are required for N-API in Node-ChakraCore. See nodejs/node-chakracore#238
test/addons-napi/test_string/test.js
Outdated
@@ -46,7 +46,8 @@ const str4 = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿'; | |||
assert.strictEqual(test_string.TestLatin1(str4), str4); | |||
assert.strictEqual(test_string.TestUtf8(str4), str4); | |||
assert.strictEqual(test_string.TestUtf16(str4), str4); | |||
assert.strictEqual(test_string.TestLatin1Insufficient(str4), str4.slice(0, 3)); | |||
// TODO: https://github.com/nodejs/abi-stable-node/issues/235 | |||
// assert.strictEqual(test_string.TestLatin1Insufficient(str4), str4.slice(0, 3)); |
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.
/home/kfarnung/GitHub/node-chakracore/test/addons-napi/test_string/test.js
50:1 error Line 50 exceeds the maximum line length of 80 max-len
61:1 error Line 61 exceeds the maximum line length of 80 max-len
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.
Fixed.
Made some modifications to your original review and pushed to my fork: https://github.com/kfarnung/node-chakracore/tree/napi
|
Thanks @kfarnung! I rebased on top of the latest |
CI: https://ci.nodejs.org/job/chakracore-test-pull-request/31/ - One failure |
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.
LGTM
- Copy `node_api_jsrt.cc` from abi-stable-node fork - Update `node_api_jsrt.cc` for renamed JSRT string APIs: `JsCopyStringUtf8` -> `JsCopyString`, etc - Update `node.gyp` to build `node_api_jsrt.cc` instead of `node_api.cc` - Temporarily disable 2 N-API test cases with known failures PR-URL: nodejs#238 Reviewed-By: Taylor Woll <taylor.woll@microsoft.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
PR-URL: nodejs#238 Reviewed-By: Taylor Woll <taylor.woll@microsoft.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
PR-URL: nodejs#238 Reviewed-By: Taylor Woll <taylor.woll@microsoft.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
PR-URL: nodejs#238 Reviewed-By: Taylor Woll <taylor.woll@microsoft.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
When Node-ChakraCore merged the latest changes from upstream node last week, it got the V8 N-API implementation. This change replaces that with a JSRT implementation, so that N-API calls do not go through the shim. The public API surface in
node_api.h
is unchanged.This code is a result of a collaborative effort from the N-API working group in the api-prototype-chakracore-8.x branch of the abi-stable-node fork. It includes contributions from the following people in alphabetical order:
In addition to all the work done in the abi-stable-node fork, the following changes were done for this PR:
node_api_jsrt.cc
from abi-stable-node forknode_api_jsrt.cc
for renamed JSRT string APIs:JsCopyStringUtf8
->JsCopyString
, etcnode.gyp
to buildnode_api_jsrt.cc
instead ofnode_api.cc
node_api_jsrt.cc
(in the second commit)The N-API V8 implementation (
node_api.cc
) is not deleted here, but merely excluded from the build, so that there are no conflicts in future merges from upstream node.Related links:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
n-api