changeset 14841:d069f5506f71

8004845: Catch incorrect usage of new and delete during compile time for value objects and stack objects Summary: Makes the "new" and "delete" operator of _ValueObj and StackObj private Reviewed-by: dholmes, coleenp Contributed-by: erik.helin@oracle.com
author brutisso
date Mon, 17 Dec 2012 15:25:26 +0100
parents 8994c2377547
children 4cdc5a61a7c2
files hotspot/src/share/vm/memory/allocation.hpp hotspot/src/share/vm/opto/node.cpp hotspot/src/share/vm/services/memBaseline.hpp hotspot/src/share/vm/utilities/workgroup.hpp hotspot/src/share/vm/utilities/yieldingWorkgroup.hpp
diffstat 5 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/memory/allocation.hpp	Mon Dec 17 08:49:20 2012 +0100
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Mon Dec 17 15:25:26 2012 +0100
@@ -202,7 +202,7 @@
 // Calling new or delete will result in fatal error.
 
 class StackObj ALLOCATION_SUPER_CLASS_SPEC {
- public:
+ private:
   void* operator new(size_t size);
   void  operator delete(void* p);
 };
@@ -226,7 +226,7 @@
 // be defined as a an empty string "".
 //
 class _ValueObj {
- public:
+ private:
   void* operator new(size_t size);
   void operator delete(void* p);
 };
--- a/hotspot/src/share/vm/opto/node.cpp	Mon Dec 17 08:49:20 2012 +0100
+++ b/hotspot/src/share/vm/opto/node.cpp	Mon Dec 17 15:25:26 2012 +0100
@@ -1839,15 +1839,16 @@
   return idx;                   // True for other than index 0 (control)
 }
 
+static RegMask _not_used_at_all;
 // Register classes are defined for specific machines
 const RegMask &Node::out_RegMask() const {
   ShouldNotCallThis();
-  return *(new RegMask());
+  return _not_used_at_all;
 }
 
 const RegMask &Node::in_RegMask(uint) const {
   ShouldNotCallThis();
-  return *(new RegMask());
+  return _not_used_at_all;
 }
 
 //=============================================================================
--- a/hotspot/src/share/vm/services/memBaseline.hpp	Mon Dec 17 08:49:20 2012 +0100
+++ b/hotspot/src/share/vm/services/memBaseline.hpp	Mon Dec 17 15:25:26 2012 +0100
@@ -334,7 +334,7 @@
   // create a memory baseline
   MemBaseline();
 
-  virtual ~MemBaseline();
+  ~MemBaseline();
 
   inline bool baselined() const {
     return _baselined;
--- a/hotspot/src/share/vm/utilities/workgroup.hpp	Mon Dec 17 08:49:20 2012 +0100
+++ b/hotspot/src/share/vm/utilities/workgroup.hpp	Mon Dec 17 15:25:26 2012 +0100
@@ -90,7 +90,7 @@
     NOT_PRODUCT(_name = name);
     _counter = 0;
   }
-  virtual ~AbstractGangTask() { }
+  ~AbstractGangTask() { }
 
 public:
 };
--- a/hotspot/src/share/vm/utilities/yieldingWorkgroup.hpp	Mon Dec 17 08:49:20 2012 +0100
+++ b/hotspot/src/share/vm/utilities/yieldingWorkgroup.hpp	Mon Dec 17 15:25:26 2012 +0100
@@ -106,7 +106,7 @@
     _status(INACTIVE),
     _gang(NULL) { }
 
-  virtual ~YieldingFlexibleGangTask() { }
+  ~YieldingFlexibleGangTask() { }
 
   friend class YieldingFlexibleWorkGang;
   friend class YieldingFlexibleGangWorker;