This commit is contained in:
Zhengyu Gu 2013-08-30 12:22:02 -04:00
commit 38fac8c706
51 changed files with 418 additions and 242 deletions

View file

@ -139,6 +139,7 @@ ifeq ($(USE_CLANG), true)
PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)
endif
else # ($(USE_CLANG), true)
@ -306,6 +307,7 @@ OPT_CFLAGS/NOOPT=-O0
ifeq ($(USE_CLANG), true)
ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
OPT_CFLAGS/unsafe.o += -01
endif
else
# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.

View file

@ -2943,6 +2943,53 @@ bool os::pd_uncommit_memory(char* addr, size_t size) {
return res != (uintptr_t) MAP_FAILED;
}
static
address get_stack_commited_bottom(address bottom, size_t size) {
address nbot = bottom;
address ntop = bottom + size;
size_t page_sz = os::vm_page_size();
unsigned pages = size / page_sz;
unsigned char vec[1];
unsigned imin = 1, imax = pages + 1, imid;
int mincore_return_value;
while (imin < imax) {
imid = (imax + imin) / 2;
nbot = ntop - (imid * page_sz);
// Use a trick with mincore to check whether the page is mapped or not.
// mincore sets vec to 1 if page resides in memory and to 0 if page
// is swapped output but if page we are asking for is unmapped
// it returns -1,ENOMEM
mincore_return_value = mincore(nbot, page_sz, vec);
if (mincore_return_value == -1) {
// Page is not mapped go up
// to find first mapped page
if (errno != EAGAIN) {
assert(errno == ENOMEM, "Unexpected mincore errno");
imax = imid;
}
} else {
// Page is mapped go down
// to find first not mapped page
imin = imid + 1;
}
}
nbot = nbot + page_sz;
// Adjust stack bottom one page up if last checked page is not mapped
if (mincore_return_value == -1) {
nbot = nbot + page_sz;
}
return nbot;
}
// Linux uses a growable mapping for the stack, and if the mapping for
// the stack guard pages is not removed when we detach a thread the
// stack cannot grow beyond the pages where the stack guard was
@ -2957,59 +3004,37 @@ bool os::pd_uncommit_memory(char* addr, size_t size) {
// So, we need to know the extent of the stack mapping when
// create_stack_guard_pages() is called.
// Find the bounds of the stack mapping. Return true for success.
//
// We only need this for stacks that are growable: at the time of
// writing thread stacks don't use growable mappings (i.e. those
// creeated with MAP_GROWSDOWN), and aren't marked "[stack]", so this
// only applies to the main thread.
static
bool get_stack_bounds(uintptr_t *bottom, uintptr_t *top) {
char buf[128];
int fd, sz;
if ((fd = ::open("/proc/self/maps", O_RDONLY)) < 0) {
return false;
}
const char kw[] = "[stack]";
const int kwlen = sizeof(kw)-1;
// Address part of /proc/self/maps couldn't be more than 128 bytes
while ((sz = os::get_line_chars(fd, buf, sizeof(buf))) > 0) {
if (sz > kwlen && ::memcmp(buf+sz-kwlen, kw, kwlen) == 0) {
// Extract addresses
if (sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, bottom, top) == 2) {
uintptr_t sp = (uintptr_t) __builtin_frame_address(0);
if (sp >= *bottom && sp <= *top) {
::close(fd);
return true;
}
}
}
}
::close(fd);
return false;
}
// If the (growable) stack mapping already extends beyond the point
// where we're going to put our guard pages, truncate the mapping at
// that point by munmap()ping it. This ensures that when we later
// munmap() the guard pages we don't leave a hole in the stack
// mapping. This only affects the main/initial thread, but guard
// against future OS changes
// mapping. This only affects the main/initial thread
bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
uintptr_t stack_extent, stack_base;
bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
assert(os::Linux::is_initial_thread(),
"growable stack in non-initial thread");
if (stack_extent < (uintptr_t)addr)
::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent);
if (os::Linux::is_initial_thread()) {
// As we manually grow stack up to bottom inside create_attached_thread(),
// it's likely that os::Linux::initial_thread_stack_bottom is mapped and
// we don't need to do anything special.
// Check it first, before calling heavy function.
uintptr_t stack_extent = (uintptr_t) os::Linux::initial_thread_stack_bottom();
unsigned char vec[1];
if (mincore((address)stack_extent, os::vm_page_size(), vec) == -1) {
// Fallback to slow path on all errors, including EAGAIN
stack_extent = (uintptr_t) get_stack_commited_bottom(
os::Linux::initial_thread_stack_bottom(),
(size_t)addr - stack_extent);
}
if (stack_extent < (uintptr_t)addr) {
::munmap((void*)stack_extent, (uintptr_t)(addr - stack_extent));
}
}
return os::commit_memory(addr, size, !ExecMem);
@ -3018,13 +3043,13 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
// If this is a growable mapping, remove the guard pages entirely by
// munmap()ping them. If not, just call uncommit_memory(). This only
// affects the main/initial thread, but guard against future OS changes
// It's safe to always unmap guard pages for initial thread because we
// always place it right after end of the mapped region
bool os::remove_stack_guard_pages(char* addr, size_t size) {
uintptr_t stack_extent, stack_base;
bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
assert(os::Linux::is_initial_thread(),
"growable stack in non-initial thread");
if (os::Linux::is_initial_thread()) {
return ::munmap(addr, size) == 0;
}

View file

@ -1,5 +1,5 @@
/*
* 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
@ -30,6 +30,8 @@
#include <unistd.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <pthread.h>
#include <signal.h>
// Check core dump limit and report possible place where core can be found
@ -271,11 +273,17 @@ os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
* The callback is supposed to provide the method that should be protected.
*/
bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
sigset_t saved_sig_mask;
assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
assert(!WatcherThread::watcher_thread()->has_crash_protection(),
"crash_protection already set?");
if (sigsetjmp(_jmpbuf, 1) == 0) {
// we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
// since on at least some systems (OS X) siglongjmp will restore the mask
// for the process, not the thread
pthread_sigmask(0, NULL, &saved_sig_mask);
if (sigsetjmp(_jmpbuf, 0) == 0) {
// make sure we can see in the signal handler that we have crash protection
// installed
WatcherThread::watcher_thread()->set_crash_protection(this);
@ -285,6 +293,7 @@ bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
return true;
}
// this happens when we siglongjmp() back
pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
WatcherThread::watcher_thread()->set_crash_protection(NULL);
return false;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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,7 +24,7 @@
#include "adlc.hpp"
void* Chunk::operator new(size_t requested_size, size_t length) {
void* Chunk::operator new(size_t requested_size, size_t length) throw() {
return CHeapObj::operator new(requested_size + length);
}
@ -163,7 +163,7 @@ bool Arena::contains( const void *ptr ) const {
//-----------------------------------------------------------------------------
// CHeapObj
void* CHeapObj::operator new(size_t size){
void* CHeapObj::operator new(size_t size) throw() {
return (void *) malloc(size);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -42,7 +42,7 @@
class CHeapObj {
public:
void* operator new(size_t size);
void* operator new(size_t size) throw();
void operator delete(void* p);
void* new_array(size_t size);
};
@ -53,7 +53,7 @@ class CHeapObj {
class ValueObj {
public:
void* operator new(size_t size);
void* operator new(size_t size) throw();
void operator delete(void* p);
};
@ -61,7 +61,7 @@ class ValueObj {
class AllStatic {
public:
void* operator new(size_t size);
void* operator new(size_t size) throw();
void operator delete(void* p);
};
@ -70,7 +70,7 @@ class AllStatic {
// Linked list of raw memory chunks
class Chunk: public CHeapObj {
public:
void* operator new(size_t size, size_t length);
void* operator new(size_t size, size_t length) throw();
void operator delete(void* p, size_t length);
Chunk(size_t length);

View file

@ -1,5 +1,5 @@
/*
* 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
@ -485,7 +485,7 @@ int get_legal_text(FileBuff &fbuf, char **legal_text)
// VS2005 has its own definition, identical to this one.
#if !defined(_WIN32) || defined(_WIN64) || _MSC_VER < 1400
void *operator new( size_t size, int, const char *, int ) {
void *operator new( size_t size, int, const char *, int ) throw() {
return ::operator new( size );
}
#endif

View file

@ -1,5 +1,5 @@
/*
* 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
@ -296,7 +296,7 @@ class CodeBuffer: public StackObj {
// CodeBuffers must be allocated on the stack except for a single
// special case during expansion which is handled internally. This
// is done to guarantee proper cleanup of resources.
void* operator new(size_t size) { return ResourceObj::operator new(size); }
void* operator new(size_t size) throw() { return ResourceObj::operator new(size); }
void operator delete(void* p) { ShouldNotCallThis(); }
public:

View file

@ -1,5 +1,5 @@
/*
* 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
@ -279,8 +279,8 @@ class InstructionMark: public StackObj {
// Base class for objects allocated by the compiler in the compilation arena
class CompilationResourceObj ALLOCATION_SUPER_CLASS_SPEC {
public:
void* operator new(size_t size) { return Compilation::current()->arena()->Amalloc(size); }
void* operator new(size_t size, Arena* arena) {
void* operator new(size_t size) throw() { return Compilation::current()->arena()->Amalloc(size); }
void* operator new(size_t size, Arena* arena) throw() {
return arena->Amalloc(size);
}
void operator delete(void* p) {} // nothing to do

View file

@ -1,5 +1,5 @@
/*
* 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
@ -323,7 +323,7 @@ class Instruction: public CompilationResourceObj {
}
public:
void* operator new(size_t size) {
void* operator new(size_t size) throw() {
Compilation* c = Compilation::current();
void* res = c->arena()->Amalloc(size);
((Instruction*)res)->_id = c->get_next_id();
@ -1611,7 +1611,7 @@ LEAF(BlockBegin, StateSplit)
friend class SuxAndWeightAdjuster;
public:
void* operator new(size_t size) {
void* operator new(size_t size) throw() {
Compilation* c = Compilation::current();
void* res = c->arena()->Amalloc(size);
((BlockBegin*)res)->_id = c->get_next_id();

View file

@ -2318,9 +2318,6 @@ void ClassVerifier::verify_invoke_instructions(
types = 1 << JVM_CONSTANT_InvokeDynamic;
break;
case Bytecodes::_invokespecial:
types = (1 << JVM_CONSTANT_InterfaceMethodref) |
(1 << JVM_CONSTANT_Methodref);
break;
case Bytecodes::_invokestatic:
types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ?
(1 << JVM_CONSTANT_Methodref) :

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -245,7 +245,7 @@ BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
}
void* BufferBlob::operator new(size_t s, unsigned size) {
void* BufferBlob::operator new(size_t s, unsigned size) throw() {
void* p = CodeCache::allocate(size);
return p;
}
@ -347,14 +347,14 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
}
void* RuntimeStub::operator new(size_t s, unsigned size) {
void* RuntimeStub::operator new(size_t s, unsigned size) throw() {
void* p = CodeCache::allocate(size, true);
if (!p) fatal("Initial size of CodeCache is too small");
return p;
}
// operator new shared by all singletons:
void* SingletonBlob::operator new(size_t s, unsigned size) {
void* SingletonBlob::operator new(size_t s, unsigned size) throw() {
void* p = CodeCache::allocate(size, true);
if (!p) fatal("Initial size of CodeCache is too small");
return p;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -209,7 +209,7 @@ class BufferBlob: public CodeBlob {
BufferBlob(const char* name, int size);
BufferBlob(const char* name, int size, CodeBuffer* cb);
void* operator new(size_t s, unsigned size);
void* operator new(size_t s, unsigned size) throw();
public:
// Creation
@ -283,7 +283,7 @@ class RuntimeStub: public CodeBlob {
bool caller_must_gc_arguments
);
void* operator new(size_t s, unsigned size);
void* operator new(size_t s, unsigned size) throw();
public:
// Creation
@ -321,7 +321,7 @@ class SingletonBlob: public CodeBlob {
friend class VMStructs;
protected:
void* operator new(size_t s, unsigned size);
void* operator new(size_t s, unsigned size) throw();
public:
SingletonBlob(

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -38,7 +38,7 @@ class DIR_Chunk {
int _length; // number of bytes in the stream
int _hash; // hash of stream bytes (for quicker reuse)
void* operator new(size_t ignore, DebugInformationRecorder* dir) {
void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() {
assert(ignore == sizeof(DIR_Chunk), "");
if (dir->_next_chunk >= dir->_next_chunk_limit) {
const int CHUNK = 100;

View file

@ -1,5 +1,5 @@
/*
* 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

View file

@ -1,5 +1,5 @@
/*
* 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
@ -265,7 +265,7 @@ class nmethod : public CodeBlob {
int comp_level);
// helper methods
void* operator new(size_t size, int nmethod_size);
void* operator new(size_t size, int nmethod_size) throw();
const char* reloc_string_for(u_char* begin, u_char* end);
// Returns true if this thread changed the state of the nmethod or

View file

@ -1,5 +1,5 @@
/*
* 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
@ -677,7 +677,7 @@ class Relocation VALUE_OBJ_CLASS_SPEC {
}
public:
void* operator new(size_t size, const RelocationHolder& holder) {
void* operator new(size_t size, const RelocationHolder& holder) throw() {
if (size > sizeof(holder._relocbuf)) guarantee_size();
assert((void* const *)holder.reloc() == &holder._relocbuf[0], "ptrs must agree");
return holder.reloc();

View file

@ -1,5 +1,5 @@
/*
* 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
@ -49,7 +49,7 @@ VMReg VtableStub::_receiver_location = VMRegImpl::Bad();
static int num_vtable_chunks = 0;
void* VtableStub::operator new(size_t size, int code_size) {
void* VtableStub::operator new(size_t size, int code_size) throw() {
assert(size == sizeof(VtableStub), "mismatched size");
num_vtable_chunks++;
// compute real VtableStub size (rounded to nearest word)

View file

@ -1,5 +1,5 @@
/*
* 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
@ -46,7 +46,7 @@ class VtableStub {
bool _is_vtable_stub; // True if vtable stub, false, is itable stub
/* code follows here */ // The vtableStub code
void* operator new(size_t size, int code_size);
void* operator new(size_t size, int code_size) throw();
VtableStub(bool is_vtable_stub, int index)
: _next(NULL), _is_vtable_stub(is_vtable_stub),

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
@ -144,9 +144,9 @@ class AdaptivePaddedAverage : public AdaptiveWeightedAverage {
_padded_avg(0.0), _deviation(0.0), _padding(padding) {}
// Placement support
void* operator new(size_t ignored, void* p) { return p; }
void* operator new(size_t ignored, void* p) throw() { return p; }
// Allocator
void* operator new(size_t size) { return CHeapObj<mtGC>::operator new(size); }
void* operator new(size_t size) throw() { return CHeapObj<mtGC>::operator new(size); }
// Accessor
float padded_average() const { return _padded_avg; }

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, 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
@ -163,7 +163,7 @@ extern void safe_free (const char *file, unsigned line, void *ptr);
extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size);
extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size);
extern char *safe_strdup (const char *file, unsigned line, const char *src);
inline void *operator new( size_t size ) { return malloc(size); }
inline void *operator new( size_t size ) throw() { return malloc(size); }
inline void operator delete( void *ptr ) { free(ptr); }
#endif

View file

@ -49,19 +49,19 @@
# include "os_bsd.inline.hpp"
#endif
void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }
void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
void StackObj::operator delete(void* p) { ShouldNotCallThis(); }
void* StackObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; }
void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
void StackObj::operator delete [](void* p) { ShouldNotCallThis(); }
void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }
void* _ValueObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }
void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; }
void* _ValueObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); }
void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
size_t word_size, bool read_only,
MetaspaceObj::Type type, TRAPS) {
MetaspaceObj::Type type, TRAPS) throw() {
// Klass has it's own operator new
return Metaspace::allocate(loader_data, word_size, read_only,
type, CHECK_NULL);
@ -80,7 +80,7 @@ void MetaspaceObj::print_address_on(outputStream* st) const {
st->print(" {"INTPTR_FORMAT"}", this);
}
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) {
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
address res;
switch (type) {
case C_HEAP:
@ -97,12 +97,12 @@ void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flag
return res;
}
void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) {
void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
return (address) operator new(size, type, flags);
}
void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) {
allocation_type type, MEMFLAGS flags) throw() {
//should only call this with std::nothrow, use other operator new() otherwise
address res;
switch (type) {
@ -121,7 +121,7 @@ void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_cons
}
void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) {
allocation_type type, MEMFLAGS flags) throw() {
return (address)operator new(size, nothrow_constant, type, flags);
}
@ -370,7 +370,7 @@ class ChunkPoolCleaner : public PeriodicTask {
//--------------------------------------------------------------------------------------
// Chunk implementation
void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) {
void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) throw() {
// requested_size is equal to sizeof(Chunk) but in order for the arena
// allocations to come out aligned as expected the size must be aligned
// to expected arena alignment.
@ -478,18 +478,18 @@ Arena::~Arena() {
NOT_PRODUCT(Atomic::dec(&_instance_count);)
}
void* Arena::operator new(size_t size) {
void* Arena::operator new(size_t size) throw() {
assert(false, "Use dynamic memory type binding");
return NULL;
}
void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) {
void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) throw() {
assert(false, "Use dynamic memory type binding");
return NULL;
}
// dynamic memory type binding
void* Arena::operator new(size_t size, MEMFLAGS flags) {
void* Arena::operator new(size_t size, MEMFLAGS flags) throw() {
#ifdef ASSERT
void* p = (void*)AllocateHeap(size, flags|otArena, CALLER_PC);
if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
@ -499,7 +499,7 @@ void* Arena::operator new(size_t size, MEMFLAGS flags) {
#endif
}
void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) {
void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() {
#ifdef ASSERT
void* p = os::malloc(size, flags|otArena, CALLER_PC);
if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
@ -688,22 +688,22 @@ void* Arena::internal_malloc_4(size_t x) {
// define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed.
//
#ifndef ALLOW_OPERATOR_NEW_USAGE
void* operator new(size_t size){
void* operator new(size_t size) throw() {
assert(false, "Should not call global operator new");
return 0;
}
void* operator new [](size_t size){
void* operator new [](size_t size) throw() {
assert(false, "Should not call global operator new[]");
return 0;
}
void* operator new(size_t size, const std::nothrow_t& nothrow_constant){
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
assert(false, "Should not call global operator new");
return 0;
}
void* operator new [](size_t size, std::nothrow_t& nothrow_constant){
void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw() {
assert(false, "Should not call global operator new[]");
return 0;
}

View file

@ -204,12 +204,12 @@ const bool NMT_track_callsite = false;
template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
public:
_NOINLINE_ void* operator new(size_t size, address caller_pc = 0);
_NOINLINE_ void* operator new(size_t size, address caller_pc = 0) throw();
_NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
address caller_pc = 0);
_NOINLINE_ void* operator new [](size_t size, address caller_pc = 0);
address caller_pc = 0) throw();
_NOINLINE_ void* operator new [](size_t size, address caller_pc = 0) throw();
_NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
address caller_pc = 0);
address caller_pc = 0) throw();
void operator delete(void* p);
void operator delete [] (void* p);
};
@ -219,9 +219,9 @@ template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
class StackObj ALLOCATION_SUPER_CLASS_SPEC {
private:
void* operator new(size_t size);
void* operator new(size_t size) throw();
void operator delete(void* p);
void* operator new [](size_t size);
void* operator new [](size_t size) throw();
void operator delete [](void* p);
};
@ -245,9 +245,9 @@ class StackObj ALLOCATION_SUPER_CLASS_SPEC {
//
class _ValueObj {
private:
void* operator new(size_t size);
void* operator new(size_t size) throw();
void operator delete(void* p);
void* operator new [](size_t size);
void* operator new [](size_t size) throw();
void operator delete [](void* p);
};
@ -316,7 +316,7 @@ class MetaspaceObj {
void* operator new(size_t size, ClassLoaderData* loader_data,
size_t word_size, bool read_only,
Type type, Thread* thread);
Type type, Thread* thread) throw();
// can't use TRAPS from this header file.
void operator delete(void* p) { ShouldNotCallThis(); }
};
@ -339,7 +339,7 @@ class Chunk: CHeapObj<mtChunk> {
Chunk* _next; // Next Chunk in list
const size_t _len; // Size of this Chunk
public:
void* operator new(size_t size, AllocFailType alloc_failmode, size_t length);
void* operator new(size_t size, AllocFailType alloc_failmode, size_t length) throw();
void operator delete(void* p);
Chunk(size_t length);
@ -422,12 +422,12 @@ protected:
char* hwm() const { return _hwm; }
// new operators
void* operator new (size_t size);
void* operator new (size_t size, const std::nothrow_t& nothrow_constant);
void* operator new (size_t size) throw();
void* operator new (size_t size, const std::nothrow_t& nothrow_constant) throw();
// dynamic memory type tagging
void* operator new(size_t size, MEMFLAGS flags);
void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags);
void* operator new(size_t size, MEMFLAGS flags) throw();
void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw();
void operator delete(void* p);
// Fast allocate in the arena. Common case is: pointer test + increment.
@ -583,44 +583,44 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
#endif // ASSERT
public:
void* operator new(size_t size, allocation_type type, MEMFLAGS flags);
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags);
void* operator new(size_t size, allocation_type type, MEMFLAGS flags) throw();
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw();
void* operator new(size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags);
allocation_type type, MEMFLAGS flags) throw();
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags);
allocation_type type, MEMFLAGS flags) throw();
void* operator new(size_t size, Arena *arena) {
void* operator new(size_t size, Arena *arena) throw() {
address res = (address)arena->Amalloc(size);
DEBUG_ONLY(set_allocation_type(res, ARENA);)
return res;
}
void* operator new [](size_t size, Arena *arena) {
void* operator new [](size_t size, Arena *arena) throw() {
address res = (address)arena->Amalloc(size);
DEBUG_ONLY(set_allocation_type(res, ARENA);)
return res;
}
void* operator new(size_t size) {
void* operator new(size_t size) throw() {
address res = (address)resource_allocate_bytes(size);
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
return res;
}
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) {
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
return res;
}
void* operator new [](size_t size) {
void* operator new [](size_t size) throw() {
address res = (address)resource_allocate_bytes(size);
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
return res;
}
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) {
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) throw() {
address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
return res;

View file

@ -85,7 +85,7 @@ inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) {
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
address caller_pc){
address caller_pc) throw() {
void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC));
#ifdef ASSERT
if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
@ -94,7 +94,7 @@ template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
}
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
const std::nothrow_t& nothrow_constant, address caller_pc) {
const std::nothrow_t& nothrow_constant, address caller_pc) throw() {
void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC),
AllocFailStrategy::RETURN_NULL);
#ifdef ASSERT
@ -104,12 +104,12 @@ template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
}
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
address caller_pc){
address caller_pc) throw() {
return CHeapObj<F>::operator new(size, caller_pc);
}
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
const std::nothrow_t& nothrow_constant, address caller_pc) {
const std::nothrow_t& nothrow_constant, address caller_pc) throw() {
return CHeapObj<F>::operator new(size, nothrow_constant, caller_pc);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -102,11 +102,11 @@ MemRegion MemRegion::minus(const MemRegion mr2) const {
return MemRegion();
}
void* MemRegion::operator new(size_t size) {
void* MemRegion::operator new(size_t size) throw() {
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL);
}
void* MemRegion::operator new [](size_t size) {
void* MemRegion::operator new [](size_t size) throw() {
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL);
}
void MemRegion::operator delete(void* p) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -94,8 +94,8 @@ public:
size_t word_size() const { return _word_size; }
bool is_empty() const { return word_size() == 0; }
void* operator new(size_t size);
void* operator new [](size_t size);
void* operator new(size_t size) throw();
void* operator new [](size_t size) throw();
void operator delete(void* p);
void operator delete [](void* p);
};
@ -111,13 +111,13 @@ public:
class MemRegionClosureRO: public MemRegionClosure {
public:
void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) {
void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) throw() {
return ResourceObj::operator new(size, type, flags);
}
void* operator new(size_t size, Arena *arena) {
void* operator new(size_t size, Arena *arena) throw() {
return ResourceObj::operator new(size, arena);
}
void* operator new(size_t size) {
void* operator new(size_t size) throw() {
return ResourceObj::operator new(size);
}

View file

@ -139,7 +139,7 @@ Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
return NULL;
}
void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) {
void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
return Metaspace::allocate(loader_data, word_size, /*read_only*/false,
MetaspaceObj::ClassType, CHECK_NULL);
}

