Fix incremental build. Enable incremental build in junit CLI

This commit is contained in:
Alexey Andreev 2015-06-10 11:33:05 +03:00
parent fe7ae9f052
commit fc8200f135
8 changed files with 70 additions and 16 deletions

View File

@ -343,16 +343,18 @@ public class TDecimalFormat extends TNumberFormat {
int mantissaLength = fastLn10(mantissa) + 1; int mantissaLength = fastLn10(mantissa) + 1;
++exponent; ++exponent;
int multiplierDigits = fastLn10(multiplier); if (multiplier != 1) {
int tenMultiplier = POW10_INT_ARRAY[multiplierDigits]; int multiplierDigits = fastLn10(multiplier);
if (tenMultiplier == multiplier) { int tenMultiplier = POW10_INT_ARRAY[multiplierDigits];
exponent += multiplierDigits; if (tenMultiplier == multiplier) {
} else if (mantissa >= Long.MAX_VALUE / multiplier || mantissa <= Long.MIN_VALUE / multiplier) { exponent += multiplierDigits;
formatRegular(new BigDecimal(BigInteger.valueOf(mantissa), mantissaLength - exponent), buffer); } else if (mantissa >= Long.MAX_VALUE / multiplier || mantissa <= Long.MIN_VALUE / multiplier) {
return; formatRegular(new BigDecimal(BigInteger.valueOf(mantissa), mantissaLength - exponent), buffer);
} else { return;
mantissa *= multiplier; } else {
mantissaLength = fastLn10(mantissa) + 1; mantissa *= multiplier;
mantissaLength = fastLn10(mantissa) + 1;
}
} }
// Apply rounding if necessary // Apply rounding if necessary

View File

@ -65,6 +65,10 @@ public final class TeaVMTestRunner {
.withDescription("qualified class names of transformers") .withDescription("qualified class names of transformers")
.withLongOpt("transformers") .withLongOpt("transformers")
.create("T")); .create("T"));
options.addOption(OptionBuilder
.withDescription("Incremental build")
.withLongOpt("incremental")
.create('i'));
if (args.length == 0) { if (args.length == 0) {
printUsage(options); printUsage(options);
@ -97,6 +101,10 @@ public final class TeaVMTestRunner {
tool.getTransformers().add(instantiateTransformer(transformerType)); tool.getTransformers().add(instantiateTransformer(transformerType));
} }
} }
if (commandLine.hasOption('i')) {
tool.setIncremental(true);
}
args = commandLine.getArgs(); args = commandLine.getArgs();
if (args.length == 0) { if (args.length == 0) {
System.err.println("You did not specify any test classes"); System.err.println("You did not specify any test classes");

View File

@ -0,0 +1,30 @@
/*
* Copyright 2015 Alexey Andreev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teavm.cache;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author Alexey Andreev
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface NoCache {
}

View File

@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.teavm.cache.NoCache;
import org.teavm.common.Graph; import org.teavm.common.Graph;
import org.teavm.common.GraphIndexer; import org.teavm.common.GraphIndexer;
import org.teavm.common.Loop; import org.teavm.common.Loop;
@ -245,7 +246,7 @@ public class Decompiler {
} }
public RegularMethodNode decompileRegular(MethodHolder method) { public RegularMethodNode decompileRegular(MethodHolder method) {
if (regularMethodCache == null) { if (regularMethodCache == null || method.getAnnotations().get(NoCache.class.getName()) != null) {
return decompileRegularCacheMiss(method); return decompileRegularCacheMiss(method);
} }
RegularMethodNode node = regularMethodCache.get(method.getReference()); RegularMethodNode node = regularMethodCache.get(method.getReference());
@ -283,7 +284,7 @@ public class Decompiler {
} }
public AsyncMethodNode decompileAsync(MethodHolder method) { public AsyncMethodNode decompileAsync(MethodHolder method) {
if (regularMethodCache == null) { if (regularMethodCache == null || method.getAnnotations().get(NoCache.class.getName()) != null) {
return decompileAsyncCacheMiss(method); return decompileAsyncCacheMiss(method);
} }
AsyncMethodNode node = regularMethodCache.getAsync(method.getReference()); AsyncMethodNode node = regularMethodCache.getAsync(method.getReference());

View File

@ -17,6 +17,7 @@ package org.teavm.model;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.teavm.model.util.ProgramUtils;
/** /**
* *
@ -27,11 +28,12 @@ public class InMemoryProgramCache implements ProgramCache {
@Override @Override
public Program get(MethodReference method) { public Program get(MethodReference method) {
return cache.get(method); Program program = cache.get(method);
return program != null ? ProgramUtils.copy(program) : null;
} }
@Override @Override
public void store(MethodReference method, Program program) { public void store(MethodReference method, Program program) {
cache.put(method, program); cache.put(method, ProgramUtils.copy(program));
} }
} }

View File

@ -236,7 +236,7 @@ public class TeaVMTool {
symbolTable.update(); symbolTable.update();
fileTable.update(); fileTable.update();
} catch (IOException e) { } catch (IOException e) {
log.info("Cache was not read"); log.info("Cache is missing");
} }
vmBuilder.setClassLoader(classLoader).setClassSource(cachedClassSource); vmBuilder.setClassLoader(classLoader).setClassSource(cachedClassSource);
} else { } else {

View File

@ -17,6 +17,7 @@ package org.teavm.vm;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import org.teavm.cache.NoCache;
import org.teavm.codegen.*; import org.teavm.codegen.*;
import org.teavm.common.ServiceRepository; import org.teavm.common.ServiceRepository;
import org.teavm.debugging.information.DebugInformationEmitter; import org.teavm.debugging.information.DebugInformationEmitter;
@ -616,7 +617,9 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
if (method.getProgram() == null) { if (method.getProgram() == null) {
return; return;
} }
Program optimizedProgram = incremental && programCache != null ?
boolean noCache = method.getAnnotations().get(NoCache.class.getName()) != null;
Program optimizedProgram = incremental && !noCache && programCache != null ?
programCache.get(method.getReference()) : null; programCache.get(method.getReference()) : null;
if (optimizedProgram == null) { if (optimizedProgram == null) {
optimizedProgram = ProgramUtils.copy(method.getProgram()); optimizedProgram = ProgramUtils.copy(method.getProgram());

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.platform.plugin; package org.teavm.platform.plugin;
import org.teavm.cache.NoCache;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.javascript.spi.GeneratedBy; import org.teavm.javascript.spi.GeneratedBy;
import org.teavm.model.*; import org.teavm.model.*;
@ -49,10 +50,14 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
method.getReference(), ClassScopedMetadataProvider.class.getName(), method.getReference(), ClassScopedMetadataProvider.class.getName(),
PlatformClass.class.getName()); PlatformClass.class.getName());
} }
AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName());
genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( genAnnot.getValues().put("value", new AnnotationValue(ValueType.object(
ClassScopedMetadataProviderNativeGenerator.class.getName()))); ClassScopedMetadataProviderNativeGenerator.class.getName())));
method.getAnnotations().add(genAnnot); method.getAnnotations().add(genAnnot);
AnnotationHolder noCacheAnnot = new AnnotationHolder(NoCache.class.getName());
method.getAnnotations().add(noCacheAnnot);
} }
} }
} }
@ -95,6 +100,9 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
fork.setElse(pe.createBlock()); fork.setElse(pe.createBlock());
pe.setField(field.getReference(), field.getType(), pe.invoke(createMethod.getReference())); pe.setField(field.getReference(), field.getType(), pe.invoke(createMethod.getReference()));
pe.jump(resourceFound); pe.jump(resourceFound);
AnnotationHolder noCacheAnnot = new AnnotationHolder(NoCache.class.getName());
method.getAnnotations().add(noCacheAnnot);
} }
private boolean validate(MethodHolder method, Diagnostics diagnostics) { private boolean validate(MethodHolder method, Diagnostics diagnostics) {