comparison src/cpu/x86/vm/sharedRuntime_x86_64.cpp @ 6518:ea845fd3c820

add hashCode fast path for System.identityHashCode
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 05 Oct 2012 15:17:27 +0200
parents 2dfab5607b3d
children e522a00b91aa
comparison
equal deleted inserted replaced
6517:2dfab5607b3d 6518:ea845fd3c820
1968 __ bind(hit); 1968 __ bind(hit);
1969 1969
1970 int vep_offset = ((intptr_t)__ pc()) - start; 1970 int vep_offset = ((intptr_t)__ pc()) - start;
1971 1971
1972 #ifdef GRAAL 1972 #ifdef GRAAL
1973 if (InlineObjectHash && method->intrinsic_id() == vmIntrinsics::_hashCode) { 1973 if (InlineObjectHash && (method->intrinsic_id() == vmIntrinsics::_hashCode || method->intrinsic_id() == vmIntrinsics::_identityHashCode)) {
1974 // Object.hashCode can pull the hashCode from the header word 1974 // Object.hashCode can pull the hashCode from the header word
1975 // instead of doing a full VM transition once it's been computed. 1975 // instead of doing a full VM transition once it's been computed.
1976 // Since hashCode is usually polymorphic at call sites we can't do 1976 // Since hashCode is usually polymorphic at call sites we can't do
1977 // this optimization at the call site without a lot of work. 1977 // this optimization at the call site without a lot of work.
1978 Label slowCase; 1978 Label slowCase;
1979 Label nullCase;
1979 Register result = rax; 1980 Register result = rax;
1981
1982 if (method->intrinsic_id() == vmIntrinsics::_identityHashCode) {
1983 __ cmpptr(receiver, 0);
1984 __ jcc(Assembler::equal, nullCase);
1985 }
1980 1986
1981 __ movptr(result, Address(receiver, oopDesc::mark_offset_in_bytes())); 1987 __ movptr(result, Address(receiver, oopDesc::mark_offset_in_bytes()));
1982 1988
1983 // check if locked 1989 // check if locked
1984 __ testptr(result, markOopDesc::unlocked_value); 1990 __ testptr(result, markOopDesc::unlocked_value);
1994 __ shrptr(result, markOopDesc::hash_shift); 2000 __ shrptr(result, markOopDesc::hash_shift);
1995 __ andptr(result, markOopDesc::hash_mask); 2001 __ andptr(result, markOopDesc::hash_mask);
1996 // test if hashCode exists 2002 // test if hashCode exists
1997 __ jcc (Assembler::zero, slowCase); 2003 __ jcc (Assembler::zero, slowCase);
1998 __ ret(0); 2004 __ ret(0);
2005
2006 if (method->intrinsic_id() == vmIntrinsics::_identityHashCode) {
2007 __ bind(nullCase);
2008 __ movl(result, 0);
2009 __ ret(0);
2010 }
1999 2011
2000 __ bind (slowCase); 2012 __ bind (slowCase);
2001 } 2013 }
2002 #endif // GRAAL 2014 #endif // GRAAL
2003 2015