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

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: Indentation. 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 8933 matching lines...) Expand 10 before | Expand all | Expand 10 after
8944 ASSERT(left_type->Is(Type::String())); 8944 ASSERT(left_type->Is(Type::String()));
8945 right = BuildNumberToString(right, right_type); 8945 right = BuildNumberToString(right, right_type);
8946 } else if (!right_type->Is(Type::String())) { 8946 } else if (!right_type->Is(Type::String())) {
8947 ASSERT(left_type->Is(Type::String())); 8947 ASSERT(left_type->Is(Type::String()));
8948 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); 8948 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT);
8949 Add<HPushArgument>(left); 8949 Add<HPushArgument>(left);
8950 Add<HPushArgument>(right); 8950 Add<HPushArgument>(right);
8951 return AddUncasted<HInvokeFunction>(function, 2); 8951 return AddUncasted<HInvokeFunction>(function, 2);
8952 } 8952 }
8953 8953
8954 // Inline the string addition into the stub when creating allocation 8954 // Fast path for empty constant strings.
8955 // mementos to gather allocation site feedback. 8955 if (left->IsConstant() &&
8956 if (graph()->info()->IsStub() && 8956 HConstant::cast(left)->HasStringValue() &&
8957 allocation_mode.CreateAllocationMementos()) { 8957 HConstant::cast(left)->StringValue()->length() == 0) {
8958 return BuildStringAdd(left, right, allocation_mode); 8958 return right;
8959 }
8960 if (right->IsConstant() &&
8961 HConstant::cast(right)->HasStringValue() &&
8962 HConstant::cast(right)->StringValue()->length() == 0) {
8963 return left;
8959 } 8964 }
8960 8965
8961 // Register the dependent code with the allocation site. 8966 // Register the dependent code with the allocation site.
8962 if (!allocation_mode.feedback_site().is_null()) { 8967 if (!allocation_mode.feedback_site().is_null()) {
8963 ASSERT(!graph()->info()->IsStub()); 8968 ASSERT(!graph()->info()->IsStub());
8964 Handle<AllocationSite> site(allocation_mode.feedback_site()); 8969 Handle<AllocationSite> site(allocation_mode.feedback_site());
8965 AllocationSite::AddDependentCompilationInfo( 8970 AllocationSite::AddDependentCompilationInfo(
8966 site, AllocationSite::TENURING, top_info()); 8971 site, AllocationSite::TENURING, top_info());
8967 } 8972 }
8968 8973
8969 // Inline string addition if we know that we'll create a cons string. 8974 // Inline the string addition into the stub when creating allocation
8970 if (left->IsConstant()) { 8975 // mementos to gather allocation site feedback, or if we can statically
8971 HConstant* c_left = HConstant::cast(left); 8976 // infer that we're going to create a cons string.
8972 if (c_left->HasStringValue()) { 8977 if ((graph()->info()->IsStub() &&
8973 int c_left_length = c_left->StringValue()->length(); 8978 allocation_mode.CreateAllocationMementos()) ||
8974 if (c_left_length == 0) { 8979 (left->IsConstant() &&
8975 return right; 8980 HConstant::cast(left)->HasStringValue() &&
8976 } else if (c_left_length + 1 >= ConsString::kMinLength) { 8981 HConstant::cast(left)->StringValue()->length() + 1 >=
8977 return BuildStringAdd(left, right, allocation_mode); 8982 ConsString::kMinLength) ||
8978 } 8983 (right->IsConstant() &&
8979 } 8984 HConstant::cast(right)->HasStringValue() &&
8980 } 8985 HConstant::cast(right)->StringValue()->length() + 1 >=
8981 if (right->IsConstant()) { 8986 ConsString::kMinLength)) {
8982 HConstant* c_right = HConstant::cast(right); 8987 return BuildStringAdd(left, right, allocation_mode);
8983 if (c_right->HasStringValue()) {
8984 int c_right_length = c_right->StringValue()->length();
8985 if (c_right_length == 0) {
8986 return left;
8987 } else if (c_right_length + 1 >= ConsString::kMinLength) {
8988 return BuildStringAdd(left, right, allocation_mode);
8989 }
8990 }
8991 } 8988 }
8992 8989
8993 // Fallback to using the string add stub. 8990 // Fallback to using the string add stub.
8994 return AddUncasted<HStringAdd>( 8991 return AddUncasted<HStringAdd>(
8995 left, right, allocation_mode.GetPretenureMode(), 8992 left, right, allocation_mode.GetPretenureMode(),
8996 STRING_ADD_CHECK_NONE, allocation_mode.feedback_site()); 8993 STRING_ADD_CHECK_NONE, allocation_mode.feedback_site());
8997 } 8994 }
8998 8995
8999 if (graph()->info()->IsStub()) { 8996 if (graph()->info()->IsStub()) {
9000 left = EnforceNumberType(left, left_type); 8997 left = EnforceNumberType(left, left_type);
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
11003 if (ShouldProduceTraceOutput()) { 11000 if (ShouldProduceTraceOutput()) {
11004 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11001 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11005 } 11002 }
11006 11003
11007 #ifdef DEBUG 11004 #ifdef DEBUG
11008 graph_->Verify(false); // No full verify. 11005 graph_->Verify(false); // No full verify.
11009 #endif 11006 #endif
11010 } 11007 }
11011 11008
11012 } } // namespace v8::internal 11009 } } // 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