2146 InstanceKlass* ik = InstanceKlass::cast(entry);
2147 if (ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
2148 size_t obj_size = ik->size_helper();
2149 oop result = NULL;
2150 // If the TLAB isn't pre-zeroed then we'll have to do it
2151 bool need_zero = !ZeroTLAB;
2152 if (UseTLAB) {
2153 result = (oop) THREAD->tlab().allocate(obj_size);
2154 }
2155 // Disable non-TLAB-based fast-path, because profiling requires that all
2156 // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate
2157 // returns NULL.
2158 #ifndef CC_INTERP_PROFILE
2159 if (result == NULL) {
2160 need_zero = true;
2161 // Try allocate in shared eden
2162 retry:
2163 HeapWord* compare_to = *Universe::heap()->top_addr();
2164 HeapWord* new_top = compare_to + obj_size;
2165 if (new_top <= *Universe::heap()->end_addr()) {
2166 if (Atomic::cmpxchg(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) {
2167 goto retry;
2168 }
2169 result = (oop) compare_to;
2170 }
2171 }
2172 #endif
2173 if (result != NULL) {
2174 // Initialize object (if nonzero size and need) and then the header
2175 if (need_zero ) {
2176 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize;
2177 obj_size -= sizeof(oopDesc) / oopSize;
2178 if (obj_size > 0 ) {
2179 memset(to_zero, 0, obj_size * HeapWordSize);
2180 }
2181 }
2182 if (UseBiasedLocking) {
2183 result->set_mark(ik->prototype_header());
2184 } else {
2185 result->set_mark(markWord::prototype());
2186 }
|
2146 InstanceKlass* ik = InstanceKlass::cast(entry);
2147 if (ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
2148 size_t obj_size = ik->size_helper();
2149 oop result = NULL;
2150 // If the TLAB isn't pre-zeroed then we'll have to do it
2151 bool need_zero = !ZeroTLAB;
2152 if (UseTLAB) {
2153 result = (oop) THREAD->tlab().allocate(obj_size);
2154 }
2155 // Disable non-TLAB-based fast-path, because profiling requires that all
2156 // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate
2157 // returns NULL.
2158 #ifndef CC_INTERP_PROFILE
2159 if (result == NULL) {
2160 need_zero = true;
2161 // Try allocate in shared eden
2162 retry:
2163 HeapWord* compare_to = *Universe::heap()->top_addr();
2164 HeapWord* new_top = compare_to + obj_size;
2165 if (new_top <= *Universe::heap()->end_addr()) {
2166 if (Atomic::cmpxchg(Universe::heap()->top_addr(), compare_to, new_top) != compare_to) {
2167 goto retry;
2168 }
2169 result = (oop) compare_to;
2170 }
2171 }
2172 #endif
2173 if (result != NULL) {
2174 // Initialize object (if nonzero size and need) and then the header
2175 if (need_zero ) {
2176 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize;
2177 obj_size -= sizeof(oopDesc) / oopSize;
2178 if (obj_size > 0 ) {
2179 memset(to_zero, 0, obj_size * HeapWordSize);
2180 }
2181 }
2182 if (UseBiasedLocking) {
2183 result->set_mark(ik->prototype_header());
2184 } else {
2185 result->set_mark(markWord::prototype());
2186 }
|