98 });
99 }
100
101 if (DEBUG) {
102 System.err.println("Java arguments:");
103 System.err.println(Arrays.toString(args).indent(2));
104 }
105
106 Object o = mh.invoke(args);
107
108 if (DEBUG) {
109 System.err.println("Java return:");
110 System.err.println(Objects.toString(o).indent(2));
111 }
112
113 if (mh.type().returnType() != void.class) {
114 BindingInterpreter.unbox(o, callingSequence.returnBindings(),
115 (storage, type, value) -> {
116 MemoryAddress ptr = bufferBase.addOffset(layout.retOffset(storage));
117 SharedUtils.writeOverSized(ptr, type, value);
118 }, new ArrayList<>());
119 }
120
121 if (DEBUG) {
122 System.err.println("Buffer state after:");
123 layout.dump(abi.arch, buffer, System.err);
124 }
125 } catch (Throwable t) {
126 throw new IllegalStateException(t);
127 }
128 }
129
130 public native long allocateUpcallStub(ABIDescriptor abi, BufferLayout layout);
131
132 private static native void registerNatives();
133 static {
134 registerNatives();
135 }
136 }
|
98 });
99 }
100
101 if (DEBUG) {
102 System.err.println("Java arguments:");
103 System.err.println(Arrays.toString(args).indent(2));
104 }
105
106 Object o = mh.invoke(args);
107
108 if (DEBUG) {
109 System.err.println("Java return:");
110 System.err.println(Objects.toString(o).indent(2));
111 }
112
113 if (mh.type().returnType() != void.class) {
114 BindingInterpreter.unbox(o, callingSequence.returnBindings(),
115 (storage, type, value) -> {
116 MemoryAddress ptr = bufferBase.addOffset(layout.retOffset(storage));
117 SharedUtils.writeOverSized(ptr, type, value);
118 }, null);
119 }
120
121 if (DEBUG) {
122 System.err.println("Buffer state after:");
123 layout.dump(abi.arch, buffer, System.err);
124 }
125 } catch (Throwable t) {
126 throw new IllegalStateException(t);
127 }
128 }
129
130 public native long allocateUpcallStub(ABIDescriptor abi, BufferLayout layout);
131
132 private static native void registerNatives();
133 static {
134 registerNatives();
135 }
136 }
|