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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/builtin_operator.dart

Issue 1184963006: dart2js cps: Better 'is int' checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update comment Created 5 years, 6 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library builtin_operator; 4 library builtin_operator;
5 // This is shared by the CPS and Tree IRs. 5 // This is shared by the CPS and Tree IRs.
6 // Both cps_ir_nodes and tree_ir_nodes import and re-export this file. 6 // Both cps_ir_nodes and tree_ir_nodes import and re-export this file.
7 7
8 /// An operator supported natively in the CPS and Tree IRs using the 8 /// An operator supported natively in the CPS and Tree IRs using the
9 /// `ApplyBuiltinOperator` instructions. 9 /// `ApplyBuiltinOperator` instructions.
10 /// 10 ///
11 /// These operators are pure in the sense that they cannot throw, diverge, 11 /// These operators are pure in the sense that they cannot throw, diverge,
12 /// have observable side-effects, return new objects, nor depend on any 12 /// have observable side-effects, return new objects, nor depend on any
13 /// mutable state. 13 /// mutable state.
14 /// 14 ///
15 /// Most operators place restrictions on the values that may be given as 15 /// Most operators place restrictions on the values that may be given as
16 /// argument; their behaviour is unspecified if those requirements are violated. 16 /// argument; their behaviour is unspecified if those requirements are violated.
17 /// 17 ///
18 /// In all cases, the word "null" refers to the Dart null object, corresponding 18 /// In all cases, the word "null" refers to the Dart null object, corresponding
19 /// to both JS null and JS undefined. 19 /// to both JS null and JS undefined.
20 ///
21 /// Some operators, notably [IsFloor] and [IsNumberAndFloor], take "repeated"
22 /// arguments to reflect the number of times the given value is referenced
23 /// by the generated code. The tree IR needs to know the number of references
24 /// to safely propagate assignments.
20 enum BuiltinOperator { 25 enum BuiltinOperator {
21 /// The numeric binary operators must take two numbers as argument. 26 /// The numeric binary operators must take two numbers as argument.
22 /// The bitwise operators coerce the result to an unsigned integer, but 27 /// The bitwise operators coerce the result to an unsigned integer, but
23 /// otherwise these all behave like the corresponding JS operator. 28 /// otherwise these all behave like the corresponding JS operator.
24 NumAdd, 29 NumAdd,
25 NumSubtract, 30 NumSubtract,
26 NumMultiply, 31 NumMultiply,
27 NumAnd, 32 NumAnd,
28 NumOr, 33 NumOr,
29 NumXor, 34 NumXor,
(...skipping 18 matching lines...) Expand all
48 /// One of the following must hold: 53 /// One of the following must hold:
49 /// - At least one argument is null. 54 /// - At least one argument is null.
50 /// - Arguments are both strings, or both booleans, or both numbers. 55 /// - Arguments are both strings, or both booleans, or both numbers.
51 LooseEq, 56 LooseEq,
52 57
53 /// Negated version of [LooseEq]. Introduced by [LogicalRewriter] in Tree IR. 58 /// Negated version of [LooseEq]. Introduced by [LogicalRewriter] in Tree IR.
54 LooseNeq, 59 LooseNeq,
55 60
56 /// Returns true if the argument is false, +0. -0, NaN, the empty string, 61 /// Returns true if the argument is false, +0. -0, NaN, the empty string,
57 /// or null. 62 /// or null.
58 IsFalsy 63 IsFalsy,
64
65 /// Returns true if the argument is a number.
66 ///
67 /// Compiles to `typeof x === 'number'`
68 IsNumber,
69
70 /// Returns true if the argument is not a number.
71 ///
72 /// Compiles to `typeof x !== 'number'`.
73 IsNotNumber,
74
75 /// Returns true if the argument is an integer, false if it is a double or
76 /// null, and unspecified if it is anything else.
77 ///
78 /// The argument must be repeated 2 times.
79 ///
80 /// Compiles to `Math.floor(x) === x`
81 IsFloor,
82
83 /// Returns true if the argument is an integer.
84 ///
85 /// The argument must be repeated 3 times.
86 ///
87 /// Compiles to `typeof x === 'number' && Math.floor(x) === x`
88 IsNumberAndFloor,
59 } 89 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698