src/share/vm/gc_implementation/g1/g1OopClosures.hpp

changeset 6269
5a9a209853bf
parent 6231
889068b9a088
child 6329
86b64209f715
     1.1 --- a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Fri Jan 31 09:55:59 2014 +0100
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Fri Jan 31 09:57:50 2014 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -86,13 +86,26 @@
    1.11  
    1.12  #define G1_PARTIAL_ARRAY_MASK 0x2
    1.13  
    1.14 -template <class T> inline bool has_partial_array_mask(T* ref) {
    1.15 +inline bool has_partial_array_mask(oop* ref) {
    1.16    return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
    1.17  }
    1.18  
    1.19 -template <class T> inline T* set_partial_array_mask(T obj) {
    1.20 +// We never encode partial array oops as narrowOop*, so return false immediately.
    1.21 +// This allows the compiler to create optimized code when popping references from
    1.22 +// the work queue.
    1.23 +inline bool has_partial_array_mask(narrowOop* ref) {
    1.24 +  assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*");
    1.25 +  return false;
    1.26 +}
    1.27 +
    1.28 +// Only implement set_partial_array_mask() for regular oops, not for narrowOops.
    1.29 +// We always encode partial arrays as regular oop, to allow the
    1.30 +// specialization for has_partial_array_mask() for narrowOops above.
    1.31 +// This means that unintentional use of this method with narrowOops are caught
    1.32 +// by the compiler.
    1.33 +inline oop* set_partial_array_mask(oop obj) {
    1.34    assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
    1.35 -  return (T*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
    1.36 +  return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
    1.37  }
    1.38  
    1.39  template <class T> inline oop clear_partial_array_mask(T* ref) {

mercurial