Lines 412-417
Link Here
|
412 |
this.produceAttributes = options.produceDebugAttributes; |
412 |
this.produceAttributes = options.produceDebugAttributes; |
413 |
this.referenceBinding = typeBinding; |
413 |
this.referenceBinding = typeBinding; |
414 |
if (this.targetJDK >= ClassFileConstants.JDK1_6) { |
414 |
if (this.targetJDK >= ClassFileConstants.JDK1_6) { |
|
|
415 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE; |
416 |
this.codeStream = new StackMapFrameCodeStream(this); |
417 |
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) { |
418 |
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3 |
415 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP; |
419 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP; |
416 |
this.codeStream = new StackMapFrameCodeStream(this); |
420 |
this.codeStream = new StackMapFrameCodeStream(this); |
417 |
} else { |
421 |
} else { |
Lines 1484-1490
Link Here
|
1484 |
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8); |
1488 |
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8); |
1485 |
this.contents[codeAttributeOffset + 13] = (byte) code_length; |
1489 |
this.contents[codeAttributeOffset + 13] = (byte) code_length; |
1486 |
|
1490 |
|
1487 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0; |
1491 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0; |
1488 |
// write the exception table |
1492 |
// write the exception table |
1489 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
1493 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
1490 |
int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous) |
1494 |
int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous) |
Lines 2111-2116
Link Here
|
2111 |
} |
2115 |
} |
2112 |
} |
2116 |
} |
2113 |
|
2117 |
|
|
|
2118 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
2119 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
2120 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
2121 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
2122 |
ArrayList frames = new ArrayList(); |
2123 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
2124 |
int numberOfFrames = frames.size(); |
2125 |
if (numberOfFrames > 1) { |
2126 |
int stackMapTableAttributeOffset = localContentsOffset; |
2127 |
// add the stack map table attribute |
2128 |
if (localContentsOffset + 8 >= this.contents.length) { |
2129 |
resizeContents(8); |
2130 |
} |
2131 |
int stackMapAttributeNameIndex = |
2132 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
2133 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
2134 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
2135 |
|
2136 |
int stackMapAttributeLengthOffset = localContentsOffset; |
2137 |
// generate the attribute |
2138 |
localContentsOffset += 4; |
2139 |
if (localContentsOffset + 4 >= this.contents.length) { |
2140 |
resizeContents(4); |
2141 |
} |
2142 |
int numberOfFramesOffset = localContentsOffset; |
2143 |
localContentsOffset += 2; |
2144 |
if (localContentsOffset + 2 >= this.contents.length) { |
2145 |
resizeContents(2); |
2146 |
} |
2147 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
2148 |
for (int j = 1; j < numberOfFrames; j++) { |
2149 |
// select next frame |
2150 |
currentFrame = (StackMapFrame) frames.get(j); |
2151 |
// generate current frame |
2152 |
// need to find differences between the current frame and the previous frame |
2153 |
int frameOffset = currentFrame.pc; |
2154 |
// FULL_FRAME |
2155 |
if (localContentsOffset + 5 >= this.contents.length) { |
2156 |
resizeContents(5); |
2157 |
} |
2158 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
2159 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
2160 |
int numberOfLocalOffset = localContentsOffset; |
2161 |
localContentsOffset += 2; // leave two spots for number of locals |
2162 |
int numberOfLocalEntries = 0; |
2163 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
2164 |
int numberOfEntries = 0; |
2165 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
2166 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
2167 |
if (localContentsOffset + 3 >= this.contents.length) { |
2168 |
resizeContents(3); |
2169 |
} |
2170 |
VerificationTypeInfo info = currentFrame.locals[i]; |
2171 |
if (info == null) { |
2172 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
2173 |
} else { |
2174 |
switch(info.id()) { |
2175 |
case T_boolean : |
2176 |
case T_byte : |
2177 |
case T_char : |
2178 |
case T_int : |
2179 |
case T_short : |
2180 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
2181 |
break; |
2182 |
case T_float : |
2183 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
2184 |
break; |
2185 |
case T_long : |
2186 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
2187 |
i++; |
2188 |
break; |
2189 |
case T_double : |
2190 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
2191 |
i++; |
2192 |
break; |
2193 |
case T_null : |
2194 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
2195 |
break; |
2196 |
default: |
2197 |
this.contents[localContentsOffset++] = (byte) info.tag; |
2198 |
switch (info.tag) { |
2199 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
2200 |
int offset = info.offset; |
2201 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
2202 |
this.contents[localContentsOffset++] = (byte) offset; |
2203 |
break; |
2204 |
case VerificationTypeInfo.ITEM_OBJECT : |
2205 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
2206 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
2207 |
this.contents[localContentsOffset++] = (byte) indexForType; |
2208 |
} |
2209 |
} |
2210 |
numberOfLocalEntries++; |
2211 |
} |
2212 |
numberOfEntries++; |
2213 |
} |
2214 |
if (localContentsOffset + 4 >= this.contents.length) { |
2215 |
resizeContents(4); |
2216 |
} |
2217 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
2218 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
2219 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
2220 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
2221 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
2222 |
for (int i = 0; i < numberOfStackItems; i++) { |
2223 |
if (localContentsOffset + 3 >= this.contents.length) { |
2224 |
resizeContents(3); |
2225 |
} |
2226 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
2227 |
if (info == null) { |
2228 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
2229 |
} else { |
2230 |
switch(info.id()) { |
2231 |
case T_boolean : |
2232 |
case T_byte : |
2233 |
case T_char : |
2234 |
case T_int : |
2235 |
case T_short : |
2236 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
2237 |
break; |
2238 |
case T_float : |
2239 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
2240 |
break; |
2241 |
case T_long : |
2242 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
2243 |
break; |
2244 |
case T_double : |
2245 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
2246 |
break; |
2247 |
case T_null : |
2248 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
2249 |
break; |
2250 |
default: |
2251 |
this.contents[localContentsOffset++] = (byte) info.tag; |
2252 |
switch (info.tag) { |
2253 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
2254 |
int offset = info.offset; |
2255 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
2256 |
this.contents[localContentsOffset++] = (byte) offset; |
2257 |
break; |
2258 |
case VerificationTypeInfo.ITEM_OBJECT : |
2259 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
2260 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
2261 |
this.contents[localContentsOffset++] = (byte) indexForType; |
2262 |
} |
2263 |
} |
2264 |
} |
2265 |
} |
2266 |
} |
2267 |
|
2268 |
numberOfFrames--; |
2269 |
if (numberOfFrames != 0) { |
2270 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
2271 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
2272 |
|
2273 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
2274 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
2275 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
2276 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
2277 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
2278 |
attributeNumber++; |
2279 |
} else { |
2280 |
localContentsOffset = stackMapTableAttributeOffset; |
2281 |
} |
2282 |
} |
2283 |
} |
2284 |
} |
2285 |
|
2114 |
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8); |
2286 |
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8); |
2115 |
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber; |
2287 |
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber; |
2116 |
|
2288 |
|
Lines 2162-2168
Link Here
|
2162 |
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8); |
2334 |
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8); |
2163 |
this.contents[codeAttributeOffset + 13] = (byte) code_length; |
2335 |
this.contents[codeAttributeOffset + 13] = (byte) code_length; |
2164 |
|
2336 |
|
2165 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0; |
2337 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0; |
2166 |
// write the exception table |
2338 |
// write the exception table |
2167 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
2339 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
2168 |
int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous) |
2340 |
int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous) |
Lines 2403-2409
Link Here
|
2403 |
} |
2575 |
} |
2404 |
} |
2576 |
} |
2405 |
|
2577 |
|
2406 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
2578 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) { |
2407 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
2579 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
2408 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
2580 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
2409 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
2581 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
Lines 2752-2757
Link Here
|
2752 |
} |
2924 |
} |
2753 |
} |
2925 |
} |
2754 |
|
2926 |
|
|
|
2927 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
2928 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
2929 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
2930 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
2931 |
ArrayList frames = new ArrayList(); |
2932 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
2933 |
int numberOfFrames = frames.size(); |
2934 |
if (numberOfFrames > 1) { |
2935 |
int stackMapTableAttributeOffset = localContentsOffset; |
2936 |
// add the stack map table attribute |
2937 |
if (localContentsOffset + 8 >= this.contents.length) { |
2938 |
resizeContents(8); |
2939 |
} |
2940 |
int stackMapAttributeNameIndex = |
2941 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
2942 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
2943 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
2944 |
|
2945 |
int stackMapAttributeLengthOffset = localContentsOffset; |
2946 |
// generate the attribute |
2947 |
localContentsOffset += 4; |
2948 |
if (localContentsOffset + 4 >= this.contents.length) { |
2949 |
resizeContents(4); |
2950 |
} |
2951 |
int numberOfFramesOffset = localContentsOffset; |
2952 |
localContentsOffset += 2; |
2953 |
if (localContentsOffset + 2 >= this.contents.length) { |
2954 |
resizeContents(2); |
2955 |
} |
2956 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
2957 |
for (int j = 1; j < numberOfFrames; j++) { |
2958 |
// select next frame |
2959 |
currentFrame = (StackMapFrame) frames.get(j); |
2960 |
// generate current frame |
2961 |
// need to find differences between the current frame and the previous frame |
2962 |
int frameOffset = currentFrame.pc; |
2963 |
// FULL_FRAME |
2964 |
if (localContentsOffset + 5 >= this.contents.length) { |
2965 |
resizeContents(5); |
2966 |
} |
2967 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
2968 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
2969 |
int numberOfLocalOffset = localContentsOffset; |
2970 |
localContentsOffset += 2; // leave two spots for number of locals |
2971 |
int numberOfLocalEntries = 0; |
2972 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
2973 |
int numberOfEntries = 0; |
2974 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
2975 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
2976 |
if (localContentsOffset + 3 >= this.contents.length) { |
2977 |
resizeContents(3); |
2978 |
} |
2979 |
VerificationTypeInfo info = currentFrame.locals[i]; |
2980 |
if (info == null) { |
2981 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
2982 |
} else { |
2983 |
switch(info.id()) { |
2984 |
case T_boolean : |
2985 |
case T_byte : |
2986 |
case T_char : |
2987 |
case T_int : |
2988 |
case T_short : |
2989 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
2990 |
break; |
2991 |
case T_float : |
2992 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
2993 |
break; |
2994 |
case T_long : |
2995 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
2996 |
i++; |
2997 |
break; |
2998 |
case T_double : |
2999 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
3000 |
i++; |
3001 |
break; |
3002 |
case T_null : |
3003 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
3004 |
break; |
3005 |
default: |
3006 |
this.contents[localContentsOffset++] = (byte) info.tag; |
3007 |
switch (info.tag) { |
3008 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
3009 |
int offset = info.offset; |
3010 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
3011 |
this.contents[localContentsOffset++] = (byte) offset; |
3012 |
break; |
3013 |
case VerificationTypeInfo.ITEM_OBJECT : |
3014 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
3015 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
3016 |
this.contents[localContentsOffset++] = (byte) indexForType; |
3017 |
} |
3018 |
} |
3019 |
numberOfLocalEntries++; |
3020 |
} |
3021 |
numberOfEntries++; |
3022 |
} |
3023 |
if (localContentsOffset + 4 >= this.contents.length) { |
3024 |
resizeContents(4); |
3025 |
} |
3026 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
3027 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
3028 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
3029 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
3030 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
3031 |
for (int i = 0; i < numberOfStackItems; i++) { |
3032 |
if (localContentsOffset + 3 >= this.contents.length) { |
3033 |
resizeContents(3); |
3034 |
} |
3035 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
3036 |
if (info == null) { |
3037 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
3038 |
} else { |
3039 |
switch(info.id()) { |
3040 |
case T_boolean : |
3041 |
case T_byte : |
3042 |
case T_char : |
3043 |
case T_int : |
3044 |
case T_short : |
3045 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
3046 |
break; |
3047 |
case T_float : |
3048 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
3049 |
break; |
3050 |
case T_long : |
3051 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
3052 |
break; |
3053 |
case T_double : |
3054 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
3055 |
break; |
3056 |
case T_null : |
3057 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
3058 |
break; |
3059 |
default: |
3060 |
this.contents[localContentsOffset++] = (byte) info.tag; |
3061 |
switch (info.tag) { |
3062 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
3063 |
int offset = info.offset; |
3064 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
3065 |
this.contents[localContentsOffset++] = (byte) offset; |
3066 |
break; |
3067 |
case VerificationTypeInfo.ITEM_OBJECT : |
3068 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
3069 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
3070 |
this.contents[localContentsOffset++] = (byte) indexForType; |
3071 |
} |
3072 |
} |
3073 |
} |
3074 |
} |
3075 |
} |
3076 |
|
3077 |
numberOfFrames--; |
3078 |
if (numberOfFrames != 0) { |
3079 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
3080 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
3081 |
|
3082 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
3083 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
3084 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
3085 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
3086 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
3087 |
attributeNumber++; |
3088 |
} else { |
3089 |
localContentsOffset = stackMapTableAttributeOffset; |
3090 |
} |
3091 |
} |
3092 |
} |
3093 |
} |
3094 |
|
2755 |
// update the number of attributes |
3095 |
// update the number of attributes |
2756 |
// ensure first that there is enough space available inside the contents array |
3096 |
// ensure first that there is enough space available inside the contents array |
2757 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
3097 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
Lines 2866-2872
Link Here
|
2866 |
attributeNumber++; |
3206 |
attributeNumber++; |
2867 |
} |
3207 |
} |
2868 |
|
3208 |
|
2869 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
3209 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) { |
2870 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
3210 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
2871 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
3211 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
2872 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
3212 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
Lines 3216-3221
Link Here
|
3216 |
} |
3556 |
} |
3217 |
} |
3557 |
} |
3218 |
|
3558 |
|
|
|
3559 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
3560 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
3561 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
3562 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
3563 |
ArrayList frames = new ArrayList(); |
3564 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
3565 |
int numberOfFrames = frames.size(); |
3566 |
if (numberOfFrames > 1) { |
3567 |
int stackMapTableAttributeOffset = localContentsOffset; |
3568 |
// add the stack map table attribute |
3569 |
if (localContentsOffset + 8 >= this.contents.length) { |
3570 |
resizeContents(8); |
3571 |
} |
3572 |
int stackMapAttributeNameIndex = |
3573 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
3574 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
3575 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
3576 |
|
3577 |
int stackMapAttributeLengthOffset = localContentsOffset; |
3578 |
// generate the attribute |
3579 |
localContentsOffset += 4; |
3580 |
if (localContentsOffset + 4 >= this.contents.length) { |
3581 |
resizeContents(4); |
3582 |
} |
3583 |
int numberOfFramesOffset = localContentsOffset; |
3584 |
localContentsOffset += 2; |
3585 |
if (localContentsOffset + 2 >= this.contents.length) { |
3586 |
resizeContents(2); |
3587 |
} |
3588 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
3589 |
for (int j = 1; j < numberOfFrames; j++) { |
3590 |
// select next frame |
3591 |
currentFrame = (StackMapFrame) frames.get(j); |
3592 |
// generate current frame |
3593 |
// need to find differences between the current frame and the previous frame |
3594 |
int frameOffset = currentFrame.pc; |
3595 |
// FULL_FRAME |
3596 |
if (localContentsOffset + 5 >= this.contents.length) { |
3597 |
resizeContents(5); |
3598 |
} |
3599 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
3600 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
3601 |
int numberOfLocalOffset = localContentsOffset; |
3602 |
localContentsOffset += 2; // leave two spots for number of locals |
3603 |
int numberOfLocalEntries = 0; |
3604 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
3605 |
int numberOfEntries = 0; |
3606 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
3607 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
3608 |
if (localContentsOffset + 3 >= this.contents.length) { |
3609 |
resizeContents(3); |
3610 |
} |
3611 |
VerificationTypeInfo info = currentFrame.locals[i]; |
3612 |
if (info == null) { |
3613 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
3614 |
} else { |
3615 |
switch(info.id()) { |
3616 |
case T_boolean : |
3617 |
case T_byte : |
3618 |
case T_char : |
3619 |
case T_int : |
3620 |
case T_short : |
3621 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
3622 |
break; |
3623 |
case T_float : |
3624 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
3625 |
break; |
3626 |
case T_long : |
3627 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
3628 |
i++; |
3629 |
break; |
3630 |
case T_double : |
3631 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
3632 |
i++; |
3633 |
break; |
3634 |
case T_null : |
3635 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
3636 |
break; |
3637 |
default: |
3638 |
this.contents[localContentsOffset++] = (byte) info.tag; |
3639 |
switch (info.tag) { |
3640 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
3641 |
int offset = info.offset; |
3642 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
3643 |
this.contents[localContentsOffset++] = (byte) offset; |
3644 |
break; |
3645 |
case VerificationTypeInfo.ITEM_OBJECT : |
3646 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
3647 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
3648 |
this.contents[localContentsOffset++] = (byte) indexForType; |
3649 |
} |
3650 |
} |
3651 |
numberOfLocalEntries++; |
3652 |
} |
3653 |
numberOfEntries++; |
3654 |
} |
3655 |
if (localContentsOffset + 4 >= this.contents.length) { |
3656 |
resizeContents(4); |
3657 |
} |
3658 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
3659 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
3660 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
3661 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
3662 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
3663 |
for (int i = 0; i < numberOfStackItems; i++) { |
3664 |
if (localContentsOffset + 3 >= this.contents.length) { |
3665 |
resizeContents(3); |
3666 |
} |
3667 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
3668 |
if (info == null) { |
3669 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
3670 |
} else { |
3671 |
switch(info.id()) { |
3672 |
case T_boolean : |
3673 |
case T_byte : |
3674 |
case T_char : |
3675 |
case T_int : |
3676 |
case T_short : |
3677 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
3678 |
break; |
3679 |
case T_float : |
3680 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
3681 |
break; |
3682 |
case T_long : |
3683 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
3684 |
break; |
3685 |
case T_double : |
3686 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
3687 |
break; |
3688 |
case T_null : |
3689 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
3690 |
break; |
3691 |
default: |
3692 |
this.contents[localContentsOffset++] = (byte) info.tag; |
3693 |
switch (info.tag) { |
3694 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
3695 |
int offset = info.offset; |
3696 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
3697 |
this.contents[localContentsOffset++] = (byte) offset; |
3698 |
break; |
3699 |
case VerificationTypeInfo.ITEM_OBJECT : |
3700 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
3701 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
3702 |
this.contents[localContentsOffset++] = (byte) indexForType; |
3703 |
} |
3704 |
} |
3705 |
} |
3706 |
} |
3707 |
} |
3708 |
|
3709 |
numberOfFrames--; |
3710 |
if (numberOfFrames != 0) { |
3711 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
3712 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
3713 |
|
3714 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
3715 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
3716 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
3717 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
3718 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
3719 |
attributeNumber++; |
3720 |
} else { |
3721 |
localContentsOffset = stackMapTableAttributeOffset; |
3722 |
} |
3723 |
} |
3724 |
} |
3725 |
} |
3726 |
|
3219 |
// update the number of attributes |
3727 |
// update the number of attributes |
3220 |
// ensure first that there is enough space available inside the contents array |
3728 |
// ensure first that there is enough space available inside the contents array |
3221 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
3729 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
Lines 3301-3307
Link Here
|
3301 |
attributeNumber++; |
3809 |
attributeNumber++; |
3302 |
} |
3810 |
} |
3303 |
|
3811 |
|
3304 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
3812 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) { |
3305 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
3813 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
3306 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
3814 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
3307 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
3815 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
Lines 3651-3656
Link Here
|
3651 |
} |
4159 |
} |
3652 |
} |
4160 |
} |
3653 |
|
4161 |
|
|
|
4162 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
4163 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
4164 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
4165 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
4166 |
ArrayList frames = new ArrayList(); |
4167 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
4168 |
int numberOfFrames = frames.size(); |
4169 |
if (numberOfFrames > 1) { |
4170 |
int stackMapTableAttributeOffset = localContentsOffset; |
4171 |
// add the stack map table attribute |
4172 |
if (localContentsOffset + 8 >= this.contents.length) { |
4173 |
resizeContents(8); |
4174 |
} |
4175 |
int stackMapAttributeNameIndex = |
4176 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
4177 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
4178 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
4179 |
|
4180 |
int stackMapAttributeLengthOffset = localContentsOffset; |
4181 |
// generate the attribute |
4182 |
localContentsOffset += 4; |
4183 |
if (localContentsOffset + 4 >= this.contents.length) { |
4184 |
resizeContents(4); |
4185 |
} |
4186 |
int numberOfFramesOffset = localContentsOffset; |
4187 |
localContentsOffset += 2; |
4188 |
if (localContentsOffset + 2 >= this.contents.length) { |
4189 |
resizeContents(2); |
4190 |
} |
4191 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
4192 |
for (int j = 1; j < numberOfFrames; j++) { |
4193 |
// select next frame |
4194 |
currentFrame = (StackMapFrame) frames.get(j); |
4195 |
// generate current frame |
4196 |
// need to find differences between the current frame and the previous frame |
4197 |
int frameOffset = currentFrame.pc; |
4198 |
// FULL_FRAME |
4199 |
if (localContentsOffset + 5 >= this.contents.length) { |
4200 |
resizeContents(5); |
4201 |
} |
4202 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
4203 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
4204 |
int numberOfLocalOffset = localContentsOffset; |
4205 |
localContentsOffset += 2; // leave two spots for number of locals |
4206 |
int numberOfLocalEntries = 0; |
4207 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
4208 |
int numberOfEntries = 0; |
4209 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
4210 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
4211 |
if (localContentsOffset + 3 >= this.contents.length) { |
4212 |
resizeContents(3); |
4213 |
} |
4214 |
VerificationTypeInfo info = currentFrame.locals[i]; |
4215 |
if (info == null) { |
4216 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
4217 |
} else { |
4218 |
switch(info.id()) { |
4219 |
case T_boolean : |
4220 |
case T_byte : |
4221 |
case T_char : |
4222 |
case T_int : |
4223 |
case T_short : |
4224 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
4225 |
break; |
4226 |
case T_float : |
4227 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
4228 |
break; |
4229 |
case T_long : |
4230 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
4231 |
i++; |
4232 |
break; |
4233 |
case T_double : |
4234 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
4235 |
i++; |
4236 |
break; |
4237 |
case T_null : |
4238 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
4239 |
break; |
4240 |
default: |
4241 |
this.contents[localContentsOffset++] = (byte) info.tag; |
4242 |
switch (info.tag) { |
4243 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
4244 |
int offset = info.offset; |
4245 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
4246 |
this.contents[localContentsOffset++] = (byte) offset; |
4247 |
break; |
4248 |
case VerificationTypeInfo.ITEM_OBJECT : |
4249 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
4250 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
4251 |
this.contents[localContentsOffset++] = (byte) indexForType; |
4252 |
} |
4253 |
} |
4254 |
numberOfLocalEntries++; |
4255 |
} |
4256 |
numberOfEntries++; |
4257 |
} |
4258 |
if (localContentsOffset + 4 >= this.contents.length) { |
4259 |
resizeContents(4); |
4260 |
} |
4261 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
4262 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
4263 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
4264 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
4265 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
4266 |
for (int i = 0; i < numberOfStackItems; i++) { |
4267 |
if (localContentsOffset + 3 >= this.contents.length) { |
4268 |
resizeContents(3); |
4269 |
} |
4270 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
4271 |
if (info == null) { |
4272 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
4273 |
} else { |
4274 |
switch(info.id()) { |
4275 |
case T_boolean : |
4276 |
case T_byte : |
4277 |
case T_char : |
4278 |
case T_int : |
4279 |
case T_short : |
4280 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
4281 |
break; |
4282 |
case T_float : |
4283 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
4284 |
break; |
4285 |
case T_long : |
4286 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
4287 |
break; |
4288 |
case T_double : |
4289 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
4290 |
break; |
4291 |
case T_null : |
4292 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
4293 |
break; |
4294 |
default: |
4295 |
this.contents[localContentsOffset++] = (byte) info.tag; |
4296 |
switch (info.tag) { |
4297 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
4298 |
int offset = info.offset; |
4299 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
4300 |
this.contents[localContentsOffset++] = (byte) offset; |
4301 |
break; |
4302 |
case VerificationTypeInfo.ITEM_OBJECT : |
4303 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
4304 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
4305 |
this.contents[localContentsOffset++] = (byte) indexForType; |
4306 |
} |
4307 |
} |
4308 |
} |
4309 |
} |
4310 |
} |
4311 |
|
4312 |
numberOfFrames--; |
4313 |
if (numberOfFrames != 0) { |
4314 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
4315 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
4316 |
|
4317 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
4318 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
4319 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
4320 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
4321 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
4322 |
attributeNumber++; |
4323 |
} else { |
4324 |
localContentsOffset = stackMapTableAttributeOffset; |
4325 |
} |
4326 |
} |
4327 |
} |
4328 |
} |
4329 |
|
3654 |
// then we do the local variable attribute |
4330 |
// then we do the local variable attribute |
3655 |
// update the number of attributes// ensure first that there is enough space available inside the localContents array |
4331 |
// update the number of attributes// ensure first that there is enough space available inside the localContents array |
3656 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
4332 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
Lines 3969-3975
Link Here
|
3969 |
} |
4645 |
} |
3970 |
} |
4646 |
} |
3971 |
|
4647 |
|
3972 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
4648 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) { |
3973 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
4649 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
3974 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
4650 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
3975 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
4651 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
Lines 4319-4324
Link Here
|
4319 |
} |
4995 |
} |
4320 |
} |
4996 |
} |
4321 |
|
4997 |
|
|
|
4998 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
4999 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
5000 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
5001 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
5002 |
ArrayList frames = new ArrayList(); |
5003 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
5004 |
int numberOfFrames = frames.size(); |
5005 |
if (numberOfFrames > 1) { |
5006 |
int stackMapTableAttributeOffset = localContentsOffset; |
5007 |
// add the stack map table attribute |
5008 |
if (localContentsOffset + 8 >= this.contents.length) { |
5009 |
resizeContents(8); |
5010 |
} |
5011 |
int stackMapAttributeNameIndex = |
5012 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
5013 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
5014 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
5015 |
|
5016 |
int stackMapAttributeLengthOffset = localContentsOffset; |
5017 |
// generate the attribute |
5018 |
localContentsOffset += 4; |
5019 |
if (localContentsOffset + 4 >= this.contents.length) { |
5020 |
resizeContents(4); |
5021 |
} |
5022 |
int numberOfFramesOffset = localContentsOffset; |
5023 |
localContentsOffset += 2; |
5024 |
if (localContentsOffset + 2 >= this.contents.length) { |
5025 |
resizeContents(2); |
5026 |
} |
5027 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
5028 |
for (int j = 1; j < numberOfFrames; j++) { |
5029 |
// select next frame |
5030 |
currentFrame = (StackMapFrame) frames.get(j); |
5031 |
// generate current frame |
5032 |
// need to find differences between the current frame and the previous frame |
5033 |
int frameOffset = currentFrame.pc; |
5034 |
// FULL_FRAME |
5035 |
if (localContentsOffset + 5 >= this.contents.length) { |
5036 |
resizeContents(5); |
5037 |
} |
5038 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
5039 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
5040 |
int numberOfLocalOffset = localContentsOffset; |
5041 |
localContentsOffset += 2; // leave two spots for number of locals |
5042 |
int numberOfLocalEntries = 0; |
5043 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
5044 |
int numberOfEntries = 0; |
5045 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
5046 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
5047 |
if (localContentsOffset + 3 >= this.contents.length) { |
5048 |
resizeContents(3); |
5049 |
} |
5050 |
VerificationTypeInfo info = currentFrame.locals[i]; |
5051 |
if (info == null) { |
5052 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
5053 |
} else { |
5054 |
switch(info.id()) { |
5055 |
case T_boolean : |
5056 |
case T_byte : |
5057 |
case T_char : |
5058 |
case T_int : |
5059 |
case T_short : |
5060 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
5061 |
break; |
5062 |
case T_float : |
5063 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
5064 |
break; |
5065 |
case T_long : |
5066 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
5067 |
i++; |
5068 |
break; |
5069 |
case T_double : |
5070 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
5071 |
i++; |
5072 |
break; |
5073 |
case T_null : |
5074 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
5075 |
break; |
5076 |
default: |
5077 |
this.contents[localContentsOffset++] = (byte) info.tag; |
5078 |
switch (info.tag) { |
5079 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
5080 |
int offset = info.offset; |
5081 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
5082 |
this.contents[localContentsOffset++] = (byte) offset; |
5083 |
break; |
5084 |
case VerificationTypeInfo.ITEM_OBJECT : |
5085 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
5086 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
5087 |
this.contents[localContentsOffset++] = (byte) indexForType; |
5088 |
} |
5089 |
} |
5090 |
numberOfLocalEntries++; |
5091 |
} |
5092 |
numberOfEntries++; |
5093 |
} |
5094 |
if (localContentsOffset + 4 >= this.contents.length) { |
5095 |
resizeContents(4); |
5096 |
} |
5097 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
5098 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
5099 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
5100 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
5101 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
5102 |
for (int i = 0; i < numberOfStackItems; i++) { |
5103 |
if (localContentsOffset + 3 >= this.contents.length) { |
5104 |
resizeContents(3); |
5105 |
} |
5106 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
5107 |
if (info == null) { |
5108 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
5109 |
} else { |
5110 |
switch(info.id()) { |
5111 |
case T_boolean : |
5112 |
case T_byte : |
5113 |
case T_char : |
5114 |
case T_int : |
5115 |
case T_short : |
5116 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
5117 |
break; |
5118 |
case T_float : |
5119 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
5120 |
break; |
5121 |
case T_long : |
5122 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
5123 |
break; |
5124 |
case T_double : |
5125 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
5126 |
break; |
5127 |
case T_null : |
5128 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
5129 |
break; |
5130 |
default: |
5131 |
this.contents[localContentsOffset++] = (byte) info.tag; |
5132 |
switch (info.tag) { |
5133 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
5134 |
int offset = info.offset; |
5135 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
5136 |
this.contents[localContentsOffset++] = (byte) offset; |
5137 |
break; |
5138 |
case VerificationTypeInfo.ITEM_OBJECT : |
5139 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
5140 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
5141 |
this.contents[localContentsOffset++] = (byte) indexForType; |
5142 |
} |
5143 |
} |
5144 |
} |
5145 |
} |
5146 |
} |
5147 |
|
5148 |
numberOfFrames--; |
5149 |
if (numberOfFrames != 0) { |
5150 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
5151 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
5152 |
|
5153 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
5154 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
5155 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
5156 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
5157 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
5158 |
attributeNumber++; |
5159 |
} else { |
5160 |
localContentsOffset = stackMapTableAttributeOffset; |
5161 |
} |
5162 |
} |
5163 |
} |
5164 |
} |
5165 |
|
4322 |
// update the number of attributes// ensure first that there is enough space available inside the localContents array |
5166 |
// update the number of attributes// ensure first that there is enough space available inside the localContents array |
4323 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
5167 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
4324 |
resizeContents(2); |
5168 |
resizeContents(2); |
Lines 4374-4380
Link Here
|
4374 |
resizeContents(40); |
5218 |
resizeContents(40); |
4375 |
} |
5219 |
} |
4376 |
|
5220 |
|
4377 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0; |
5221 |
boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0; |
4378 |
if (hasExceptionHandlers) { |
5222 |
if (hasExceptionHandlers) { |
4379 |
// write the exception table |
5223 |
// write the exception table |
4380 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
5224 |
ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels; |
Lines 4953-4958
Link Here
|
4953 |
} |
5797 |
} |
4954 |
} |
5798 |
} |
4955 |
|
5799 |
|
|
|
5800 |
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) { |
5801 |
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream; |
5802 |
stackMapFrameCodeStream.removeFramePosition(code_length); |
5803 |
if (stackMapFrameCodeStream.hasFramePositions()) { |
5804 |
ArrayList frames = new ArrayList(); |
5805 |
traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false); |
5806 |
int numberOfFrames = frames.size(); |
5807 |
if (numberOfFrames > 1) { |
5808 |
int stackMapTableAttributeOffset = localContentsOffset; |
5809 |
// add the stack map table attribute |
5810 |
if (localContentsOffset + 8 >= this.contents.length) { |
5811 |
resizeContents(8); |
5812 |
} |
5813 |
int stackMapAttributeNameIndex = |
5814 |
constantPool.literalIndex(AttributeNamesConstants.StackMapName); |
5815 |
this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8); |
5816 |
this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex; |
5817 |
|
5818 |
int stackMapAttributeLengthOffset = localContentsOffset; |
5819 |
// generate the attribute |
5820 |
localContentsOffset += 4; |
5821 |
if (localContentsOffset + 4 >= this.contents.length) { |
5822 |
resizeContents(4); |
5823 |
} |
5824 |
int numberOfFramesOffset = localContentsOffset; |
5825 |
localContentsOffset += 2; |
5826 |
if (localContentsOffset + 2 >= this.contents.length) { |
5827 |
resizeContents(2); |
5828 |
} |
5829 |
StackMapFrame currentFrame = (StackMapFrame) frames.get(0); |
5830 |
for (int j = 1; j < numberOfFrames; j++) { |
5831 |
// select next frame |
5832 |
currentFrame = (StackMapFrame) frames.get(j); |
5833 |
// generate current frame |
5834 |
// need to find differences between the current frame and the previous frame |
5835 |
int frameOffset = currentFrame.pc; |
5836 |
// FULL_FRAME |
5837 |
if (localContentsOffset + 5 >= this.contents.length) { |
5838 |
resizeContents(5); |
5839 |
} |
5840 |
this.contents[localContentsOffset++] = (byte) (frameOffset >> 8); |
5841 |
this.contents[localContentsOffset++] = (byte) frameOffset; |
5842 |
int numberOfLocalOffset = localContentsOffset; |
5843 |
localContentsOffset += 2; // leave two spots for number of locals |
5844 |
int numberOfLocalEntries = 0; |
5845 |
int numberOfLocals = currentFrame.getNumberOfLocals(); |
5846 |
int numberOfEntries = 0; |
5847 |
int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length; |
5848 |
for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) { |
5849 |
if (localContentsOffset + 3 >= this.contents.length) { |
5850 |
resizeContents(3); |
5851 |
} |
5852 |
VerificationTypeInfo info = currentFrame.locals[i]; |
5853 |
if (info == null) { |
5854 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
5855 |
} else { |
5856 |
switch(info.id()) { |
5857 |
case T_boolean : |
5858 |
case T_byte : |
5859 |
case T_char : |
5860 |
case T_int : |
5861 |
case T_short : |
5862 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
5863 |
break; |
5864 |
case T_float : |
5865 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
5866 |
break; |
5867 |
case T_long : |
5868 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
5869 |
i++; |
5870 |
break; |
5871 |
case T_double : |
5872 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
5873 |
i++; |
5874 |
break; |
5875 |
case T_null : |
5876 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
5877 |
break; |
5878 |
default: |
5879 |
this.contents[localContentsOffset++] = (byte) info.tag; |
5880 |
switch (info.tag) { |
5881 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
5882 |
int offset = info.offset; |
5883 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
5884 |
this.contents[localContentsOffset++] = (byte) offset; |
5885 |
break; |
5886 |
case VerificationTypeInfo.ITEM_OBJECT : |
5887 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
5888 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
5889 |
this.contents[localContentsOffset++] = (byte) indexForType; |
5890 |
} |
5891 |
} |
5892 |
numberOfLocalEntries++; |
5893 |
} |
5894 |
numberOfEntries++; |
5895 |
} |
5896 |
if (localContentsOffset + 4 >= this.contents.length) { |
5897 |
resizeContents(4); |
5898 |
} |
5899 |
this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8); |
5900 |
this.contents[numberOfLocalOffset] = (byte) numberOfEntries; |
5901 |
int numberOfStackItems = currentFrame.numberOfStackItems; |
5902 |
this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8); |
5903 |
this.contents[localContentsOffset++] = (byte) numberOfStackItems; |
5904 |
for (int i = 0; i < numberOfStackItems; i++) { |
5905 |
if (localContentsOffset + 3 >= this.contents.length) { |
5906 |
resizeContents(3); |
5907 |
} |
5908 |
VerificationTypeInfo info = currentFrame.stackItems[i]; |
5909 |
if (info == null) { |
5910 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP; |
5911 |
} else { |
5912 |
switch(info.id()) { |
5913 |
case T_boolean : |
5914 |
case T_byte : |
5915 |
case T_char : |
5916 |
case T_int : |
5917 |
case T_short : |
5918 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER; |
5919 |
break; |
5920 |
case T_float : |
5921 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT; |
5922 |
break; |
5923 |
case T_long : |
5924 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG; |
5925 |
break; |
5926 |
case T_double : |
5927 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE; |
5928 |
break; |
5929 |
case T_null : |
5930 |
this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL; |
5931 |
break; |
5932 |
default: |
5933 |
this.contents[localContentsOffset++] = (byte) info.tag; |
5934 |
switch (info.tag) { |
5935 |
case VerificationTypeInfo.ITEM_UNINITIALIZED : |
5936 |
int offset = info.offset; |
5937 |
this.contents[localContentsOffset++] = (byte) (offset >> 8); |
5938 |
this.contents[localContentsOffset++] = (byte) offset; |
5939 |
break; |
5940 |
case VerificationTypeInfo.ITEM_OBJECT : |
5941 |
int indexForType = constantPool.literalIndexForType(info.constantPoolName()); |
5942 |
this.contents[localContentsOffset++] = (byte) (indexForType >> 8); |
5943 |
this.contents[localContentsOffset++] = (byte) indexForType; |
5944 |
} |
5945 |
} |
5946 |
} |
5947 |
} |
5948 |
} |
5949 |
|
5950 |
numberOfFrames--; |
5951 |
if (numberOfFrames != 0) { |
5952 |
this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8); |
5953 |
this.contents[numberOfFramesOffset] = (byte) numberOfFrames; |
5954 |
|
5955 |
int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4; |
5956 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24); |
5957 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16); |
5958 |
this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8); |
5959 |
this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength; |
5960 |
attributeNumber++; |
5961 |
} else { |
5962 |
localContentsOffset = stackMapTableAttributeOffset; |
5963 |
} |
5964 |
} |
5965 |
} |
5966 |
} |
5967 |
|
4956 |
// update the number of attributes |
5968 |
// update the number of attributes |
4957 |
// ensure first that there is enough space available inside the contents array |
5969 |
// ensure first that there is enough space available inside the contents array |
4958 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
5970 |
if (codeAttributeAttributeOffset + 2 >= this.contents.length) { |
Lines 5976-5981
Link Here
|
5976 |
this.targetJDK = options.targetJDK; |
6988 |
this.targetJDK = options.targetJDK; |
5977 |
this.produceAttributes = options.produceDebugAttributes; |
6989 |
this.produceAttributes = options.produceDebugAttributes; |
5978 |
if (this.targetJDK >= ClassFileConstants.JDK1_6) { |
6990 |
if (this.targetJDK >= ClassFileConstants.JDK1_6) { |
|
|
6991 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE; |
6992 |
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) { |
6993 |
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3 |
5979 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP; |
6994 |
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP; |
5980 |
} |
6995 |
} |
5981 |
this.bytes = null; |
6996 |
this.bytes = null; |