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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 JSTypedLowering::JSTypedLowering(JSGraph* jsgraph) | 33 JSTypedLowering::JSTypedLowering(JSGraph* jsgraph) |
34 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) { | 34 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) { |
35 Factory* factory = zone()->isolate()->factory(); | 35 Factory* factory = zone()->isolate()->factory(); |
36 Handle<Object> zero = factory->NewNumber(0.0); | 36 Handle<Object> zero = factory->NewNumber(0.0); |
37 Handle<Object> one = factory->NewNumber(1.0); | 37 Handle<Object> one = factory->NewNumber(1.0); |
38 zero_range_ = Type::Range(zero, zero, zone()); | 38 zero_range_ = Type::Range(zero, zero, zone()); |
39 one_range_ = Type::Range(one, one, zone()); | 39 one_range_ = Type::Range(one, one, zone()); |
40 Handle<Object> thirtyone = factory->NewNumber(31.0); | 40 Handle<Object> thirtyone = factory->NewNumber(31.0); |
41 zero_thirtyone_range_ = Type::Range(zero, thirtyone, zone()); | 41 zero_thirtyone_range_ = Type::Range(zero, thirtyone, zone()); |
42 for (size_t k = 0; k < arraysize(shifted_int32_ranges_); ++k) { | 42 // TODO(jarin): Can we have a correctification of the stupid type system? |
43 Handle<Object> min = factory->NewNumber(kMinInt / (1 << k)); | 43 // These stupid work-arounds are just stupid! |
44 Handle<Object> max = factory->NewNumber(kMaxInt / (1 << k)); | 44 shifted_int32_ranges_[0] = Type::Signed32(); |
45 shifted_int32_ranges_[k] = Type::Range(min, max, zone()); | 45 if (SmiValuesAre31Bits()) { |
| 46 shifted_int32_ranges_[1] = Type::SignedSmall(); |
| 47 for (size_t k = 2; k < arraysize(shifted_int32_ranges_); ++k) { |
| 48 Handle<Object> min = factory->NewNumber(kMinInt / (1 << k)); |
| 49 Handle<Object> max = factory->NewNumber(kMaxInt / (1 << k)); |
| 50 shifted_int32_ranges_[k] = Type::Range(min, max, zone()); |
| 51 } |
| 52 } else { |
| 53 for (size_t k = 1; k < arraysize(shifted_int32_ranges_); ++k) { |
| 54 Handle<Object> min = factory->NewNumber(kMinInt / (1 << k)); |
| 55 Handle<Object> max = factory->NewNumber(kMaxInt / (1 << k)); |
| 56 shifted_int32_ranges_[k] = Type::Range(min, max, zone()); |
| 57 } |
46 } | 58 } |
47 } | 59 } |
48 | 60 |
49 | 61 |
50 Reduction JSTypedLowering::ReplaceEagerly(Node* old, Node* node) { | 62 Reduction JSTypedLowering::ReplaceEagerly(Node* old, Node* node) { |
51 NodeProperties::ReplaceWithValue(old, node, node); | 63 NodeProperties::ReplaceWithValue(old, node, node); |
52 return Changed(node); | 64 return Changed(node); |
53 } | 65 } |
54 | 66 |
55 | 67 |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 899 |
888 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { | 900 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { |
889 if (rhs == 0) return lhs; | 901 if (rhs == 0) return lhs; |
890 return graph()->NewNode(machine()->Word32Shl(), lhs, | 902 return graph()->NewNode(machine()->Word32Shl(), lhs, |
891 jsgraph()->Int32Constant(rhs)); | 903 jsgraph()->Int32Constant(rhs)); |
892 } | 904 } |
893 | 905 |
894 } // namespace compiler | 906 } // namespace compiler |
895 } // namespace internal | 907 } // namespace internal |
896 } // namespace v8 | 908 } // namespace v8 |
OLD | NEW |