hotspot/src/os/aix/vm/misc_aix.cpp
author stuefe
Fri, 30 Oct 2015 12:36:54 +0100
changeset 33743 e21d93a9e062
child 34647 fafb32d71489
permissions -rw-r--r--
8140645: Recent Developments for AIX Summary: Port recent developments from SAP for AIX to the OpenJDK Reviewed-by: goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     1
/*
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     2
 * Copyright 2015 SAP AG. All rights reserved.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     4
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     8
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    13
 * accompanied this code).
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    14
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    18
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    21
 * questions.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    22
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    23
 */
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    24
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    25
#include "misc_aix.hpp"
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    26
#include "runtime/stubRoutines.hpp"
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    27
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    28
#include <pthread.h>
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    29
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    30
void MiscUtils::init_critsect(MiscUtils::critsect_t* cs) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    31
  const int rc = pthread_mutex_init(cs, NULL);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    32
  assert0(rc == 0);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    33
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    34
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    35
void MiscUtils::free_critsect(MiscUtils::critsect_t* cs) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    36
  const int rc = pthread_mutex_destroy(cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    37
  assert0(rc == 0);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    38
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    39
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    40
void MiscUtils::enter_critsect(MiscUtils::critsect_t* cs) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    41
  const int rc = pthread_mutex_lock(cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    42
  assert0(rc == 0);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    43
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    44
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    45
void MiscUtils::leave_critsect(MiscUtils::critsect_t* cs) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    46
  const int rc = pthread_mutex_unlock(cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    47
  assert0(rc == 0);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    48
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    49
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    50
bool MiscUtils::is_readable_pointer(const void* p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    51
  if (!CanUseSafeFetch32()) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    52
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    53
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    54
  int* const aligned = (int*) align_size_down((intptr_t)p, 4);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    55
  int cafebabe = 0xcafebabe;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    56
  int deadbeef = 0xdeadbeef;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    57
  return (SafeFetch32(aligned, cafebabe) != cafebabe) ||
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    58
         (SafeFetch32(aligned, deadbeef) != deadbeef);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    59
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    60
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    61