196 address buffer2 = (address) round_to((intptr_t)&lbuffer2[4], BytesPerLong);
197 // do an aligned copy
198 ((arraycopy_fn)func)(buffer, buffer2, 0);
199 for (i = 0; i < sizeof(lbuffer); i++) {
200 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
201 }
202 // adjust destination alignment
203 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
204 for (i = 0; i < sizeof(lbuffer); i++) {
205 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
206 }
207 // adjust source alignment
208 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
209 for (i = 0; i < sizeof(lbuffer); i++) {
210 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
211 }
212 }
213
214 // simple test for SafeFetch32
215 static void test_safefetch32() {
216 int dummy = 17;
217 int* const p_invalid = (int*) get_segfault_address();
218 int* const p_valid = &dummy;
219 int result_invalid = SafeFetch32(p_invalid, 0xABC);
220 assert(result_invalid == 0xABC, "SafeFetch32 error");
221 int result_valid = SafeFetch32(p_valid, 0xABC);
222 assert(result_valid == 17, "SafeFetch32 error");
223 }
224
225 // simple test for SafeFetchN
226 static void test_safefetchN() {
227 #ifdef _LP64
228 const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
229 const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
230 #else
231 const intptr_t v1 = 0xABCDABCD;
232 const intptr_t v2 = 0xDEFDDEFD;
233 #endif
234 intptr_t dummy = v1;
235 intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
236 intptr_t* const p_valid = &dummy;
237 intptr_t result_invalid = SafeFetchN(p_invalid, v2);
238 assert(result_invalid == v2, "SafeFetchN error");
239 intptr_t result_valid = SafeFetchN(p_valid, v2);
240 assert(result_valid == v1, "SafeFetchN error");
241 }
242 #endif
243
244 void StubRoutines::initialize2() {
245 if (_code2 == NULL) {
246 ResourceMark rm;
247 TraceTime timer("StubRoutines generation 2", TraceStartupTime);
248 _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
249 if (_code2 == NULL) {
250 vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
251 }
252 CodeBuffer buffer(_code2);
253 StubGenerator_generate(&buffer, true);
254 }
255
256 #ifdef ASSERT
257
258 #define TEST_ARRAYCOPY(type) \
259 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
260 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
|
196 address buffer2 = (address) round_to((intptr_t)&lbuffer2[4], BytesPerLong);
197 // do an aligned copy
198 ((arraycopy_fn)func)(buffer, buffer2, 0);
199 for (i = 0; i < sizeof(lbuffer); i++) {
200 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
201 }
202 // adjust destination alignment
203 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
204 for (i = 0; i < sizeof(lbuffer); i++) {
205 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
206 }
207 // adjust source alignment
208 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
209 for (i = 0; i < sizeof(lbuffer); i++) {
210 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
211 }
212 }
213
214 // simple test for SafeFetch32
215 static void test_safefetch32() {
216 if (CanUseSafeFetch32()) {
217 int dummy = 17;
218 int* const p_invalid = (int*) get_segfault_address();
219 int* const p_valid = &dummy;
220 int result_invalid = SafeFetch32(p_invalid, 0xABC);
221 assert(result_invalid == 0xABC, "SafeFetch32 error");
222 int result_valid = SafeFetch32(p_valid, 0xABC);
223 assert(result_valid == 17, "SafeFetch32 error");
224 }
225 }
226
227 // simple test for SafeFetchN
228 static void test_safefetchN() {
229 if (CanUseSafeFetchN()) {
230 #ifdef _LP64
231 const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
232 const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
233 #else
234 const intptr_t v1 = 0xABCDABCD;
235 const intptr_t v2 = 0xDEFDDEFD;
236 #endif
237 intptr_t dummy = v1;
238 intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
239 intptr_t* const p_valid = &dummy;
240 intptr_t result_invalid = SafeFetchN(p_invalid, v2);
241 assert(result_invalid == v2, "SafeFetchN error");
242 intptr_t result_valid = SafeFetchN(p_valid, v2);
243 assert(result_valid == v1, "SafeFetchN error");
244 }
245 }
246 #endif
247
248 void StubRoutines::initialize2() {
249 if (_code2 == NULL) {
250 ResourceMark rm;
251 TraceTime timer("StubRoutines generation 2", TraceStartupTime);
252 _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
253 if (_code2 == NULL) {
254 vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
255 }
256 CodeBuffer buffer(_code2);
257 StubGenerator_generate(&buffer, true);
258 }
259
260 #ifdef ASSERT
261
262 #define TEST_ARRAYCOPY(type) \
263 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
264 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
|