1 /* |
1 /* |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
1922 if (v.start_pc != Character.MAX_VALUE) { |
1922 if (v.start_pc != Character.MAX_VALUE) { |
1923 char length = (char)(curPc() - v.start_pc); |
1923 char length = (char)(curPc() - v.start_pc); |
1924 if (length < Character.MAX_VALUE) { |
1924 if (length < Character.MAX_VALUE) { |
1925 v.length = length; |
1925 v.length = length; |
1926 putVar(v); |
1926 putVar(v); |
|
1927 fillLocalVarPosition(v); |
1927 } |
1928 } |
1928 } |
1929 } |
1929 } |
1930 } |
1930 state.defined.excl(adr); |
1931 state.defined.excl(adr); |
|
1932 } |
|
1933 |
|
1934 private void fillLocalVarPosition(LocalVar lv) { |
|
1935 if (lv == null || lv.sym == null |
|
1936 || lv.sym.annotations.isTypesEmpty()) |
|
1937 return; |
|
1938 for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { |
|
1939 TypeAnnotationPosition p = ta.position; |
|
1940 p.lvarOffset = new int[] { (int)lv.start_pc }; |
|
1941 p.lvarLength = new int[] { (int)lv.length }; |
|
1942 p.lvarIndex = new int[] { (int)lv.reg }; |
|
1943 p.isValidOffset = true; |
|
1944 } |
|
1945 } |
|
1946 |
|
1947 // Method to be called after compressCatchTable to |
|
1948 // fill in the exception table index for type |
|
1949 // annotations on exception parameters. |
|
1950 public void fillExceptionParameterPositions() { |
|
1951 for (int i = 0; i < varBufferSize; ++i) { |
|
1952 LocalVar lv = varBuffer[i]; |
|
1953 if (lv == null || lv.sym == null |
|
1954 || lv.sym.annotations.isTypesEmpty() |
|
1955 || !lv.sym.isExceptionParameter()) |
|
1956 return; |
|
1957 |
|
1958 int exidx = findExceptionIndex(lv); |
|
1959 |
|
1960 for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { |
|
1961 TypeAnnotationPosition p = ta.position; |
|
1962 p.exception_index = exidx; |
|
1963 } |
|
1964 } |
|
1965 } |
|
1966 |
|
1967 private int findExceptionIndex(LocalVar lv) { |
|
1968 List<char[]> iter = catchInfo.toList(); |
|
1969 int len = catchInfo.length(); |
|
1970 for (int i = 0; i < len; ++i) { |
|
1971 char[] catchEntry = iter.head; |
|
1972 iter = iter.tail; |
|
1973 char handlerpc = catchEntry[2]; |
|
1974 if (lv.start_pc == handlerpc + 1) { |
|
1975 return i; |
|
1976 } |
|
1977 } |
|
1978 return -1; |
1931 } |
1979 } |
1932 |
1980 |
1933 /** Put a live variable range into the buffer to be output to the |
1981 /** Put a live variable range into the buffer to be output to the |
1934 * class file. |
1982 * class file. |
1935 */ |
1983 */ |
1936 void putVar(LocalVar var) { |
1984 void putVar(LocalVar var) { |
1937 if (!varDebugInfo) return; |
1985 // Keep local variables if |
|
1986 // 1) we need them for debug information |
|
1987 // 2) it is an exception type and it contains type annotations |
|
1988 if (!varDebugInfo && |
|
1989 (!var.sym.isExceptionParameter() || |
|
1990 var.sym.annotations.isTypesEmpty())) return; |
1938 if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; |
1991 if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; |
1939 if (varBuffer == null) |
1992 if (varBuffer == null) |
1940 varBuffer = new LocalVar[20]; |
1993 varBuffer = new LocalVar[20]; |
1941 else |
1994 else |
1942 varBuffer = ArrayUtils.ensureCapacity(varBuffer, varBufferSize); |
1995 varBuffer = ArrayUtils.ensureCapacity(varBuffer, varBufferSize); |