Repository navigation
perf(android): faster object lifecycle and call paths in the JNI bridge - #134
Open
ammarahm-ed wants to merge 16 commits into
Open
ammarahm-ed wants to merge 16 commits into
ammarahm-ed wants to merge 16 commits into
Conversation
…the reserved object id
…ches the class once
…dex runtimes by id
…cache their final fields
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the Java ↔ JS bridge and first-access work of NativeScript/android#2099 into both the Node-API and the direct runtime, adapted to the existing wrapper lifecycle, and fixes the construction-window id misroute.
Changes
long[](values, then one type byte per argument) read with a single region copyClass.getName()andFindClassper new wrapper;GetOrCreateJSWrappercollapses the id lookup and wrapper creationObjectTablereplaces the four id maps (and the threeNativeScript*Mapclasses), with optimisticStampedLockreads on API 24+makeInstancesWeakcall per post-GC drainregisterConstructedInstancereturns used memory in the same upcallruntimeTag__nsandobjectId__ns, used as the receiver hint; runtimes are indexed by idMethodNameIdsgives each callback name a process-wide id and native keeps one name value per runtime-Bsymbolic-functionsNot ported: the admission gate, instance-template wrappers, internalized names from the metadata table, the unconverted-argument cleanup (no equivalent in this tree), and non-constructor methods on Node-API (
napi_create_functionhas no option for it).Before / after
Release build, V8, Sony SO-01M, 2 launches after a warm-up, base is the stack top (#132), same harness on both sides. Differences under ~5% are noise. ns per call unless marked.
Large packages are deliberately not put in dictionary mode: it made package member reads 3x slower (4 → 12 ns) for a small first-access gain.
The harness has no wrapper-release or multithreaded rows, so the batching and
ObjectTablechanges are not measured here.Tests
Jasmine suite on the device with V8: Node-API 529 specs, 0 failures; direct 457 specs, 0 failures (stack top: 522/0 and 450/0). New specs cover wrapper identity, construction windows and a callback that throws after a GC. The
NativeScriptRuntimeBoundinterface count in the generated-class specs is updated.ObjectTableTestandMethodNameIdsTestrun in the runtime unit tests.Only V8 was built and run.
static-binding-generatorGeneratorTestfails on the base as well (ClassFormatError) and could not be run. The runtime generator's dex output for the new binding fields was compile-checked only.Stacked on #132.