Skip to content

Commit eb03bf7

Browse files
author
Vladimir Kempik
committed
8261075: Create stubRoutines.inline.hpp with SafeFetch implementation
Reviewed-by: phh, mdoerr Backport-of: b955f85
1 parent d5017c3 commit eb03bf7

File tree

10 files changed

+62
-30
lines changed

10 files changed

+62
-30
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
#include "runtime/os.hpp"
6565
#include "runtime/osThread.hpp"
6666
#include "runtime/perfMemory.hpp"
67+
#include "runtime/safefetch.hpp"
6768
#include "runtime/sharedRuntime.hpp"
6869
#include "runtime/statSampler.hpp"
69-
#include "runtime/stubRoutines.hpp"
7070
#include "runtime/thread.inline.hpp"
7171
#include "runtime/threadCritical.hpp"
7272
#include "runtime/timer.hpp"

src/hotspot/os/windows/os_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
#include "runtime/orderAccess.hpp"
5757
#include "runtime/osThread.hpp"
5858
#include "runtime/perfMemory.hpp"
59+
#include "runtime/safefetch.hpp"
5960
#include "runtime/sharedRuntime.hpp"
6061
#include "runtime/statSampler.hpp"
61-
#include "runtime/stubRoutines.hpp"
6262
#include "runtime/thread.inline.hpp"
6363
#include "runtime/threadCritical.hpp"
6464
#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, 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
@@ -34,8 +34,8 @@
3434
#include "runtime/mutex.hpp"
3535
#include "runtime/mutexLocker.hpp"
3636
#include "runtime/orderAccess.hpp"
37+
#include "runtime/safefetch.hpp"
3738
#include "runtime/safepoint.hpp"
38-
#include "runtime/stubRoutines.hpp"
3939
#include "runtime/thread.hpp"
4040
#include "utilities/align.hpp"
4141
#include "utilities/count_trailing_zeros.hpp"

src/hotspot/share/runtime/objectMonitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
#include "runtime/objectMonitor.inline.hpp"
3939
#include "runtime/orderAccess.hpp"
4040
#include "runtime/osThread.hpp"
41+
#include "runtime/safefetch.hpp"
4142
#include "runtime/safepointMechanism.inline.hpp"
4243
#include "runtime/sharedRuntime.hpp"
43-
#include "runtime/stubRoutines.hpp"
4444
#include "runtime/thread.inline.hpp"
4545
#include "services/threadService.hpp"
4646
#include "utilities/dtrace.hpp"

src/hotspot/share/runtime/os.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
#include "runtime/javaCalls.hpp"
5454
#include "runtime/mutexLocker.hpp"
5555
#include "runtime/os.inline.hpp"
56+
#include "runtime/safefetch.hpp"
5657
#include "runtime/sharedRuntime.hpp"
57-
#include "runtime/stubRoutines.hpp"
5858
#include "runtime/thread.inline.hpp"
5959
#include "runtime/threadSMR.hpp"
6060
#include "runtime/vm_version.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, 2018, 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
@@ -29,8 +29,8 @@
2929
#include "oops/oop.inline.hpp"
3030
#include "runtime/interfaceSupport.inline.hpp"
3131
#include "runtime/timerTrace.hpp"
32+
#include "runtime/safefetch.hpp"
3233
#include "runtime/sharedRuntime.hpp"
33-
#include "runtime/stubRoutines.hpp"
3434
#include "utilities/align.hpp"
3535
#include "utilities/copy.hpp"
3636
#include "utilities/vmError.hpp"

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, 2017, 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
@@ -458,24 +458,4 @@ class StubRoutines: AllStatic {
458458
static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
459459
};
460460

461-
// Safefetch allows to load a value from a location that's not known
462-
// to be valid. If the load causes a fault, the error value is returned.
463-
inline int SafeFetch32(int* adr, int errValue) {
464-
assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
465-
return StubRoutines::SafeFetch32_stub()(adr, errValue);
466-
}
467-
inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
468-
assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
469-
return StubRoutines::SafeFetchN_stub()(adr, errValue);
470-
}
471-
472-
473-
// returns true if SafeFetch32 and SafeFetchN can be used safely (stubroutines are already generated)
474-
inline bool CanUseSafeFetch32() {
475-
return StubRoutines::SafeFetch32_stub() ? true : false;
476-
}
477-
478-
inline bool CanUseSafeFetchN() {
479-
return StubRoutines::SafeFetchN_stub() ? true : false;
480-
}
481461
#endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP

src/hotspot/share/utilities/vmError.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "runtime/frame.inline.hpp"
3838
#include "runtime/init.hpp"
3939
#include "runtime/os.hpp"
40+
#include "runtime/safefetch.hpp"
4041
#include "runtime/thread.inline.hpp"
4142
#include "runtime/threadSMR.hpp"
4243
#include "runtime/vmThread.hpp"

test/hotspot/gtest/runtime/test_safefetch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "precompiled.hpp"
2626
#include "runtime/interfaceSupport.inline.hpp"
27-
#include "runtime/stubRoutines.hpp"
27+
#include "runtime/safefetch.hpp"
2828
#include "runtime/vmOperations.hpp"
2929
#include "runtime/vmThread.hpp"
3030
#include "utilities/globalDefinitions.hpp"

0 commit comments

Comments
 (0)