Simplify and enable by default inline/optimize/assertions
Inline, optimize, call assertions, param assertions are turned on by default now almost everywhere; invert their meaning
This commit is contained in:
@@ -535,7 +535,7 @@ public class AsmUtil {
|
||||
@NotNull FunctionDescriptor descriptor,
|
||||
@NotNull FrameMap frameMap
|
||||
) {
|
||||
if (!state.isGenerateNotNullParamAssertions()) return;
|
||||
if (!state.isParamAssertionsEnabled()) return;
|
||||
|
||||
// Private method is not accessible from other classes, no assertions needed
|
||||
if (getVisibilityAccessFlag(descriptor) == ACC_PRIVATE) return;
|
||||
@@ -580,7 +580,7 @@ public class AsmUtil {
|
||||
@NotNull CallableDescriptor descriptor,
|
||||
@NotNull String assertMethodToCall
|
||||
) {
|
||||
if (!state.isGenerateNotNullAssertions()) return;
|
||||
if (!state.isCallAssertionsEnabled()) return;
|
||||
|
||||
if (!isDeclaredInJava(descriptor)) return;
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
||||
public class InlineCodegenUtil {
|
||||
public static final int API = Opcodes.ASM5;
|
||||
public static final String INVOKE = "invoke";
|
||||
public static final boolean DEFAULT_INLINE_FLAG = true;
|
||||
|
||||
public static final String CAPTURED_FIELD_PREFIX = "$";
|
||||
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ import org.jetbrains.jet.codegen.optimization.boxing.RedundantBoxingMethodTransf
|
||||
import org.jetbrains.jet.codegen.optimization.boxing.RedundantNullCheckMethodTransformer;
|
||||
import org.jetbrains.jet.codegen.optimization.transformer.MethodTransformer;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.jetbrains.org.objectweb.asm.tree.LocalVariableNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
import org.jetbrains.org.objectweb.asm.util.Textifier;
|
||||
@@ -48,7 +49,7 @@ public class OptimizationMethodVisitor extends MethodVisitor {
|
||||
@Nullable String signature,
|
||||
@Nullable String[] exceptions
|
||||
) {
|
||||
super(OptimizationUtils.API);
|
||||
super(Opcodes.ASM5);
|
||||
this.delegate = delegate;
|
||||
this.methodNode = new MethodNode(access, name, desc, signature, exceptions);
|
||||
this.methodNode.localVariables = new ArrayList<LocalVariableNode>(5);
|
||||
@@ -69,7 +70,7 @@ public class OptimizationMethodVisitor extends MethodVisitor {
|
||||
MAIN_METHOD_TRANSFORMER.transform("fake", methodNode);
|
||||
}
|
||||
|
||||
methodNode.accept(new EndIgnoringMethodVisitorDecorator(OptimizationUtils.API, delegate));
|
||||
methodNode.accept(new EndIgnoringMethodVisitorDecorator(Opcodes.ASM5, delegate));
|
||||
|
||||
|
||||
// In case of empty instructions list MethodNode.accept doesn't call visitLocalVariables of delegate
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* 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.jetbrains.jet.codegen.optimization;
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
|
||||
public class OptimizationUtils {
|
||||
public final static int API = Opcodes.ASM5;
|
||||
public static final boolean DEFAULT_OPTIMIZATION_FLAG = true;
|
||||
}
|
||||
+1
-2
@@ -20,7 +20,6 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.optimization.OptimizationUtils;
|
||||
import org.jetbrains.jet.codegen.optimization.transformer.MethodTransformer;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -279,7 +278,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
|
||||
@NotNull Pair<AbstractInsnNode, Type> castWithType
|
||||
) {
|
||||
AbstractInsnNode castInsn = castWithType.getFirst();
|
||||
MethodNode castInsnsListener = new MethodNode(OptimizationUtils.API);
|
||||
MethodNode castInsnsListener = new MethodNode(Opcodes.ASM5);
|
||||
new InstructionAdapter(castInsnsListener).cast(value.getPrimitiveType(), castWithType.getSecond());
|
||||
|
||||
for (AbstractInsnNode insn : castInsnsListener.instructions.toArray()) {
|
||||
|
||||
@@ -21,10 +21,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.codegen.optimization.OptimizationClassBuilderFactory;
|
||||
import org.jetbrains.jet.codegen.optimization.OptimizationUtils;
|
||||
import org.jetbrains.jet.codegen.when.MappingsClassesForWhenByEnum;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
@@ -89,13 +87,13 @@ public class GenerationState {
|
||||
@NotNull
|
||||
private final JetTypeMapper typeMapper;
|
||||
|
||||
private final boolean generateNotNullAssertions;
|
||||
private final boolean disableCallAssertions;
|
||||
|
||||
private final boolean generateNotNullParamAssertions;
|
||||
private final boolean disableParamAssertions;
|
||||
|
||||
private final GenerateClassFilter generateClassFilter;
|
||||
|
||||
private final boolean inlineEnabled;
|
||||
private final boolean disableInline;
|
||||
|
||||
@Nullable
|
||||
private List<ScriptDescriptor> earlierScriptsForReplInterpreter;
|
||||
@@ -121,10 +119,8 @@ public class GenerationState {
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> files
|
||||
) {
|
||||
this(project, builderFactory, Progress.DEAF, module, bindingContext, files, true, false, GenerateClassFilter.GENERATE_ALL,
|
||||
InlineCodegenUtil.DEFAULT_INLINE_FLAG, OptimizationUtils.DEFAULT_OPTIMIZATION_FLAG,
|
||||
null, null, DiagnosticHolder.DO_NOTHING, null
|
||||
);
|
||||
this(project, builderFactory, Progress.DEAF, module, bindingContext, files, true, true, GenerateClassFilter.GENERATE_ALL,
|
||||
false, false, null, null, DiagnosticHolder.DO_NOTHING, null);
|
||||
}
|
||||
|
||||
public GenerationState(
|
||||
@@ -134,11 +130,11 @@ public class GenerationState {
|
||||
@NotNull ModuleDescriptor module,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> files,
|
||||
boolean generateNotNullAssertions,
|
||||
boolean generateNotNullParamAssertions,
|
||||
boolean disableCallAssertions,
|
||||
boolean disableParamAssertions,
|
||||
GenerateClassFilter generateClassFilter,
|
||||
boolean inlineEnabled,
|
||||
boolean optimizationEnabled,
|
||||
boolean disableInline,
|
||||
boolean disableOptimization,
|
||||
@Nullable Collection<FqName> packagesWithRemovedFiles,
|
||||
@Nullable String moduleId,
|
||||
@NotNull DiagnosticHolder diagnostics,
|
||||
@@ -151,7 +147,7 @@ public class GenerationState {
|
||||
this.moduleId = moduleId;
|
||||
this.packagesWithRemovedFiles = packagesWithRemovedFiles == null ? Collections.<FqName>emptySet() : packagesWithRemovedFiles;
|
||||
this.classBuilderMode = builderFactory.getClassBuilderMode();
|
||||
this.inlineEnabled = inlineEnabled;
|
||||
this.disableInline = disableInline;
|
||||
|
||||
this.bindingTrace = new DelegatingBindingTrace(bindingContext, "trace in GenerationState");
|
||||
this.bindingContext = bindingTrace.getBindingContext();
|
||||
@@ -161,15 +157,15 @@ public class GenerationState {
|
||||
|
||||
this.intrinsics = new IntrinsicMethods();
|
||||
|
||||
if (optimizationEnabled) {
|
||||
if (!disableOptimization) {
|
||||
builderFactory = new OptimizationClassBuilderFactory(builderFactory);
|
||||
}
|
||||
|
||||
this.classFileFactory = new ClassFileFactory(this, new BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
builderFactory, this.bindingContext, diagnostics));
|
||||
|
||||
this.generateNotNullAssertions = generateNotNullAssertions;
|
||||
this.generateNotNullParamAssertions = generateNotNullParamAssertions;
|
||||
this.disableCallAssertions = disableCallAssertions;
|
||||
this.disableParamAssertions = disableParamAssertions;
|
||||
this.generateClassFilter = generateClassFilter;
|
||||
|
||||
ReflectionTypes reflectionTypes = new ReflectionTypes(module);
|
||||
@@ -231,12 +227,12 @@ public class GenerationState {
|
||||
return mappingsClassesForWhenByEnum;
|
||||
}
|
||||
|
||||
public boolean isGenerateNotNullAssertions() {
|
||||
return generateNotNullAssertions;
|
||||
public boolean isCallAssertionsEnabled() {
|
||||
return !disableCallAssertions;
|
||||
}
|
||||
|
||||
public boolean isGenerateNotNullParamAssertions() {
|
||||
return generateNotNullParamAssertions;
|
||||
public boolean isParamAssertionsEnabled() {
|
||||
return !disableParamAssertions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -250,7 +246,7 @@ public class GenerationState {
|
||||
}
|
||||
|
||||
public boolean isInlineEnabled() {
|
||||
return inlineEnabled;
|
||||
return !disableInline;
|
||||
}
|
||||
|
||||
public void beforeCompile() {
|
||||
|
||||
Reference in New Issue
Block a user