Skip to content

Commit

Permalink
Refactor the IsolateArgumentParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Schrott committed Oct 9, 2024
1 parent c69a606 commit 020757d
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core;

import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;

import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.word.WordFactory;

public class IsolateArgumentAccess {

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static long readLong(IsolateArguments arguments, int index) {
return arguments.getParsedArgs().read(index);
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static void writeLong(IsolateArguments arguments, int index, long value) {
arguments.getParsedArgs().write(index, value);
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static int readInt(IsolateArguments arguments, int index) {
return (int) readLong(arguments, index);
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static void writeInt(IsolateArguments arguments, int index, int value) {
writeLong(arguments, index, value);
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static boolean readBoolean(IsolateArguments arguments, int index) {
return readLong(arguments, index) == 1L;
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static void writeBoolean(IsolateArguments arguments, int index, boolean value) {
writeLong(arguments, index, value ? 1L : 0L);
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static CCharPointer readCCharPointer(IsolateArguments arguments, int index) {
return WordFactory.pointer(readLong(arguments, index));
}

@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static void writeCCharPointer(IsolateArguments arguments, int index, CCharPointer value) {
writeLong(arguments, index, value.rawValue());
}

}
Loading

0 comments on commit 020757d

Please sign in to comment.