question about testing arrays

Thomas Wuerthinger thomas.wuerthinger at oracle.com
Fri Mar 1 12:21:04 PST 2013


Vasanth,

Do you want to completely avoid the array bounds check for the example below (i.e., you assume all array accesses are safe), or what would be the desired behavior in case of an out-of-bounds access?

- thomas


On Mar 1, 2013, at 8:07 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:

> Hi,
> 
> My question has to do with arrays. I am implementing a new test harness for my ISA backend, modeling it after the test harness that Christian and Thomas recently checked in.
> 
> Thomas's test example was doing a simple addition. I would like to try something involving arrays, like:
> 
> public static int test1Snippet(int array1[], int array2[]) {
> 
> return array1[0]* array2[0] + array1[1] *array2[1];
> }
> 
> For this type of code, it looks like Graal emits a Guard check which results in the emission of a compare-branch in the LIR, which in turn is getting some unexpected values. Does anyone have more insight into this error and the best way to work around it? Also are there are other array test examples I can look at to see how array operations may have to be implemented?
> 
> instruction ICMP (x: int[0|0x0], y: v1|i) condition: AE
> mode: USE  flags: [REG]
> Unexpected value: Constant int[0|0x0]
> scope: GraalCompiler.BackEnd.LIRGen.InterceptException
> Exception occurred in scope: GraalCompiler.BackEnd.LIRGen.InterceptException
> Context obj com.oracle.graal.graph.GraalInternalError: should not reach here
>        at node: 12|Guard
> Context obj com.oracle.graal.compiler.hsail.HSAILLIRGenerator at 6035b93b<mailto:com.oracle.graal.compiler.hsail.HSAILLIRGenerator at 6035b93b>
> 1) test1(com.oracle.graal.compiler.hsail.test.BasicHSAILTest)
> com.oracle.graal.graph.GraalInternalError: should not reach here
>        at node: 12|Guard
>        at com.oracle.graal.graph.GraalInternalError.shouldNotReachHere(GraalInternalError.java:46)
>        at com.oracle.graal.lir.LIRVerifier.allowed(LIRVerifier.java:241)
>        at com.oracle.graal.lir.LIRVerifier.access$000(LIRVerifier.java:37)
>        at com.oracle.graal.lir.LIRVerifier$1.doValue(LIRVerifier.java:68)
>        at com.oracle.graal.lir.LIRInstructionClass.forEach(LIRInstructionClass.java:346)
>        at com.oracle.graal.lir.LIRInstructionClass.forEachUse(LIRInstructionCla
> at com.oracle.graal.compiler.gen.LIRGenerator.append(LIRGenerator.java:258)
>        at com.oracle.graal.compiler.hsail.HSAILLIRGenerator.emitCompareBranch(HSAILLIRGenerator.java:196)
>        at com.oracle.graal.compiler.gen.LIRGenerator.emitCompareBranch(LIRGenerator.java:634)
>        at com.oracle.graal.compiler.gen.LIRGenerator.emitBranch(LIRGenerator.java:611)
>        at com.oracle.graal.compiler.gen.LIRGenerator.emitGuardCheck(LIRGenerator.java:600)
>        at com.oracle.graal.nodes.GuardNode.generate(GuardNode.java:95)
>        at com.oracle.graal.compiler.gen.LIRGenerator.emitNode(LIRGenerator.java:460)
>        at com.oracle.graal.compiler.hsail.HSAILLIRGenerator.emitNode(HSAILLIRGenerator.java:78)
> 
> 



More information about the graal-dev mailing list