Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2025, 2025, 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.libgraal;

import java.util.function.BooleanSupplier;

import com.oracle.svm.core.SubstrateOptions;

public class LibGraalBuild implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return !SubstrateOptions.LibGraalClassLoader.getValue().isBlank();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
*/
package com.oracle.svm.core.libgraal;

import com.oracle.svm.core.Isolates;
import org.graalvm.nativeimage.libgraal.impl.LibGraalRuntimeSupport;

import com.oracle.svm.core.Isolates;
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
import com.oracle.svm.core.heap.Heap;
import com.oracle.svm.core.util.VMError;

import org.graalvm.nativeimage.libgraal.impl.LibGraalRuntimeSupport;

@AutomaticallyRegisteredImageSingleton({LibGraalRuntimeSupport.class})
@AutomaticallyRegisteredImageSingleton(value = LibGraalRuntimeSupport.class, onlyWith = LibGraalBuild.class)
public final class LibGraalRuntimeSupportImpl implements LibGraalRuntimeSupport {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@
import java.util.List;
import java.util.function.BooleanSupplier;

import com.oracle.svm.util.ReflectionUtil;
import jdk.graal.compiler.serviceprovider.GlobalAtomicLong;
import org.graalvm.nativeimage.libgraal.hosted.GlobalData;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.FieldValueTransformer;
import org.graalvm.nativeimage.hosted.RuntimeReflection;

import com.oracle.svm.core.c.GlobalLongSupplier;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.graal.GraalConfiguration;
import com.oracle.svm.core.graal.RuntimeCompilation;
import com.oracle.svm.graal.GraalCompilerSupport;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.util.ReflectionUtil;

import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.serviceprovider.GlobalAtomicLong;
import jdk.vm.ci.meta.JavaKind;

/**
Expand All @@ -64,8 +65,11 @@ public List<Class<? extends Feature>> getRequiredFeatures() {

@Override
public void duringSetup(DuringSetupAccess c) {
ImageSingletons.add(GraalCompilerSupport.class, new GraalCompilerSupport());
if (!RuntimeCompilation.isEnabled()) {
return;
}

ImageSingletons.add(GraalCompilerSupport.class, new GraalCompilerSupport());
((FeatureImpl.DuringSetupAccessImpl) c).registerClassReachabilityListener(GraalCompilerSupport::registerPhaseStatistics);
}

Expand All @@ -76,12 +80,17 @@ void register(BeforeAnalysisAccess access) {

@Override
public Object transform(Object receiver, Object originalValue) {
return GlobalData.createGlobal(((GlobalAtomicLong) receiver).getInitialValue());
long initialValue = ((GlobalAtomicLong) receiver).getInitialValue();
return new GlobalLongSupplier(initialValue);
}
}

@Override
public void beforeAnalysis(BeforeAnalysisAccess c) {
if (!RuntimeCompilation.isEnabled()) {
return;
}

DebugContext debug = DebugContext.forCurrentThread();

new GlobalAtomicLongTransformer().register(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

import java.util.function.Supplier;

import org.graalvm.nativeimage.libgraal.impl.GlobalDataSupport;

import com.oracle.svm.core.c.GlobalLongSupplier;
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
import com.oracle.svm.core.libgraal.LibGraalBuild;

import org.graalvm.nativeimage.libgraal.impl.GlobalDataSupport;

@AutomaticallyRegisteredImageSingleton(GlobalDataSupport.class)
@AutomaticallyRegisteredImageSingleton(value = GlobalDataSupport.class, onlyWith = LibGraalBuild.class)
public final class GlobalDataSupportImpl implements GlobalDataSupport {
@Override
public Supplier<Long> createGlobal(long initialValue) {
Expand Down
Loading