Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 18173:8c079b8d0446
Reduce allocation during scope recording
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 24 Oct 2014 12:48:53 -0700 |
parents | c59612b9d110 |
children | 26d381457145 |
comparison
equal
deleted
inserted
replaced
18172:c59612b9d110 | 18173:8c079b8d0446 |
---|---|
50 #endif | 50 #endif |
51 #ifdef TARGET_ARCH_ppc | 51 #ifdef TARGET_ARCH_ppc |
52 # include "vmreg_ppc.inline.hpp" | 52 # include "vmreg_ppc.inline.hpp" |
53 #endif | 53 #endif |
54 | 54 |
55 | |
56 // frequently used constants | |
57 // Allocate them with new so they are never destroyed (otherwise, a | |
58 // forced exit could destroy these objects while they are still in | |
59 // use). | |
60 ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantOopWriteValue(NULL); | |
61 ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(-1); | |
62 ConstantIntValue* CodeInstaller::_int_0_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(0); | |
63 ConstantIntValue* CodeInstaller::_int_1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(1); | |
64 ConstantIntValue* CodeInstaller::_int_2_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(2); | |
65 LocationValue* CodeInstaller::_illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location()); | |
66 | |
55 Method* getMethodFromHotSpotMethod(oop hotspot_method) { | 67 Method* getMethodFromHotSpotMethod(oop hotspot_method) { |
56 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity"); | 68 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity"); |
57 return asMethod(HotSpotResolvedJavaMethod::metaspaceMethod(hotspot_method)); | 69 return asMethod(HotSpotResolvedJavaMethod::metaspaceMethod(hotspot_method)); |
58 } | 70 } |
59 | 71 |
190 } | 202 } |
191 | 203 |
192 ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) { | 204 ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) { |
193 second = NULL; | 205 second = NULL; |
194 if (value == Value::ILLEGAL()) { | 206 if (value == Value::ILLEGAL()) { |
195 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); | 207 return _illegal_value; |
196 } | 208 } |
197 | 209 |
198 oop lirKind = AbstractValue::lirKind(value); | 210 oop lirKind = AbstractValue::lirKind(value); |
199 oop platformKind = LIRKind::platformKind(lirKind); | 211 oop platformKind = LIRKind::platformKind(lirKind); |
200 jint referenceMask = LIRKind::referenceMask(lirKind); | 212 jint referenceMask = LIRKind::referenceMask(lirKind); |
281 if(value->is_a(RawConstant::klass())) { | 293 if(value->is_a(RawConstant::klass())) { |
282 jlong prim = PrimitiveConstant::primitive(value); | 294 jlong prim = PrimitiveConstant::primitive(value); |
283 return new ConstantLongValue(prim); | 295 return new ConstantLongValue(prim); |
284 } else if (type == T_INT || type == T_FLOAT) { | 296 } else if (type == T_INT || type == T_FLOAT) { |
285 jint prim = (jint)PrimitiveConstant::primitive(value); | 297 jint prim = (jint)PrimitiveConstant::primitive(value); |
286 return new ConstantIntValue(prim); | 298 switch (prim) { |
299 case -1: return _int_m1_scope_value; | |
300 case 0: return _int_0_scope_value; | |
301 case 1: return _int_1_scope_value; | |
302 case 2: return _int_2_scope_value; | |
303 default: return new ConstantIntValue(prim); | |
304 } | |
287 } else { | 305 } else { |
288 assert(type == T_LONG || type == T_DOUBLE, "unexpected primitive constant type"); | 306 assert(type == T_LONG || type == T_DOUBLE, "unexpected primitive constant type"); |
289 jlong prim = PrimitiveConstant::primitive(value); | 307 jlong prim = PrimitiveConstant::primitive(value); |
290 second = new ConstantIntValue(0); | 308 second = _int_1_scope_value; |
291 return new ConstantLongValue(prim); | 309 return new ConstantLongValue(prim); |
292 } | 310 } |
293 } else { | 311 } else { |
294 assert(reference, "unexpected object constant type"); | 312 assert(reference, "unexpected object constant type"); |
295 if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { | 313 if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { |
296 return new ConstantOopWriteValue(NULL); | 314 return _oop_null_scope_value; |
297 } else { | 315 } else { |
298 assert(value->is_a(HotSpotObjectConstant::klass()), "unexpected constant type"); | 316 assert(value->is_a(HotSpotObjectConstant::klass()), "unexpected constant type"); |
299 oop obj = HotSpotObjectConstant::object(value); | 317 oop obj = HotSpotObjectConstant::object(value); |
300 assert(obj != NULL, "null value must be in NullConstant"); | 318 assert(obj != NULL, "null value must be in NullConstant"); |
301 return new ConstantOopWriteValue(JNIHandles::make_local(obj)); | 319 return new ConstantOopWriteValue(JNIHandles::make_local(obj)); |
326 | 344 |
327 if (isLongArray && cur_second == NULL) { | 345 if (isLongArray && cur_second == NULL) { |
328 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. | 346 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
329 // add an int 0 constant | 347 // add an int 0 constant |
330 #ifdef VM_LITTLE_ENDIAN | 348 #ifdef VM_LITTLE_ENDIAN |
331 cur_second = new ConstantIntValue(0); | 349 cur_second = _int_0_scope_value; |
332 #else | 350 #else |
333 cur_second = value; | 351 cur_second = value; |
334 value = new ConstantIntValue(0); | 352 value = _int_0_scope_value; |
335 #endif | 353 #endif |
336 } | 354 } |
337 | 355 |
338 if (cur_second != NULL) { | 356 if (cur_second != NULL) { |
339 sv->field_values()->append(cur_second); | 357 sv->field_values()->append(cur_second); |
745 jint monitor_count = BytecodeFrame::numLocks(frame); | 763 jint monitor_count = BytecodeFrame::numLocks(frame); |
746 objArrayOop values = BytecodeFrame::values(frame); | 764 objArrayOop values = BytecodeFrame::values(frame); |
747 | 765 |
748 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); | 766 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); |
749 | 767 |
750 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); | 768 GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; |
751 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); | 769 GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; |
752 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> (); | 770 GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; |
753 | 771 |
754 if (TraceGraal >= 2) { | 772 if (TraceGraal >= 2) { |
755 tty->print_cr("Scope at bci %d with %d values", bci, values->length()); | 773 tty->print_cr("Scope at bci %d with %d values", bci, values->length()); |
756 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); | 774 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
757 } | 775 } |