Mercurial > hg > graal-jvmci-8
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java @ 1430:949ade3f2ff3
added assertions, nop added to implicit exception sites
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Wed, 01 Sep 2010 13:45:57 -0700 |
parents | abc670a709dc |
children | efba53f86c4f |
comparison
equal
deleted
inserted
replaced
1429:abc670a709dc | 1430:949ade3f2ff3 |
---|---|
240 } | 240 } |
241 | 241 |
242 private XirTemplate buildArrayLength() { | 242 private XirTemplate buildArrayLength() { |
243 XirOperand result = asm.restart(CiKind.Int); | 243 XirOperand result = asm.restart(CiKind.Int); |
244 XirParameter object = asm.createInputParameter("object", CiKind.Object); | 244 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
245 asm.nop(1); | |
245 asm.mark(MARK_IMPLICIT_NULL); | 246 asm.mark(MARK_IMPLICIT_NULL); |
246 asm.pload(CiKind.Int, result, object, asm.i(config.arrayLengthOffset), true); | 247 asm.pload(CiKind.Int, result, object, asm.i(config.arrayLengthOffset), true); |
247 return asm.finishTemplate("arrayLength"); | 248 return asm.finishTemplate("arrayLength"); |
248 } | 249 } |
249 | 250 |
272 { | 273 { |
273 // resolved case | 274 // resolved case |
274 XirOperand result = asm.restart(kind); | 275 XirOperand result = asm.restart(kind); |
275 XirParameter object = asm.createInputParameter("object", CiKind.Object); | 276 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
276 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); | 277 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
278 asm.nop(1); | |
277 asm.mark(MARK_IMPLICIT_NULL); | 279 asm.mark(MARK_IMPLICIT_NULL); |
278 asm.pload(kind, result, object, fieldOffset, true); | 280 asm.pload(kind, result, object, fieldOffset, true); |
279 resolved = asm.finishTemplate("getfield<" + kind + ">"); | 281 resolved = asm.finishTemplate("getfield<" + kind + ">"); |
280 } | 282 } |
281 unresolved = null; | 283 unresolved = null; |
289 // resolved case | 291 // resolved case |
290 asm.restart(CiKind.Void); | 292 asm.restart(CiKind.Void); |
291 XirParameter object = asm.createInputParameter("object", CiKind.Object); | 293 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
292 XirParameter value = asm.createInputParameter("value", kind); | 294 XirParameter value = asm.createInputParameter("value", kind); |
293 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); | 295 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
296 asm.nop(1); | |
294 asm.mark(MARK_IMPLICIT_NULL); | 297 asm.mark(MARK_IMPLICIT_NULL); |
295 asm.pstore(kind, object, fieldOffset, value, true); | 298 asm.pstore(kind, object, fieldOffset, value, true); |
296 if (genWriteBarrier) { | 299 if (genWriteBarrier) { |
297 // TODO write barrier | 300 // TODO write barrier |
298 // addWriteBarrier(asm, object, value); | 301 // addWriteBarrier(asm, object, value); |
309 { | 312 { |
310 // resolved case | 313 // resolved case |
311 XirOperand result = asm.restart(kind); | 314 XirOperand result = asm.restart(kind); |
312 XirParameter object = asm.createInputParameter("object", CiKind.Object); | 315 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
313 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); | 316 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
317 asm.nop(1); | |
314 asm.mark(MARK_IMPLICIT_NULL); | 318 asm.mark(MARK_IMPLICIT_NULL); |
315 asm.pload(kind, result, object, fieldOffset, true); | 319 asm.pload(kind, result, object, fieldOffset, true); |
316 resolved = asm.finishTemplate("getfield<" + kind + ">"); | 320 resolved = asm.finishTemplate("getfield<" + kind + ">"); |
317 } | 321 } |
318 unresolved = null; | 322 unresolved = null; |
326 // resolved case | 330 // resolved case |
327 asm.restart(CiKind.Void); | 331 asm.restart(CiKind.Void); |
328 XirParameter object = asm.createInputParameter("object", CiKind.Object); | 332 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
329 XirParameter value = asm.createInputParameter("value", kind); | 333 XirParameter value = asm.createInputParameter("value", kind); |
330 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); | 334 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
335 asm.nop(1); | |
331 asm.mark(MARK_IMPLICIT_NULL); | 336 asm.mark(MARK_IMPLICIT_NULL); |
332 asm.pstore(kind, object, fieldOffset, value, true); | 337 asm.pstore(kind, object, fieldOffset, value, true); |
333 if (genWriteBarrier) { | 338 if (genWriteBarrier) { |
334 // TODO write barrier | 339 // TODO write barrier |
335 // addWriteBarrier(asm, object, value); | 340 // addWriteBarrier(asm, object, value); |
498 XirOperand length; | 503 XirOperand length; |
499 if (withLength) { | 504 if (withLength) { |
500 length = asm.createInputParameter("length", CiKind.Int); | 505 length = asm.createInputParameter("length", CiKind.Int); |
501 } else { | 506 } else { |
502 length = asm.createTemp("length", CiKind.Int); | 507 length = asm.createTemp("length", CiKind.Int); |
508 asm.nop(1); | |
503 asm.mark(MARK_IMPLICIT_NULL); | 509 asm.mark(MARK_IMPLICIT_NULL); |
504 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), true); | 510 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), true); |
505 implicitNullException = false; | 511 implicitNullException = false; |
506 } | 512 } |
507 asm.jugteq(failBoundsCheck, index, length); | 513 asm.jugteq(failBoundsCheck, index, length); |
563 XirOperand length; | 569 XirOperand length; |
564 if (withLength) { | 570 if (withLength) { |
565 length = asm.createInputParameter("length", CiKind.Int); | 571 length = asm.createInputParameter("length", CiKind.Int); |
566 } else { | 572 } else { |
567 length = asm.createTemp("length", CiKind.Int); | 573 length = asm.createTemp("length", CiKind.Int); |
574 asm.nop(1); | |
568 asm.mark(MARK_IMPLICIT_NULL); | 575 asm.mark(MARK_IMPLICIT_NULL); |
569 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), true); | 576 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), true); |
570 implicitNullException = false; | 577 implicitNullException = false; |
571 } | 578 } |
572 asm.jugteq(failBoundsCheck, index, length); | 579 asm.jugteq(failBoundsCheck, index, length); |
573 implicitNullException = false; | 580 implicitNullException = false; |
574 } | 581 } |
575 int elemSize = target.sizeInBytes(kind); | 582 int elemSize = target.sizeInBytes(kind); |
576 if (implicitNullException) { | 583 if (implicitNullException) { |
584 asm.nop(1); | |
577 asm.mark(MARK_IMPLICIT_NULL); | 585 asm.mark(MARK_IMPLICIT_NULL); |
578 } | 586 } |
579 asm.pload(kind, result, array, index, config.getArrayOffset(kind), Scale.fromInt(elemSize), implicitNullException); | 587 asm.pload(kind, result, array, index, config.getArrayOffset(kind), Scale.fromInt(elemSize), implicitNullException); |
580 if (genBoundsCheck) { | 588 if (genBoundsCheck) { |
581 asm.bindOutOfLine(failBoundsCheck); | 589 asm.bindOutOfLine(failBoundsCheck); |
609 XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object); | 617 XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object); |
610 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | 618 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
611 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); | 619 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); |
612 XirLabel stub = asm.createOutOfLineLabel("call stub"); | 620 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
613 | 621 |
622 asm.nop(1); | |
614 asm.mark(MARK_IMPLICIT_NULL); | 623 asm.mark(MARK_IMPLICIT_NULL); |
615 asm.pload(CiKind.Word, temp, receiver, true); | 624 asm.pload(CiKind.Word, temp, receiver, true); |
616 asm.mark(MARK_INVOKESPECIAL); | 625 asm.mark(MARK_INVOKESPECIAL); |
617 | 626 |
618 // -- out of line ------------------------------------------------------- | 627 // -- out of line ------------------------------------------------------- |
633 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | 642 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
634 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); | 643 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); |
635 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); | 644 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); |
636 XirLabel stub = asm.createOutOfLineLabel("call stub"); | 645 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
637 | 646 |
647 asm.nop(1); | |
638 asm.mark(MARK_IMPLICIT_NULL); | 648 asm.mark(MARK_IMPLICIT_NULL); |
639 asm.pload(CiKind.Word, temp, receiver, true); | 649 asm.pload(CiKind.Word, temp, receiver, true); |
640 asm.mark(MARK_INVOKEINTERFACE); | 650 asm.mark(MARK_INVOKEINTERFACE); |
641 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); | 651 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); |
642 | 652 |
657 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | 667 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
658 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); | 668 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); |
659 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); | 669 XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); |
660 XirLabel stub = asm.createOutOfLineLabel("call stub"); | 670 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
661 | 671 |
672 asm.nop(1); | |
662 asm.mark(MARK_IMPLICIT_NULL); | 673 asm.mark(MARK_IMPLICIT_NULL); |
663 asm.pload(CiKind.Word, temp, receiver, true); | 674 asm.pload(CiKind.Word, temp, receiver, true); |
664 asm.mark(MARK_INVOKEVIRTUAL); | 675 asm.mark(MARK_INVOKEVIRTUAL); |
665 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); | 676 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); |
666 | 677 |
970 return new XirSnippet(multiNewArrayTemplate.get(lengths.length).unresolved, lengths); | 981 return new XirSnippet(multiNewArrayTemplate.get(lengths.length).unresolved, lengths); |
971 } | 982 } |
972 | 983 |
973 @Override | 984 @Override |
974 public XirSnippet genResolveClass(XirSite site, RiType type, Representation representation) { | 985 public XirSnippet genResolveClass(XirSite site, RiType type, Representation representation) { |
975 assert representation == Representation.ObjectHub; | 986 assert representation == Representation.ObjectHub : "unexpected representation: " + representation; |
976 if (type instanceof HotSpotTypeResolved) { | 987 if (type instanceof HotSpotTypeResolved) { |
977 return new XirSnippet(resolveClassTemplate.resolved, XirArgument.forObject(type)); | 988 return new XirSnippet(resolveClassTemplate.resolved, XirArgument.forObject(type)); |
978 } | 989 } |
979 return new XirSnippet(resolveClassTemplate.unresolved); | 990 return new XirSnippet(resolveClassTemplate.unresolved); |
980 } | 991 } |