void branch() { if (this.position == POS_NOT_SET) { addForwardReference(this.codeStream.position); // Leave 4 bytes free to generate the jump offset afterwards this.codeStream.position += 4; this.codeStream.classFileOffset += 4; } else { //Position is set. Write it! /* * Position is set. Write it if it is not a wide branch. */ this.codeStream.writeSignedWord(this.position - this.instructionPosition); } }
public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { this.countLabels = 0; this.stackDepth--; int length = keys.length; int pos = this.position; defaultLabel.placeInstruction(); for (int i = 0; i < length; i++) { casesLabel[i].placeInstruction(); } if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lookupswitch; for (int i = (3 - (pos & 3)); i > 0; i--) { // faster than % 4 if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = 0; } defaultLabel.branch(); writeSignedWord(length); for (int i = 0; i < length; i++) { writeSignedWord(keys[sortedIndexes[i]]); casesLabel[sortedIndexes[i]].branch(); } }
public void place() { if ((this.tagBits & USED) != 0) { this.position = this.codeStream.getPosition(); } else { this.position = this.codeStream.position; } if (this.instructionPosition != POS_NOT_SET) { int offset = this.position - this.instructionPosition; int[] forwardRefs = forwardReferences(); for (int i = 0, length = forwardReferenceCount(); i < length; i++) { this.codeStream.writeSignedWord(forwardRefs[i], offset); } // add the label in the codeStream labels collection this.codeStream.addLabel(this); } }
sourceCaseLabels[i].tagBits |= BranchLabel.USED; stringCases[i] = new StringSwitchCase(this.stringConstants[i].hashCode(), this.stringConstants[i], sourceCaseLabels[i]); hashCodeCaseLabels[i] = new CaseLabel(codeStream); hashCodeCaseLabels[i].tagBits |= BranchLabel.USED; CaseLabel defaultCaseLabel = new CaseLabel(codeStream); defaultCaseLabel.tagBits |= BranchLabel.USED; codeStream.goto_(defaultBranchLabel); hashCodeCaseLabels[j++].place(); } else { if (statement == this.defaultCase) { // statements[i] is a case or a default case defaultCaseLabel.place(); // branch label gets placed by generateCode below. this.scope.enclosingCase = this.defaultCase; // record entering in a switch case block if (this.preSwitchInitStateIndex != -1) { defaultCaseLabel.place(); defaultBranchLabel.place();
@Override void branchWide() { branch(); // case label branch is already wide }
/** * Case code generation * */ public void generateCode(BlockScope currentScope, CodeStream codeStream) { if ((this.bits & ASTNode.IsReachable) == 0) { return; } int pc = codeStream.position; this.targetLabel.place(); codeStream.recordPositionsFrom(pc, this.sourceStart); }
sourceCaseLabels[i].tagBits |= BranchLabel.USED; stringCases[i] = new StringSwitchCase(this.stringConstants[i].hashCode(), this.stringConstants[i], sourceCaseLabels[i]); hashCodeCaseLabels[i] = new CaseLabel(codeStream); hashCodeCaseLabels[i].tagBits |= BranchLabel.USED; CaseLabel defaultCaseLabel = new CaseLabel(codeStream); defaultCaseLabel.tagBits |= BranchLabel.USED; codeStream.goto_(defaultBranchLabel); hashCodeCaseLabels[j++].place(); } else { if (statement == this.defaultCase) { // statements[i] is a case or a default case defaultCaseLabel.place(); // branch label gets placed by generateCode below. this.scope.enclosingCase = this.defaultCase; // record entering in a switch case block if (this.preSwitchInitStateIndex != -1) { defaultCaseLabel.place(); defaultBranchLabel.place();
void branchWide() { branch(); // case label branch is already wide }
/** * Case code generation * */ public void generateCode(BlockScope currentScope, CodeStream codeStream) { if ((this.bits & ASTNode.IsReachable) == 0) { return; } int pc = codeStream.position; this.targetLabel.place(); codeStream.recordPositionsFrom(pc, this.sourceStart); }
sourceCaseLabels[i].tagBits |= BranchLabel.USED; stringCases[i] = new StringSwitchCase(this.stringConstants[i].hashCode(), this.stringConstants[i], sourceCaseLabels[i]); hashCodeCaseLabels[i] = new CaseLabel(codeStream); hashCodeCaseLabels[i].tagBits |= BranchLabel.USED; CaseLabel defaultCaseLabel = new CaseLabel(codeStream); defaultCaseLabel.tagBits |= BranchLabel.USED; codeStream.goto_(defaultBranchLabel); hashCodeCaseLabels[j++].place(); } else { if (statement == this.defaultCase) { // statements[i] is a case or a default case defaultCaseLabel.place(); // branch label gets placed by generateCode below. this.scope.enclosingCase = this.defaultCase; // record entering in a switch case block if (this.preSwitchInitStateIndex != -1) { defaultCaseLabel.place(); defaultBranchLabel.place();
public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { this.countLabels = 0; this.stackDepth--; int length = keys.length; int pos = this.position; defaultLabel.placeInstruction(); for (int i = 0; i < length; i++) { casesLabel[i].placeInstruction(); } if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lookupswitch; for (int i = (3 - (pos & 3)); i > 0; i--) { // faster than % 4 if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = 0; } defaultLabel.branch(); writeSignedWord(length); for (int i = 0; i < length; i++) { writeSignedWord(keys[sortedIndexes[i]]); casesLabel[sortedIndexes[i]].branch(); } }
public void place() { if ((this.tagBits & USED) != 0) { this.position = this.codeStream.getPosition(); } else { this.position = this.codeStream.position; } if (this.instructionPosition != POS_NOT_SET) { int offset = this.position - this.instructionPosition; int[] forwardRefs = forwardReferences(); for (int i = 0, length = forwardReferenceCount(); i < length; i++) { this.codeStream.writeSignedWord(forwardRefs[i], offset); } // add the label in the codeStream labels collection this.codeStream.addLabel(this); } }
void branchWide() { branch(); // case label branch is already wide }
void branch() { if (this.position == POS_NOT_SET) { addForwardReference(this.codeStream.position); // Leave 4 bytes free to generate the jump offset afterwards this.codeStream.position += 4; this.codeStream.classFileOffset += 4; } else { //Position is set. Write it! /* * Position is set. Write it if it is not a wide branch. */ this.codeStream.writeSignedWord(this.position - this.instructionPosition); } }
sourceCaseLabels[i].tagBits |= BranchLabel.USED; stringCases[i] = new StringSwitchCase(this.stringConstants[i].hashCode(), this.stringConstants[i], sourceCaseLabels[i]); hashCodeCaseLabels[i] = new CaseLabel(codeStream); hashCodeCaseLabels[i].tagBits |= BranchLabel.USED; CaseLabel defaultCaseLabel = new CaseLabel(codeStream); defaultCaseLabel.tagBits |= BranchLabel.USED; codeStream.goto_(defaultBranchLabel); hashCodeCaseLabels[j++].place(); } else { if (statement == this.defaultCase) { // statements[i] is a case or a default case defaultCaseLabel.place(); // branch label gets placed by generateCode below. this.scope.enclosingCase = this.defaultCase; // record entering in a switch case block if (this.preSwitchInitStateIndex != -1) { defaultCaseLabel.place(); defaultBranchLabel.place();
public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { this.countLabels = 0; this.stackDepth--; int length = keys.length; int pos = this.position; defaultLabel.placeInstruction(); for (int i = 0; i < length; i++) { casesLabel[i].placeInstruction(); } if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lookupswitch; for (int i = (3 - (pos & 3)); i > 0; i--) { // faster than % 4 if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } this.position++; this.bCodeStream[this.classFileOffset++] = 0; } defaultLabel.branch(); writeSignedWord(length); for (int i = 0; i < length; i++) { writeSignedWord(keys[sortedIndexes[i]]); casesLabel[sortedIndexes[i]].branch(); } }
public void place() { if ((this.tagBits & USED) != 0) { this.position = this.codeStream.getPosition(); } else { this.position = this.codeStream.position; } if (this.instructionPosition != POS_NOT_SET) { int offset = this.position - this.instructionPosition; int[] forwardRefs = forwardReferences(); for (int i = 0, length = forwardReferenceCount(); i < length; i++) { this.codeStream.writeSignedWord(forwardRefs[i], offset); } // add the label in the codeStream labels collection this.codeStream.addLabel(this); } }
void branchWide() { branch(); // case label branch is already wide }
void branch() { if (this.position == POS_NOT_SET) { addForwardReference(this.codeStream.position); // Leave 4 bytes free to generate the jump offset afterwards this.codeStream.position += 4; this.codeStream.classFileOffset += 4; } else { //Position is set. Write it! /* * Position is set. Write it if it is not a wide branch. */ this.codeStream.writeSignedWord(this.position - this.instructionPosition); } }
sourceCaseLabels[i].tagBits |= BranchLabel.USED; stringCases[i] = new StringSwitchCase(this.stringConstants[i].hashCode(), this.stringConstants[i], sourceCaseLabels[i]); hashCodeCaseLabels[i] = new CaseLabel(codeStream); hashCodeCaseLabels[i].tagBits |= BranchLabel.USED; CaseLabel defaultCaseLabel = new CaseLabel(codeStream); defaultCaseLabel.tagBits |= BranchLabel.USED; codeStream.goto_(defaultBranchLabel); hashCodeCaseLabels[j++].place(); } else { if (statement == this.defaultCase) { // statements[i] is a case or a default case defaultCaseLabel.place(); // branch label gets placed by generateCode below. this.scope.enclosingCase = this.defaultCase; // record entering in a switch case block if (this.preSwitchInitStateIndex != -1) { defaultCaseLabel.place(); defaultBranchLabel.place();