Skip to content
Merged
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
Expand Up @@ -26,20 +26,18 @@

import org.graalvm.collections.EconomicMap;

import com.oracle.svm.common.option.MultiOptionValue;

import jdk.graal.compiler.options.OptionKey;
import jdk.graal.compiler.options.OptionValues;

public class HostedOptionCustomizer implements HostedOptionProvider {

private final EconomicMap<OptionKey<?>, Object> hostedValues;
private final EconomicMap<OptionKey<?>, Object> runtimeValues;

public HostedOptionCustomizer(HostedOptionProvider original) {
hostedValues = OptionValues.newOptionMap();
hostedValues.putAll(original.getHostedValues());

runtimeValues = OptionValues.newOptionMap();
runtimeValues.putAll(original.getRuntimeValues());
public HostedOptionCustomizer(HostedOptionParser hostedOptionParser) {
this.hostedValues = copyOptionValues(hostedOptionParser.getHostedValues());
this.runtimeValues = copyOptionValues(hostedOptionParser.getRuntimeValues());
}

@Override
Expand All @@ -51,4 +49,18 @@ public EconomicMap<OptionKey<?>, Object> getHostedValues() {
public EconomicMap<OptionKey<?>, Object> getRuntimeValues() {
return runtimeValues;
}

private static EconomicMap<OptionKey<?>, Object> copyOptionValues(EconomicMap<OptionKey<?>, Object> original) {
EconomicMap<OptionKey<?>, Object> result = OptionValues.newOptionMap();
var cursor = original.getEntries();
while (cursor.advance()) {
OptionKey<?> key = cursor.getKey();
Object value = cursor.getValue();
if (value instanceof MultiOptionValue<?> v) {
value = v.createCopy();
}
result.put(key, value);
}
return result;
}
}