1370 // 1371 1372 // Values used by the compiler. 1373 jvalue MethodHandleCompiler::zero_jvalue = { 0 }; 1374 jvalue MethodHandleCompiler::one_jvalue = { 1 }; 1375 1376 // Fetch any values from CountingMethodHandles and capture them for profiles 1377 bool MethodHandleCompiler::fetch_counts(ArgToken arg1, ArgToken arg2) { 1378 int count1 = -1, count2 = -1; 1379 if (arg1.token_type() == tt_constant && arg1.basic_type() == T_OBJECT && 1380 java_lang_invoke_CountingMethodHandle::is_instance(arg1.object()())) { 1381 count1 = java_lang_invoke_CountingMethodHandle::vmcount(arg1.object()()); 1382 } 1383 if (arg2.token_type() == tt_constant && arg2.basic_type() == T_OBJECT && 1384 java_lang_invoke_CountingMethodHandle::is_instance(arg2.object()())) { 1385 count2 = java_lang_invoke_CountingMethodHandle::vmcount(arg2.object()()); 1386 } 1387 int total = count1 + count2; 1388 if (count1 != -1 && count2 != -1 && total != 0) { 1389 // Normalize the collect counts to the invoke_count 1390 tty->print("counts %d %d scaled by %d = ", count2, count1, _invoke_count); 1391 if (count1 != 0) _not_taken_count = (int)(_invoke_count * count1 / (double)total); 1392 if (count2 != 0) _taken_count = (int)(_invoke_count * count2 / (double)total); 1393 tty->print_cr("%d %d", _taken_count, _not_taken_count); 1394 return true; 1395 } 1396 return false; 1397 } 1398 1399 // Emit bytecodes for the given invoke instruction. 1400 MethodHandleWalker::ArgToken 1401 MethodHandleCompiler::make_invoke(methodHandle m, vmIntrinsics::ID iid, 1402 Bytecodes::Code op, bool tailcall, 1403 int argc, MethodHandleWalker::ArgToken* argv, 1404 TRAPS) { 1405 ArgToken zero; 1406 if (m.is_null()) { 1407 // Get the intrinsic methodOop. 1408 m = methodHandle(THREAD, vmIntrinsics::method_for(iid)); 1409 if (m.is_null()) { 1410 lose(vmIntrinsics::name_at(iid), CHECK_(zero)); 1411 } 1412 } 1413 | 1370 // 1371 1372 // Values used by the compiler. 1373 jvalue MethodHandleCompiler::zero_jvalue = { 0 }; 1374 jvalue MethodHandleCompiler::one_jvalue = { 1 }; 1375 1376 // Fetch any values from CountingMethodHandles and capture them for profiles 1377 bool MethodHandleCompiler::fetch_counts(ArgToken arg1, ArgToken arg2) { 1378 int count1 = -1, count2 = -1; 1379 if (arg1.token_type() == tt_constant && arg1.basic_type() == T_OBJECT && 1380 java_lang_invoke_CountingMethodHandle::is_instance(arg1.object()())) { 1381 count1 = java_lang_invoke_CountingMethodHandle::vmcount(arg1.object()()); 1382 } 1383 if (arg2.token_type() == tt_constant && arg2.basic_type() == T_OBJECT && 1384 java_lang_invoke_CountingMethodHandle::is_instance(arg2.object()())) { 1385 count2 = java_lang_invoke_CountingMethodHandle::vmcount(arg2.object()()); 1386 } 1387 int total = count1 + count2; 1388 if (count1 != -1 && count2 != -1 && total != 0) { 1389 // Normalize the collect counts to the invoke_count 1390 if (count1 != 0) _not_taken_count = (int)(_invoke_count * count1 / (double)total); 1391 if (count2 != 0) _taken_count = (int)(_invoke_count * count2 / (double)total); 1392 return true; 1393 } 1394 return false; 1395 } 1396 1397 // Emit bytecodes for the given invoke instruction. 1398 MethodHandleWalker::ArgToken 1399 MethodHandleCompiler::make_invoke(methodHandle m, vmIntrinsics::ID iid, 1400 Bytecodes::Code op, bool tailcall, 1401 int argc, MethodHandleWalker::ArgToken* argv, 1402 TRAPS) { 1403 ArgToken zero; 1404 if (m.is_null()) { 1405 // Get the intrinsic methodOop. 1406 m = methodHandle(THREAD, vmIntrinsics::method_for(iid)); 1407 if (m.is_null()) { 1408 lose(vmIntrinsics::name_at(iid), CHECK_(zero)); 1409 } 1410 } 1411 |