OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 | 6 |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 return NoChange(); | 880 return NoChange(); |
881 } | 881 } |
882 | 882 |
883 // ES6 section 20.1.2.13 Number.parseInt ( string, radix ) | 883 // ES6 section 20.1.2.13 Number.parseInt ( string, radix ) |
884 Reduction JSBuiltinReducer::ReduceNumberParseInt(Node* node) { | 884 Reduction JSBuiltinReducer::ReduceNumberParseInt(Node* node) { |
885 JSCallReduction r(node); | 885 JSCallReduction r(node); |
886 if (r.InputsMatchOne(type_cache_.kSafeInteger) || | 886 if (r.InputsMatchOne(type_cache_.kSafeInteger) || |
887 r.InputsMatchTwo(type_cache_.kSafeInteger, | 887 r.InputsMatchTwo(type_cache_.kSafeInteger, |
888 type_cache_.kZeroOrUndefined) || | 888 type_cache_.kZeroOrUndefined) || |
889 r.InputsMatchTwo(type_cache_.kSafeInteger, type_cache_.kTenOrUndefined)) { | 889 r.InputsMatchTwo(type_cache_.kSafeInteger, type_cache_.kTenOrUndefined)) { |
890 // Number.parseInt(a:safe-integer) -> NumberToInt32(a) | 890 // Number.parseInt(a:safe-integer) -> a |
891 // Number.parseInt(a:safe-integer,b:#0\/undefined) -> NumberToInt32(a) | 891 // Number.parseInt(a:safe-integer,b:#0\/undefined) -> a |
892 // Number.parseInt(a:safe-integer,b:#10\/undefined) -> NumberToInt32(a) | 892 // Number.parseInt(a:safe-integer,b:#10\/undefined) -> a |
893 Node* input = r.GetJSCallInput(0); | 893 Node* value = r.GetJSCallInput(0); |
894 Node* value = graph()->NewNode(simplified()->NumberToInt32(), input); | |
895 return Replace(value); | 894 return Replace(value); |
896 } | 895 } |
897 return NoChange(); | 896 return NoChange(); |
898 } | 897 } |
899 | 898 |
900 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) | 899 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) |
901 Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) { | 900 Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) { |
902 JSCallReduction r(node); | 901 JSCallReduction r(node); |
903 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 902 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
904 // String.fromCharCode(a:plain-primitive) -> StringFromCharCode(a) | 903 // String.fromCharCode(a:plain-primitive) -> StringFromCharCode(a) |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 return jsgraph()->simplified(); | 1439 return jsgraph()->simplified(); |
1441 } | 1440 } |
1442 | 1441 |
1443 JSOperatorBuilder* JSBuiltinReducer::javascript() const { | 1442 JSOperatorBuilder* JSBuiltinReducer::javascript() const { |
1444 return jsgraph()->javascript(); | 1443 return jsgraph()->javascript(); |
1445 } | 1444 } |
1446 | 1445 |
1447 } // namespace compiler | 1446 } // namespace compiler |
1448 } // namespace internal | 1447 } // namespace internal |
1449 } // namespace v8 | 1448 } // namespace v8 |
OLD | NEW |