Skip to content

Commit ca7ee3e

Browse files
Automatic merge of master into galahad
2 parents 6a5d97b + 0185ec6 commit ca7ee3e

File tree

4 files changed

+91
-43
lines changed

4 files changed

+91
-43
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CheckGraalInvariants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ private static void loadVerifiers(List<VerifyPhase<CoreProviders>> verifiers) {
546546
}
547547

548548
/**
549-
* Initializes a map from a field annotated by {@link Option} to a set that will be used to
550-
* collect methods that accesses the option field.
551-
*
552-
* @param tool
549+
* Initializes a map from fields annotated with {@link Option} whose usages should be checked to
550+
* empty sets that will collect the methods accessing each field.
551+
* <p>
552+
* The sets are synchronized to support parallel processing of methods.
553553
*/
554554
private static Map<ResolvedJavaField, Set<ResolvedJavaMethod>> initOptionFieldUsagesMap(InvariantsTool tool, MetaAccessProvider metaAccess, List<String> errors) {
555555
Map<ResolvedJavaField, Set<ResolvedJavaMethod>> optionFields = new EconomicHashMap<>();
@@ -559,7 +559,7 @@ private static Map<ResolvedJavaField, Set<ResolvedJavaMethod>> initOptionFieldUs
559559
Class<?> declaringClass = option.getDeclaringClass();
560560
try {
561561
Field javaField = declaringClass.getDeclaredField(option.getFieldName());
562-
optionFields.put(metaAccess.lookupJavaField(javaField), new EconomicHashSet<>());
562+
optionFields.put(metaAccess.lookupJavaField(javaField), Collections.synchronizedSet(new EconomicHashSet<>()));
563563
} catch (NoSuchFieldException e) {
564564
errors.add(e.toString());
565565
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ public static Resources[] layeredSingletons() {
132132
private final EconomicMap<RequestedPattern, RuntimeConditionSet> requestedPatterns = ImageHeapMap.createNonLayeredMap();
133133

134134
/**
135-
* The string representation of {@link ModuleResourceKey} that are already registered in
136-
* previous layers. Since the {@link ModuleResourceKey} contains a reference to a
135+
* The string representation of {@link ModuleNameResourceKey} that are already registered in
136+
* previous layers. Since the {@link ModuleInstanceResourceKey} contains a reference to a
137137
* {@link Module}, the {@link Module} name is used instead of the object itself in the string
138-
* representation. This works under the assumption that all modules have a different unique name
139-
* in Layered Images. More details can be found in
140-
* {@link Resources#getModuleResourceKeyString(ModuleResourceKey)}.
138+
* representation. This works under the assumption (enforced by
139+
* LayeredModuleSingleton.setPackages) that all modules have a different unique name in Layered
140+
* Images.
141141
*
142-
* The boolean associated to each {@link ModuleResourceKey} is true if the registered value is
143-
* complete and false in the case of a negative query.
142+
* The boolean associated to each {@link ModuleNameResourceKey} is true if the registered value
143+
* is complete and false in the case of a negative query.
144144
*/
145145
@Platforms(Platform.HOSTED_ONLY.class) //
146146
private final Map<String, Boolean> previousLayerResources;
@@ -155,7 +155,65 @@ public static Resources[] layeredSingletons() {
155155
public record RequestedPattern(String module, String resource) {
156156
}
157157

158-
public record ModuleResourceKey(Module module, String resource) {
158+
public interface ModuleResourceKey {
159+
Module getModule();
160+
161+
String getModuleName();
162+
163+
Object module();
164+
165+
String resource();
166+
}
167+
168+
/**
169+
* In standalone images, the module object is the {@link Module} reference itself.
170+
*/
171+
public record ModuleInstanceResourceKey(Module module, String resource) implements ModuleResourceKey {
172+
public ModuleInstanceResourceKey {
173+
assert !ImageLayerBuildingSupport.buildingImageLayer() : "The ModuleInstanceResourceKey should only be used in standalone images.";
174+
}
175+
176+
@Override
177+
public Module getModule() {
178+
return module;
179+
}
180+
181+
@Override
182+
public String getModuleName() {
183+
if (module == null) {
184+
return null;
185+
}
186+
return module.getName();
187+
}
188+
}
189+
190+
/**
191+
* In Layered Image, only the module name is stored in the record.
192+
*/
193+
public record ModuleNameResourceKey(Object module, String resource) implements ModuleResourceKey {
194+
public ModuleNameResourceKey {
195+
/*
196+
* A null module in the ModuleResourceKey represents any unnamed module, meaning that
197+
* only one marker (null) is needed for all of them and that if the module is not null,
198+
* it is named (see Resources.createStorageKey). This string representation relies on
199+
* the assumption (enforced by LayeredModuleSingleton.setPackages) that a layered image
200+
* build cannot contain two modules with the same name, so Module#getName() is
201+
* guaranteed to be unique for layered images.
202+
*/
203+
assert module == null || module instanceof Module : "The ModuleNameResourceKey constructor should only be called with a Module as first argument";
204+
assert ImageLayerBuildingSupport.buildingImageLayer() : "The ModuleNameResourceKey should only be used in layered images.";
205+
module = (module != null) ? ((Module) module).getName() : module;
206+
}
207+
208+
@Override
209+
public Module getModule() {
210+
throw VMError.shouldNotReachHere("Accessing the module instance of the ModuleResourceKey is not supported in layered images.");
211+
}
212+
213+
@Override
214+
public String getModuleName() {
215+
return (String) module;
216+
}
159217
}
160218

161219
/**
@@ -251,7 +309,7 @@ public static ModuleResourceKey createStorageKey(Module module, String resourceN
251309
m = currentLayer().hostedToRuntimeModuleMapper.apply(m);
252310
}
253311
}
254-
return new ModuleResourceKey(m, resourceName);
312+
return ImageLayerBuildingSupport.buildingImageLayer() ? new ModuleNameResourceKey(m, resourceName) : new ModuleInstanceResourceKey(m, resourceName);
255313
}
256314

257315
@Platforms(Platform.HOSTED_ONLY.class) //
@@ -262,9 +320,8 @@ public void setHostedToRuntimeModuleMapper(Function<Module, Module> hostedToRunt
262320
@Platforms(Platform.HOSTED_ONLY.class)
263321
public static Set<String> getIncludedResourcesModules() {
264322
return StreamSupport.stream(currentLayer().resources.getKeys().spliterator(), false)
265-
.map(ModuleResourceKey::module)
323+
.map(ModuleResourceKey::getModuleName)
266324
.filter(Objects::nonNull)
267-
.map(Module::getName)
268325
.collect(Collectors.toSet());
269326
}
270327

@@ -282,21 +339,8 @@ private void updateTimeStamp() {
282339
}
283340
}
284341

285-
private static String getModuleResourceKeyString(ModuleResourceKey m) {
286-
/*
287-
* A null module in the ModuleResourceKey represents any unnamed module, meaning that only
288-
* one marker is needed for all of them and that if the module is not null, it is named (see
289-
* Resources.createStorageKey). This string representation relies on the assumption that a
290-
* layered image build cannot contain two modules with the same name, so Module#getName() is
291-
* guaranteed to be unique for layered images.
292-
*/
293-
String moduleName = m.module == null ? LayeredModuleSingleton.ALL_UNNAMED_MODULE_NAME : m.module.getName();
294-
return moduleName + m.resource;
295-
}
296-
297342
private void addResource(ModuleResourceKey key, ConditionalRuntimeValue<ResourceStorageEntryBase> entry) {
298-
String moduleResourceKeyString = getModuleResourceKeyString(key);
299-
Boolean previousLayerData = previousLayerResources.get(moduleResourceKeyString);
343+
Boolean previousLayerData = ImageLayerBuildingSupport.buildingImageLayer() ? previousLayerResources.get(key.toString()) : null;
300344
if (previousLayerData == null || (!previousLayerData && entry.getValueUnconditionally() != NEGATIVE_QUERY_MARKER)) {
301345
resources.put(key, entry);
302346
}
@@ -721,7 +765,7 @@ public PersistFlags preparePersist(ImageSingletonWriter writer) {
721765

722766
var cursor = resources.getEntries();
723767
while (cursor.advance()) {
724-
resourceKeys.add(getModuleResourceKeyString(cursor.getKey()));
768+
resourceKeys.add(cursor.getKey().toString());
725769
boolean isNegativeQuery = cursor.getValue().getValueUnconditionally() == NEGATIVE_QUERY_MARKER;
726770
resourceRegistrationStates.add(!isNegativeQuery);
727771
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/EmbeddedResourceExporter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class EmbeddedResourceExporter {
5151
public record SourceSizePair(String source, Object origin, int size) {
5252
}
5353

54-
public record ResourceReportEntry(Module module, String resourceName, List<SourceSizePair> entries, boolean isDirectory, boolean isMissing) {
54+
public record ResourceReportEntry(String module, String resourceName, List<SourceSizePair> entries, boolean isDirectory, boolean isMissing) {
5555
}
5656

5757
public static void printReport(JsonWriter writer) throws IOException {
@@ -65,7 +65,7 @@ private static void resourceReportElement(ResourceReportEntry p, JsonWriter w) t
6565
w.appendObjectStart();
6666
w.appendKeyValue("name", p.resourceName()).appendSeparator();
6767
if (p.module() != null) {
68-
w.appendKeyValue("module", p.module().getName()).appendSeparator();
68+
w.appendKeyValue("module", p.module()).appendSeparator();
6969
}
7070

7171
if (p.isDirectory()) {
@@ -100,7 +100,7 @@ public static List<ResourceReportEntry> getResourceReportEntryList(ConcurrentHas
100100

101101
List<ResourceReportEntry> resourceInfoList = new ArrayList<>();
102102
Resources.currentLayer().forEachResource((key, value) -> {
103-
Module module = key.module();
103+
String module = key.getModuleName();
104104
String resourceName = key.resource();
105105

106106
ResourceStorageEntryBase storageEntry = value.getValueUnconditionally();

vm/ci/ci_common/common.jsonnet

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,14 @@ local devkits = graal_common.devkits;
265265
polyglot_isolate_distributions(language_ids, current_os, current_arch, current_only=false)::
266266
std.flattenArrays([self.language_polyglot_isolate_distributions(id, current_os, current_arch, current_only) for id in language_ids]),
267267

268-
# To add a polyglot isolate build for a language, ensure that the language is included in the `ee_suites`
269-
# and add the language id to `polyglot_isolate_languages`.
268+
# To enable polyglot isolate builds for a language:
269+
# 1. Add the language ID to `polyglot_isolate_languages`.
270+
# 2. Ensure the language is either:
271+
# - already included in `ee_suites`, or
272+
# - its suite is listed in `polyglot_isolate_ce_suites`.
270273
local polyglot_isolate_languages = ['js', 'python'],
271-
274+
local polyglot_isolate_ce_suites = ['graal-js', 'graalpython'],
275+
local polyglot_isolate_mx_args = std.flattenArrays([['--suite', s] for s in polyglot_isolate_ce_suites]),
272276

273277
legacy_mx_args:: [], # `['--force-bash-launcher=true', '--skip-libraries=true']` have been replaced by arguments from `vm.maven_deploy_base_functions.mx_args(os, arch)`
274278
mx_args(os, arch, reduced):: self.legacy_mx_args + vm.maven_deploy_base_functions.mx_args(os, arch, reduced),
@@ -327,8 +331,8 @@ local devkits = graal_common.devkits;
327331
if (vm.maven_deploy_base_functions.edition == 'ce') then
328332
self.deploy_ce(os, arch, false, dry_run, [remote_mvn_repo])
329333
else
330-
self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--skip', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', remote_mvn_repo])
331-
+ self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch, true)) + ',TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', remote_mvn_repo], extra_mx_args=['--suite', 'graal-js']);
334+
self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--skip', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS,LANGUAGES,TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', remote_mvn_repo])
335+
+ self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch, true)) + ',TOOLS,LANGUAGES,TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', remote_mvn_repo], extra_mx_args=polyglot_isolate_mx_args);
332336

333337
local mvn_bundle_snippet =
334338
[
@@ -342,8 +346,8 @@ local devkits = graal_common.devkits;
342346
if (vm.maven_deploy_base_functions.edition == 'ce') then
343347
self.deploy_ce(os, arch, false, dry_run, [local_repo, '${LOCAL_MAVEN_REPO_URL}'])
344348
else
345-
self.deploy_ce(os, arch, false, dry_run, ['--dummy-javadoc', '--skip', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', local_repo, '${LOCAL_MAVEN_REPO_URL}'])
346-
+ self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', local_repo, '${LOCAL_MAVEN_REPO_URL}'], extra_mx_args=['--suite', 'graal-js'])
349+
self.deploy_ce(os, arch, false, dry_run, ['--dummy-javadoc', '--skip', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS,LANGUAGES,TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', local_repo, '${LOCAL_MAVEN_REPO_URL}'])
350+
+ self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch)) + ',TOOLS,LANGUAGES,TOOLS_COMMUNITY,LANGUAGES_COMMUNITY', local_repo, '${LOCAL_MAVEN_REPO_URL}'], extra_mx_args=polyglot_isolate_mx_args)
347351
+ self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', local_repo, '${LOCAL_MAVEN_REPO_URL}'])
348352
)
349353
+ (
@@ -374,7 +378,7 @@ local devkits = graal_common.devkits;
374378
+ (
375379
# Locally deploy all relevant suites
376380
self.deploy_ce(os, arch, true, dry_run, ['--dummy-javadoc', '--only', vm.maven_deploy_base_functions.reduced_ce_dists, local_repo, '${LOCAL_MAVEN_REDUCED_REPO_URL}'])
377-
+ self.deploy_ee(os, arch, true, dry_run, ['--dummy-javadoc', '--only', vm.maven_deploy_base_functions.reduced_ee_dists, local_repo, '${LOCAL_MAVEN_REDUCED_REPO_URL}'], extra_mx_args=['--suite', 'graal-js'])
381+
+ self.deploy_ee(os, arch, true, dry_run, ['--dummy-javadoc', '--only', vm.maven_deploy_base_functions.reduced_ee_dists, local_repo, '${LOCAL_MAVEN_REDUCED_REPO_URL}'], extra_mx_args=polyglot_isolate_mx_args)
378382
)
379383
+ (
380384
# Archive and deploy
@@ -425,7 +429,7 @@ local devkits = graal_common.devkits;
425429
else
426430
self.build(os, arch, reduced=false, build_args=['--targets=' + self.only_native_dists + ',' + std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch, true)) + ',{PLATFORM_DEPENDENT_LAYOUT_DIR_DISTRIBUTIONS}']) +
427431
[['echo', 'Skipping the deployment of ' + self.only_native_dists + ': It is already deployed by the ce job']] +
428-
self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch, true)), remote_mvn_repo], extra_mx_args=['--suite', 'graal-js'])
432+
self.deploy_ee(os, arch, false, dry_run, ['--dummy-javadoc', '--only', std.join(',', self.polyglot_isolate_distributions(polyglot_isolate_languages, os, arch, true)), remote_mvn_repo], extra_mx_args=polyglot_isolate_mx_args)
429433
)
430434
+ [self.mx_cmd_base(os, arch, reduced=false) + ['archive-pd-layouts', self.pd_layouts_archive_name(os + '-' + arch)]]
431435
),

0 commit comments

Comments
 (0)