diff options
author | kvn <none@none> | 2011-02-07 10:25:39 -0800 |
---|---|---|
committer | kvn <none@none> | 2011-02-07 10:25:39 -0800 |
commit | 9c3e52a2e942e4e96b51f2ae0b313d3e2bce6dac (patch) | |
tree | 30d234d88329857726af75d8848474392b743b2b /src/share/vm/libadt | |
parent | 8523be06a01cce672c5873150d08dfca4cdab163 (diff) | |
download | jdk8u_hotspot-9c3e52a2e942e4e96b51f2ae0b313d3e2bce6dac.tar.gz |
7013538: Java memory leak with escape analysis
Summary: Don't allocate VectorSet iterator on C heap. Reuse resource storage in EA.
Reviewed-by: never
Diffstat (limited to 'src/share/vm/libadt')
-rw-r--r-- | src/share/vm/libadt/vectset.cpp | 23 | ||||
-rw-r--r-- | src/share/vm/libadt/vectset.hpp | 30 |
2 files changed, 21 insertions, 32 deletions
diff --git a/src/share/vm/libadt/vectset.cpp b/src/share/vm/libadt/vectset.cpp index 1dd9f4e26..93cb48d69 100644 --- a/src/share/vm/libadt/vectset.cpp +++ b/src/share/vm/libadt/vectset.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, 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 @@ -350,28 +350,11 @@ int VectorSet::hash() const return (int)_xor; } -//------------------------------iterate---------------------------------------- -SetI_ *VectorSet::iterate(uint &elem) const -{ - VSetI_ *foo = (new(ResourceObj::C_HEAP) VSetI_(this)); - elem = foo->next(); - return foo; -} - //============================================================================= -//------------------------------VSetI_----------------------------------------- -// Initialize the innards of a VectorSet iterator -VSetI_::VSetI_( const VectorSet *vset ) : s(vset) -{ - i = (uint)-1L; - j = (uint)-1L; - mask = (unsigned)(1L<<31); -} - //------------------------------next------------------------------------------- // Find and return the next element of a vector set, or return garbage and -// make "VSetI_::test()" fail. -uint VSetI_::next(void) +// make "VectorSetI::test()" fail. +uint VectorSetI::next(void) { j++; // Next element in word mask = (mask & max_jint) << 1;// Next bit in word diff --git a/src/share/vm/libadt/vectset.hpp b/src/share/vm/libadt/vectset.hpp index 22c97b2a2..c184773ca 100644 --- a/src/share/vm/libadt/vectset.hpp +++ b/src/share/vm/libadt/vectset.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, 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 @@ -98,6 +98,9 @@ public: uint Size(void) const; // Number of elements in the Set. void Sort(void); // Sort before iterating int hash() const; // Hash function + void Reset(void) { // Reset a set + memset( data, 0, size*sizeof(uint32) ); + } /* Removed for MCC BUG operator const VectorSet* (void) const { return this; } */ @@ -148,8 +151,7 @@ public: private: - friend class VSetI_; - SetI_ *iterate(uint&) const; + SetI_ *iterate(uint&) const { ShouldNotCallThis(); return NULL; } // Removed }; //------------------------------Iteration-------------------------------------- @@ -158,22 +160,26 @@ private: // or may not be iterated over; untouched elements will be affected once. // Usage: for( VectorSetI i(s); i.test(); i++ ) { body = i.elem; } -class VSetI_ : public SetI_ { +class VectorSetI : public StackObj { friend class VectorSet; - friend class VectorSetI; const VectorSet *s; uint i, j; uint32 mask; - VSetI_(const VectorSet *vset); uint next(void); - int test(void) { return i < s->size; } -}; -class VectorSetI : public SetI { public: - VectorSetI( const VectorSet *s ) : SetI(s) { } - void operator ++(void) { elem = ((VSetI_*)impl)->next(); } - int test(void) { return ((VSetI_*)impl)->test(); } + uint elem; // The publically accessible element + + VectorSetI( const VectorSet *vset ) : + s(vset), + i((uint)-1L), + j((uint)-1L), + mask((unsigned)(1L<<31)) { + elem = next(); + } + + void operator ++(void) { elem = next(); } + int test(void) { return i < s->size; } }; #endif // SHARE_VM_LIBADT_VECTSET_HPP |