src/share/vm/code/oopRecorder.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6951083 Sdiff src/share/vm/code

src/share/vm/code/oopRecorder.cpp

Print this page


   1 /*
   2  * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  33 
  34 
  35 OopRecorder::OopRecorder(Arena* arena) {
  36   _handles  = NULL;
  37   _indexes  = NULL;
  38   _arena    = arena;
  39   _complete = false;
  40 }
  41 
  42 OopRecorder::IndexCache::IndexCache() {
  43   assert(first_index > 0, "initial zero state of cache must be invalid index");
  44   Copy::zero_to_bytes(&_cache[0], sizeof(_cache));
  45 }
  46 
  47 int OopRecorder::oop_size() {
  48   _complete = true;
  49   if (_handles == NULL)  return 0;
  50   return _handles->length() * sizeof(oop);
  51 }
  52 
  53 void OopRecorder::copy_to(CodeBlob* code) {
  54   assert(_complete, "must be frozen");
  55   maybe_initialize();  // get non-null handles, even if we have no oops
  56   code->copy_oops(_handles);
  57 }
  58 
  59 void OopRecorder::maybe_initialize() {
  60   if (_handles == NULL) {
  61     if (_arena != NULL) {
  62       _handles  = new(_arena) GrowableArray<jobject>(_arena, 10, 0, 0);
  63       _no_finds = new(_arena) GrowableArray<int>(    _arena, 10, 0, 0);
  64     } else {
  65       _handles  = new GrowableArray<jobject>(10, 0, 0);
  66       _no_finds = new GrowableArray<int>(    10, 0, 0);
  67     }
  68   }
  69 }
  70 
  71 
  72 jobject OopRecorder::handle_at(int index) {
  73   // there is always a NULL virtually present as first object
  74   if (index == null_index)  return NULL;
  75   return _handles->at(index - first_index);
  76 }


   1 /*
   2  * Copyright 1998-2010 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  33 
  34 
  35 OopRecorder::OopRecorder(Arena* arena) {
  36   _handles  = NULL;
  37   _indexes  = NULL;
  38   _arena    = arena;
  39   _complete = false;
  40 }
  41 
  42 OopRecorder::IndexCache::IndexCache() {
  43   assert(first_index > 0, "initial zero state of cache must be invalid index");
  44   Copy::zero_to_bytes(&_cache[0], sizeof(_cache));
  45 }
  46 
  47 int OopRecorder::oop_size() {
  48   _complete = true;
  49   if (_handles == NULL)  return 0;
  50   return _handles->length() * sizeof(oop);
  51 }
  52 
  53 void OopRecorder::copy_to(nmethod* nm) {
  54   assert(_complete, "must be frozen");
  55   maybe_initialize();  // get non-null handles, even if we have no oops
  56   nm->copy_oops(_handles);
  57 }
  58 
  59 void OopRecorder::maybe_initialize() {
  60   if (_handles == NULL) {
  61     if (_arena != NULL) {
  62       _handles  = new(_arena) GrowableArray<jobject>(_arena, 10, 0, 0);
  63       _no_finds = new(_arena) GrowableArray<int>(    _arena, 10, 0, 0);
  64     } else {
  65       _handles  = new GrowableArray<jobject>(10, 0, 0);
  66       _no_finds = new GrowableArray<int>(    10, 0, 0);
  67     }
  68   }
  69 }
  70 
  71 
  72 jobject OopRecorder::handle_at(int index) {
  73   // there is always a NULL virtually present as first object
  74   if (index == null_index)  return NULL;
  75   return _handles->at(index - first_index);
  76 }


src/share/vm/code/oopRecorder.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File