Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java @ 19189:7ebed83df427
[SPARC] fixing (wrong) duplicate exception handler for a particular PC
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Mon, 09 Feb 2015 17:06:21 +0100 |
parents | 07f2a49f0bfb |
children | 063e8873bd14 |
line wrap: on
line diff
--- 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