hotspot/src/share/vm/utilities/accessFlags.cpp
author kvn
Fri, 07 Nov 2008 09:29:38 -0800
changeset 1500 bea9a90f3e8f
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6462850: generate biased locking code in C2 ideal graph Summary: Inline biased locking code in C2 ideal graph during macro nodes expansion Reviewed-by: never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_accessFlags.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
void AccessFlags::atomic_set_bits(jint bits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  // Atomically update the flags with the bits given
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  jint old_flags, new_flags, f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    old_flags = _flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    new_flags = old_flags | bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    f = Atomic::cmpxchg(new_flags, &_flags, old_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  } while(f != old_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
void AccessFlags::atomic_clear_bits(jint bits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  // Atomically update the flags with the bits given
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  jint old_flags, new_flags, f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    old_flags = _flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    new_flags = old_flags & ~bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    f = Atomic::cmpxchg(new_flags, &_flags, old_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  } while(f != old_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
void AccessFlags::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  if (is_public      ()) st->print("public "      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (is_private     ()) st->print("private "     );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  if (is_protected   ()) st->print("protected "   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  if (is_static      ()) st->print("static "      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  if (is_final       ()) st->print("final "       );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  if (is_synchronized()) st->print("synchronized ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  if (is_volatile    ()) st->print("volatile "    );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  if (is_transient   ()) st->print("transient "   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  if (is_native      ()) st->print("native "      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  if (is_interface   ()) st->print("interface "   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  if (is_abstract    ()) st->print("abstract "    );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  if (is_strict      ()) st->print("strict "      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  if (is_synthetic   ()) st->print("synthetic "   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  if (is_old         ()) st->print("{old} "       );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  if (is_obsolete    ()) st->print("{obsolete} "  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
void accessFlags_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  assert(sizeof(AccessFlags) == sizeof(jint), "just checking size of flags");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}