diff src/share/vm/memory/allocation.cpp @ 10135:5a9fa2ba85f0

8012907: anti-delta fix for 8010992 Summary: anti-delta fix for 8010992 until 8012902 can be fixed Reviewed-by: acorn, minqi, rdurbin
author dcubed
date Sun, 21 Apr 2013 20:41:04 -0700
parents 6f817ce50129
children 746b070f5022 4b52137b07c9
line wrap: on
line diff
--- a/src/share/vm/memory/allocation.cpp	Fri Apr 19 11:08:52 2013 -0700
+++ b/src/share/vm/memory/allocation.cpp	Sun Apr 21 20:41:04 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, 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
@@ -51,12 +51,8 @@
 
 void* StackObj::operator new(size_t size)  { ShouldNotCallThis(); return 0; };
 void  StackObj::operator delete(void* p)   { ShouldNotCallThis(); };
-void* StackObj::operator new [](size_t size)  { ShouldNotCallThis(); return 0; };
-void  StackObj::operator delete [](void* p)   { ShouldNotCallThis(); };
 void* _ValueObj::operator new(size_t size)  { ShouldNotCallThis(); return 0; };
 void  _ValueObj::operator delete(void* p)   { ShouldNotCallThis(); };
-void* _ValueObj::operator new [](size_t size)  { 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, TRAPS) {
@@ -85,6 +81,7 @@
   st->print(" {"INTPTR_FORMAT"}", this);
 }
 
+
 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) {
   address res;
   switch (type) {
@@ -102,10 +99,6 @@
   return res;
 }
 
-void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) {
-  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) {
   //should only call this with std::nothrow, use other operator new() otherwise
@@ -125,10 +118,6 @@
   return res;
 }
 
-void* ResourceObj::operator new [](size_t size, const std::nothrow_t&  nothrow_constant,
-    allocation_type type, MEMFLAGS flags) {
-  return (address)operator new(size, nothrow_constant, type, flags);
-}
 
 void ResourceObj::operator delete(void* p) {
   assert(((ResourceObj *)p)->allocated_on_C_heap(),
@@ -137,10 +126,6 @@
   FreeHeap(p);
 }
 
-void ResourceObj::operator delete [](void* p) {
-  operator delete(p);
-}
-
 #ifdef ASSERT
 void ResourceObj::set_allocation_type(address res, allocation_type type) {
     // Set allocation type in the resource object
@@ -375,7 +360,7 @@
 void* Chunk::operator new(size_t requested_size, size_t length) {
   // 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.
+  // to expected arean alignment.
   // expect requested_size but if sizeof(Chunk) doesn't match isn't proper size we must align it.
   assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment");
   size_t bytes = ARENA_ALIGN(requested_size) + length;
@@ -684,21 +669,19 @@
 // a memory leak.  Use CHeapObj as the base class of such objects to make it explicit
 // that they're allocated on the C heap.
 // Commented out in product version to avoid conflicts with third-party C++ native code.
+// %% note this is causing a problem on solaris debug build. the global
+// new is being called from jdk source and causing data corruption.
+// src/share/native/sun/awt/font/fontmanager/textcache/hsMemory.cpp::hsSoftNew
+// define CATCH_OPERATOR_NEW_USAGE if you want to use this.
+#ifdef CATCH_OPERATOR_NEW_USAGE
 void* operator new(size_t size){
-  ShouldNotReachHere(); return 0;
-}
-
-void* operator new [](size_t size){
-  ShouldNotReachHere(); return 0;
+  static bool warned = false;
+  if (!warned && warn_new_operator)
+    warning("should not call global (default) operator new");
+  warned = true;
+  return (void *) AllocateHeap(size, "global operator new");
 }
-
-void* operator new(size_t size, const std::nothrow_t&  nothrow_constant){
-  ShouldNotReachHere(); return 0;
-}
-
-void* operator new [](size_t size, std::nothrow_t&  nothrow_constant){
-  ShouldNotReachHere(); return 0;
-}
+#endif
 
 void AllocatedObj::print() const       { print_on(tty); }
 void AllocatedObj::print_value() const { print_value_on(tty); }