26
26
27
27
import org .graalvm .collections .EconomicMap ;
28
28
29
+ import com .oracle .svm .common .option .MultiOptionValue ;
30
+
29
31
import jdk .graal .compiler .options .OptionKey ;
30
32
import jdk .graal .compiler .options .OptionValues ;
31
33
32
34
public class HostedOptionCustomizer implements HostedOptionProvider {
33
-
34
35
private final EconomicMap <OptionKey <?>, Object > hostedValues ;
35
36
private final EconomicMap <OptionKey <?>, Object > runtimeValues ;
36
37
37
- public HostedOptionCustomizer (HostedOptionProvider original ) {
38
- hostedValues = OptionValues .newOptionMap ();
39
- hostedValues .putAll (original .getHostedValues ());
40
-
41
- runtimeValues = OptionValues .newOptionMap ();
42
- runtimeValues .putAll (original .getRuntimeValues ());
38
+ public HostedOptionCustomizer (HostedOptionParser hostedOptionParser ) {
39
+ this .hostedValues = copyOptionValues (hostedOptionParser .getHostedValues ());
40
+ this .runtimeValues = copyOptionValues (hostedOptionParser .getRuntimeValues ());
43
41
}
44
42
45
43
@ Override
@@ -51,4 +49,18 @@ public EconomicMap<OptionKey<?>, Object> getHostedValues() {
51
49
public EconomicMap <OptionKey <?>, Object > getRuntimeValues () {
52
50
return runtimeValues ;
53
51
}
52
+
53
+ private static EconomicMap <OptionKey <?>, Object > copyOptionValues (EconomicMap <OptionKey <?>, Object > original ) {
54
+ EconomicMap <OptionKey <?>, Object > result = OptionValues .newOptionMap ();
55
+ var cursor = original .getEntries ();
56
+ while (cursor .advance ()) {
57
+ OptionKey <?> key = cursor .getKey ();
58
+ Object value = cursor .getValue ();
59
+ if (value instanceof MultiOptionValue <?> v ) {
60
+ value = v .createCopy ();
61
+ }
62
+ result .put (key , value );
63
+ }
64
+ return result ;
65
+ }
54
66
}
0 commit comments