Skip to content

Commit

Permalink
Merge branch 'Guardsquare:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zlataovce authored Oct 18, 2024
2 parents 928446b + 60ee99a commit 02dc0a5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public void appendInstruction(int oldInstructionOffset, Instruction instruction)
int newCodeLength = codeLength + instruction.length(codeLength);

ensureCodeLength(newCodeLength);
ensureFragmentLength(oldInstructionOffset + 1);

// Remember the old offset of the appended instruction.
oldInstructionOffsets[codeLength] = oldInstructionOffset;
Expand Down Expand Up @@ -325,6 +326,7 @@ public void appendLabel(int oldInstructionOffset) {

// Make sure the code and offset arrays are large enough.
ensureCodeLength(codeLength + 1);
ensureFragmentLength(oldInstructionOffset + 1);

// Remember the old offset of the following instruction.
oldInstructionOffsets[codeLength] = oldInstructionOffset;
Expand Down Expand Up @@ -1067,6 +1069,22 @@ private void ensureCodeLength(int newCodeLength) {
}
}

/** Make sure the code fragment offset array have at least the given size. */
private void ensureFragmentLength(int newFragmentLength) {
if (codeFragmentLengths[level] < newFragmentLength) {
codeFragmentLengths[level] = newFragmentLength;

int oldFragmentLength = instructionOffsetMap[level].length;
if (newFragmentLength > oldFragmentLength) {
// Add 20% to avoid extending the arrays too often.
newFragmentLength = newFragmentLength * 6 / 5;
instructionOffsetMap[level] =
ArrayUtil.extendArray(instructionOffsetMap[level], newFragmentLength);
Arrays.fill(instructionOffsetMap[level], oldFragmentLength, newFragmentLength, INVALID);
}
}
}

/** Adjusts the given jump offsets for the instruction at the given offset. */
private void updateJumpOffsets(int offset, int[] jumpOffsets) {
for (int index = 0; index < jumpOffsets.length; index++) {
Expand Down
20 changes: 14 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false
id 'com.adarshr.test-logger' version '3.0.0' apply false
id "org.sonarqube" version "3.4.0.2513"
id "io.freefair.aggregate-javadoc" version "6.5.0.3"
id "io.freefair.aggregate-javadoc" version "8.10"
id "com.diffplug.spotless" version "6.13.0" apply false
}

Expand Down Expand Up @@ -75,14 +75,22 @@ allprojects {
}
}

aggregateJavadoc {
dependencies {
rootProject.subprojects { subproject ->
subproject.plugins.withId("java") {
javadoc subproject
}
}
}

javadoc {
title = 'ProGuardCORE'
destinationDir = file('docs/md/api')
options.addStringOption('Xdoclint:none', '-quiet')
}

task buildDocumentation(type: Exec) {
dependsOn aggregateJavadoc
dependsOn javadoc
inputs.dir 'docs/md'
inputs.file 'docs/mkdocs.yml'
outputs.dir 'docs/html'
Expand All @@ -91,7 +99,7 @@ task buildDocumentation(type: Exec) {
}

clean {
delete aggregateJavadoc.outputs
delete javadoc.outputs
//delete buildDocumentation.outputs
}

Expand Down Expand Up @@ -122,11 +130,11 @@ distributions {
distTar {
compression = Compression.GZIP
archiveExtension.set('tar.gz')
dependsOn('aggregateJavadoc')
dependsOn('javadoc')
}

distZip {
dependsOn('aggregateJavadoc')
dependsOn('javadoc')
}

nexusPublishing {
Expand Down

0 comments on commit 02dc0a5

Please sign in to comment.