Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: src/hydrogen.cc

Issue 1109223004: [strong] Disallow implicit conversions for add (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback 3 Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10593 matching lines...) Expand 10 before | Expand all | Expand 10 after
10604 if (left_type->Is(Type::String())) { 10604 if (left_type->Is(Type::String())) {
10605 left = BuildCheckString(left); 10605 left = BuildCheckString(left);
10606 } 10606 }
10607 10607
10608 // Validate type feedback for right argument. 10608 // Validate type feedback for right argument.
10609 if (right_type->Is(Type::String())) { 10609 if (right_type->Is(Type::String())) {
10610 right = BuildCheckString(right); 10610 right = BuildCheckString(right);
10611 } 10611 }
10612 10612
10613 // Convert left argument as necessary. 10613 // Convert left argument as necessary.
10614 if (left_type->Is(Type::Number())) { 10614 if (left_type->Is(Type::Number()) && !is_strong(language_mode)) {
10615 DCHECK(right_type->Is(Type::String())); 10615 DCHECK(right_type->Is(Type::String()));
10616 left = BuildNumberToString(left, left_type); 10616 left = BuildNumberToString(left, left_type);
10617 } else if (!left_type->Is(Type::String())) { 10617 } else if (!left_type->Is(Type::String())) {
10618 DCHECK(right_type->Is(Type::String())); 10618 DCHECK(right_type->Is(Type::String()));
10619 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); 10619 HValue* function = AddLoadJSBuiltin(is_strong(language_mode) ?
10620 Builtins::STRING_ADD_RIGHT_STRONG :
10621 Builtins::STRING_ADD_RIGHT);
10620 Add<HPushArguments>(left, right); 10622 Add<HPushArguments>(left, right);
10621 return AddUncasted<HInvokeFunction>(function, 2); 10623 return AddUncasted<HInvokeFunction>(function, 2);
10622 } 10624 }
10623 10625
10624 // Convert right argument as necessary. 10626 // Convert right argument as necessary.
10625 if (right_type->Is(Type::Number())) { 10627 if (right_type->Is(Type::Number()) && !is_strong(language_mode)) {
10626 DCHECK(left_type->Is(Type::String())); 10628 DCHECK(left_type->Is(Type::String()));
10627 right = BuildNumberToString(right, right_type); 10629 right = BuildNumberToString(right, right_type);
10628 } else if (!right_type->Is(Type::String())) { 10630 } else if (!right_type->Is(Type::String())) {
10629 DCHECK(left_type->Is(Type::String())); 10631 DCHECK(left_type->Is(Type::String()));
10630 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); 10632 HValue* function = AddLoadJSBuiltin(is_strong(language_mode) ?
10633 Builtins::STRING_ADD_LEFT_STRONG :
10634 Builtins::STRING_ADD_LEFT);
10631 Add<HPushArguments>(left, right); 10635 Add<HPushArguments>(left, right);
10632 return AddUncasted<HInvokeFunction>(function, 2); 10636 return AddUncasted<HInvokeFunction>(function, 2);
10633 } 10637 }
10634 10638
10635 // Fast paths for empty constant strings. 10639 // Fast paths for empty constant strings.
10636 Handle<String> left_string = 10640 Handle<String> left_string =
10637 left->IsConstant() && HConstant::cast(left)->HasStringValue() 10641 left->IsConstant() && HConstant::cast(left)->HasStringValue()
10638 ? HConstant::cast(left)->StringValue() 10642 ? HConstant::cast(left)->StringValue()
10639 : Handle<String>(); 10643 : Handle<String>();
10640 Handle<String> right_string = 10644 Handle<String> right_string =
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
13106 if (ShouldProduceTraceOutput()) { 13110 if (ShouldProduceTraceOutput()) {
13107 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13111 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13108 } 13112 }
13109 13113
13110 #ifdef DEBUG 13114 #ifdef DEBUG
13111 graph_->Verify(false); // No full verify. 13115 graph_->Verify(false); // No full verify.
13112 #endif 13116 #endif
13113 } 13117 }
13114 13118
13115 } } // namespace v8::internal 13119 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ic/ic.cc » ('j') | test/mjsunit/strong/implicit-conversions.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698