| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 case Runtime::kInlineConstructDouble: | 38 case Runtime::kInlineConstructDouble: |
| 39 return ReduceConstructDouble(node); | 39 return ReduceConstructDouble(node); |
| 40 case Runtime::kInlineCreateIterResultObject: | 40 case Runtime::kInlineCreateIterResultObject: |
| 41 return ReduceCreateIterResultObject(node); | 41 return ReduceCreateIterResultObject(node); |
| 42 case Runtime::kInlineDeoptimizeNow: | 42 case Runtime::kInlineDeoptimizeNow: |
| 43 return ReduceDeoptimizeNow(node); | 43 return ReduceDeoptimizeNow(node); |
| 44 case Runtime::kInlineDoubleHi: | 44 case Runtime::kInlineDoubleHi: |
| 45 return ReduceDoubleHi(node); | 45 return ReduceDoubleHi(node); |
| 46 case Runtime::kInlineDoubleLo: | 46 case Runtime::kInlineDoubleLo: |
| 47 return ReduceDoubleLo(node); | 47 return ReduceDoubleLo(node); |
| 48 case Runtime::kInlineIncrementStatsCounter: | |
| 49 return ReduceIncrementStatsCounter(node); | |
| 50 case Runtime::kInlineIsArray: | 48 case Runtime::kInlineIsArray: |
| 51 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); | 49 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); |
| 52 case Runtime::kInlineIsTypedArray: | 50 case Runtime::kInlineIsTypedArray: |
| 53 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); | 51 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); |
| 54 case Runtime::kInlineIsRegExp: | 52 case Runtime::kInlineIsRegExp: |
| 55 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); | 53 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); |
| 56 case Runtime::kInlineIsJSReceiver: | 54 case Runtime::kInlineIsJSReceiver: |
| 57 return ReduceIsJSReceiver(node); | 55 return ReduceIsJSReceiver(node); |
| 58 case Runtime::kInlineIsSmi: | 56 case Runtime::kInlineIsSmi: |
| 59 return ReduceIsSmi(node); | 57 return ReduceIsSmi(node); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { | 149 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { |
| 152 return Change(node, machine()->Float64ExtractHighWord32()); | 150 return Change(node, machine()->Float64ExtractHighWord32()); |
| 153 } | 151 } |
| 154 | 152 |
| 155 | 153 |
| 156 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { | 154 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { |
| 157 return Change(node, machine()->Float64ExtractLowWord32()); | 155 return Change(node, machine()->Float64ExtractLowWord32()); |
| 158 } | 156 } |
| 159 | 157 |
| 160 | 158 |
| 161 Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) { | |
| 162 if (!FLAG_native_code_counters) return ChangeToUndefined(node); | |
| 163 HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0)); | |
| 164 if (!m.HasValue() || !m.Value()->IsString()) { | |
| 165 return ChangeToUndefined(node); | |
| 166 } | |
| 167 base::SmartArrayPointer<char> name = | |
| 168 Handle<String>::cast(m.Value())->ToCString(); | |
| 169 StatsCounter counter(jsgraph()->isolate(), name.get()); | |
| 170 if (!counter.Enabled()) return ChangeToUndefined(node); | |
| 171 | |
| 172 Node* effect = NodeProperties::GetEffectInput(node); | |
| 173 Node* control = NodeProperties::GetControlInput(node); | |
| 174 FieldAccess access = AccessBuilder::ForStatsCounter(); | |
| 175 Node* cnt = jsgraph()->ExternalConstant(ExternalReference(&counter)); | |
| 176 Node* load = | |
| 177 graph()->NewNode(simplified()->LoadField(access), cnt, effect, control); | |
| 178 Node* inc = | |
| 179 graph()->NewNode(machine()->Int32Add(), load, jsgraph()->OneConstant()); | |
| 180 Node* store = graph()->NewNode(simplified()->StoreField(access), cnt, inc, | |
| 181 load, control); | |
| 182 return ChangeToUndefined(node, store); | |
| 183 } | |
| 184 | |
| 185 | |
| 186 Reduction JSIntrinsicLowering::ReduceIsInstanceType( | 159 Reduction JSIntrinsicLowering::ReduceIsInstanceType( |
| 187 Node* node, InstanceType instance_type) { | 160 Node* node, InstanceType instance_type) { |
| 188 // if (%_IsSmi(value)) { | 161 // if (%_IsSmi(value)) { |
| 189 // return false; | 162 // return false; |
| 190 // } else { | 163 // } else { |
| 191 // return %_GetInstanceType(%_GetMap(value)) == instance_type; | 164 // return %_GetInstanceType(%_GetMap(value)) == instance_type; |
| 192 // } | 165 // } |
| 193 Node* value = NodeProperties::GetValueInput(node, 0); | 166 Node* value = NodeProperties::GetValueInput(node, 0); |
| 194 Node* effect = NodeProperties::GetEffectInput(node); | 167 Node* effect = NodeProperties::GetEffectInput(node); |
| 195 Node* control = NodeProperties::GetControlInput(node); | 168 Node* control = NodeProperties::GetControlInput(node); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 } | 576 } |
| 604 | 577 |
| 605 | 578 |
| 606 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 579 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
| 607 return jsgraph()->simplified(); | 580 return jsgraph()->simplified(); |
| 608 } | 581 } |
| 609 | 582 |
| 610 } // namespace compiler | 583 } // namespace compiler |
| 611 } // namespace internal | 584 } // namespace internal |
| 612 } // namespace v8 | 585 } // namespace v8 |
| OLD | NEW |