Skip to content

Commit eb4dc58

Browse files
author
Thomas Schrott
committed
[GR-57270] Refactor the IsolateArgumentParser
PullRequest: graal/18681
2 parents d3dc5fd + 020757d commit eb4dc58

File tree

10 files changed

+446
-133
lines changed

10 files changed

+446
-133
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core;
26+
27+
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
28+
29+
import org.graalvm.nativeimage.c.type.CCharPointer;
30+
import org.graalvm.word.WordFactory;
31+
32+
public class IsolateArgumentAccess {
33+
34+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
35+
public static long readLong(IsolateArguments arguments, int index) {
36+
return arguments.getParsedArgs().read(index);
37+
}
38+
39+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
40+
public static void writeLong(IsolateArguments arguments, int index, long value) {
41+
arguments.getParsedArgs().write(index, value);
42+
}
43+
44+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
45+
public static int readInt(IsolateArguments arguments, int index) {
46+
return (int) readLong(arguments, index);
47+
}
48+
49+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
50+
public static void writeInt(IsolateArguments arguments, int index, int value) {
51+
writeLong(arguments, index, value);
52+
}
53+
54+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
55+
public static boolean readBoolean(IsolateArguments arguments, int index) {
56+
return readLong(arguments, index) == 1L;
57+
}
58+
59+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
60+
public static void writeBoolean(IsolateArguments arguments, int index, boolean value) {
61+
writeLong(arguments, index, value ? 1L : 0L);
62+
}
63+
64+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
65+
public static CCharPointer readCCharPointer(IsolateArguments arguments, int index) {
66+
return WordFactory.pointer(readLong(arguments, index));
67+
}
68+
69+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
70+
public static void writeCCharPointer(IsolateArguments arguments, int index, CCharPointer value) {
71+
writeLong(arguments, index, value.rawValue());
72+
}
73+
74+
}

0 commit comments

Comments
 (0)