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

Side by Side Diff: src/runtime.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 | « src/objects.cc ('k') | 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 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 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 position = 0; 2397 position = 0;
2398 Object* object; 2398 Object* object;
2399 if (ascii) { 2399 if (ascii) {
2400 object = Heap::AllocateRawAsciiString(length); 2400 object = Heap::AllocateRawAsciiString(length);
2401 } else { 2401 } else {
2402 object = Heap::AllocateRawTwoByteString(length); 2402 object = Heap::AllocateRawTwoByteString(length);
2403 } 2403 }
2404 if (object->IsFailure()) return object; 2404 if (object->IsFailure()) return object;
2405 2405
2406 String* answer = String::cast(object); 2406 String* answer = String::cast(object);
2407 StringHasher hasher(length);
2408 for (int i = 0; i < array_length; i++) { 2407 for (int i = 0; i < array_length; i++) {
2409 Object* element = fixed_array->get(i); 2408 Object* element = fixed_array->get(i);
2410 if (element->IsSmi()) { 2409 if (element->IsSmi()) {
2411 int len = Smi::cast(element)->value(); 2410 int len = Smi::cast(element)->value();
2412 int pos = len >> 11; 2411 int pos = len >> 11;
2413 len &= 0x7ff; 2412 len &= 0x7ff;
2414 String::Flatten(special, answer, pos, pos + len, position, &hasher); 2413 String::Flatten(special, answer, pos, pos + len, position);
2415 position += len; 2414 position += len;
2416 } else { 2415 } else {
2417 String* string = String::cast(element); 2416 String* string = String::cast(element);
2418 int element_length = string->length(); 2417 int element_length = string->length();
2419 String::Flatten(string, answer, 0, element_length, position, &hasher); 2418 String::Flatten(string, answer, 0, element_length, position);
2420 position += element_length; 2419 position += element_length;
2421 } 2420 }
2422 } 2421 }
2423 if (hasher.is_valid())
2424 answer->set_length_field(hasher.GetHashField());
2425 return answer; 2422 return answer;
2426 } 2423 }
2427 2424
2428 2425
2429 static Object* Runtime_NumberOr(Arguments args) { 2426 static Object* Runtime_NumberOr(Arguments args) {
2430 NoHandleAllocation ha; 2427 NoHandleAllocation ha;
2431 ASSERT(args.length() == 2); 2428 ASSERT(args.length() == 2);
2432 2429
2433 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 2430 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
2434 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 2431 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after
5197 5194
5198 void Runtime::PerformGC(Object* result) { 5195 void Runtime::PerformGC(Object* result) {
5199 Failure* failure = Failure::cast(result); 5196 Failure* failure = Failure::cast(result);
5200 // Try to do a garbage collection; ignore it if it fails. The C 5197 // Try to do a garbage collection; ignore it if it fails. The C
5201 // entry stub will throw an out-of-memory exception in that case. 5198 // entry stub will throw an out-of-memory exception in that case.
5202 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); 5199 Heap::CollectGarbage(failure->requested(), failure->allocation_space());
5203 } 5200 }
5204 5201
5205 5202
5206 } } // namespace v8::internal 5203 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698