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-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 | 6 |
7 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Check if a string addition will definitely result in creating a ConsString, | 77 // Check if a string addition will definitely result in creating a ConsString, |
78 // i.e. if the combined length of the resulting string exceeds the ConsString | 78 // i.e. if the combined length of the resulting string exceeds the ConsString |
79 // minimum length. | 79 // minimum length. |
80 bool ShouldCreateConsString() { | 80 bool ShouldCreateConsString() { |
81 DCHECK_EQ(IrOpcode::kJSAdd, node_->opcode()); | 81 DCHECK_EQ(IrOpcode::kJSAdd, node_->opcode()); |
82 if (BothInputsAre(Type::String()) || | 82 if (BothInputsAre(Type::String()) || |
83 ((lowering_->flags() & JSTypedLowering::kDeoptimizationEnabled) && | 83 ((lowering_->flags() & JSTypedLowering::kDeoptimizationEnabled) && |
84 BinaryOperationHintOf(node_->op()) == BinaryOperationHint::kString)) { | 84 BinaryOperationHintOf(node_->op()) == BinaryOperationHint::kString)) { |
85 HeapObjectBinopMatcher m(node_); | 85 HeapObjectBinopMatcher m(node_); |
86 if (m.left().HasValue() && m.left().Value()->IsString()) { | |
87 Handle<String> left_string = Handle<String>::cast(m.left().Value()); | |
88 if (left_string->length() >= ConsString::kMinLength) return true; | |
89 } | |
90 if (m.right().HasValue() && m.right().Value()->IsString()) { | 86 if (m.right().HasValue() && m.right().Value()->IsString()) { |
91 Handle<String> right_string = Handle<String>::cast(m.right().Value()); | 87 Handle<String> right_string = Handle<String>::cast(m.right().Value()); |
92 if (right_string->length() >= ConsString::kMinLength) return true; | 88 if (right_string->length() >= ConsString::kMinLength) return true; |
93 } | 89 } |
| 90 if (m.left().HasValue() && m.left().Value()->IsString()) { |
| 91 Handle<String> left_string = Handle<String>::cast(m.left().Value()); |
| 92 if (left_string->length() >= ConsString::kMinLength) { |
| 93 // The invariant for ConsString requires the left hand side to be |
| 94 // a sequential or external string if the right hand side is the |
| 95 // empty string. Since we don't know anything about the right hand |
| 96 // side here, we must ensure that the left hand side satisfy the |
| 97 // constraints independent of the right hand side. |
| 98 return left_string->IsSeqString() || left_string->IsExternalString(); |
| 99 } |
| 100 } |
94 } | 101 } |
95 return false; | 102 return false; |
96 } | 103 } |
97 | 104 |
98 void ConvertInputsToNumber() { | 105 void ConvertInputsToNumber() { |
99 // To convert the inputs to numbers, we have to provide frame states | 106 // To convert the inputs to numbers, we have to provide frame states |
100 // for lazy bailouts in the ToNumber conversions. | 107 // for lazy bailouts in the ToNumber conversions. |
101 // We use a little hack here: we take the frame state before the binary | 108 // We use a little hack here: we take the frame state before the binary |
102 // operation and use it to construct the frame states for the conversion | 109 // operation and use it to construct the frame states for the conversion |
103 // so that after the deoptimization, the binary operation IC gets | 110 // so that after the deoptimization, the binary operation IC gets |
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 } | 2179 } |
2173 | 2180 |
2174 | 2181 |
2175 CompilationDependencies* JSTypedLowering::dependencies() const { | 2182 CompilationDependencies* JSTypedLowering::dependencies() const { |
2176 return dependencies_; | 2183 return dependencies_; |
2177 } | 2184 } |
2178 | 2185 |
2179 } // namespace compiler | 2186 } // namespace compiler |
2180 } // namespace internal | 2187 } // namespace internal |
2181 } // namespace v8 | 2188 } // namespace v8 |
OLD | NEW |