# HG changeset patch # User Stefan Anzinger # Date 1423497981 -3600 # Node ID 7ebed83df427fc7dab02fb878de41c3c930fa6e4 # Parent c79d0ed463681fda197734ec0e2a1d84e83f5237 [SPARC] fixing (wrong) duplicate exception handler for a particular PC diff -r c79d0ed46368 -r 7ebed83df427 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Mon Feb 09 11:56:31 2015 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Mon Feb 09 17:06:21 2015 +0100 @@ -684,10 +684,38 @@ * @param handlerPos the position of the handler */ public void recordExceptionHandler(int codePos, int handlerPos) { + assert validateExceptionHandlerAdd(codePos, handlerPos) : String.format("Duplicate exception handler for pc 0x%x handlerPos 0x%x", codePos, handlerPos); exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos)); } /** + * Validate if the exception handler for codePos already exists and handlerPos is different. + * + * @param codePos + * @param handlerPos + * @return true if the validation is successful + */ + private boolean validateExceptionHandlerAdd(int codePos, int handlerPos) { + ExceptionHandler exHandler = getExceptionHandlerForCodePos(codePos); + return exHandler == null || exHandler.handlerPos == handlerPos; + } + + /** + * Returns the first ExceptionHandler which matches codePos. + * + * @param codePos position to search for + * @return first matching ExceptionHandler + */ + private ExceptionHandler getExceptionHandlerForCodePos(int codePos) { + for (ExceptionHandler h : exceptionHandlers) { + if (h.pcOffset == codePos) { + return h; + } + } + return null; + } + + /** * Records an infopoint in the code array. * * @param codePos the position of the infopoint in the code array diff -r c79d0ed46368 -r 7ebed83df427 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Feb 09 11:56:31 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Feb 09 17:06:21 2015 +0100 @@ -383,5 +383,11 @@ public void reset() { asm.reset(); compilationResult.reset(); + if (exceptionInfoList != null) { + exceptionInfoList.clear(); + } + if (dataCache != null) { + dataCache.clear(); + } } }