Skip to content

Commit 27b92fc

Browse files
[GR-65865] Misc. espresso usability fixes.
PullRequest: graal/21069
2 parents 84eee1d + b29441c commit 27b92fc

File tree

14 files changed

+400
-180
lines changed

14 files changed

+400
-180
lines changed

espresso/mx.espresso/mx_espresso.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
569569
register_espresso_runtime_resources(register_project, register_distribution, _suite)
570570
register_distribution(DeliverableStandaloneArchive(_suite,
571571
standalone_dist='ESPRESSO_NATIVE_STANDALONE',
572-
community_archive_name="espresso-community",
573-
enterprise_archive_name="espresso",
572+
community_archive_name=f"espresso-community-java{java_home_dep.major_version}",
573+
enterprise_archive_name=f"espresso-java{java_home_dep.major_version}",
574574
community_dist_name=f'GRAALVM_ESPRESSO_COMMUNITY_JAVA{java_home_dep.major_version}',
575575
enterprise_dist_name=f'GRAALVM_ESPRESSO_JAVA{java_home_dep.major_version}'))
576576

espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/PolyglotArgs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void parsePolyglotOption(String group, String key, String value, String arg, boo
148148

149149
private OptionDescriptor findOptionDescriptor(String group, String key) {
150150
OptionDescriptors descriptors = null;
151-
if (group.equals("engine")) {
151+
if ("engine".equals(group) || "compiler".equals(group)) {
152152
descriptors = getTempEngine().getOptions();
153153
} else {
154154
Engine engine = getTempEngine();

espresso/src/com.oracle.truffle.espresso.mokapot/include/jmm_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ enum {
5454
JMM_VERSION_4 = 0x20040000, // JDK 21
5555
};
5656

57-
typedef struct {
57+
typedef struct jmmOptionalSupport {
5858
unsigned int isLowMemoryDetectionSupported : 1;
5959
unsigned int isCompilationTimeMonitoringSupported : 1;
6060
unsigned int isThreadContentionMonitoringSupported : 1;

espresso/src/com.oracle.truffle.espresso.mokapot/include/structs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#include <stddef.h>
2828

2929
typedef struct member_info {
30-
char* id;
31-
size_t offset;
32-
struct member_info *next;
30+
char* id;
31+
size_t offset;
32+
struct member_info *next;
3333
} member_info;
3434

3535
JNIEXPORT size_t JNICALL lookupMemberOffset(void* info, char* id);

espresso/src/com.oracle.truffle.espresso.mokapot/src/structs.c

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "jvm.h"
2525
#include "jvmti.h"
26+
#include "jmm_common.h"
2627
#include "structs.h"
2728

2829
#include <jni.h>
@@ -31,9 +32,9 @@
3132
#include <string.h>
3233

3334
#define JNI_STRUCT_MEMBER_LIST(V) \
34-
V(JavaVMAttachArgs, version) \
35-
V(JavaVMAttachArgs, name) \
36-
V(JavaVMAttachArgs, group) \
35+
V(JavaVMAttachArgs, version) \
36+
V(JavaVMAttachArgs, name) \
37+
V(JavaVMAttachArgs, group)
3738

3839
#define JVM_STRUCT_MEMBER_LIST(V) \
3940
V(jdk_version_info, jdk_version)
@@ -171,20 +172,29 @@
171172
V(_jvmtiEventCallbacks, VMObjectAlloc) \
172173
V(_jvmtiEventCallbacks, reserved85) \
173174
V(_jvmtiEventCallbacks, SampledObjectAlloc)
174-
175+
176+
#define JMM_STRUCT_BITFIELD_MEMBER_LIST(V) \
177+
V(jmmOptionalSupport, isLowMemoryDetectionSupported) \
178+
V(jmmOptionalSupport, isCompilationTimeMonitoringSupported) \
179+
V(jmmOptionalSupport, isThreadContentionMonitoringSupported) \
180+
V(jmmOptionalSupport, isCurrentThreadCpuTimeSupported) \
181+
V(jmmOptionalSupport, isOtherThreadCpuTimeSupported) \
182+
V(jmmOptionalSupport, isObjectMonitorUsageSupported) \
183+
V(jmmOptionalSupport, isSynchronizerUsageSupported) \
184+
V(jmmOptionalSupport, isThreadAllocatedMemorySupported) \
185+
V(jmmOptionalSupport, isRemoteDiagnosticCommandsSupported)
186+
175187
#define MEMBER_INFO_STRUCT_MEMBER_LIST(V) \
176188
V(member_info, id) \
177189
V(member_info, offset) \
178190
V(member_info, next)
179-
191+
180192
#define JNI_STRUCT_LIST(V) \
181-
V(JavaVMAttachArgs) \
182-
V(JavaVMAttachArgs) \
183-
V(JavaVMAttachArgs) \
193+
V(JavaVMAttachArgs)
184194

185195
#define JVM_STRUCT_LIST(V) \
186196
V(jdk_version_info)
187-
197+
188198
#define JVMTI_STRUCT_LIST(V) \
189199
V(_jvmtiThreadInfo) \
190200
V(_jvmtiMonitorStackDepthInfo) \
@@ -208,37 +218,44 @@
208218
V(_jvmtiTimerInfo) \
209219
V(_jvmtiAddrLocationMap) \
210220
V(_jvmtiEventCallbacks)
211-
221+
222+
#define JMM_STRUCT_LIST(V) \
223+
V(jmmOptionalSupport)
224+
212225
#define MEMBER_INFO_STRUCT_LIST(V) \
213226
V(member_info)
214227

215228
#define STRUCT_LIST_LIST(V) \
216-
JNI_STRUCT_LIST(V) \
217-
JVM_STRUCT_LIST(V) \
229+
JNI_STRUCT_LIST(V) \
230+
JVM_STRUCT_LIST(V) \
218231
JVMTI_STRUCT_LIST(V) \
232+
JMM_STRUCT_LIST(V) \
219233
MEMBER_INFO_STRUCT_LIST(V)
220-
234+
221235
#define STRUCT_MEMBER_LIST_LIST(V) \
222-
JNI_STRUCT_MEMBER_LIST(V) \
223-
JVM_STRUCT_MEMBER_LIST(V) \
236+
JNI_STRUCT_MEMBER_LIST(V) \
237+
JVM_STRUCT_MEMBER_LIST(V) \
224238
JVMTI_STRUCT_MEMBER_LIST(V) \
225239
MEMBER_INFO_STRUCT_MEMBER_LIST(V)
226240

241+
#define STRUCT_BITFIELD_MEMBER_LIST_LIST(V) \
242+
JMM_STRUCT_BITFIELD_MEMBER_LIST(V)
243+
227244
void add_member_info(member_info** info, char* id, size_t offset) {
228-
member_info* current = malloc(sizeof(struct member_info));
229-
current->id = id;
230-
current->offset = offset;
231-
current->next = (*info);
232-
*info = current;
245+
member_info* current = malloc(sizeof(struct member_info));
246+
current->id = id;
247+
current->offset = offset;
248+
current->next = (*info);
249+
*info = current;
233250
}
234251

235252
size_t lookup_member_info(member_info** info, char* id) {
236-
for (member_info* current = *info; current != NULL; current = current->next) {
237-
if (strcmp(id, current->id) == 0) {
238-
return current->offset;
239-
}
240-
}
241-
return -1;
253+
for (member_info* current = *info; current != NULL; current = current->next) {
254+
if (strcmp(id, current->id) == 0) {
255+
return current->offset;
256+
}
257+
}
258+
return -1;
242259
}
243260

244261
void free_member_info(member_info** info) {
@@ -256,21 +273,62 @@ void free_member_info(member_info** info) {
256273
JNIEXPORT void JNICALL initializeStructs(void (*notify_member_offset_init)(void *)) {
257274
member_info** info = malloc(sizeof(struct member_info*));
258275
(*info) = NULL;
259-
276+
260277
#define MEMBER_INFO__(STRUCT_NAME, MEMBER_NAME) \
261278
add_member_info(info, #STRUCT_NAME "." #MEMBER_NAME, offsetof(struct STRUCT_NAME, MEMBER_NAME));
262-
279+
263280
STRUCT_MEMBER_LIST_LIST(MEMBER_INFO__)
264281
#undef MEMBER_INFO__
265282

283+
// from com.oracle.svm.hosted.c.codegen.QueryCodeWriter#visitStructBitfieldInfo
284+
#define MEMBER_INFO__(STRUCT_NAME, MEMBER_NAME) \
285+
{ \
286+
struct _w { \
287+
STRUCT_NAME s; \
288+
jlong pad; \
289+
} w; \
290+
char *p; \
291+
size_t byte_offset; \
292+
unsigned char start_bit = 0, end_bit = 0; \
293+
jlong v; \
294+
jlong all_bits_set = -1; \
295+
memset(&w, 0x0, sizeof(w)); \
296+
w.s.MEMBER_NAME = all_bits_set; \
297+
p = (char*)&w.s; \
298+
byte_offset = 0; \
299+
while (byte_offset < sizeof(w.s) && *(p + byte_offset) == 0) { \
300+
byte_offset++; \
301+
} \
302+
if (byte_offset >= sizeof(w.s)) { \
303+
start_bit = end_bit = -1;\
304+
} else { \
305+
v = *((jlong*) (p + byte_offset)); \
306+
while ((v & 0x1) == 0) { \
307+
start_bit++; \
308+
v = v >> 1; \
309+
} \
310+
end_bit = start_bit; \
311+
while (v != 1) { \
312+
end_bit++; \
313+
v = v >> 1; \
314+
} \
315+
} \
316+
add_member_info(info, #STRUCT_NAME "." #MEMBER_NAME, byte_offset); \
317+
add_member_info(info, #STRUCT_NAME "." #MEMBER_NAME ".StartBit", start_bit); \
318+
add_member_info(info, #STRUCT_NAME "." #MEMBER_NAME ".EndBit", end_bit + 1); \
319+
}
320+
321+
STRUCT_BITFIELD_MEMBER_LIST_LIST(MEMBER_INFO__)
322+
#undef MEMBER_INFO__
323+
266324
#define STRUCT_INFO__(STRUCT_NAME) \
267325
add_member_info(info, #STRUCT_NAME, sizeof(struct STRUCT_NAME));
268326

269327
STRUCT_LIST_LIST(STRUCT_INFO__)
270328
#undef STRUCT_INFO__
271-
329+
272330
notify_member_offset_init(info);
273-
331+
274332
free_member_info(info);
275333
}
276334

espresso/src/com.oracle.truffle.espresso.processor/src/com/oracle/truffle/espresso/processor/NativeType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ public enum NativeType {
3939

4040
OBJECT, // word-sized handle
4141
POINTER,
42+
BITFIELD_INT,
4243
}

0 commit comments

Comments
 (0)