Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 10886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10897 | 10897 |
| 10898 if (!maybe_string_add && !is_strong(strength)) { | 10898 if (!maybe_string_add && !is_strong(strength)) { |
| 10899 left = TruncateToNumber(left, &left_type); | 10899 left = TruncateToNumber(left, &left_type); |
| 10900 right = TruncateToNumber(right, &right_type); | 10900 right = TruncateToNumber(right, &right_type); |
| 10901 } | 10901 } |
| 10902 | 10902 |
| 10903 // Special case for string addition here. | 10903 // Special case for string addition here. |
| 10904 if (op == Token::ADD && | 10904 if (op == Token::ADD && |
| 10905 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { | 10905 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { |
| 10906 // Validate type feedback for left argument. | 10906 // Validate type feedback for left argument. |
| 10907 if (left_type->Is(Type::String())) { | 10907 if (left_type->Is(Type::String())) { |
|
Jarin
2015/08/13 06:23:51
Could not you say here
if (left_type->Is(Type::S
Benedikt Meurer
2015/08/13 06:31:13
Restructured to simplify strong case as per offlin
| |
| 10908 left = BuildCheckString(left); | 10908 left = BuildCheckString(left); |
| 10909 } | 10909 } |
| 10910 | 10910 |
| 10911 // Validate type feedback for right argument. | 10911 // Validate type feedback for right argument. |
| 10912 if (right_type->Is(Type::String())) { | 10912 if (right_type->Is(Type::String())) { |
| 10913 right = BuildCheckString(right); | 10913 right = BuildCheckString(right); |
| 10914 } | 10914 } |
| 10915 | 10915 |
| 10916 // Convert left argument as necessary. | 10916 // Convert left argument as necessary. |
| 10917 if (left_type->Is(Type::Number()) && !is_strong(strength)) { | 10917 if (!left_type->Is(Type::String())) { |
| 10918 DCHECK(right_type->Is(Type::String())); | 10918 DCHECK(right_type->Is(Type::String())); |
| 10919 left = BuildNumberToString(left, left_type); | 10919 if (is_strong(strength)) { |
| 10920 } else if (!left_type->Is(Type::String())) { | 10920 // In strong mode, if the left hand side of an additition is a string, |
|
Jarin
2015/08/13 06:23:50
additition -> addition (Here and below.)
Benedikt Meurer
2015/08/13 06:31:13
Done.
| |
| 10921 DCHECK(right_type->Is(Type::String())); | 10921 // the right hand side must be a string too. |
| 10922 HValue* function = AddLoadJSBuiltin( | 10922 left = BuildCheckString(left); |
| 10923 is_strong(strength) ? Builtins::STRING_ADD_RIGHT_STRONG | 10923 } else if (left_type->Is(Type::Number())) { |
| 10924 : Builtins::STRING_ADD_RIGHT); | 10924 left = BuildNumberToString(left, left_type); |
| 10925 Add<HPushArguments>(left, right); | 10925 } else { |
| 10926 return AddUncasted<HInvokeFunction>(function, 2); | 10926 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); |
| 10927 Add<HPushArguments>(left, right); | |
| 10928 return AddUncasted<HInvokeFunction>(function, 2); | |
| 10929 } | |
| 10927 } | 10930 } |
| 10928 | 10931 |
| 10929 // Convert right argument as necessary. | 10932 // Convert right argument as necessary. |
| 10930 if (right_type->Is(Type::Number()) && !is_strong(strength)) { | 10933 if (!right_type->Is(Type::String())) { |
| 10931 DCHECK(left_type->Is(Type::String())); | 10934 DCHECK(left_type->Is(Type::String())); |
| 10932 right = BuildNumberToString(right, right_type); | 10935 if (is_strong(strength)) { |
| 10933 } else if (!right_type->Is(Type::String())) { | 10936 // In strong mode, if the right hand side of an additition is a string, |
| 10934 DCHECK(left_type->Is(Type::String())); | 10937 // the left hand side must be a string too. |
| 10935 HValue* function = AddLoadJSBuiltin(is_strong(strength) | 10938 right = BuildCheckString(right); |
| 10936 ? Builtins::STRING_ADD_LEFT_STRONG | 10939 } else if (right_type->Is(Type::Number())) { |
| 10937 : Builtins::STRING_ADD_LEFT); | 10940 right = BuildNumberToString(right, right_type); |
| 10938 Add<HPushArguments>(left, right); | 10941 } else { |
| 10939 return AddUncasted<HInvokeFunction>(function, 2); | 10942 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); |
| 10943 Add<HPushArguments>(left, right); | |
| 10944 return AddUncasted<HInvokeFunction>(function, 2); | |
| 10945 } | |
| 10940 } | 10946 } |
| 10941 | 10947 |
| 10942 // Fast paths for empty constant strings. | 10948 // Fast paths for empty constant strings. |
| 10943 Handle<String> left_string = | 10949 Handle<String> left_string = |
| 10944 left->IsConstant() && HConstant::cast(left)->HasStringValue() | 10950 left->IsConstant() && HConstant::cast(left)->HasStringValue() |
| 10945 ? HConstant::cast(left)->StringValue() | 10951 ? HConstant::cast(left)->StringValue() |
| 10946 : Handle<String>(); | 10952 : Handle<String>(); |
| 10947 Handle<String> right_string = | 10953 Handle<String> right_string = |
| 10948 right->IsConstant() && HConstant::cast(right)->HasStringValue() | 10954 right->IsConstant() && HConstant::cast(right)->HasStringValue() |
| 10949 ? HConstant::cast(right)->StringValue() | 10955 ? HConstant::cast(right)->StringValue() |
| (...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13432 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13438 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13433 } | 13439 } |
| 13434 | 13440 |
| 13435 #ifdef DEBUG | 13441 #ifdef DEBUG |
| 13436 graph_->Verify(false); // No full verify. | 13442 graph_->Verify(false); // No full verify. |
| 13437 #endif | 13443 #endif |
| 13438 } | 13444 } |
| 13439 | 13445 |
| 13440 } // namespace internal | 13446 } // namespace internal |
| 13441 } // namespace v8 | 13447 } // namespace v8 |
| OLD | NEW |