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

Side by Side Diff: src/hydrogen.cc

Issue 1396333004: Bailout to runtime when BuildUncheckedStringAdd results in a large object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/allocation-site-scopes.h" 9 #include "src/allocation-site-scopes.h"
10 #include "src/ast-numbering.h" 10 #include "src/ast-numbering.h"
(...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 Push(string_map); 2404 Push(string_map);
2405 } 2405 }
2406 if_onebyte.End(); 2406 if_onebyte.End();
2407 HValue* map = Pop(); 2407 HValue* map = Pop();
2408 2408
2409 // Calculate the number of bytes needed for the characters in the 2409 // Calculate the number of bytes needed for the characters in the
2410 // string while observing object alignment. 2410 // string while observing object alignment.
2411 STATIC_ASSERT((SeqString::kHeaderSize & kObjectAlignmentMask) == 0); 2411 STATIC_ASSERT((SeqString::kHeaderSize & kObjectAlignmentMask) == 0);
2412 HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize); 2412 HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize);
2413 2413
2414 // Allocate the string object. HAllocate does not care whether we pass 2414 IfBuilder if_size(this);
2415 // STRING_TYPE or ONE_BYTE_STRING_TYPE here, so we just use STRING_TYPE. 2415 if_size.If<HCompareNumericAndBranch>(
2416 HAllocate* result = BuildAllocate( 2416 size, Add<HConstant>(Page::kMaxRegularHeapObjectSize), Token::LT);
2417 size, HType::String(), STRING_TYPE, allocation_mode); 2417 if_size.Then();
2418 Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map); 2418 {
2419 // Allocate the string object. HAllocate does not care whether we pass
2420 // STRING_TYPE or ONE_BYTE_STRING_TYPE here, so we just use STRING_TYPE.
2421 HAllocate* result =
2422 BuildAllocate(size, HType::String(), STRING_TYPE, allocation_mode);
2423 Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map);
2419 2424
2420 // Initialize the string fields. 2425 // Initialize the string fields.
2421 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), 2426 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
2422 Add<HConstant>(String::kEmptyHashField)); 2427 Add<HConstant>(String::kEmptyHashField));
2423 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); 2428 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
2424 2429
2425 // Copy characters to the result string. 2430 // Copy characters to the result string.
2426 IfBuilder if_twobyte(this); 2431 IfBuilder if_twobyte(this);
2427 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); 2432 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map);
2428 if_twobyte.Then(); 2433 if_twobyte.Then();
2434 {
2435 // Copy characters from the left string.
2436 BuildCopySeqStringChars(
2437 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, result,
2438 graph()->GetConstant0(), String::TWO_BYTE_ENCODING, left_length);
2439
2440 // Copy characters from the right string.
2441 BuildCopySeqStringChars(
2442 right, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, result,
2443 left_length, String::TWO_BYTE_ENCODING, right_length);
2444 }
2445 if_twobyte.Else();
2446 {
2447 // Copy characters from the left string.
2448 BuildCopySeqStringChars(
2449 left, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, result,
2450 graph()->GetConstant0(), String::ONE_BYTE_ENCODING, left_length);
2451
2452 // Copy characters from the right string.
2453 BuildCopySeqStringChars(
2454 right, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, result,
2455 left_length, String::ONE_BYTE_ENCODING, right_length);
2456 }
2457 if_twobyte.End();
2458
2459 // Count the native string addition.
2460 AddIncrementCounter(isolate()->counters()->string_add_native());
2461
2462 // Return the sequential string.
2463 Push(result);
2464 }
2465 if_size.Else();
2429 { 2466 {
2430 // Copy characters from the left string. 2467 // Fallback to the runtime to add the two strings. The string has to be
2431 BuildCopySeqStringChars( 2468 // allocated in LO space.
2432 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2469 Add<HPushArguments>(left, right);
2433 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2470 Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kStringAdd), 2));
2434 left_length);
2435
2436 // Copy characters from the right string.
2437 BuildCopySeqStringChars(
2438 right, graph()->GetConstant0(), String::TWO_BYTE_ENCODING,
2439 result, left_length, String::TWO_BYTE_ENCODING,
2440 right_length);
2441 } 2471 }
2442 if_twobyte.Else(); 2472 if_size.End();
2443 {
2444 // Copy characters from the left string.
2445 BuildCopySeqStringChars(
2446 left, graph()->GetConstant0(), String::ONE_BYTE_ENCODING,
2447 result, graph()->GetConstant0(), String::ONE_BYTE_ENCODING,
2448 left_length);
2449
2450 // Copy characters from the right string.
2451 BuildCopySeqStringChars(
2452 right, graph()->GetConstant0(), String::ONE_BYTE_ENCODING,
2453 result, left_length, String::ONE_BYTE_ENCODING,
2454 right_length);
2455 }
2456 if_twobyte.End();
2457
2458 // Count the native string addition.
2459 AddIncrementCounter(isolate()->counters()->string_add_native());
2460
2461 // Return the sequential string.
2462 Push(result);
2463 } 2473 }
2464 if_sameencodingandsequential.Else(); 2474 if_sameencodingandsequential.Else();
2465 { 2475 {
2466 // Fallback to the runtime to add the two strings. 2476 // Fallback to the runtime to add the two strings.
2467 Add<HPushArguments>(left, right); 2477 Add<HPushArguments>(left, right);
2468 Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kStringAdd), 2)); 2478 Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kStringAdd), 2));
2469 } 2479 }
2470 if_sameencodingandsequential.End(); 2480 if_sameencodingandsequential.End();
2471 } 2481 }
2472 if_createcons.End(); 2482 if_createcons.End();
(...skipping 11188 matching lines...) Expand 10 before | Expand all | Expand 10 after
13661 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13671 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13662 } 13672 }
13663 13673
13664 #ifdef DEBUG 13674 #ifdef DEBUG
13665 graph_->Verify(false); // No full verify. 13675 graph_->Verify(false); // No full verify.
13666 #endif 13676 #endif
13667 } 13677 }
13668 13678
13669 } // namespace internal 13679 } // namespace internal
13670 } // namespace v8 13680 } // namespace v8
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