Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1OopClosures.hpp @ 14344:bec0ef450ead
6991197: G1: specialize deal_with_reference() for narrowOop*
Summary: Clean up and slightly optimize reference handling from the GC reference task queue. Since we never push partial array chunks as narrowOop* we can manually specialize the code so that some code can be optimized away.
Reviewed-by: tonyp, brutisso, stefank
author | tschatzl |
---|---|
date | Fri, 31 Jan 2014 09:57:50 +0100 |
parents | c685ef164975 |
children | e9d5c28e5059 |
comparison
equal
deleted
inserted
replaced
14343:05ede1d98e1e | 14344:bec0ef450ead |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
84 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | 84 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
85 }; | 85 }; |
86 | 86 |
87 #define G1_PARTIAL_ARRAY_MASK 0x2 | 87 #define G1_PARTIAL_ARRAY_MASK 0x2 |
88 | 88 |
89 template <class T> inline bool has_partial_array_mask(T* ref) { | 89 inline bool has_partial_array_mask(oop* ref) { |
90 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; | 90 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; |
91 } | 91 } |
92 | 92 |
93 template <class T> inline T* set_partial_array_mask(T obj) { | 93 // We never encode partial array oops as narrowOop*, so return false immediately. |
94 // This allows the compiler to create optimized code when popping references from | |
95 // the work queue. | |
96 inline bool has_partial_array_mask(narrowOop* ref) { | |
97 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); | |
98 return false; | |
99 } | |
100 | |
101 // Only implement set_partial_array_mask() for regular oops, not for narrowOops. | |
102 // We always encode partial arrays as regular oop, to allow the | |
103 // specialization for has_partial_array_mask() for narrowOops above. | |
104 // This means that unintentional use of this method with narrowOops are caught | |
105 // by the compiler. | |
106 inline oop* set_partial_array_mask(oop obj) { | |
94 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); | 107 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); |
95 return (T*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); | 108 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); |
96 } | 109 } |
97 | 110 |
98 template <class T> inline oop clear_partial_array_mask(T* ref) { | 111 template <class T> inline oop clear_partial_array_mask(T* ref) { |
99 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); | 112 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); |
100 } | 113 } |