1 /* 2 * Copyright (c) 2016, 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 #include "precompiled.hpp" 26 #include "asm/macroAssembler.hpp" 27 #include "runtime/interfaceSupport.inline.hpp" 28 #include "runtime/sharedRuntime.hpp" 29 #include "utilities/globalDefinitions.hpp" 30 #include "vmreg_x86.inline.hpp" 31 #ifdef COMPILER1 32 #include "c1/c1_Runtime1.hpp" 33 #endif //COMPILER1 34 35 #define __ masm-> 36 37 #ifdef COMPILER1 38 // --------------------------------------------------------------------------- 39 // Object.hashCode, System.identityHashCode can pull the hashCode from the 40 // header word instead of doing a full VM transition once it's been computed. 41 // Since hashCode is usually polymorphic at call sites we can't do this 42 // optimization at the call site without a lot of work. 43 void SharedRuntime::inline_check_hashcode_from_object_header(MacroAssembler* masm, 44 const methodHandle& method, 45 Register obj_reg, 46 Register result) { 47 Label slowCase; 48 49 // Unlike for Object.hashCode, System.identityHashCode is static method and 50 // gets object as argument instead of the receiver. 51 if (method->intrinsic_id() == vmIntrinsics::_identityHashCode) { 52 Label Continue; 53 // return 0 for null reference input 54 __ cmpptr(obj_reg, NULL_WORD); 55 __ jcc(Assembler::notEqual, Continue); 56 __ xorptr(result, result); 57 __ ret(0); 58 __ bind(Continue); 59 } 60 61 __ movptr(result, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 62 63 64 if (LockingMode == LM_LIGHTWEIGHT) { 65 if (!UseObjectMonitorTable) { 66 // check if monitor 67 __ testptr(result, markWord::monitor_value); 68 __ jcc(Assembler::notZero, slowCase); 69 } 70 } else { 71 // check if locked 72 __ testptr(result, markWord::unlocked_value); 73 __ jcc(Assembler::zero, slowCase); 74 } 75 76 // get hash 77 #ifdef _LP64 78 // Read the header and build a mask to get its hash field. 79 // Depend on hash_mask being at most 32 bits and avoid the use of hash_mask_in_place 80 // because it could be larger than 32 bits in a 64-bit vm. See markWord.hpp. 81 if (UseCompactObjectHeaders) { 82 STATIC_ASSERT(markWord::hash_mask_compact < nth_bit(32)); 83 __ shrptr(result, markWord::hash_shift_compact); 84 __ andptr(result, markWord::hash_mask_compact); 85 } else { 86 __ shrptr(result, markWord::hash_shift); 87 __ andptr(result, markWord::hash_mask); 88 } 89 #else 90 __ andptr(result, markWord::hash_mask_in_place); 91 #endif //_LP64 92 93 // test if hashCode exists 94 __ jcc(Assembler::zero, slowCase); 95 #ifndef _LP64 96 __ shrptr(result, markWord::hash_shift); 97 #endif 98 __ ret(0); 99 __ bind(slowCase); 100 } 101 #endif //COMPILER1 102 103 JRT_LEAF(jfloat, SharedRuntime::frem(jfloat x, jfloat y)) 104 assert(StubRoutines::fmod() != nullptr, ""); 105 jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod(); 106 jdouble dx = (jdouble) x; 107 jdouble dy = (jdouble) y; 108 109 return (jfloat) (*addr)(dx, dy); 110 JRT_END 111 112 JRT_LEAF(jdouble, SharedRuntime::drem(jdouble x, jdouble y)) 113 assert(StubRoutines::fmod() != nullptr, ""); 114 jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod(); 115 116 return (*addr)(x, y); 117 JRT_END