-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat: dynamically register jni methods and use @FastNative & @CriticalNative #1792
Open
triniwiz
wants to merge
1
commit into
main
Choose a base branch
from
feat/fast-y-crit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+363
−43
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: use @fastNative & @CriticalNative
Using the new annotations to improve the runtime for our jni calls
commit 04216ae454f0254ca214fdedcbb1a3493117a24e
There are no files selected for viewing
This file contains 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
This file contains 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
35 changes: 35 additions & 0 deletions
35
test-app/runtime/src/main/cpp/com_tns_AndroidJsV8Inspector.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by Osei Fortune on 07/11/2023. | ||
// | ||
#include "jni.h" | ||
#include "JEnv.h" | ||
#include "NativeScriptException.h" | ||
#include <sstream> | ||
#include "JsV8InspectorClient.h" | ||
#include "ArgConverter.h" | ||
|
||
|
||
using namespace tns; | ||
using namespace std; | ||
|
||
#ifndef COM_TNS_ANDROIDJSV8INSPECTOR_H | ||
#define COM_TNS_ANDROIDJSV8INSPECTOR_H | ||
|
||
void init(JNIEnv *env, jobject object); | ||
|
||
void initCritical(); | ||
|
||
void connect(JNIEnv *env, jobject instance, jobject connection); | ||
|
||
void scheduleBreak(JNIEnv *env, jobject instance); | ||
|
||
void scheduleBreakCritical(); | ||
|
||
void disconnect(JNIEnv *env, jobject instance); | ||
|
||
void disconnectCritical(); | ||
|
||
void dispatchMessage(JNIEnv *env, jobject instance, jstring jMessage); | ||
|
||
|
||
#endif //COM_TNS_ANDROIDJSV8INSPECTOR_H |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Created by Osei Fortune on 07/11/2023. | ||
// | ||
|
||
#include "jni.h" | ||
#include "AssetExtractor.h" | ||
#include "NativeScriptException.h" | ||
|
||
#include <sstream> | ||
|
||
#ifndef COM_TNS_ASSETEXTRACTOR_H | ||
#define COM_TNS_ASSETEXTRACTOR_H | ||
|
||
using namespace std; | ||
using namespace tns; | ||
|
||
void extractAssets(JNIEnv* env, jobject obj, jstring apk, jstring inputDir, jstring outputDir, jboolean _forceOverwrite); | ||
|
||
#endif //COM_TNS_ASSETEXTRACTOR_H |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
test-app/runtime/src/main/java/dalvik/annotation/optimization/CriticalNative.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dalvik.annotation.optimization; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.CLASS) // Save memory, don't instantiate as an object at runtime. | ||
@Target(ElementType.METHOD) | ||
public @interface CriticalNative {} |
11 changes: 11 additions & 0 deletions
11
test-app/runtime/src/main/java/dalvik/annotation/optimization/FastNative.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dalvik.annotation.optimization; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.METHOD}) | ||
public @interface FastNative { | ||
} |
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.
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.
not sure if these should be FastNative. FastNative completely disables GC while it's running, and these could likely run for a good while.
callJSMethodNative is even trickier because we can go java->native->java->native multiple times in long running methods
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.
So the fastest we can go for those would be
!