src/share/classes/com/sun/tools/javac/jvm/Code.java

changeset 2709
dca7f60e618d
parent 2595
1cf5a53613ae
child 2734
ba758e1ffa69
equal deleted inserted replaced
2708:385488f3737c 2709:dca7f60e618d
1 /* 1 /*
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2015, 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
180 */ 180 */
181 final Pool pool; 181 final Pool pool;
182 182
183 final MethodSymbol meth; 183 final MethodSymbol meth;
184 184
185 final LVTRanges lvtRanges;
186
187 /** Construct a code object, given the settings of the fatcode, 185 /** Construct a code object, given the settings of the fatcode,
188 * debugging info switches and the CharacterRangeTable. 186 * debugging info switches and the CharacterRangeTable.
189 */ 187 */
190 public Code(MethodSymbol meth, 188 public Code(MethodSymbol meth,
191 boolean fatcode, 189 boolean fatcode,
194 StackMapFormat stackMap, 192 StackMapFormat stackMap,
195 boolean debugCode, 193 boolean debugCode,
196 CRTable crt, 194 CRTable crt,
197 Symtab syms, 195 Symtab syms,
198 Types types, 196 Types types,
199 Pool pool, 197 Pool pool) {
200 LVTRanges lvtRanges) {
201 this.meth = meth; 198 this.meth = meth;
202 this.fatcode = fatcode; 199 this.fatcode = fatcode;
203 this.lineMap = lineMap; 200 this.lineMap = lineMap;
204 this.lineDebugInfo = lineMap != null; 201 this.lineDebugInfo = lineMap != null;
205 this.varDebugInfo = varDebugInfo; 202 this.varDebugInfo = varDebugInfo;
217 this.needStackMap = false; 214 this.needStackMap = false;
218 } 215 }
219 state = new State(); 216 state = new State();
220 lvar = new LocalVar[20]; 217 lvar = new LocalVar[20];
221 this.pool = pool; 218 this.pool = pool;
222 this.lvtRanges = lvtRanges;
223 } 219 }
224 220
225 221
226 /* ************************************************************************** 222 /* **************************************************************************
227 * Typecodes & related stuff 223 * Typecodes & related stuff
1191 * return current code pointer 1187 * return current code pointer
1192 */ 1188 */
1193 public int entryPoint(State state) { 1189 public int entryPoint(State state) {
1194 int pc = curCP(); 1190 int pc = curCP();
1195 alive = true; 1191 alive = true;
1196 this.state = state.dup(); 1192 State newState = state.dup();
1193 setDefined(newState.defined);
1194 this.state = newState;
1197 Assert.check(state.stacksize <= max_stack); 1195 Assert.check(state.stacksize <= max_stack);
1198 if (debugCode) System.err.println("entry point " + state); 1196 if (debugCode) System.err.println("entry point " + state);
1199 pendingStackMap = needStackMap; 1197 pendingStackMap = needStackMap;
1200 return pc; 1198 return pc;
1201 } 1199 }
1204 * return current code pointer 1202 * return current code pointer
1205 */ 1203 */
1206 public int entryPoint(State state, Type pushed) { 1204 public int entryPoint(State state, Type pushed) {
1207 int pc = curCP(); 1205 int pc = curCP();
1208 alive = true; 1206 alive = true;
1209 this.state = state.dup(); 1207 State newState = state.dup();
1208 setDefined(newState.defined);
1209 this.state = newState;
1210 Assert.check(state.stacksize <= max_stack); 1210 Assert.check(state.stacksize <= max_stack);
1211 this.state.push(pushed); 1211 this.state.push(pushed);
1212 if (debugCode) System.err.println("entry point " + state); 1212 if (debugCode) System.err.println("entry point " + state);
1213 pendingStackMap = needStackMap; 1213 pendingStackMap = needStackMap;
1214 return pc; 1214 return pc;
2004 if (pendingJumps != null) { 2004 if (pendingJumps != null) {
2005 resolvePending(); 2005 resolvePending();
2006 } 2006 }
2007 lvar[adr] = new LocalVar(v); 2007 lvar[adr] = new LocalVar(v);
2008 state.defined.excl(adr); 2008 state.defined.excl(adr);
2009 }
2010
2011
2012 public void closeAliveRanges(JCTree tree) {
2013 closeAliveRanges(tree, cp);
2014 }
2015
2016 public void closeAliveRanges(JCTree tree, int closingCP) {
2017 List<VarSymbol> locals = lvtRanges.getVars(meth, tree);
2018 for (LocalVar localVar: lvar) {
2019 for (VarSymbol aliveLocal : locals) {
2020 if (localVar != null) {
2021 if (localVar.sym == aliveLocal && localVar.lastRange() != null) {
2022 char length = (char)(closingCP - localVar.lastRange().start_pc);
2023 if (length < Character.MAX_VALUE) {
2024 localVar.closeRange(length);
2025 }
2026 }
2027 }
2028 }
2029 }
2030 } 2009 }
2031 2010
2032 void adjustAliveRanges(int oldCP, int delta) { 2011 void adjustAliveRanges(int oldCP, int delta) {
2033 for (LocalVar localVar: lvar) { 2012 for (LocalVar localVar: lvar) {
2034 if (localVar != null) { 2013 if (localVar != null) {

mercurial