hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp
changeset 23995 fc58ec725daf
parent 22234 da823d78ad65
child 25905 04a3d83cc752
equal deleted inserted replaced
23994:bf66a565b65f 23995:fc58ec725daf
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2014, 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.
    68   assert(!Universe::is_fully_initialized() || obj->klass() != NULL,
    68   assert(!Universe::is_fully_initialized() || obj->klass() != NULL,
    69          "missing klass");
    69          "missing klass");
    70 }
    70 }
    71 
    71 
    72 // Support for jvmti and dtrace
    72 // Support for jvmti and dtrace
    73 inline void post_allocation_notify(KlassHandle klass, oop obj) {
    73 inline void post_allocation_notify(KlassHandle klass, oop obj, int size) {
    74   // support low memory notifications (no-op if not enabled)
    74   // support low memory notifications (no-op if not enabled)
    75   LowMemoryDetector::detect_low_memory_for_collected_pools();
    75   LowMemoryDetector::detect_low_memory_for_collected_pools();
    76 
    76 
    77   // support for JVMTI VMObjectAlloc event (no-op if not enabled)
    77   // support for JVMTI VMObjectAlloc event (no-op if not enabled)
    78   JvmtiExport::vm_object_alloc_event_collector(obj);
    78   JvmtiExport::vm_object_alloc_event_collector(obj);
    79 
    79 
    80   if (DTraceAllocProbes) {
    80   if (DTraceAllocProbes) {
    81     // support for Dtrace object alloc event (no-op most of the time)
    81     // support for Dtrace object alloc event (no-op most of the time)
    82     if (klass() != NULL && klass()->name() != NULL) {
    82     if (klass() != NULL && klass()->name() != NULL) {
    83       SharedRuntime::dtrace_object_alloc(obj);
    83       SharedRuntime::dtrace_object_alloc(obj, size);
    84     }
    84     }
    85   }
    85   }
    86 }
    86 }
    87 
    87 
    88 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
    88 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
    89                                               HeapWord* obj) {
    89                                               HeapWord* obj,
       
    90                                               int size) {
    90   post_allocation_setup_common(klass, obj);
    91   post_allocation_setup_common(klass, obj);
    91   assert(Universe::is_bootstrapping() ||
    92   assert(Universe::is_bootstrapping() ||
    92          !((oop)obj)->is_array(), "must not be an array");
    93          !((oop)obj)->is_array(), "must not be an array");
    93   // notify jvmti and dtrace
    94   // notify jvmti and dtrace
    94   post_allocation_notify(klass, (oop)obj);
    95   post_allocation_notify(klass, (oop)obj, size);
    95 }
    96 }
    96 
    97 
    97 void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
    98 void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
    98                                                 HeapWord* obj,
    99                                                 HeapWord* obj,
    99                                                 int length) {
   100                                                 int length) {
   101   // in post_allocation_setup_common() because the klass field
   102   // in post_allocation_setup_common() because the klass field
   102   // indicates that the object is parsable by concurrent GC.
   103   // indicates that the object is parsable by concurrent GC.
   103   assert(length >= 0, "length should be non-negative");
   104   assert(length >= 0, "length should be non-negative");
   104   ((arrayOop)obj)->set_length(length);
   105   ((arrayOop)obj)->set_length(length);
   105   post_allocation_setup_common(klass, obj);
   106   post_allocation_setup_common(klass, obj);
   106   assert(((oop)obj)->is_array(), "must be an array");
   107   oop new_obj = (oop)obj;
       
   108   assert(new_obj->is_array(), "must be an array");
   107   // notify jvmti and dtrace (must be after length is set for dtrace)
   109   // notify jvmti and dtrace (must be after length is set for dtrace)
   108   post_allocation_notify(klass, (oop)obj);
   110   post_allocation_notify(klass, new_obj, new_obj->size());
   109 }
   111 }
   110 
   112 
   111 HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
   113 HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
   112 
   114 
   113   // Clear unhandled oops for memory allocation.  Memory allocation might
   115   // Clear unhandled oops for memory allocation.  Memory allocation might
   197 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
   199 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
   198   debug_only(check_for_valid_allocation_state());
   200   debug_only(check_for_valid_allocation_state());
   199   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
   201   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
   200   assert(size >= 0, "int won't convert to size_t");
   202   assert(size >= 0, "int won't convert to size_t");
   201   HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
   203   HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
   202   post_allocation_setup_obj(klass, obj);
   204   post_allocation_setup_obj(klass, obj, size);
   203   NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
   205   NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
   204   return (oop)obj;
   206   return (oop)obj;
   205 }
   207 }
   206 
   208 
   207 oop CollectedHeap::array_allocate(KlassHandle klass,
   209 oop CollectedHeap::array_allocate(KlassHandle klass,