| OLD | NEW |
| 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 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2373 position = 0; | 2373 position = 0; |
| 2374 Object* object; | 2374 Object* object; |
| 2375 if (ascii) { | 2375 if (ascii) { |
| 2376 object = Heap::AllocateRawAsciiString(length); | 2376 object = Heap::AllocateRawAsciiString(length); |
| 2377 } else { | 2377 } else { |
| 2378 object = Heap::AllocateRawTwoByteString(length); | 2378 object = Heap::AllocateRawTwoByteString(length); |
| 2379 } | 2379 } |
| 2380 if (object->IsFailure()) return object; | 2380 if (object->IsFailure()) return object; |
| 2381 | 2381 |
| 2382 String* answer = String::cast(object); | 2382 String* answer = String::cast(object); |
| 2383 StringHasher hasher(length); |
| 2383 for (int i = 0; i < array_length; i++) { | 2384 for (int i = 0; i < array_length; i++) { |
| 2384 Object* element = fixed_array->get(i); | 2385 Object* element = fixed_array->get(i); |
| 2385 if (element->IsSmi()) { | 2386 if (element->IsSmi()) { |
| 2386 int len = Smi::cast(element)->value(); | 2387 int len = Smi::cast(element)->value(); |
| 2387 int pos = len >> 11; | 2388 int pos = len >> 11; |
| 2388 len &= 0x7ff; | 2389 len &= 0x7ff; |
| 2389 String::Flatten(special, answer, pos, pos + len, position); | 2390 String::Flatten(special, answer, pos, pos + len, position, &hasher); |
| 2390 position += len; | 2391 position += len; |
| 2391 } else { | 2392 } else { |
| 2392 String* string = String::cast(element); | 2393 String* string = String::cast(element); |
| 2393 int element_length = string->length(); | 2394 int element_length = string->length(); |
| 2394 String::Flatten(string, answer, 0, element_length, position); | 2395 String::Flatten(string, answer, 0, element_length, position, &hasher); |
| 2395 position += element_length; | 2396 position += element_length; |
| 2396 } | 2397 } |
| 2397 } | 2398 } |
| 2399 if (hasher.is_valid()) |
| 2400 answer->set_length_field(hasher.GetHashField()); |
| 2398 return answer; | 2401 return answer; |
| 2399 } | 2402 } |
| 2400 | 2403 |
| 2401 | 2404 |
| 2402 static Object* Runtime_NumberOr(Arguments args) { | 2405 static Object* Runtime_NumberOr(Arguments args) { |
| 2403 NoHandleAllocation ha; | 2406 NoHandleAllocation ha; |
| 2404 ASSERT(args.length() == 2); | 2407 ASSERT(args.length() == 2); |
| 2405 | 2408 |
| 2406 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 2409 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 2407 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 2410 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| (...skipping 2758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5166 | 5169 |
| 5167 void Runtime::PerformGC(Object* result) { | 5170 void Runtime::PerformGC(Object* result) { |
| 5168 Failure* failure = Failure::cast(result); | 5171 Failure* failure = Failure::cast(result); |
| 5169 // Try to do a garbage collection; ignore it if it fails. The C | 5172 // Try to do a garbage collection; ignore it if it fails. The C |
| 5170 // entry stub will throw an out-of-memory exception in that case. | 5173 // entry stub will throw an out-of-memory exception in that case. |
| 5171 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); | 5174 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); |
| 5172 } | 5175 } |
| 5173 | 5176 |
| 5174 | 5177 |
| 5175 } } // namespace v8::internal | 5178 } } // namespace v8::internal |
| OLD | NEW |