View file

@ -179,7 +179,7 @@ class Klass : public Metadata {
// Constructor
Klass();
void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS);
void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
public:
bool is_klass() const volatile { return true; }

View file

@ -41,19 +41,19 @@ Symbol::Symbol(const u1* name, int length, int refcount) {
}
}
void* Symbol::operator new(size_t sz, int len, TRAPS) {
void* Symbol::operator new(size_t sz, int len, TRAPS) throw() {
int alloc_size = size(len)*HeapWordSize;
address res = (address) AllocateHeap(alloc_size, mtSymbol);
return res;
}
void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) {
void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() {
int alloc_size = size(len)*HeapWordSize;
address res = (address)arena->Amalloc(alloc_size);
return res;
}
void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) {
void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) throw() {
address res;
int alloc_size = size(len)*HeapWordSize;
res = (address) Metaspace::allocate(loader_data, size(len), true,

View file

@ -136,9 +136,9 @@ class Symbol : private SymbolBase {
}
Symbol(const u1* name, int length, int refcount);
void* operator new(size_t size, int len, TRAPS);
void* operator new(size_t size, int len, Arena* arena, TRAPS);
void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS);
void* operator new(size_t size, int len, TRAPS) throw();
void* operator new(size_t size, int len, Arena* arena, TRAPS) throw();
void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS) throw();
void operator delete(void* p);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -260,7 +260,7 @@ class WarmCallInfo : public ResourceObj {
// Because WarmInfo objects live over the entire lifetime of the
// Compile object, they are allocated into the comp_arena, which
// does not get resource marked or reset during the compile process
void *operator new( size_t x, Compile* C ) { return C->comp_arena()->Amalloc(x); }
void *operator new( size_t x, Compile* C ) throw() { return C->comp_arena()->Amalloc(x); }
void operator delete( void * ) { } // fast deallocation
static WarmCallInfo* always_hot();

View file

@ -1,5 +1,5 @@
/*
* 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
@ -216,7 +216,7 @@ public:
// Because JVMState objects live over the entire lifetime of the
// Compile object, they are allocated into the comp_arena, which
// does not get resource marked or reset during the compile process
void *operator new( size_t x, Compile* C ) { return C->comp_arena()->Amalloc(x); }
void *operator new( size_t x, Compile* C ) throw() { return C->comp_arena()->Amalloc(x); }
void operator delete( void * ) { } // fast deallocation
// Create a new JVMState, ready for abstract interpretation.

View file

@ -1,5 +1,5 @@
/*
* 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
@ -58,7 +58,7 @@ class State;
class MachOper : public ResourceObj {
public:
// Allocate right next to the MachNodes in the same arena
void *operator new( size_t x, Compile* C ) { return C->node_arena()->Amalloc_D(x); }
void *operator new( size_t x, Compile* C ) throw() { return C->node_arena()->Amalloc_D(x); }
// Opcode
virtual uint opcode() const = 0;

View file

@ -1,5 +1,5 @@
/*
* 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
@ -211,7 +211,7 @@ public:
// New Operator that takes a Compile pointer, this will eventually
// be the "new" New operator.
inline void* operator new( size_t x, Compile* C) {
inline void* operator new( size_t x, Compile* C) throw() {
Node* n = (Node*)C->node_arena()->Amalloc_D(x);
#ifdef ASSERT
n->_in = (Node**)n; // magic cookie for assertion check

View file

@ -1,5 +1,5 @@
/*
* 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
@ -169,7 +169,7 @@ protected:
public:
inline void* operator new( size_t x ) {
inline void* operator new( size_t x ) throw() {
Compile* compile = Compile::current();
compile->set_type_last_size(x);
void *temp = compile->type_arena()->Amalloc_D(x);

View file

@ -264,7 +264,7 @@ class ProfilerNode {
public:
void* operator new(size_t size, ThreadProfiler* tp);
void* operator new(size_t size, ThreadProfiler* tp) throw();
void operator delete(void* p);
ProfilerNode() {
@ -373,7 +373,7 @@ class ProfilerNode {
}
};
void* ProfilerNode::operator new(size_t size, ThreadProfiler* tp){
void* ProfilerNode::operator new(size_t size, ThreadProfiler* tp) throw() {
void* result = (void*) tp->area_top;
tp->area_top += size;

View file

@ -1,5 +1,5 @@
/*
* 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
@ -179,11 +179,11 @@ HandleMark::~HandleMark() {
_thread->set_last_handle_mark(previous_handle_mark());
}
void* HandleMark::operator new(size_t size) {
void* HandleMark::operator new(size_t size) throw() {
return AllocateHeap(size, mtThread);
}
void* HandleMark::operator new [] (size_t size) {
void* HandleMark::operator new [] (size_t size) throw() {
return AllocateHeap(size, mtThread);
}

View file

@ -309,8 +309,8 @@ class HandleMark {
// called in the destructor of HandleMarkCleaner
void pop_and_restore();
// overloaded operators
void* operator new(size_t size);
void* operator new [](size_t size);
void* operator new(size_t size) throw();
void* operator new [](size_t size) throw();
void operator delete(void* p);
void operator delete[](void* p);
};

View file

@ -1,5 +1,5 @@
/*
* 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
@ -56,7 +56,7 @@ class HandleMarkCleaner: public StackObj {
}
private:
inline void* operator new(size_t size, void* ptr) {
inline void* operator new(size_t size, void* ptr) throw() {
return ptr;
}
};

View file

@ -312,10 +312,10 @@ public:
public:
static int Knob_Verbose;
static int Knob_SpinLimit;
void* operator new (size_t size) {
void* operator new (size_t size) throw() {
return AllocateHeap(size, mtInternal);
}
void* operator new[] (size_t size) {
void* operator new[] (size_t size) throw() {
return operator new (size);
}
void operator delete(void* p) {

View file

@ -1424,44 +1424,6 @@ bool os::is_server_class_machine() {
return result;
}
// Read file line by line, if line is longer than bsize,
// skip rest of line.
int os::get_line_chars(int fd, char* buf, const size_t bsize){
size_t sz, i = 0;
// read until EOF, EOL or buf is full
while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') {
++i;
}
if (buf[i] == '\n') {
// EOL reached so ignore EOL character and return
buf[i] = 0;
return (int) i;
}
buf[i+1] = 0;
if (sz != 1) {
// EOF reached. if we read chars before EOF return them and
// return EOF on next call otherwise return EOF
return (i == 0) ? -1 : (int) i;
}
// line is longer than size of buf, skip to EOL
char ch;
while (read(fd, &ch, 1) == 1 && ch != '\n') {
// Do nothing
}
// return initial part of line that fits in buf.
// If we reached EOF, it will be returned on next call.
return (int) i;
}
void os::SuspendedThreadTask::run() {
assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this");
internal_do_task();

View file

@ -725,10 +725,6 @@ class os: AllStatic {
// Hook for os specific jvm options that we don't want to abort on seeing
static bool obsolete_option(const JavaVMOption *option);
// Read file line by line. If line is longer than bsize,
// rest of line is skipped. Returns number of bytes read or -1 on EOF
static int get_line_chars(int fd, char *buf, const size_t bsize);
// Extensions
#include "runtime/os_ext.hpp"

View file

@ -1,5 +1,5 @@
/*
* 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
@ -140,7 +140,7 @@ void ParkEvent::Release (ParkEvent * ev) {
// well as bank access imbalance on Niagara-like platforms,
// although Niagara's hash function should help.
void * ParkEvent::operator new (size_t sz) {
void * ParkEvent::operator new (size_t sz) throw() {
return (void *) ((intptr_t (AllocateHeap(sz + 256, mtInternal, CALLER_PC)) + 256) & -256) ;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, 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
@ -166,7 +166,7 @@ class ParkEvent : public os::PlatformEvent {
// aligned on 256-byte address boundaries. This ensures that the least
// significant byte of a ParkEvent address is always 0.
void * operator new (size_t sz) ;
void * operator new (size_t sz) throw();
void operator delete (void * a) ;
public:

View file

@ -113,8 +113,9 @@ class Thread: public ThreadShadow {
// Support for forcing alignment of thread objects for biased locking
void* _real_malloc_address;
public:
void* operator new(size_t size) { return allocate(size, true); }
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { return allocate(size, false); }
void* operator new(size_t size) throw() { return allocate(size, true); }
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
return allocate(size, false); }
void operator delete(void* p);
protected:

View file

@ -53,13 +53,13 @@ template <class E, int SIZE> class FixedSizeMemPointerArray :
}
}
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) {
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
// the instance is part of memRecorder, needs to be tagged with 'otNMTRecorder'
// to avoid recursion
return os::malloc(size, (mtNMT | otNMTRecorder));
}
void* operator new(size_t size) {
void* operator new(size_t size) throw() {
assert(false, "use nothrow version");
return NULL;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 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
@ -63,12 +63,12 @@ MemTrackWorker::~MemTrackWorker() {
}
}
void* MemTrackWorker::operator new(size_t size) {
void* MemTrackWorker::operator new(size_t size) throw() {
assert(false, "use nothrow version");
return NULL;
}
void* MemTrackWorker::operator new(size_t size, const std::nothrow_t& nothrow_constant) {
void* MemTrackWorker::operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
return allocate(size, false, mtNMT);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 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
@ -90,8 +90,8 @@ class MemTrackWorker : public NamedThread {
public:
MemTrackWorker(MemSnapshot* snapshot);
~MemTrackWorker();
_NOINLINE_ void* operator new(size_t size);
_NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant);
_NOINLINE_ void* operator new(size_t size) throw();
_NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw();
void start();
void run();

View file

@ -317,7 +317,7 @@ protected:
Array(const Array<T>&);
void operator=(const Array<T>&);
void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) {
void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) throw() {
size_t word_size = Array::size(length);
return (void*) Metaspace::allocate(loader_data, word_size, read_only,
MetaspaceObj::array_type(sizeof(T)), CHECK_NULL);

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class DoOverflow {
static int count;
public void overflow() {
count+=1;
overflow();
}
public static void printIt() {
System.out.println("Going to overflow stack");
try {
new DoOverflow().overflow();
} catch(java.lang.StackOverflowError e) {
System.out.println("Overflow OK " + count);
}
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <assert.h>
#include <jni.h>
#include <pthread.h>
JavaVM* jvm;
void *
floobydust (void *p) {
JNIEnv *env;
jvm->AttachCurrentThread((void**)&env, NULL);
jclass class_id = env->FindClass ("DoOverflow");
assert (class_id);
jmethodID method_id = env->GetStaticMethodID(class_id, "printIt", "()V");
assert (method_id);
env->CallStaticVoidMethod(class_id, method_id, NULL);
jvm->DetachCurrentThread();
}
int
main (int argc, const char** argv) {
JavaVMOption options[1];
options[0].optionString = (char*) "-Xss320k";
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_2;
vm_args.ignoreUnrecognized = JNI_TRUE;
vm_args.options = options;
vm_args.nOptions = 1;
JNIEnv* env;
jint result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
assert(result >= 0);
pthread_t thr;
pthread_create(&thr, NULL, floobydust, NULL);
pthread_join(thr, NULL);
floobydust(NULL);
return 0;
}

View file

@ -0,0 +1,73 @@
#!/bin/sh
# Copyright (c) 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
# @test testme.sh
# @bug 8009062
# @summary Poor performance of JNI AttachCurrentThread after fix for 7017193
# @compile DoOverflow.java
# @run shell testme.sh
set -x
if [ "${TESTSRC}" = "" ]
then
TESTSRC=${PWD}
echo "TESTSRC not set. Using "${TESTSRC}" as default"
fi
echo "TESTSRC=${TESTSRC}"
## Adding common setup Variables for running shell tests.
. ${TESTSRC}/../../test_env.sh
if [ "${VM_OS}" != "linux" ]
then
echo "Test only valid for Linux"
exit 0
fi
gcc_cmd=`which gcc`
if [ "x$gcc_cmd" == "x" ]; then
echo "WARNING: gcc not found. Cannot execute test." 2>&1
exit 0;
fi
CFLAGS="-m${VM_BITS}"
LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
cp ${TESTSRC}${FS}invoke.cxx .
# Copy the result of our @compile action:
cp ${TESTCLASSES}${FS}DoOverflow.class .
echo "Compilation flag: ${COMP_FLAG}"
# Note pthread may not be found thus invoke creation will fail to be created.
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
$gcc_cmd -DLINUX ${CFLAGS} -o invoke \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
-ljvm -lpthread invoke.cxx
./invoke
exit $?