1340 {
1341 // Enter VM mode
1342
1343 ResetNoHandleMark rnhm;
1344 patch_code(thread, access_field_patching_id);
1345 }
1346 // Back in JAVA, use no oops DON'T safepoint
1347
1348 // Return true if calling code is deoptimized
1349
1350 return caller_is_deopted();
1351 JRT_END
1352
1353
1354 JRT_LEAF(void, Runtime1::trace_block_entry(jint block_id))
1355 // for now we just print out the block id
1356 tty->print("%d ", block_id);
1357 JRT_END
1358
1359
1360 // Array copy return codes.
1361 enum {
1362 ac_failed = -1, // arraycopy failed
1363 ac_ok = 0 // arraycopy succeeded
1364 };
1365
1366
1367 // Below length is the # elements copied.
1368 template <class T> int obj_arraycopy_work(oopDesc* src, T* src_addr,
1369 oopDesc* dst, T* dst_addr,
1370 int length) {
1371 if (src == dst) {
1372 // same object, no check
1373 HeapAccess<>::oop_arraycopy(arrayOop(src), arrayOop(dst), src_addr, dst_addr, length);
1374 return ac_ok;
1375 } else {
1376 Klass* bound = ObjArrayKlass::cast(dst->klass())->element_klass();
1377 Klass* stype = ObjArrayKlass::cast(src->klass())->element_klass();
1378 if (stype == bound || stype->is_subtype_of(bound)) {
1379 // Elements are guaranteed to be subtypes, so no check necessary
1380 HeapAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(arrayOop(src), arrayOop(dst), src_addr, dst_addr, length);
1381 return ac_ok;
1382 }
1383 }
1384 return ac_failed;
1385 }
1386
1387 // fast and direct copy of arrays; returning -1, means that an exception may be thrown
1388 // and we did not copy anything
1389 JRT_LEAF(int, Runtime1::arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length))
1390 #ifndef PRODUCT
1391 _generic_arraycopy_cnt++; // Slow-path oop array copy
1392 #endif
1393
1394 if (src == NULL || dst == NULL || src_pos < 0 || dst_pos < 0 || length < 0) return ac_failed;
1395 if (!dst->is_array() || !src->is_array()) return ac_failed;
1396 if ((unsigned int) arrayOop(src)->length() < (unsigned int)src_pos + (unsigned int)length) return ac_failed;
1397 if ((unsigned int) arrayOop(dst)->length() < (unsigned int)dst_pos + (unsigned int)length) return ac_failed;
1398
1399 if (length == 0) return ac_ok;
1400 if (src->is_typeArray()) {
1401 Klass* klass_oop = src->klass();
1402 if (klass_oop != dst->klass()) return ac_failed;
1403 TypeArrayKlass* klass = TypeArrayKlass::cast(klass_oop);
1404 klass->copy_array(arrayOop(src), src_pos, arrayOop(dst), dst_pos, length, Thread::current());
1405 return ac_ok;
1406 } else if (src->is_objArray() && dst->is_objArray()) {
1407 if (UseCompressedOops) {
1408 narrowOop *src_addr = objArrayOop(src)->obj_at_addr<narrowOop>(src_pos);
1409 narrowOop *dst_addr = objArrayOop(dst)->obj_at_addr<narrowOop>(dst_pos);
1410 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1411 } else {
1412 oop *src_addr = objArrayOop(src)->obj_at_addr<oop>(src_pos);
1413 oop *dst_addr = objArrayOop(dst)->obj_at_addr<oop>(dst_pos);
1414 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1415 }
1416 }
1417 return ac_failed;
1418 JRT_END
1419
1420
1421 JRT_LEAF(int, Runtime1::is_instance_of(oopDesc* mirror, oopDesc* obj))
1422 // had to return int instead of bool, otherwise there may be a mismatch
1423 // between the C calling convention and the Java one.
1424 // e.g., on x86, GCC may clear only %al when returning a bool false, but
1425 // JVM takes the whole %eax as the return value, which may misinterpret
1426 // the return value as a boolean true.
1427
1428 assert(mirror != NULL, "should null-check on mirror before calling");
1429 Klass* k = java_lang_Class::as_Klass(mirror);
1430 return (k != NULL && obj != NULL && obj->is_a(k)) ? 1 : 0;
1431 JRT_END
1432
1433 JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* thread))
1434 ResourceMark rm;
1435
1436 assert(!TieredCompilation, "incompatible with tiered compilation");
1437
1438 RegisterMap reg_map(thread, false);
1439 frame runtime_frame = thread->last_frame();
|
1340 {
1341 // Enter VM mode
1342
1343 ResetNoHandleMark rnhm;
1344 patch_code(thread, access_field_patching_id);
1345 }
1346 // Back in JAVA, use no oops DON'T safepoint
1347
1348 // Return true if calling code is deoptimized
1349
1350 return caller_is_deopted();
1351 JRT_END
1352
1353
1354 JRT_LEAF(void, Runtime1::trace_block_entry(jint block_id))
1355 // for now we just print out the block id
1356 tty->print("%d ", block_id);
1357 JRT_END
1358
1359
1360 JRT_LEAF(int, Runtime1::is_instance_of(oopDesc* mirror, oopDesc* obj))
1361 // had to return int instead of bool, otherwise there may be a mismatch
1362 // between the C calling convention and the Java one.
1363 // e.g., on x86, GCC may clear only %al when returning a bool false, but
1364 // JVM takes the whole %eax as the return value, which may misinterpret
1365 // the return value as a boolean true.
1366
1367 assert(mirror != NULL, "should null-check on mirror before calling");
1368 Klass* k = java_lang_Class::as_Klass(mirror);
1369 return (k != NULL && obj != NULL && obj->is_a(k)) ? 1 : 0;
1370 JRT_END
1371
1372 JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* thread))
1373 ResourceMark rm;
1374
1375 assert(!TieredCompilation, "incompatible with tiered compilation");
1376
1377 RegisterMap reg_map(thread, false);
1378 frame runtime_frame = thread->last_frame();
|