Skip to content

Commit b955f85

Browse files
AntonKozlovVladimir Kempik
authored andcommitted
8261075: Create stubRoutines.inline.hpp with SafeFetch implementation
Reviewed-by: dcubed, stuefe, stefank
1 parent d195033 commit b955f85

File tree

11 files changed

+65
-33
lines changed

11 files changed

+65
-33
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
#include "runtime/os.hpp"
6363
#include "runtime/osThread.hpp"
6464
#include "runtime/perfMemory.hpp"
65+
#include "runtime/safefetch.hpp"
6566
#include "runtime/sharedRuntime.hpp"
6667
#include "runtime/statSampler.hpp"
67-
#include "runtime/stubRoutines.hpp"
6868
#include "runtime/thread.inline.hpp"
6969
#include "runtime/threadCritical.hpp"
7070
#include "runtime/timer.hpp"

src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
3434
#include "logging/log.hpp"
3535
#include "runtime/init.hpp"
3636
#include "runtime/os.hpp"
37-
#include "runtime/stubRoutines.hpp"
37+
#include "runtime/safefetch.hpp"
3838
#include "utilities/align.hpp"
3939
#include "utilities/debug.hpp"
4040
#include "utilities/growableArray.hpp"

src/hotspot/os/windows/os_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
#include "runtime/orderAccess.hpp"
5858
#include "runtime/osThread.hpp"
5959
#include "runtime/perfMemory.hpp"
60+
#include "runtime/safefetch.hpp"
6061
#include "runtime/safepointMechanism.hpp"
6162
#include "runtime/sharedRuntime.hpp"
6263
#include "runtime/statSampler.hpp"
63-
#include "runtime/stubRoutines.hpp"
6464
#include "runtime/thread.inline.hpp"
6565
#include "runtime/threadCritical.hpp"
6666
#include "runtime/timer.hpp"

src/hotspot/share/gc/shared/oopStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,8 @@
3636
#include "runtime/mutexLocker.hpp"
3737
#include "runtime/orderAccess.hpp"
3838
#include "runtime/os.hpp"
39+
#include "runtime/safefetch.hpp"
3940
#include "runtime/safepoint.hpp"
40-
#include "runtime/stubRoutines.hpp"
4141
#include "runtime/thread.hpp"
4242
#include "services/memTracker.hpp"
4343
#include "utilities/align.hpp"

src/hotspot/share/runtime/objectMonitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
#include "runtime/orderAccess.hpp"
4848
#include "runtime/osThread.hpp"
4949
#include "runtime/perfData.hpp"
50+
#include "runtime/safefetch.hpp"
5051
#include "runtime/safepointMechanism.inline.hpp"
5152
#include "runtime/sharedRuntime.hpp"
52-
#include "runtime/stubRoutines.hpp"
5353
#include "runtime/thread.inline.hpp"
5454
#include "services/threadService.hpp"
5555
#include "utilities/dtrace.hpp"

src/hotspot/share/runtime/os.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
#include "runtime/mutexLocker.hpp"
5656
#include "runtime/os.inline.hpp"
5757
#include "runtime/osThread.hpp"
58+
#include "runtime/safefetch.hpp"
5859
#include "runtime/sharedRuntime.hpp"
59-
#include "runtime/stubRoutines.hpp"
6060
#include "runtime/thread.inline.hpp"
6161
#include "runtime/threadSMR.hpp"
6262
#include "runtime/vmOperations.hpp"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 1997, 2021, 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.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#ifndef SHARE_RUNTIME_SAFEFETCH_HPP
26+
#define SHARE_RUNTIME_SAFEFETCH_HPP
27+
28+
#include "runtime/stubRoutines.hpp"
29+
30+
// Safefetch allows to load a value from a location that's not known
31+
// to be valid. If the load causes a fault, the error value is returned.
32+
inline int SafeFetch32(int* adr, int errValue) {
33+
assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
34+
return StubRoutines::SafeFetch32_stub()(adr, errValue);
35+
}
36+
37+
inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
38+
assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
39+
return StubRoutines::SafeFetchN_stub()(adr, errValue);
40+
}
41+
42+
// returns true if SafeFetch32 and SafeFetchN can be used safely (stubroutines are already generated)
43+
inline bool CanUseSafeFetch32() {
44+
return StubRoutines::SafeFetch32_stub() ? true : false;
45+
}
46+
47+
inline bool CanUseSafeFetchN() {
48+
return StubRoutines::SafeFetchN_stub() ? true : false;
49+
}
50+
51+
#endif // SHARE_RUNTIME_SAFEFETCH_HPP

src/hotspot/share/runtime/stubRoutines.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,8 @@
3030
#include "oops/oop.inline.hpp"
3131
#include "runtime/interfaceSupport.inline.hpp"
3232
#include "runtime/timerTrace.hpp"
33+
#include "runtime/safefetch.hpp"
3334
#include "runtime/sharedRuntime.hpp"
34-
#include "runtime/stubRoutines.hpp"
3535
#include "utilities/align.hpp"
3636
#include "utilities/copy.hpp"
3737
#ifdef COMPILER2

src/hotspot/share/runtime/stubRoutines.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -488,24 +488,4 @@ class StubRoutines: AllStatic {
488488
static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
489489
};
490490

491-
// Safefetch allows to load a value from a location that's not known
492-
// to be valid. If the load causes a fault, the error value is returned.
493-
inline int SafeFetch32(int* adr, int errValue) {
494-
assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
495-
return StubRoutines::SafeFetch32_stub()(adr, errValue);
496-
}
497-
inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
498-
assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
499-
return StubRoutines::SafeFetchN_stub()(adr, errValue);
500-
}
501-
502-
503-
// returns true if SafeFetch32 and SafeFetchN can be used safely (stubroutines are already generated)
504-
inline bool CanUseSafeFetch32() {
505-
return StubRoutines::SafeFetch32_stub() ? true : false;
506-
}
507-
508-
inline bool CanUseSafeFetchN() {
509-
return StubRoutines::SafeFetchN_stub() ? true : false;
510-
}
511491
#endif // SHARE_RUNTIME_STUBROUTINES_HPP

src/hotspot/share/utilities/vmError.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "runtime/init.hpp"
4444
#include "runtime/os.hpp"
4545
#include "runtime/osThread.hpp"
46+
#include "runtime/safefetch.hpp"
4647
#include "runtime/safepointMechanism.hpp"
4748
#include "runtime/thread.inline.hpp"
4849
#include "runtime/threadSMR.hpp"

0 commit comments

Comments
 (0)