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-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 JSTypedLowering::JSTypedLowering(JSGraph* jsgraph) | 32 JSTypedLowering::JSTypedLowering(JSGraph* jsgraph) |
33 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) { | 33 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) { |
34 Factory* factory = zone()->isolate()->factory(); | 34 Factory* factory = zone()->isolate()->factory(); |
35 Handle<Object> zero = factory->NewNumber(0.0); | 35 Handle<Object> zero = factory->NewNumber(0.0); |
36 Handle<Object> one = factory->NewNumber(1.0); | 36 Handle<Object> one = factory->NewNumber(1.0); |
37 zero_range_ = Type::Range(zero, zero, zone()); | 37 zero_range_ = Type::Range(zero, zero, zone()); |
38 one_range_ = Type::Range(one, one, zone()); | 38 one_range_ = Type::Range(one, one, zone()); |
| 39 Handle<Object> thirtyone = factory->NewNumber(31.0); |
| 40 zero_thirtyone_range_ = Type::Range(zero, thirtyone, zone()); |
39 } | 41 } |
40 | 42 |
41 | 43 |
42 JSTypedLowering::~JSTypedLowering() {} | 44 JSTypedLowering::~JSTypedLowering() {} |
43 | 45 |
44 | 46 |
45 Reduction JSTypedLowering::ReplaceEagerly(Node* old, Node* node) { | 47 Reduction JSTypedLowering::ReplaceEagerly(Node* old, Node* node) { |
46 NodeProperties::ReplaceWithValue(old, node, node); | 48 NodeProperties::ReplaceWithValue(old, node, node); |
47 return Changed(node); | 49 return Changed(node); |
48 } | 50 } |
(...skipping 23 matching lines...) Expand all Loading... |
72 | 74 |
73 void ConvertInputsToString() { | 75 void ConvertInputsToString() { |
74 node_->ReplaceInput(0, ConvertToString(left())); | 76 node_->ReplaceInput(0, ConvertToString(left())); |
75 node_->ReplaceInput(1, ConvertToString(right())); | 77 node_->ReplaceInput(1, ConvertToString(right())); |
76 } | 78 } |
77 | 79 |
78 // Convert inputs for bitwise shift operation (ES5 spec 11.7). | 80 // Convert inputs for bitwise shift operation (ES5 spec 11.7). |
79 void ConvertInputsForShift(bool left_signed) { | 81 void ConvertInputsForShift(bool left_signed) { |
80 node_->ReplaceInput(0, ConvertToI32(left_signed, left())); | 82 node_->ReplaceInput(0, ConvertToI32(left_signed, left())); |
81 Node* rnum = ConvertToI32(false, right()); | 83 Node* rnum = ConvertToI32(false, right()); |
82 node_->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rnum, | 84 Type* rnum_type = NodeProperties::GetBounds(rnum).upper; |
83 jsgraph()->Int32Constant(0x1F))); | 85 if (!rnum_type->Is(lowering_->zero_thirtyone_range_)) { |
| 86 rnum = graph()->NewNode(machine()->Word32And(), rnum, |
| 87 jsgraph()->Int32Constant(0x1F)); |
| 88 } |
| 89 node_->ReplaceInput(1, rnum); |
84 } | 90 } |
85 | 91 |
86 void SwapInputs() { | 92 void SwapInputs() { |
87 Node* l = left(); | 93 Node* l = left(); |
88 Node* r = right(); | 94 Node* r = right(); |
89 node_->ReplaceInput(0, r); | 95 node_->ReplaceInput(0, r); |
90 node_->ReplaceInput(1, l); | 96 node_->ReplaceInput(1, l); |
91 std::swap(left_type_, right_type_); | 97 std::swap(left_type_, right_type_); |
92 } | 98 } |
93 | 99 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 return JSBuiltinReducer(jsgraph()).Reduce(node); | 800 return JSBuiltinReducer(jsgraph()).Reduce(node); |
795 default: | 801 default: |
796 break; | 802 break; |
797 } | 803 } |
798 return NoChange(); | 804 return NoChange(); |
799 } | 805 } |
800 | 806 |
801 } // namespace compiler | 807 } // namespace compiler |
802 } // namespace internal | 808 } // namespace internal |
803 } // namespace v8 | 809 } // namespace v8 |
OLD | NEW |