提交 0c84cdb5 编写于 作者: S simonis

8008959: Fix non-PCH build on Linux, Windows and MacOS X

Summary: Fix the build without precompiled headers by either including the missing ".inline.hpp" files into the appropriate files or by turning inline-functions declared in header files into ordinary functions in ".cpp" files.
Reviewed-by: coleenp, stefank, dholmes
上级 60cdfe90
......@@ -2695,7 +2695,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
assert(thread->is_VM_thread(), "Must be VMThread");
// read current suspend action
int action = osthread->sr.suspend_action();
if (action == SR_SUSPEND) {
if (action == os::Bsd::SuspendResume::SR_SUSPEND) {
suspend_save_context(osthread, siginfo, context);
// Notify the suspend action is about to be completed. do_suspend()
......@@ -2717,12 +2717,12 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
do {
sigsuspend(&suspend_set);
// ignore all returns until we get a resume signal
} while (osthread->sr.suspend_action() != SR_CONTINUE);
} while (osthread->sr.suspend_action() != os::Bsd::SuspendResume::SR_CONTINUE);
resume_clear_context(osthread);
} else {
assert(action == SR_CONTINUE, "unexpected sr action");
assert(action == os::Bsd::SuspendResume::SR_CONTINUE, "unexpected sr action");
// nothing special to do - just leave the handler
}
......@@ -2776,7 +2776,7 @@ static int SR_finalize() {
// but this seems the normal response to library errors
static bool do_suspend(OSThread* osthread) {
// mark as suspended and send signal
osthread->sr.set_suspend_action(SR_SUSPEND);
osthread->sr.set_suspend_action(os::Bsd::SuspendResume::SR_SUSPEND);
int status = pthread_kill(osthread->pthread_id(), SR_signum);
assert_status(status == 0, status, "pthread_kill");
......@@ -2785,18 +2785,18 @@ static bool do_suspend(OSThread* osthread) {
for (int i = 0; !osthread->sr.is_suspended(); i++) {
os::yield_all(i);
}
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Bsd::SuspendResume::SR_NONE);
return true;
}
else {
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Bsd::SuspendResume::SR_NONE);
return false;
}
}
static void do_resume(OSThread* osthread) {
assert(osthread->sr.is_suspended(), "thread should be suspended");
osthread->sr.set_suspend_action(SR_CONTINUE);
osthread->sr.set_suspend_action(os::Bsd::SuspendResume::SR_CONTINUE);
int status = pthread_kill(osthread->pthread_id(), SR_signum);
assert_status(status == 0, status, "pthread_kill");
......@@ -2806,7 +2806,7 @@ static void do_resume(OSThread* osthread) {
os::yield_all(i);
}
}
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Bsd::SuspendResume::SR_NONE);
}
////////////////////////////////////////////////////////////////////////////////
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -152,35 +152,24 @@ class Bsd {
class SuspendResume {
private:
volatile int _suspend_action;
// values for suspend_action:
#define SR_NONE (0x00)
#define SR_SUSPEND (0x01) // suspend request
#define SR_CONTINUE (0x02) // resume request
volatile jint _state;
// values for _state: + SR_NONE
#define SR_SUSPENDED (0x20)
public:
// values for suspend_action:
enum {
SR_NONE = 0x00,
SR_SUSPEND = 0x01, // suspend request
SR_CONTINUE = 0x02, // resume request
SR_SUSPENDED = 0x20 // values for _state: + SR_NONE
};
SuspendResume() { _suspend_action = SR_NONE; _state = SR_NONE; }
int suspend_action() const { return _suspend_action; }
void set_suspend_action(int x) { _suspend_action = x; }
// atomic updates for _state
void set_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
void clear_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
inline void set_suspended();
inline void clear_suspended();
bool is_suspended() { return _state & SR_SUSPENDED; }
#undef SR_SUSPENDED
......
......@@ -25,7 +25,6 @@
#ifndef OS_BSD_VM_OS_BSD_INLINE_HPP
#define OS_BSD_VM_OS_BSD_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
......@@ -286,4 +285,21 @@ inline int os::set_sock_opt(int fd, int level, int optname,
const char* optval, socklen_t optlen) {
return ::setsockopt(fd, level, optname, optval, optlen);
}
inline void os::Bsd::SuspendResume::set_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
inline void os::Bsd::SuspendResume::clear_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
#endif // OS_BSD_VM_OS_BSD_INLINE_HPP
......@@ -3461,7 +3461,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
assert(thread->is_VM_thread(), "Must be VMThread");
// read current suspend action
int action = osthread->sr.suspend_action();
if (action == SR_SUSPEND) {
if (action == os::Linux::SuspendResume::SR_SUSPEND) {
suspend_save_context(osthread, siginfo, context);
// Notify the suspend action is about to be completed. do_suspend()
......@@ -3483,12 +3483,12 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
do {
sigsuspend(&suspend_set);
// ignore all returns until we get a resume signal
} while (osthread->sr.suspend_action() != SR_CONTINUE);
} while (osthread->sr.suspend_action() != os::Linux::SuspendResume::SR_CONTINUE);
resume_clear_context(osthread);
} else {
assert(action == SR_CONTINUE, "unexpected sr action");
assert(action == os::Linux::SuspendResume::SR_CONTINUE, "unexpected sr action");
// nothing special to do - just leave the handler
}
......@@ -3542,7 +3542,7 @@ static int SR_finalize() {
// but this seems the normal response to library errors
static bool do_suspend(OSThread* osthread) {
// mark as suspended and send signal
osthread->sr.set_suspend_action(SR_SUSPEND);
osthread->sr.set_suspend_action(os::Linux::SuspendResume::SR_SUSPEND);
int status = pthread_kill(osthread->pthread_id(), SR_signum);
assert_status(status == 0, status, "pthread_kill");
......@@ -3551,18 +3551,18 @@ static bool do_suspend(OSThread* osthread) {
for (int i = 0; !osthread->sr.is_suspended(); i++) {
os::yield_all(i);
}
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Linux::SuspendResume::SR_NONE);
return true;
}
else {
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Linux::SuspendResume::SR_NONE);
return false;
}
}
static void do_resume(OSThread* osthread) {
assert(osthread->sr.is_suspended(), "thread should be suspended");
osthread->sr.set_suspend_action(SR_CONTINUE);
osthread->sr.set_suspend_action(os::Linux::SuspendResume::SR_CONTINUE);
int status = pthread_kill(osthread->pthread_id(), SR_signum);
assert_status(status == 0, status, "pthread_kill");
......@@ -3572,7 +3572,7 @@ static void do_resume(OSThread* osthread) {
os::yield_all(i);
}
}
osthread->sr.set_suspend_action(SR_NONE);
osthread->sr.set_suspend_action(os::Linux::SuspendResume::SR_NONE);
}
////////////////////////////////////////////////////////////////////////////////
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -210,38 +210,26 @@ class Linux {
class SuspendResume {
private:
volatile int _suspend_action;
// values for suspend_action:
#define SR_NONE (0x00)
#define SR_SUSPEND (0x01) // suspend request
#define SR_CONTINUE (0x02) // resume request
volatile jint _state;
// values for _state: + SR_NONE
#define SR_SUSPENDED (0x20)
public:
// values for suspend_action:
enum {
SR_NONE = 0x00,
SR_SUSPEND = 0x01, // suspend request
SR_CONTINUE = 0x02, // resume request
SR_SUSPENDED = 0x20 // values for _state: + SR_NONE
};
SuspendResume() { _suspend_action = SR_NONE; _state = SR_NONE; }
int suspend_action() const { return _suspend_action; }
void set_suspend_action(int x) { _suspend_action = x; }
// atomic updates for _state
void set_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
void clear_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
inline void set_suspended();
inline void clear_suspended();
bool is_suspended() { return _state & SR_SUSPENDED; }
#undef SR_SUSPENDED
};
private:
......
......@@ -25,7 +25,6 @@
#ifndef OS_LINUX_VM_OS_LINUX_INLINE_HPP
#define OS_LINUX_VM_OS_LINUX_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
......@@ -288,4 +287,21 @@ inline int os::set_sock_opt(int fd, int level, int optname,
const char* optval, socklen_t optlen) {
return ::setsockopt(fd, level, optname, optval, optlen);
}
inline void os::Linux::SuspendResume::set_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
inline void os::Linux::SuspendResume::clear_suspended() {
jint temp, temp2;
do {
temp = _state;
temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
} while (temp2 != temp);
}
#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP
......@@ -25,7 +25,6 @@
#ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
#define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "prims/jvm.h"
#include "runtime/arguments.hpp"
#include "decoder_windows.hpp"
WindowsDecoder::WindowsDecoder() {
......
......@@ -25,7 +25,6 @@
#ifndef OS_WINDOWS_VM_OS_WINDOWS_INLINE_HPP
#define OS_WINDOWS_VM_OS_WINDOWS_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_INLINE_HPP
#define OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_INLINE_HPP
#include "orderAccess_bsd_x86.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,8 +25,9 @@
#ifndef OS_CPU_BSD_X86_VM_ORDERACCESS_BSD_X86_INLINE_HPP
#define OS_CPU_BSD_X86_VM_ORDERACCESS_BSD_X86_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
// Implementation of class OrderAccess.
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -26,7 +26,6 @@
#ifndef OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
#define OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
#include "orderAccess_bsd_zero.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_zero.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP
#define OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP
#include "orderAccess_linux_sparc.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_sparc.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_LINUX_X86_VM_ATOMIC_LINUX_X86_INLINE_HPP
#define OS_CPU_LINUX_X86_VM_ATOMIC_LINUX_X86_INLINE_HPP
#include "orderAccess_linux_x86.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,8 +25,9 @@
#ifndef OS_CPU_LINUX_X86_VM_ORDERACCESS_LINUX_X86_INLINE_HPP
#define OS_CPU_LINUX_X86_VM_ORDERACCESS_LINUX_X86_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
// Implementation of class OrderAccess.
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -26,7 +26,6 @@
#ifndef OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP
#define OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP
#include "orderAccess_linux_zero.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_zero.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_INLINE_HPP
#define OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_INLINE_HPP
#include "orderAccess_solaris_sparc.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_sparc.hpp"
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,6 +25,7 @@
#ifndef OS_CPU_SOLARIS_SPARC_VM_ORDERACCESS_SOLARIS_SPARC_INLINE_HPP
#define OS_CPU_SOLARIS_SPARC_VM_ORDERACCESS_SOLARIS_SPARC_INLINE_HPP
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "vm_version_sparc.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_INLINE_HPP
#define OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_INLINE_HPP
#include "orderAccess_solaris_x86.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,7 @@
#ifndef OS_CPU_SOLARIS_X86_VM_ORDERACCESS_SOLARIS_X86_INLINE_HPP
#define OS_CPU_SOLARIS_X86_VM_ORDERACCESS_SOLARIS_X86_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,6 @@
#ifndef OS_CPU_WINDOWS_X86_VM_ATOMIC_WINDOWS_X86_INLINE_HPP
#define OS_CPU_WINDOWS_X86_VM_ATOMIC_WINDOWS_X86_INLINE_HPP
#include "orderAccess_windows_x86.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,12 +25,11 @@
#ifndef OS_CPU_WINDOWS_X86_VM_ORDERACCESS_WINDOWS_X86_INLINE_HPP
#define OS_CPU_WINDOWS_X86_VM_ORDERACCESS_WINDOWS_X86_INLINE_HPP
#include "runtime/atomic.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "vm_version_x86.hpp"
#pragma warning(disable: 4035) // Disables warnings reporting missing return statement
// Implementation of class OrderAccess.
inline void OrderAccess::loadload() { acquire(); }
......@@ -214,6 +213,4 @@ inline void OrderAccess::release_store_ptr_fence(volatile void* p, void*
#endif // AMD64
}
#pragma warning(default: 4035) // Enables warnings reporting missing return statement
#endif // OS_CPU_WINDOWS_X86_VM_ORDERACCESS_WINDOWS_X86_INLINE_HPP
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,6 +25,7 @@
#ifndef SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
#define SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
// Explicit C-heap memory management
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -27,6 +27,7 @@
#include "classfile/altHashing.hpp"
#include "classfile/classLoaderData.hpp"
#include "oops/symbol.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/os.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
......@@ -210,6 +211,28 @@ unsigned int Symbol::new_hash(jint seed) {
return AltHashing::murmur3_32(seed, (const jbyte*)as_C_string(), utf8_length());
}
void Symbol::increment_refcount() {
// Only increment the refcount if positive. If negative either
// overflow has occurred or it is a permanent symbol in a read only
// shared archive.
if (_refcount >= 0) {
Atomic::inc(&_refcount);
NOT_PRODUCT(Atomic::inc(&_total_count);)
}
}
void Symbol::decrement_refcount() {
if (_refcount >= 0) {
Atomic::dec(&_refcount);
#ifdef ASSERT
if (_refcount < 0) {
print();
assert(false, "reference count underflow for symbol");
}
#endif
}
}
void Symbol::print_on(outputStream* st) const {
if (this == NULL) {
st->print_cr("NULL");
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -27,7 +27,6 @@
#include "utilities/utf8.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
// A Symbol is a canonicalized string.
// All Symbols reside in global SymbolTable and are reference counted.
......@@ -150,8 +149,8 @@ class Symbol : public MetaspaceObj {
// Reference counting. See comments above this class for when to use.
int refcount() const { return _refcount; }
inline void increment_refcount();
inline void decrement_refcount();
void increment_refcount();
void decrement_refcount();
int byte_at(int index) const {
assert(index >=0 && index < _length, "symbol index overflow");
......@@ -232,26 +231,4 @@ int Symbol::fast_compare(Symbol* other) const {
return (((uintptr_t)this < (uintptr_t)other) ? -1
: ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
}
inline void Symbol::increment_refcount() {
// Only increment the refcount if positive. If negative either
// overflow has occurred or it is a permanent symbol in a read only
// shared archive.
if (_refcount >= 0) {
Atomic::inc(&_refcount);
NOT_PRODUCT(Atomic::inc(&_total_count);)
}
}
inline void Symbol::decrement_refcount() {
if (_refcount >= 0) {
Atomic::dec(&_refcount);
#ifdef ASSERT
if (_refcount < 0) {
print();
assert(false, "reference count underflow for symbol");
}
#endif
}
}
#endif // SHARE_VM_OOPS_SYMBOL_HPP
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册