equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
29 #include "runtime/interfaceSupport.hpp" |
29 #include "runtime/interfaceSupport.hpp" |
30 #include "runtime/timerTrace.hpp" |
30 #include "runtime/timerTrace.hpp" |
31 #include "runtime/sharedRuntime.hpp" |
31 #include "runtime/sharedRuntime.hpp" |
32 #include "runtime/stubRoutines.hpp" |
32 #include "runtime/stubRoutines.hpp" |
33 #include "utilities/copy.hpp" |
33 #include "utilities/copy.hpp" |
|
34 #include "utilities/vmError.hpp" |
34 #ifdef COMPILER2 |
35 #ifdef COMPILER2 |
35 #include "opto/runtime.hpp" |
36 #include "opto/runtime.hpp" |
36 #endif |
37 #endif |
37 |
38 |
38 |
39 |
236 |
237 |
237 // simple test for SafeFetch32 |
238 // simple test for SafeFetch32 |
238 static void test_safefetch32() { |
239 static void test_safefetch32() { |
239 if (CanUseSafeFetch32()) { |
240 if (CanUseSafeFetch32()) { |
240 int dummy = 17; |
241 int dummy = 17; |
241 int* const p_invalid = (int*) get_segfault_address(); |
242 int* const p_invalid = (int*) VMError::get_segfault_address(); |
242 int* const p_valid = &dummy; |
243 int* const p_valid = &dummy; |
243 int result_invalid = SafeFetch32(p_invalid, 0xABC); |
244 int result_invalid = SafeFetch32(p_invalid, 0xABC); |
244 assert(result_invalid == 0xABC, "SafeFetch32 error"); |
245 assert(result_invalid == 0xABC, "SafeFetch32 error"); |
245 int result_valid = SafeFetch32(p_valid, 0xABC); |
246 int result_valid = SafeFetch32(p_valid, 0xABC); |
246 assert(result_valid == 17, "SafeFetch32 error"); |
247 assert(result_valid == 17, "SafeFetch32 error"); |
256 #else |
257 #else |
257 const intptr_t v1 = 0xABCDABCD; |
258 const intptr_t v1 = 0xABCDABCD; |
258 const intptr_t v2 = 0xDEFDDEFD; |
259 const intptr_t v2 = 0xDEFDDEFD; |
259 #endif |
260 #endif |
260 intptr_t dummy = v1; |
261 intptr_t dummy = v1; |
261 intptr_t* const p_invalid = (intptr_t*) get_segfault_address(); |
262 intptr_t* const p_invalid = (intptr_t*) VMError::get_segfault_address(); |
262 intptr_t* const p_valid = &dummy; |
263 intptr_t* const p_valid = &dummy; |
263 intptr_t result_invalid = SafeFetchN(p_invalid, v2); |
264 intptr_t result_invalid = SafeFetchN(p_invalid, v2); |
264 assert(result_invalid == v2, "SafeFetchN error"); |
265 assert(result_invalid == v2, "SafeFetchN error"); |
265 intptr_t result_valid = SafeFetchN(p_valid, v2); |
266 intptr_t result_valid = SafeFetchN(p_valid, v2); |
266 assert(result_valid == v1, "SafeFetchN error"); |
267 assert(result_valid == v1, "SafeFetchN error"); |