Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Side by Side Diff: pkg/compiler/lib/src/ssa/nodes.dart

Issue 2561533002: dart2js: Constant folding and specialization for remainder (Closed)
Patch Set: improve range analysis of remainder Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common/backend_api.dart' show BackendClasses; 7 import '../common/backend_api.dart' show BackendClasses;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 R visitLoopBranch(HLoopBranch node); 72 R visitLoopBranch(HLoopBranch node);
73 R visitMultiply(HMultiply node); 73 R visitMultiply(HMultiply node);
74 R visitNegate(HNegate node); 74 R visitNegate(HNegate node);
75 R visitNot(HNot node); 75 R visitNot(HNot node);
76 R visitOneShotInterceptor(HOneShotInterceptor node); 76 R visitOneShotInterceptor(HOneShotInterceptor node);
77 R visitParameterValue(HParameterValue node); 77 R visitParameterValue(HParameterValue node);
78 R visitPhi(HPhi node); 78 R visitPhi(HPhi node);
79 R visitRangeConversion(HRangeConversion node); 79 R visitRangeConversion(HRangeConversion node);
80 R visitReadModifyWrite(HReadModifyWrite node); 80 R visitReadModifyWrite(HReadModifyWrite node);
81 R visitRef(HRef node); 81 R visitRef(HRef node);
82 R visitRemainder(HRemainder node);
82 R visitReturn(HReturn node); 83 R visitReturn(HReturn node);
83 R visitShiftLeft(HShiftLeft node); 84 R visitShiftLeft(HShiftLeft node);
84 R visitShiftRight(HShiftRight node); 85 R visitShiftRight(HShiftRight node);
85 R visitStatic(HStatic node); 86 R visitStatic(HStatic node);
86 R visitStaticStore(HStaticStore node); 87 R visitStaticStore(HStaticStore node);
87 R visitStringConcat(HStringConcat node); 88 R visitStringConcat(HStringConcat node);
88 R visitStringify(HStringify node); 89 R visitStringify(HStringify node);
89 R visitSubtract(HSubtract node); 90 R visitSubtract(HSubtract node);
90 R visitSwitch(HSwitch node); 91 R visitSwitch(HSwitch node);
91 R visitThis(HThis node); 92 R visitThis(HThis node);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node); 380 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node);
380 visitNegate(HNegate node) => visitInvokeUnary(node); 381 visitNegate(HNegate node) => visitInvokeUnary(node);
381 visitNot(HNot node) => visitInstruction(node); 382 visitNot(HNot node) => visitInstruction(node);
382 visitOneShotInterceptor(HOneShotInterceptor node) => visitInvokeDynamic(node); 383 visitOneShotInterceptor(HOneShotInterceptor node) => visitInvokeDynamic(node);
383 visitPhi(HPhi node) => visitInstruction(node); 384 visitPhi(HPhi node) => visitInstruction(node);
384 visitMultiply(HMultiply node) => visitBinaryArithmetic(node); 385 visitMultiply(HMultiply node) => visitBinaryArithmetic(node);
385 visitParameterValue(HParameterValue node) => visitLocalValue(node); 386 visitParameterValue(HParameterValue node) => visitLocalValue(node);
386 visitRangeConversion(HRangeConversion node) => visitCheck(node); 387 visitRangeConversion(HRangeConversion node) => visitCheck(node);
387 visitReadModifyWrite(HReadModifyWrite node) => visitInstruction(node); 388 visitReadModifyWrite(HReadModifyWrite node) => visitInstruction(node);
388 visitRef(HRef node) => node.value.accept(this); 389 visitRef(HRef node) => node.value.accept(this);
390 visitRemainder(HRemainder node) => visitBinaryArithmetic(node);
389 visitReturn(HReturn node) => visitControlFlow(node); 391 visitReturn(HReturn node) => visitControlFlow(node);
390 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); 392 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node);
391 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); 393 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node);
392 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); 394 visitSubtract(HSubtract node) => visitBinaryArithmetic(node);
393 visitSwitch(HSwitch node) => visitControlFlow(node); 395 visitSwitch(HSwitch node) => visitControlFlow(node);
394 visitStatic(HStatic node) => visitInstruction(node); 396 visitStatic(HStatic node) => visitInstruction(node);
395 visitStaticStore(HStaticStore node) => visitInstruction(node); 397 visitStaticStore(HStaticStore node) => visitInstruction(node);
396 visitStringConcat(HStringConcat node) => visitInstruction(node); 398 visitStringConcat(HStringConcat node) => visitInstruction(node);
397 visitStringify(HStringify node) => visitInstruction(node); 399 visitStringify(HStringify node) => visitInstruction(node);
398 visitThis(HThis node) => visitParameterValue(node); 400 visitThis(HThis node) => visitParameterValue(node);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 static const int INTERFACE_TYPE_TYPECODE = 34; 876 static const int INTERFACE_TYPE_TYPECODE = 34;
875 static const int DYNAMIC_TYPE_TYPECODE = 35; 877 static const int DYNAMIC_TYPE_TYPECODE = 35;
876 static const int TRUNCATING_DIVIDE_TYPECODE = 36; 878 static const int TRUNCATING_DIVIDE_TYPECODE = 36;
877 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37; 879 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37;
878 880
879 static const int TYPE_INFO_READ_RAW_TYPECODE = 38; 881 static const int TYPE_INFO_READ_RAW_TYPECODE = 38;
880 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39; 882 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39;
881 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40; 883 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40;
882 884
883 static const int FOREIGN_CODE_TYPECODE = 41; 885 static const int FOREIGN_CODE_TYPECODE = 41;
886 static const int REMAINDER_TYPECODE = 42;
884 887
885 HInstruction(this.inputs, this.instructionType) 888 HInstruction(this.inputs, this.instructionType)
886 : id = idCounter++, 889 : id = idCounter++,
887 usedBy = <HInstruction>[] { 890 usedBy = <HInstruction>[] {
888 assert(inputs.every((e) => e != null)); 891 assert(inputs.every((e) => e != null));
889 } 892 }
890 893
891 int get hashCode => id; 894 int get hashCode => id;
892 895
893 bool useGvn() => _useGvn; 896 bool useGvn() => _useGvn;
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 : super(left, right, selector, type); 2004 : super(left, right, selector, type);
2002 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this); 2005 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this);
2003 2006
2004 BinaryOperation operation(ConstantSystem constantSystem) => 2007 BinaryOperation operation(ConstantSystem constantSystem) =>
2005 constantSystem.truncatingDivide; 2008 constantSystem.truncatingDivide;
2006 int typeCode() => HInstruction.TRUNCATING_DIVIDE_TYPECODE; 2009 int typeCode() => HInstruction.TRUNCATING_DIVIDE_TYPECODE;
2007 bool typeEquals(other) => other is HTruncatingDivide; 2010 bool typeEquals(other) => other is HTruncatingDivide;
2008 bool dataEquals(HInstruction other) => true; 2011 bool dataEquals(HInstruction other) => true;
2009 } 2012 }
2010 2013
2014 class HRemainder extends HBinaryArithmetic {
2015 HRemainder(
2016 HInstruction left, HInstruction right, Selector selector, TypeMask type)
2017 : super(left, right, selector, type);
2018 accept(HVisitor visitor) => visitor.visitRemainder(this);
2019
2020 BinaryOperation operation(ConstantSystem constantSystem) =>
2021 constantSystem.remainder;
2022 int typeCode() => HInstruction.REMAINDER_TYPECODE;
2023 bool typeEquals(other) => other is HRemainder;
2024 bool dataEquals(HInstruction other) => true;
2025 }
2026
2011 /** 2027 /**
2012 * An [HSwitch] instruction has one input for the incoming 2028 * An [HSwitch] instruction has one input for the incoming
2013 * value, and one input per constant that it can switch on. 2029 * value, and one input per constant that it can switch on.
2014 * Its block has one successor per constant, and one for the default. 2030 * Its block has one successor per constant, and one for the default.
2015 */ 2031 */
2016 class HSwitch extends HControlFlow { 2032 class HSwitch extends HControlFlow {
2017 HSwitch(List<HInstruction> inputs) : super(inputs); 2033 HSwitch(List<HInstruction> inputs) : super(inputs);
2018 2034
2019 HConstant constant(int index) => inputs[index + 1]; 2035 HConstant constant(int index) => inputs[index + 1];
2020 HInstruction get expression => inputs[0]; 2036 HInstruction get expression => inputs[0];
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 class HDynamicType extends HRuntimeType { 3464 class HDynamicType extends HRuntimeType {
3449 HDynamicType(DynamicType dartType, TypeMask instructionType) 3465 HDynamicType(DynamicType dartType, TypeMask instructionType)
3450 : super(const <HInstruction>[], dartType, instructionType); 3466 : super(const <HInstruction>[], dartType, instructionType);
3451 3467
3452 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3468 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3453 3469
3454 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3470 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3455 3471
3456 bool typeEquals(HInstruction other) => other is HDynamicType; 3472 bool typeEquals(HInstruction other) => other is HDynamicType;
3457 } 3473 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart ('k') | pkg/compiler/lib/src/ssa/ssa_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698