-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
61 additions
and
50 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -158,16 +158,21 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionCopyS | |
// Clone the scope info | ||
#ifdef ENABLE_NODE | ||
auto sourceScopeInfo = sourceV8InternalShared.scope_info(); | ||
#else | ||
auto sourceScopeInfo = sourceV8InternalShared->scope_info(); | ||
#endif | ||
auto emptyBlocklistHandle = V8InternalStringSet::New(v8InternalIsolate); | ||
auto targetScopeInfo = *V8InternalScopeInfo::RecreateWithBlockList( | ||
v8InternalIsolate, v8::internal::handle(sourceScopeInfo, v8InternalIsolate), emptyBlocklistHandle); | ||
#ifdef ENABLE_NODE | ||
targetV8InternalShared.set_raw_scope_info(targetScopeInfo); | ||
#else | ||
targetV8InternalShared->set_raw_scope_info(targetScopeInfo); | ||
auto sourceScopeInfo = sourceV8InternalShared->scope_info(); | ||
const int length = (sourceScopeInfo->AllocatedSize() - V8InternalHeapObject::kHeaderSize) / v8::internal::kTaggedSize; | ||
auto targetScopeInfo = v8InternalIsolate->factory()->NewScopeInfo(length); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
caoccao
Author
Owner
|
||
v8InternalIsolate->heap()->CopyRange( | ||
*targetScopeInfo, | ||
targetScopeInfo->data_start(), | ||
sourceScopeInfo->data_start(), | ||
length, | ||
V8InternalWriteBarrierMode::UPDATE_WRITE_BARRIER); | ||
targetV8InternalShared->set_raw_scope_info(*targetScopeInfo); | ||
#endif | ||
targetV8InternalFunction.set_shared(targetV8InternalShared, V8InternalWriteBarrierMode::UPDATE_WRITE_BARRIER); | ||
success = true; | ||
|
@@ -223,13 +228,13 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionDisca | |
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::handle(v8InternalShared, v8InternalIsolate)); | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetArguments | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -261,10 +266,10 @@ JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionG | |
} | ||
} | ||
return nullptr; | ||
} | ||
} | ||
|
||
JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetCachedData | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -288,13 +293,13 @@ JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionGet | |
return Javet::Converter::ToJavaByteArray(jniEnv, cachedDataPointer.get()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
||
JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetContext | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalIsolate = reinterpret_cast<V8InternalIsolate*>(v8Context->GetIsolate()); | ||
|
@@ -307,7 +312,7 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetCon | |
} | ||
|
||
JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetInternalProperties | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
// This feature is not enabled yet. | ||
|
@@ -328,7 +333,7 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetInt | |
} | ||
|
||
JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSFunctionType | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
using namespace Javet::Enums::JSFunctionType; | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
|
@@ -352,7 +357,7 @@ JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSFunc | |
} | ||
|
||
JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSScopeType | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -369,7 +374,7 @@ JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSScop | |
} | ||
|
||
JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetScopeInfos | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, | ||
jboolean includeGlobalVariables, jboolean includeScopeTypeGlobal) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
V8LocalArray v8LocalArray = v8::Array::New(v8Context->GetIsolate()); | ||
|
@@ -403,12 +408,12 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSco | |
v8LocalArray->Set(v8Context, index, innerV8LocalArray).ToChecked(); | ||
++index; | ||
} | ||
} | ||
} | ||
return v8Runtime->SafeToExternalV8Value(jniEnv, v8Context, v8LocalArray); | ||
} | ||
|
||
JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetScriptSource | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
V8InternalDisallowGarbageCollection disallowGarbageCollection; | ||
|
@@ -440,13 +445,13 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetScr | |
Javet::Converter::ToJavaString(jniEnv, sourceCode.get()), | ||
startPosition, | ||
endPosition); | ||
} | ||
} | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
||
JNIEXPORT jstring JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSourceCode | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -470,13 +475,13 @@ JNIEXPORT jstring JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSou | |
startPosition, endPosition - startPosition); | ||
#endif | ||
return Javet::Converter::ToJavaString(jniEnv, sourceCode.get()); | ||
} | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsCompiled | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -493,7 +498,7 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsCom | |
} | ||
|
||
JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsWrapped | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); | ||
|
@@ -510,7 +515,7 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsWra | |
} | ||
|
||
JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetContext | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jobject mV8ContextValue) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jobject mV8ContextValue) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
jboolean success = false; | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
|
@@ -525,7 +530,7 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetCo | |
} | ||
|
||
JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetScriptSource | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jobject mScriptSource, jboolean mCloneScript) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jobject mScriptSource, jboolean mCloneScript) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
jboolean success = false; | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
|
@@ -600,13 +605,13 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSc | |
} | ||
DELETE_LOCAL_REF(jniEnv, mSourceCode); | ||
} | ||
} | ||
} | ||
} | ||
return success; | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSourceCode | ||
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jstring mSourceCode, jboolean mCloneScript) { | ||
(JNIEnv * jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jstring mSourceCode, jboolean mCloneScript) { | ||
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); | ||
jboolean success = false; | ||
if (IS_V8_FUNCTION(v8ValueType)) { | ||
|
@@ -755,8 +760,8 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSo | |
success = true; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
return success; | ||
} |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
JAVET_REPO=sjtucaocao/javet | ||
JAVET_VERSION=3.1.8 | ||
JAVET_V8_VERSION=12.8.374.17 | ||
JAVET_V8_VERSION=12.9.202.18 | ||
JAVET_NODE_VERSION=20.17.0 |
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
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
There might be memory leak. Further check is required.