73
73
import org .graalvm .polyglot .nativeapi .types .CInt16Pointer ;
74
74
import org .graalvm .polyglot .nativeapi .types .CInt32Pointer ;
75
75
import org .graalvm .polyglot .nativeapi .types .CInt64Pointer ;
76
+ import org .graalvm .polyglot .nativeapi .types .CInt64PointerPointer ;
76
77
import org .graalvm .polyglot .nativeapi .types .CInt8Pointer ;
77
78
import org .graalvm .polyglot .nativeapi .types .CUnsignedBytePointer ;
78
79
import org .graalvm .polyglot .nativeapi .types .CUnsignedIntPointer ;
111
112
import com .oracle .svm .core .c .CUnsigned ;
112
113
import com .oracle .svm .core .handles .ObjectHandlesImpl ;
113
114
import com .oracle .svm .core .handles .ThreadLocalHandles ;
115
+ import com .oracle .svm .core .jvmstat .PerfDataSupport ;
114
116
import com .oracle .svm .core .thread .ThreadingSupportImpl ;
115
117
import com .oracle .svm .core .threadlocal .FastThreadLocalFactory ;
116
118
import com .oracle .svm .core .threadlocal .FastThreadLocalObject ;
@@ -335,7 +337,7 @@ public static PolyglotStatus poly_context_builder_engine(PolyglotIsolateThread t
335
337
public static PolyglotStatus poly_context_builder_option (PolyglotIsolateThread thread , PolyglotContextBuilder context_builder , @ CConst CCharPointer key_utf8 , @ CConst CCharPointer value_utf8 ) {
336
338
resetErrorState ();
337
339
Context .Builder contextBuilder = fetchHandle (context_builder );
338
- contextBuilder .option (CTypeConversion .toJavaString (key_utf8 ), CTypeConversion .toJavaString (value_utf8 ));
340
+ contextBuilder .option (CTypeConversion .utf8ToJavaString (key_utf8 ), CTypeConversion .utf8ToJavaString (value_utf8 ));
339
341
return poly_ok ;
340
342
}
341
343
@@ -533,8 +535,8 @@ public static PolyglotStatus poly_context_eval(PolyglotIsolateThread thread, Pol
533
535
resetErrorState ();
534
536
Context c = fetchHandle (context );
535
537
String languageName = CTypeConversion .toJavaString (language_id );
536
- String jName = CTypeConversion .toJavaString (name_utf8 );
537
- String jCode = CTypeConversion .toJavaString (source_utf8 );
538
+ String jName = CTypeConversion .utf8ToJavaString (name_utf8 );
539
+ String jCode = CTypeConversion .utf8ToJavaString (source_utf8 );
538
540
539
541
Source sourceCode = Source .newBuilder (languageName , jCode , jName ).build ();
540
542
Value evalResult = c .eval (sourceCode );
@@ -663,7 +665,7 @@ public static PolyglotStatus poly_value_execute(PolyglotIsolateThread thread, Po
663
665
public static PolyglotStatus poly_value_get_member (PolyglotIsolateThread thread , PolyglotValue value , @ CConst CCharPointer utf8_identifier , PolyglotValuePointer result ) {
664
666
resetErrorState ();
665
667
Value jObject = fetchHandle (value );
666
- result .write (createHandle (jObject .getMember (CTypeConversion .toJavaString (utf8_identifier ))));
668
+ result .write (createHandle (jObject .getMember (CTypeConversion .utf8ToJavaString (utf8_identifier ))));
667
669
return poly_ok ;
668
670
}
669
671
@@ -680,7 +682,7 @@ public static PolyglotStatus poly_value_put_member(PolyglotIsolateThread thread,
680
682
resetErrorState ();
681
683
Value jObject = fetchHandle (value );
682
684
Value jMember = fetchHandle (member );
683
- jObject .putMember (CTypeConversion .toJavaString (utf8_identifier ), jMember );
685
+ jObject .putMember (CTypeConversion .utf8ToJavaString (utf8_identifier ), jMember );
684
686
return poly_ok ;
685
687
}
686
688
@@ -696,7 +698,7 @@ public static PolyglotStatus poly_value_put_member(PolyglotIsolateThread thread,
696
698
public static PolyglotStatus poly_value_has_member (PolyglotIsolateThread thread , PolyglotValue value , @ CConst CCharPointer utf8_identifier , CBoolPointer result ) {
697
699
resetErrorState ();
698
700
Value jObject = fetchHandle (value );
699
- result .write (CTypeConversion .toCBoolean (jObject .hasMember (CTypeConversion .toJavaString (utf8_identifier ))));
701
+ result .write (CTypeConversion .toCBoolean (jObject .hasMember (CTypeConversion .utf8ToJavaString (utf8_identifier ))));
700
702
return poly_ok ;
701
703
}
702
704
@@ -1603,7 +1605,7 @@ public static PolyglotStatus poly_get_callback_info(PolyglotIsolateThread thread
1603
1605
@ CEntryPoint (name = "poly_throw_exception" , exceptionHandler = ExceptionHandler .class , documentation = {
1604
1606
"Raises an exception in a C callback." ,
1605
1607
"" ,
1606
- "Invocation of this method does not interrupt control-flow so it is neccesarry to return from a function after " ,
1608
+ "Invocation of this method does not interrupt control-flow so it is necessary to return from a function after " ,
1607
1609
"the exception has been raised. If this method is called multiple times only the last exception will be thrown in" ,
1608
1610
"in the guest language." ,
1609
1611
"" ,
@@ -1612,7 +1614,7 @@ public static PolyglotStatus poly_get_callback_info(PolyglotIsolateThread thread
1612
1614
})
1613
1615
public static PolyglotStatus poly_throw_exception (PolyglotIsolateThread thread , @ CConst CCharPointer utf8_message ) {
1614
1616
resetErrorState ();
1615
- exceptionsTL .set (new CallbackException (CTypeConversion .toJavaString (utf8_message )));
1617
+ exceptionsTL .set (new CallbackException (CTypeConversion .utf8ToJavaString (utf8_message )));
1616
1618
return poly_ok ;
1617
1619
}
1618
1620
@@ -1864,6 +1866,22 @@ private static class PolyglotCallbackInfoInternal {
1864
1866
}
1865
1867
}
1866
1868
1869
+ @ CEntryPoint (name = "poly_perf_data_get_address_of_int64_t" , exceptionHandler = ExceptionHandler .class , documentation = {
1870
+ "Gets the address of the int64_t value for a performance data entry of type long. Performance data support must be enabled." ,
1871
+ "" ,
1872
+ " @param utf8_key UTF8-encoded, 0 terminated key that identifies the performance data entry." ,
1873
+ " @param result a pointer to which the address of the int64_t value will be written." ,
1874
+ " @return poly_ok if everything went ok, otherwise an error occurred." ,
1875
+ " @since 22.3" ,
1876
+ })
1877
+ public static PolyglotStatus poly_perf_data_get_address_of_int64_t (PolyglotIsolateThread thread , CCharPointer utf8Key , CInt64PointerPointer result ) {
1878
+ resetErrorState ();
1879
+ String key = CTypeConversion .utf8ToJavaString (utf8Key );
1880
+ CInt64Pointer ptr = (CInt64Pointer ) ImageSingletons .lookup (PerfDataSupport .class ).getLong (key );
1881
+ result .write (ptr );
1882
+ return poly_ok ;
1883
+ }
1884
+
1867
1885
private static void writeString (String valueString , CCharPointer buffer , UnsignedWord length , SizeTPointer result , Charset charset ) {
1868
1886
UnsignedWord stringLength = WordFactory .unsigned (valueString .getBytes (charset ).length );
1869
1887
if (buffer .isNull ()) {
0 commit comments