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

Side by Side Diff: src/hydrogen.cc

Issue 935393002: Constant-fold strings in HGraphBuilder::BuildBinaryOperation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: argh Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10470 matching lines...) Expand 10 before | Expand all | Expand 10 after
10481 if (right_type->Is(Type::Number())) { 10481 if (right_type->Is(Type::Number())) {
10482 DCHECK(left_type->Is(Type::String())); 10482 DCHECK(left_type->Is(Type::String()));
10483 right = BuildNumberToString(right, right_type); 10483 right = BuildNumberToString(right, right_type);
10484 } else if (!right_type->Is(Type::String())) { 10484 } else if (!right_type->Is(Type::String())) {
10485 DCHECK(left_type->Is(Type::String())); 10485 DCHECK(left_type->Is(Type::String()));
10486 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); 10486 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT);
10487 Add<HPushArguments>(left, right); 10487 Add<HPushArguments>(left, right);
10488 return AddUncasted<HInvokeFunction>(function, 2); 10488 return AddUncasted<HInvokeFunction>(function, 2);
10489 } 10489 }
10490 10490
10491 // Fast path for empty constant strings. 10491 // Fast paths for empty constant strings.
10492 if (left->IsConstant() && 10492 Handle<String> left_string =
10493 HConstant::cast(left)->HasStringValue() && 10493 left->IsConstant() && HConstant::cast(left)->HasStringValue()
10494 HConstant::cast(left)->StringValue()->length() == 0) { 10494 ? HConstant::cast(left)->StringValue()
10495 return right; 10495 : Handle<String>();
10496 } 10496 Handle<String> right_string =
10497 if (right->IsConstant() && 10497 right->IsConstant() && HConstant::cast(right)->HasStringValue()
10498 HConstant::cast(right)->HasStringValue() && 10498 ? HConstant::cast(right)->StringValue()
10499 HConstant::cast(right)->StringValue()->length() == 0) { 10499 : Handle<String>();
10500 return left; 10500 if (!left_string.is_null() && left_string->length() == 0) return right;
10501 if (!right_string.is_null() && right_string->length() == 0) return left;
10502 if (!left_string.is_null() && !right_string.is_null()) {
10503 return AddUncasted<HStringAdd>(
10504 left, right, allocation_mode.GetPretenureMode(),
10505 STRING_ADD_CHECK_NONE, allocation_mode.feedback_site());
10501 } 10506 }
10502 10507
10503 // Register the dependent code with the allocation site. 10508 // Register the dependent code with the allocation site.
10504 if (!allocation_mode.feedback_site().is_null()) { 10509 if (!allocation_mode.feedback_site().is_null()) {
10505 DCHECK(!graph()->info()->IsStub()); 10510 DCHECK(!graph()->info()->IsStub());
10506 Handle<AllocationSite> site(allocation_mode.feedback_site()); 10511 Handle<AllocationSite> site(allocation_mode.feedback_site());
10507 AllocationSite::RegisterForDeoptOnTenureChange(site, top_info()); 10512 AllocationSite::RegisterForDeoptOnTenureChange(site, top_info());
10508 } 10513 }
10509 10514
10510 // Inline the string addition into the stub when creating allocation 10515 // Inline the string addition into the stub when creating allocation
(...skipping 2923 matching lines...) Expand 10 before | Expand all | Expand 10 after
13434 if (ShouldProduceTraceOutput()) { 13439 if (ShouldProduceTraceOutput()) {
13435 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13440 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13436 } 13441 }
13437 13442
13438 #ifdef DEBUG 13443 #ifdef DEBUG
13439 graph_->Verify(false); // No full verify. 13444 graph_->Verify(false); // No full verify.
13440 #endif 13445 #endif
13441 } 13446 }
13442 13447
13443 } } // namespace v8::internal 13448 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698