Skip to content

Commit 43f4b18

Browse files
JFR StackTrace and JFR Method repositories. Dump samples in form of JFR report.
1 parent 947235d commit 43f4b18

File tree

60 files changed

+2376
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2376
-379
lines changed

compiler/src/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/AbstractTypeReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public long getUV() {
3535
return read();
3636
}
3737

38-
public static long decodeSign(long value) {
38+
private static long decodeSign(long value) {
3939
return (value >>> 1) ^ -(value & 1);
4040
}
4141

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLibCSupport.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public <T extends PointerBase> T memcpy(T dest, PointerBase src, UnsignedWord n)
4141
return PosixLibC.memcpy(dest, src, n);
4242
}
4343

44+
@Override
45+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
46+
public <T extends PointerBase> int memcmp(T s1, T s2, UnsignedWord n) {
47+
return PosixLibC.memcmp(s1, s2, n);
48+
}
49+
4450
@Override
4551
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
4652
public <T extends PointerBase> T memmove(T dest, PointerBase src, UnsignedWord n) {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.oracle.svm.core.posix;
27+
28+
import org.graalvm.compiler.api.replacements.Fold;
29+
import org.graalvm.nativeimage.ImageSingletons;
30+
31+
import com.oracle.svm.core.Uninterruptible;
32+
import com.oracle.svm.core.locks.VMSemaphore;
33+
34+
public abstract class PosixVMSemaphoreSupport {
35+
36+
@Fold
37+
public static PosixVMSemaphoreSupport singleton() {
38+
return ImageSingletons.lookup(PosixVMSemaphoreSupport.class);
39+
}
40+
41+
/**
42+
* Must be called once early during startup, before any semaphore is used.
43+
*/
44+
@Uninterruptible(reason = "Called from uninterruptible code. Too early for safepoints.")
45+
public abstract boolean initialize();
46+
47+
/**
48+
* Must be called during isolate teardown.
49+
*/
50+
@Uninterruptible(reason = "The isolate teardown is in progress.")
51+
public abstract void destroy();
52+
53+
public abstract VMSemaphore[] getSemaphores();
54+
55+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.oracle.svm.core.posix.darwin;
27+
28+
import org.graalvm.nativeimage.ImageSingletons;
29+
import org.graalvm.nativeimage.Platform;
30+
import org.graalvm.nativeimage.Platforms;
31+
32+
import com.oracle.svm.core.SubstrateOptions;
33+
import com.oracle.svm.core.Uninterruptible;
34+
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
35+
import com.oracle.svm.core.feature.InternalFeature;
36+
import com.oracle.svm.core.heap.UnknownObjectField;
37+
import com.oracle.svm.core.locks.ClassInstanceReplacer;
38+
import com.oracle.svm.core.locks.VMSemaphore;
39+
import com.oracle.svm.core.posix.PosixVMSemaphoreSupport;
40+
import com.oracle.svm.core.util.VMError;
41+
42+
/**
43+
* Support of {@link VMSemaphore} in multithreaded environments on DARWIN.
44+
*/
45+
@AutomaticallyRegisteredFeature
46+
final class DarwinVMSemaphoreFeature implements InternalFeature {
47+
48+
private final ClassInstanceReplacer<VMSemaphore, VMSemaphore> semaphoreReplacer = new ClassInstanceReplacer<>(VMSemaphore.class) {
49+
@Override
50+
protected VMSemaphore createReplacement(VMSemaphore source) {
51+
return new DarwinVMSemaphore();
52+
}
53+
};
54+
55+
@Override
56+
public boolean isInConfiguration(IsInConfigurationAccess access) {
57+
return SubstrateOptions.MultiThreaded.getValue();
58+
}
59+
60+
@Override
61+
public void duringSetup(DuringSetupAccess access) {
62+
ImageSingletons.add(PosixVMSemaphoreSupport.class, new DarwinVMSemaphoreSupport());
63+
access.registerObjectReplacer(semaphoreReplacer);
64+
}
65+
66+
@Override
67+
public void beforeCompilation(BeforeCompilationAccess access) {
68+
DarwinVMSemaphoreSupport semaphoreSupport = (DarwinVMSemaphoreSupport) PosixVMSemaphoreSupport.singleton();
69+
semaphoreSupport.semaphores = semaphoreReplacer.getReplacements().toArray(new DarwinVMSemaphore[0]);
70+
}
71+
}
72+
73+
final class DarwinVMSemaphoreSupport extends PosixVMSemaphoreSupport {
74+
75+
/** All semaphores, so that we can initialize them at run time when the VM starts. */
76+
@UnknownObjectField(types = DarwinVMSemaphore[].class)//
77+
DarwinVMSemaphore[] semaphores;
78+
79+
@Override
80+
@Uninterruptible(reason = "Called from uninterruptible code. Too early for safepoints.")
81+
public boolean initialize() {
82+
for (DarwinVMSemaphore semaphore : semaphores) {
83+
if (semaphore.init() != 0) {
84+
return false;
85+
}
86+
}
87+
88+
return true;
89+
}
90+
91+
@Override
92+
@Uninterruptible(reason = "The isolate teardown is in progress.")
93+
public void destroy() {
94+
for (DarwinVMSemaphore semaphore : semaphores) {
95+
semaphore.destroy();
96+
}
97+
}
98+
99+
@Override
100+
public DarwinVMSemaphore[] getSemaphores() {
101+
return semaphores;
102+
}
103+
}
104+
105+
final class DarwinVMSemaphore extends VMSemaphore {
106+
107+
@Platforms(Platform.HOSTED_ONLY.class)
108+
DarwinVMSemaphore() {
109+
}
110+
111+
@Override
112+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
113+
protected int init() {
114+
/* sem_init method is now deprecated on DARWIN and do nothing. */
115+
return 0;
116+
}
117+
118+
@Override
119+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
120+
protected void destroy() {
121+
/* sem_destroy method is now deprecated on DARWIN and do nothing. */
122+
}
123+
124+
@Override
125+
public void await() {
126+
VMError.shouldNotReachHere("Unnamed semaphores are not supported on DARWIN.");
127+
}
128+
129+
@Override
130+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
131+
public void signal() {
132+
VMError.shouldNotReachHere("Unnamed semaphores are not supported on DARWIN.");
133+
}
134+
}

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/headers/PosixDirectives.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class PosixDirectives implements CContext.Directives {
4141
"<limits.h>",
4242
"<locale.h>",
4343
"<pthread.h>",
44+
"<semaphore.h>",
4445
"<pwd.h>",
4546
"<signal.h>",
4647
"<errno.h>",

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/headers/PosixLibC.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public class PosixLibC {
4747
@CFunction(value = "memmove", transition = CFunction.Transition.NO_TRANSITION)
4848
public static native <T extends PointerBase> T memcpy(T dest, PointerBase src, UnsignedWord n);
4949

50+
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
51+
public static native <T extends PointerBase> int memcmp(T s1, T s2, UnsignedWord n);
52+
5053
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
5154
public static native <T extends PointerBase> T memmove(T dest, PointerBase src, UnsignedWord n);
5255

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.oracle.svm.core.posix.headers;
27+
28+
import org.graalvm.nativeimage.c.CContext;
29+
import org.graalvm.nativeimage.c.function.CFunction;
30+
import org.graalvm.nativeimage.c.struct.CStruct;
31+
import org.graalvm.word.PointerBase;
32+
import org.graalvm.word.SignedWord;
33+
import org.graalvm.word.UnsignedWord;
34+
35+
// Checkstyle: stop
36+
37+
/**
38+
* Manually translated definitions from the C header file semaphore.h.
39+
*/
40+
@CContext(PosixDirectives.class)
41+
public class Semaphore {
42+
43+
@CStruct
44+
public interface sem_t extends PointerBase {
45+
}
46+
47+
@CFunction(transition = CFunction.Transition.TO_NATIVE)
48+
public static native int sem_wait(sem_t sem);
49+
50+
public static class NoTransitions {
51+
52+
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
53+
public static native int sem_init(sem_t sem, SignedWord pshared, UnsignedWord value);
54+
55+
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
56+
public static native int sem_destroy(sem_t sem);
57+
58+
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
59+
public static native int sem_post(sem_t sem);
60+
}
61+
}

0 commit comments

Comments
 (0)