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/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 10977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10988 if (right_type->Is(Type::String())) { | 10988 if (right_type->Is(Type::String())) { |
10989 right = BuildCheckString(right); | 10989 right = BuildCheckString(right); |
10990 } | 10990 } |
10991 | 10991 |
10992 // Convert left argument as necessary. | 10992 // Convert left argument as necessary. |
10993 if (left_type->Is(Type::Number())) { | 10993 if (left_type->Is(Type::Number())) { |
10994 DCHECK(right_type->Is(Type::String())); | 10994 DCHECK(right_type->Is(Type::String())); |
10995 left = BuildNumberToString(left, left_type); | 10995 left = BuildNumberToString(left, left_type); |
10996 } else if (!left_type->Is(Type::String())) { | 10996 } else if (!left_type->Is(Type::String())) { |
10997 DCHECK(right_type->Is(Type::String())); | 10997 DCHECK(right_type->Is(Type::String())); |
10998 HValue* function = | 10998 // TODO(bmeurer): We might want to optimize this, because we already |
10999 AddLoadJSBuiltin(Context::STRING_ADD_RIGHT_BUILTIN_INDEX); | 10999 // know that the right hand side is a string. |
11000 Add<HPushArguments>(left, right); | 11000 Add<HPushArguments>(left, right); |
11001 return AddUncasted<HInvokeFunction>(function, 2); | 11001 return AddUncasted<HCallRuntime>(Runtime::FunctionForId(Runtime::kAdd), |
| 11002 2); |
11002 } | 11003 } |
11003 | 11004 |
11004 // Convert right argument as necessary. | 11005 // Convert right argument as necessary. |
11005 if (right_type->Is(Type::Number())) { | 11006 if (right_type->Is(Type::Number())) { |
11006 DCHECK(left_type->Is(Type::String())); | 11007 DCHECK(left_type->Is(Type::String())); |
11007 right = BuildNumberToString(right, right_type); | 11008 right = BuildNumberToString(right, right_type); |
11008 } else if (!right_type->Is(Type::String())) { | 11009 } else if (!right_type->Is(Type::String())) { |
11009 DCHECK(left_type->Is(Type::String())); | 11010 DCHECK(left_type->Is(Type::String())); |
11010 HValue* function = | 11011 // TODO(bmeurer): We might want to optimize this, because we already |
11011 AddLoadJSBuiltin(Context::STRING_ADD_LEFT_BUILTIN_INDEX); | 11012 // know that the left hand side is a string. |
11012 Add<HPushArguments>(left, right); | 11013 Add<HPushArguments>(left, right); |
11013 return AddUncasted<HInvokeFunction>(function, 2); | 11014 return AddUncasted<HCallRuntime>(Runtime::FunctionForId(Runtime::kAdd), |
| 11015 2); |
11014 } | 11016 } |
11015 } | 11017 } |
11016 | 11018 |
11017 // Fast paths for empty constant strings. | 11019 // Fast paths for empty constant strings. |
11018 Handle<String> left_string = | 11020 Handle<String> left_string = |
11019 left->IsConstant() && HConstant::cast(left)->HasStringValue() | 11021 left->IsConstant() && HConstant::cast(left)->HasStringValue() |
11020 ? HConstant::cast(left)->StringValue() | 11022 ? HConstant::cast(left)->StringValue() |
11021 : Handle<String>(); | 11023 : Handle<String>(); |
11022 Handle<String> right_string = | 11024 Handle<String> right_string = |
11023 right->IsConstant() && HConstant::cast(right)->HasStringValue() | 11025 right->IsConstant() && HConstant::cast(right)->HasStringValue() |
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13552 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13554 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13553 } | 13555 } |
13554 | 13556 |
13555 #ifdef DEBUG | 13557 #ifdef DEBUG |
13556 graph_->Verify(false); // No full verify. | 13558 graph_->Verify(false); // No full verify. |
13557 #endif | 13559 #endif |
13558 } | 13560 } |
13559 | 13561 |
13560 } // namespace internal | 13562 } // namespace internal |
13561 } // namespace v8 | 13563 } // namespace v8 |
OLD | NEW |