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,6 +343,7 @@ public class TDecimalFormat extends TNumberFormat {
int mantissaLength = fastLn10(mantissa) + 1;
++exponent;
if (multiplier != 1) {
int multiplierDigits = fastLn10(multiplier);
int tenMultiplier = POW10_INT_ARRAY[multiplierDigits];
if (tenMultiplier == multiplier) {
@ -354,6 +355,7 @@ public class TDecimalFormat extends TNumberFormat {
mantissa *= multiplier;
mantissaLength = fastLn10(mantissa) + 1;
}
}
// Apply rounding if necessary
int roundingPos = exponent + getMaximumFractionDigits();

View File

@ -65,6 +65,10 @@ public final class TeaVMTestRunner {
.withDescription("qualified class names of transformers")
.withLongOpt("transformers")
.create("T"));
options.addOption(OptionBuilder
.withDescription("Incremental build")
.withLongOpt("incremental")
.create('i'));
if (args.length == 0) {
printUsage(options);
@ -97,6 +101,10 @@ public final class TeaVMTestRunner {
tool.getTransformers().add(instantiateTransformer(transformerType));
}
}
if (commandLine.hasOption('i')) {
tool.setIncremental(true);
}
args = commandLine.getArgs();
if (args.length == 0) {
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.Objects;
import java.util.Set;
import org.teavm.cache.NoCache;
import org.teavm.common.Graph;
import org.teavm.common.GraphIndexer;
import org.teavm.common.Loop;
@ -245,7 +246,7 @@ public class Decompiler {
}
public RegularMethodNode decompileRegular(MethodHolder method) {
if (regularMethodCache == null) {
if (regularMethodCache == null || method.getAnnotations().get(NoCache.class.getName()) != null) {
return decompileRegularCacheMiss(method);
}
RegularMethodNode node = regularMethodCache.get(method.getReference());
@ -283,7 +284,7 @@ public class Decompiler {
}
public AsyncMethodNode decompileAsync(MethodHolder method) {
if (regularMethodCache == null) {
if (regularMethodCache == null || method.getAnnotations().get(NoCache.class.getName()) != null) {
return decompileAsyncCacheMiss(method);
}
AsyncMethodNode node = regularMethodCache.getAsync(method.getReference());

View File

@ -17,6 +17,7 @@ package org.teavm.model;
import java.util.HashMap;
import java.util.Map;
import org.teavm.model.util.ProgramUtils;
/**
*
@ -27,11 +28,12 @@ public class InMemoryProgramCache implements ProgramCache {
@Override
public Program get(MethodReference method) {
return cache.get(method);
Program program = cache.get(method);
return program != null ? ProgramUtils.copy(program) : null;
}
@Override
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();
fileTable.update();
} catch (IOException e) {
log.info("Cache was not read");
log.info("Cache is missing");
}
vmBuilder.setClassLoader(classLoader).setClassSource(cachedClassSource);
} else {

View File

@ -17,6 +17,7 @@ package org.teavm.vm;
import java.io.*;
import java.util.*;
import org.teavm.cache.NoCache;
import org.teavm.codegen.*;
import org.teavm.common.ServiceRepository;
import org.teavm.debugging.information.DebugInformationEmitter;
@ -616,7 +617,9 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
if (method.getProgram() == null) {
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;
if (optimizedProgram == null) {
optimizedProgram = ProgramUtils.copy(method.getProgram());

View File

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