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

Side by Side Diff: src/hydrogen.cc

Issue 143003005: Refactor fast path for empty constant strings in BinaryOp. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8936 matching lines...) Expand 10 before | Expand all | Expand 10 after
8947 ASSERT(left_type->Is(Type::String())); 8947 ASSERT(left_type->Is(Type::String()));
8948 right = BuildNumberToString(right, right_type); 8948 right = BuildNumberToString(right, right_type);
8949 } else if (!right_type->Is(Type::String())) { 8949 } else if (!right_type->Is(Type::String())) {
8950 ASSERT(left_type->Is(Type::String())); 8950 ASSERT(left_type->Is(Type::String()));
8951 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); 8951 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT);
8952 Add<HPushArgument>(left); 8952 Add<HPushArgument>(left);
8953 Add<HPushArgument>(right); 8953 Add<HPushArgument>(right);
8954 return AddUncasted<HInvokeFunction>(function, 2); 8954 return AddUncasted<HInvokeFunction>(function, 2);
8955 } 8955 }
8956 8956
8957 // Inline the string addition into the stub when creating allocation 8957 // Fast path for empty constant strings.
8958 // mementos to gather allocation site feedback. 8958 if (left->IsConstant() &&
8959 if (graph()->info()->IsStub() && 8959 HConstant::cast(left)->HasStringValue() &&
8960 allocation_mode.CreateAllocationMementos()) { 8960 HConstant::cast(left)->StringValue()->length() == 0) {
8961 return BuildStringAdd(left, right, allocation_mode); 8961 return right;
8962 }
8963 if (right->IsConstant() &&
8964 HConstant::cast(right)->HasStringValue() &&
8965 HConstant::cast(right)->StringValue()->length() == 0) {
8966 return left;
8962 } 8967 }
8963 8968
8964 // Register the dependent code with the allocation site. 8969 // Register the dependent code with the allocation site.
8965 if (!allocation_mode.feedback_site().is_null()) { 8970 if (!allocation_mode.feedback_site().is_null()) {
8966 ASSERT(!graph()->info()->IsStub()); 8971 ASSERT(!graph()->info()->IsStub());
8967 Handle<AllocationSite> site(allocation_mode.feedback_site()); 8972 Handle<AllocationSite> site(allocation_mode.feedback_site());
8968 AllocationSite::AddDependentCompilationInfo( 8973 AllocationSite::AddDependentCompilationInfo(
8969 site, AllocationSite::TENURING, top_info()); 8974 site, AllocationSite::TENURING, top_info());
8970 } 8975 }
8971 8976
8972 // Inline string addition if we know that we'll create a cons string. 8977 // Inline the string addition into the stub when creating allocation
8973 if (left->IsConstant()) { 8978 // mementos to gather allocation site feedback, or if we can statically
8974 HConstant* c_left = HConstant::cast(left); 8979 // infer that we're going to create a cons string.
8975 if (c_left->HasStringValue()) { 8980 if ((graph()->info()->IsStub() &&
8976 int c_left_length = c_left->StringValue()->length(); 8981 allocation_mode.CreateAllocationMementos()) ||
8977 if (c_left_length == 0) { 8982 (left->IsConstant() &&
8978 return right; 8983 HConstant::cast(left)->HasStringValue() &&
8979 } else if (c_left_length + 1 >= ConsString::kMinLength) { 8984 HConstant::cast(left)->StringValue()->length() + 1 >=
8980 return BuildStringAdd(left, right, allocation_mode); 8985 ConsString::kMinLength) ||
mvstanton 2014/01/21 15:52:26 Can ConsString::kMinLength be indented 2 spaces? I
Benedikt Meurer 2014/01/22 12:29:54 Done.
8981 } 8986 (right->IsConstant() &&
8982 } 8987 HConstant::cast(right)->HasStringValue() &&
8983 } 8988 HConstant::cast(right)->StringValue()->length() + 1 >=
8984 if (right->IsConstant()) { 8989 ConsString::kMinLength)) {
mvstanton 2014/01/21 15:52:26 Same.
Benedikt Meurer 2014/01/22 12:29:54 Done.
8985 HConstant* c_right = HConstant::cast(right); 8990 return BuildStringAdd(left, right, allocation_mode);
8986 if (c_right->HasStringValue()) {
8987 int c_right_length = c_right->StringValue()->length();
8988 if (c_right_length == 0) {
8989 return left;
8990 } else if (c_right_length + 1 >= ConsString::kMinLength) {
8991 return BuildStringAdd(left, right, allocation_mode);
8992 }
8993 }
8994 } 8991 }
8995 8992
8996 // Fallback to using the string add stub. 8993 // Fallback to using the string add stub.
8997 return AddUncasted<HStringAdd>( 8994 return AddUncasted<HStringAdd>(
8998 left, right, allocation_mode.GetPretenureMode(), 8995 left, right, allocation_mode.GetPretenureMode(),
8999 STRING_ADD_CHECK_NONE, allocation_mode.feedback_site()); 8996 STRING_ADD_CHECK_NONE, allocation_mode.feedback_site());
9000 } 8997 }
9001 8998
9002 if (graph()->info()->IsStub()) { 8999 if (graph()->info()->IsStub()) {
9003 left = EnforceNumberType(left, left_type); 9000 left = EnforceNumberType(left, left_type);
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
11006 if (ShouldProduceTraceOutput()) { 11003 if (ShouldProduceTraceOutput()) {
11007 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11004 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11008 } 11005 }
11009 11006
11010 #ifdef DEBUG 11007 #ifdef DEBUG
11011 graph_->Verify(false); // No full verify. 11008 graph_->Verify(false); // No full verify.
11012 #endif 11009 #endif
11013 } 11010 }
11014 11011
11015 } } // namespace v8::internal 11012 } } // 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