Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed Jun 1, 2024
2 parents 95415ad + 30a7f72 commit 3fbd87a
Show file tree
Hide file tree
Showing 161 changed files with 4,508 additions and 2,653 deletions.
15 changes: 1 addition & 14 deletions compiler/ci/ci_common/benchmark-builders.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,7 @@
for suite in bench.groups.main_suites
],

local no_tiered_builds = [
c.monthly + hw.e3 + jdk + cc.libgraal + cc.no_tiered_comp + suite,
for jdk in cc.product_jdks
for suite in bench.groups.main_suites
],

local no_profile_info_builds = [
c.monthly + hw.e3 + jdk + cc.libgraal + cc.no_profile_info + suite,
for jdk in cc.product_jdks
for suite in bench.groups.main_suites
],


local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds + aarch64_builds + no_tiered_builds + no_profile_info_builds,
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds + aarch64_builds,
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],
// adds a "defined_in" field to all builds mentioning the location of this current file
builds:: utils.add_defined_in(filtered_builds, std.thisFile),
Expand Down
6 changes: 3 additions & 3 deletions compiler/ci/ci_common/benchmark-suites.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@
"SPECJVM2008": { name: "specjvm2008", version: "1.01" }
},
run+: [
self.benchmark_cmd + ["specjvm2008:*", "--"] + self.extra_vm_args + ["--", "-ikv", "-it", "240s", "-wt", "120s"]
self.benchmark_cmd + ["specjvm2008:*", "--"] + self.extra_vm_args + ["--", "-ikv", "-it", "30s", "-wt", "30s"]
],
timelimit: "3:00:00",
timelimit: "1:15:00",
forks_batches:: 5,
forks_timelimit:: "06:00:00",
forks_timelimit:: "02:30:00",
min_jdk_version:: 8,
max_jdk_version:: null
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
"jdk.graal.compiler.options to org.graalvm.nativeimage.driver,org.graalvm.nativeimage.junitsupport",
"jdk.graal.compiler.phases.common to org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.configure",
"jdk.graal.compiler.serviceprovider to jdk.graal.compiler.management,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.diagnostics",
"jdk.graal.compiler.util.json to org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.configure,org.graalvm.nativeimage.driver",
"jdk.graal.compiler.util.json",
],
"uses" : [
"jdk.graal.compiler.code.DisassemblerProvider",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
/*
* Copyright (c) 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 jdk.graal.compiler.util.json.test;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.graalvm.collections.EconomicMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import jdk.graal.compiler.util.json.JsonBuilder;
import jdk.graal.compiler.util.json.JsonParser;
import jdk.graal.compiler.util.json.JsonWriter;

/**
* Tests for {@link JsonBuilder}, checking that printed values round-trip when parsed with
* {@link JsonParser}.
*/
public class JsonBuilderTest {

private static final String KEY1 = "key with \\ and \"";
private static final String KEY2 = "key2";
private static final String KEY3 = "key3";
private static final String KEY4 = "key4";
private static final String VALUE1 = "value with \\";

private StringWriter stringWriter;
private JsonWriter jsonWriter;

/**
* Asserts that the given map contains exactly the given keys.
*/
private static void assertKeys(EconomicMap<String, Object> map, String... expectedKeys) {
Set<String> mapKeys = new HashSet<>(map.size());
map.getKeys().forEach(mapKeys::add);

assertEquals(mapKeys, new HashSet<>(Arrays.asList(expectedKeys)));
}

@Before
public void setup() {
stringWriter = new StringWriter();
jsonWriter = new JsonWriter(stringWriter);
}

@After
public void teardown() throws IOException {
jsonWriter.close();
}

@SuppressWarnings("unchecked")
private EconomicMap<String, Object> parseAsJsonObject() throws IOException {
return (EconomicMap<String, Object>) parseJson();
}

@SuppressWarnings("unchecked")
private List<Object> parseAsJsonArray() throws IOException {
return (List<Object>) parseJson();
}

/**
* Parses the currently written contents.
*/
private Object parseJson() throws IOException {
return new JsonParser(stringWriter.toString()).parse();
}

@Test
public void testBasicObject() throws IOException {
try (var ob = jsonWriter.objectBuilder()) {
ob.append(KEY1, VALUE1);
}

EconomicMap<String, Object> map = parseAsJsonObject();

assertKeys(map, KEY1);
assertEquals(VALUE1, map.get(KEY1));
}

@Test
public void testBasicArray() throws IOException {
try (var ab = jsonWriter.arrayBuilder()) {
ab.append(VALUE1);
}

List<Object> array = parseAsJsonArray();

assertEquals(List.of(VALUE1), array);
}

@Test
public void testString() throws IOException {
jsonWriter.valueBuilder().value(VALUE1);

String str = (String) parseJson();
assertEquals(VALUE1, str);
}

@Test
public void testInteger() throws IOException {
jsonWriter.valueBuilder().value(1234);

int i = (int) parseJson();
assertEquals(1234, i);
}

@Test
@SuppressWarnings("unchecked")
public void testNestedObject() throws IOException {
try (var ob = jsonWriter.objectBuilder()) {
ob.append(KEY1, VALUE1);
try (var ob2 = ob.append(KEY2).object()) {
ob2.append(KEY1, VALUE1);
}
}

EconomicMap<String, Object> map = parseAsJsonObject();

assertKeys(map, KEY1, KEY2);
assertEquals(VALUE1, map.get(KEY1));

EconomicMap<String, Object> nestedMap = (EconomicMap<String, Object>) map.get(KEY2);
assertKeys(nestedMap, KEY1);

assertEquals(VALUE1, nestedMap.get(KEY1));
}

@Test
@SuppressWarnings("unchecked")
public void testLargeObject() throws IOException {
final List<Object> arrayValues = List.of(VALUE1, 1, 2, Long.MAX_VALUE, true, false, 1.1d, -1223434.34d);

try (var ob = jsonWriter.objectBuilder()) {
ob.append(KEY1, VALUE1);

// Add elements individually
try (var ab = ob.append(KEY2).array()) {
for (Object arrayValue : arrayValues) {
ab.append(arrayValue);
}
}

// Add elements all at once
ob.append(KEY3).value(arrayValues);

try (var ob2 = ob.append(KEY4).object()) {
ob2.append(KEY1, arrayValues);
}
}

EconomicMap<String, Object> map = parseAsJsonObject();

assertKeys(map, KEY1, KEY2, KEY3, KEY4);
assertEquals(VALUE1, map.get(KEY1));

List<Object> nestedArray1 = (List<Object>) map.get(KEY2);
assertEquals(arrayValues, nestedArray1);

List<Object> nestedArray2 = (List<Object>) map.get(KEY3);
assertEquals(arrayValues, nestedArray2);

EconomicMap<String, Object> nestedMap = (EconomicMap<String, Object>) map.get(KEY4);
assertKeys(nestedMap, KEY1);

assertEquals(arrayValues, nestedMap.get(KEY1));
}

@Test(expected = IllegalStateException.class)
public void testMultipleValues() throws IOException {
JsonBuilder.ValueBuilder vb = jsonWriter.valueBuilder();
vb.value(1);
// This second write causes an IllegalStateException
vb.value(2);
}

@Test(expected = ConcurrentModificationException.class)
public void testIncompleteArrayValue() throws IOException {
try (var ab = jsonWriter.arrayBuilder()) {
ab.append(1);
// Because this never prints a value, control is never given back to the ArrayBuilder,
// which will, on closing, produce a ConcurrentModificationException
ab.nextEntry();
}
}

@Test(expected = ConcurrentModificationException.class)
public void testIncompleteObjectValue() throws IOException {
try (var ob = jsonWriter.objectBuilder()) {
ob.append(KEY1, VALUE1);
// Because this never prints a value, control is never given back to the ObjectBuilder,
// which will, on closing, produce a ConcurrentModificationException
ob.append(KEY2);
}
}

@Test(expected = ConcurrentModificationException.class)
public void testWrongNesting() throws IOException {
try (var ob = jsonWriter.objectBuilder()) {
ob.append(KEY1, VALUE1);
try (var ab = ob.append(KEY2).array()) {
ab.append(1);
// ob isn't currently responsible for writing and throws an exception.
ob.append(KEY3, 2);
}
}
}
}
Loading

0 comments on commit 3fbd87a

Please sign in to comment.