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

Side by Side Diff: src/heap.cc

Issue 6536: Rolled back hash calculation during flattening (Closed)
Patch Set: Created 12 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 | src/objects.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 sliced_string->set_start(start); 1393 sliced_string->set_start(start);
1394 sliced_string->set_length(length); 1394 sliced_string->set_length(length);
1395 1395
1396 return result; 1396 return result;
1397 } 1397 }
1398 1398
1399 1399
1400 Object* Heap::AllocateSubString(String* buffer, int start, int end) { 1400 Object* Heap::AllocateSubString(String* buffer, int start, int end) {
1401 int length = end - start; 1401 int length = end - start;
1402 1402
1403 if (length == 1) {
1404 return Heap::LookupSingleCharacterStringFromCode(buffer->Get(start));
1405 }
1406
1403 // Make an attempt to flatten the buffer to reduce access time. 1407 // Make an attempt to flatten the buffer to reduce access time.
1404 buffer->TryFlatten(); 1408 buffer->TryFlatten();
1405 1409
1406 Object* result = buffer->is_ascii() 1410 Object* result = buffer->is_ascii()
1407 ? AllocateRawAsciiString(length) 1411 ? AllocateRawAsciiString(length)
1408 : AllocateRawTwoByteString(length); 1412 : AllocateRawTwoByteString(length);
1409 if (result->IsFailure()) return result; 1413 if (result->IsFailure()) return result;
1410 1414
1411 // Copy the characters into the new object. 1415 // Copy the characters into the new object.
1412 String* string_result = String::cast(result); 1416 String* string_result = String::cast(result);
1413 for (int i = 0; i < length; i++) { 1417 StringHasher hasher(length);
1414 string_result->Set(i, buffer->Get(start + i)); 1418 int i = 0;
1419 for (; i < length && hasher.is_array_index(); i++) {
1420 uc32 c = buffer->Get(start + i);
1421 hasher.AddCharacter(c);
1422 string_result->Set(i, c);
1415 } 1423 }
1424 for (; i < length; i++) {
1425 uc32 c = buffer->Get(start + i);
1426 hasher.AddCharacterNoIndex(c);
1427 string_result->Set(i, c);
1428 }
1429 string_result->set_length_field(hasher.GetHashField());
1416 return result; 1430 return result;
1417 } 1431 }
1418 1432
1419 1433
1420 Object* Heap::AllocateExternalStringFromAscii( 1434 Object* Heap::AllocateExternalStringFromAscii(
1421 ExternalAsciiString::Resource* resource) { 1435 ExternalAsciiString::Resource* resource) {
1422 Map* map; 1436 Map* map;
1423 int length = resource->length(); 1437 int length = resource->length();
1424 if (length <= String::kMaxShortStringSize) { 1438 if (length <= String::kMaxShortStringSize) {
1425 map = short_external_ascii_string_map(); 1439 map = short_external_ascii_string_map();
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 return "Scavenge"; 3059 return "Scavenge";
3046 case MARK_COMPACTOR: 3060 case MARK_COMPACTOR:
3047 return MarkCompactCollector::HasCompacted() ? "Mark-compact" 3061 return MarkCompactCollector::HasCompacted() ? "Mark-compact"
3048 : "Mark-sweep"; 3062 : "Mark-sweep";
3049 } 3063 }
3050 return "Unknown GC"; 3064 return "Unknown GC";
3051 } 3065 }
3052 3066
3053 3067
3054 } } // namespace v8::internal 3068 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698