comparison src/share/vm/libadt/vectset.cpp @ 2249:3763ca6579b7

7013538: Java memory leak with escape analysis Summary: Don't allocate VectorSet iterator on C heap. Reuse resource storage in EA. Reviewed-by: never
author kvn
date Mon, 07 Feb 2011 10:25:39 -0800
parents c760f78e0a53
children f350490a45fd
comparison
equal deleted inserted replaced
2248:194c9fdee631 2249:3763ca6579b7
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
348 for( uint i = 0; i < lim; i++ ) 348 for( uint i = 0; i < lim; i++ )
349 _xor ^= data[i]; 349 _xor ^= data[i];
350 return (int)_xor; 350 return (int)_xor;
351 } 351 }
352 352
353 //------------------------------iterate----------------------------------------
354 SetI_ *VectorSet::iterate(uint &elem) const
355 {
356 VSetI_ *foo = (new(ResourceObj::C_HEAP) VSetI_(this));
357 elem = foo->next();
358 return foo;
359 }
360
361 //============================================================================= 353 //=============================================================================
362 //------------------------------VSetI_-----------------------------------------
363 // Initialize the innards of a VectorSet iterator
364 VSetI_::VSetI_( const VectorSet *vset ) : s(vset)
365 {
366 i = (uint)-1L;
367 j = (uint)-1L;
368 mask = (unsigned)(1L<<31);
369 }
370
371 //------------------------------next------------------------------------------- 354 //------------------------------next-------------------------------------------
372 // Find and return the next element of a vector set, or return garbage and 355 // Find and return the next element of a vector set, or return garbage and
373 // make "VSetI_::test()" fail. 356 // make "VectorSetI::test()" fail.
374 uint VSetI_::next(void) 357 uint VectorSetI::next(void)
375 { 358 {
376 j++; // Next element in word 359 j++; // Next element in word
377 mask = (mask & max_jint) << 1;// Next bit in word 360 mask = (mask & max_jint) << 1;// Next bit in word
378 do { // Do While still have words 361 do { // Do While still have words
379 while( mask ) { // While have bits in word 362 while( mask ) { // While have bits in word