author | coleenp |
Fri, 16 Mar 2018 09:12:13 -0400 | |
changeset 49449 | ef5d5d343e2a |
parent 47216 | 71c04702a3d5 |
child 57777 | 90ead0febf56 |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
36079
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
1 |
/* |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
36079
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
36079
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
4 |
* |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
8 |
* |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
14 |
* |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
18 |
* |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
21 |
* questions. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
22 |
* |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
23 |
*/ |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
24 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
27 |
#include "runtime/sharedRuntime.hpp" |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
28 |
#include "vmreg_x86.inline.hpp" |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
29 |
#ifdef COMPILER1 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
30 |
#include "c1/c1_Runtime1.hpp" |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
31 |
#endif //COMPILER1 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
32 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
33 |
#define __ masm-> |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
34 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
35 |
#ifdef COMPILER1 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
36 |
// --------------------------------------------------------------------------- |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
37 |
// Object.hashCode, System.identityHashCode can pull the hashCode from the |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
38 |
// header word instead of doing a full VM transition once it's been computed. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
39 |
// Since hashCode is usually polymorphic at call sites we can't do this |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
40 |
// optimization at the call site without a lot of work. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
41 |
void SharedRuntime::inline_check_hashcode_from_object_header(MacroAssembler* masm, |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
36079
diff
changeset
|
42 |
const methodHandle& method, |
36079
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
43 |
Register obj_reg, |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
44 |
Register result) { |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
45 |
Label slowCase; |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
46 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
47 |
// Unlike for Object.hashCode, System.identityHashCode is static method and |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
48 |
// gets object as argument instead of the receiver. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
49 |
if (method->intrinsic_id() == vmIntrinsics::_identityHashCode) { |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
50 |
Label Continue; |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
51 |
// return 0 for null reference input |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
52 |
__ cmpptr(obj_reg, (int32_t)NULL_WORD); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
53 |
__ jcc(Assembler::notEqual, Continue); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
54 |
__ xorptr(result, result); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
55 |
__ ret(0); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
56 |
__ bind(Continue); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
57 |
} |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
58 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
59 |
__ movptr(result, Address(obj_reg, oopDesc::mark_offset_in_bytes())); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
60 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
61 |
// check if locked |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
62 |
__ testptr(result, markOopDesc::unlocked_value); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
63 |
__ jcc(Assembler::zero, slowCase); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
64 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
65 |
if (UseBiasedLocking) { |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
66 |
// Check if biased and fall through to runtime if so |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
67 |
__ testptr(result, markOopDesc::biased_lock_bit_in_place); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
68 |
__ jcc(Assembler::notZero, slowCase); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
69 |
} |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
70 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
71 |
// get hash |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
72 |
#ifdef _LP64 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
73 |
// Read the header and build a mask to get its hash field. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
74 |
// Depend on hash_mask being at most 32 bits and avoid the use of hash_mask_in_place |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
75 |
// because it could be larger than 32 bits in a 64-bit vm. See markOop.hpp. |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
76 |
__ shrptr(result, markOopDesc::hash_shift); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
77 |
__ andptr(result, markOopDesc::hash_mask); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
78 |
#else |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
79 |
__ andptr(result, markOopDesc::hash_mask_in_place); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
80 |
#endif //_LP64 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
81 |
|
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
82 |
// test if hashCode exists |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
83 |
__ jcc(Assembler::zero, slowCase); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
84 |
#ifndef _LP64 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
85 |
__ shrptr(result, markOopDesc::hash_shift); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
86 |
#endif |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
87 |
__ ret(0); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
88 |
__ bind(slowCase); |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
89 |
} |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
90 |
#endif //COMPILER1 |
692adc3fa1b5
6378256: Performance problem with System.identityHashCode in client compiler
thartmann
parents:
diff
changeset
|
91 |