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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 207613005: No longer OOM on invalid string length. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase + addressed nits Created 6 years, 9 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 | « src/heap-inl.h ('k') | src/json-parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 HValue* context, 3916 HValue* context,
3917 HValue* left, 3917 HValue* left,
3918 HValue* right, 3918 HValue* right,
3919 PretenureFlag pretenure_flag, 3919 PretenureFlag pretenure_flag,
3920 StringAddFlags flags, 3920 StringAddFlags flags,
3921 Handle<AllocationSite> allocation_site) { 3921 Handle<AllocationSite> allocation_site) {
3922 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { 3922 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
3923 HConstant* c_right = HConstant::cast(right); 3923 HConstant* c_right = HConstant::cast(right);
3924 HConstant* c_left = HConstant::cast(left); 3924 HConstant* c_left = HConstant::cast(left);
3925 if (c_left->HasStringValue() && c_right->HasStringValue()) { 3925 if (c_left->HasStringValue() && c_right->HasStringValue()) {
3926 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( 3926 Handle<String> left_string = c_left->StringValue();
3927 c_left->StringValue(), c_right->StringValue()); 3927 Handle<String> right_string = c_right->StringValue();
3928 return HConstant::New(zone, context, concat); 3928 // Prevent possible exception by invalid string length.
3929 if (left_string->length() + right_string->length() < String::kMaxLength) {
3930 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString(
3931 c_left->StringValue(), c_right->StringValue());
3932 ASSERT(!concat.is_null());
3933 return HConstant::New(zone, context, concat);
3934 }
3929 } 3935 }
3930 } 3936 }
3931 return new(zone) HStringAdd( 3937 return new(zone) HStringAdd(
3932 context, left, right, pretenure_flag, flags, allocation_site); 3938 context, left, right, pretenure_flag, flags, allocation_site);
3933 } 3939 }
3934 3940
3935 3941
3936 void HStringAdd::PrintDataTo(StringStream* stream) { 3942 void HStringAdd::PrintDataTo(StringStream* stream) {
3937 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { 3943 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
3938 stream->Add("_CheckBoth"); 3944 stream->Add("_CheckBoth");
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
4587 break; 4593 break;
4588 case kExternalMemory: 4594 case kExternalMemory:
4589 stream->Add("[external-memory]"); 4595 stream->Add("[external-memory]");
4590 break; 4596 break;
4591 } 4597 }
4592 4598
4593 stream->Add("@%d", offset()); 4599 stream->Add("@%d", offset());
4594 } 4600 }
4595 4601
4596 } } // namespace v8::internal 4602 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698