OLD | NEW |
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 2787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 set_no_interceptor_result_sentinel(obj); | 2798 set_no_interceptor_result_sentinel(obj); |
2799 | 2799 |
2800 { MaybeObject* maybe_obj = CreateOddball("termination_exception", | 2800 { MaybeObject* maybe_obj = CreateOddball("termination_exception", |
2801 Smi::FromInt(-3), | 2801 Smi::FromInt(-3), |
2802 Oddball::kOther); | 2802 Oddball::kOther); |
2803 if (!maybe_obj->ToObject(&obj)) return false; | 2803 if (!maybe_obj->ToObject(&obj)) return false; |
2804 } | 2804 } |
2805 set_termination_exception(obj); | 2805 set_termination_exception(obj); |
2806 | 2806 |
2807 // Allocate the empty string. | 2807 // Allocate the empty string. |
2808 { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED); | 2808 { MaybeObject* maybe_obj = AllocateRawOneByteString(0, TENURED); |
2809 if (!maybe_obj->ToObject(&obj)) return false; | 2809 if (!maybe_obj->ToObject(&obj)) return false; |
2810 } | 2810 } |
2811 set_empty_string(String::cast(obj)); | 2811 set_empty_string(String::cast(obj)); |
2812 | 2812 |
2813 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { | 2813 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { |
2814 { MaybeObject* maybe_obj = | 2814 { MaybeObject* maybe_obj = |
2815 LookupAsciiSymbol(constant_symbol_table[i].contents); | 2815 LookupAsciiSymbol(constant_symbol_table[i].contents); |
2816 if (!maybe_obj->ToObject(&obj)) return false; | 2816 if (!maybe_obj->ToObject(&obj)) return false; |
2817 } | 2817 } |
2818 roots_[constant_symbol_table[i].index] = String::cast(obj); | 2818 roots_[constant_symbol_table[i].index] = String::cast(obj); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3170 const char* str; | 3170 const char* str; |
3171 if (number->IsSmi()) { | 3171 if (number->IsSmi()) { |
3172 int num = Smi::cast(number)->value(); | 3172 int num = Smi::cast(number)->value(); |
3173 str = IntToCString(num, buffer); | 3173 str = IntToCString(num, buffer); |
3174 } else { | 3174 } else { |
3175 double num = HeapNumber::cast(number)->value(); | 3175 double num = HeapNumber::cast(number)->value(); |
3176 str = DoubleToCString(num, buffer); | 3176 str = DoubleToCString(num, buffer); |
3177 } | 3177 } |
3178 | 3178 |
3179 Object* js_string; | 3179 Object* js_string; |
3180 MaybeObject* maybe_js_string = AllocateStringFromAscii(CStrVector(str)); | 3180 MaybeObject* maybe_js_string = AllocateStringFromOneByte(CStrVector(str)); |
3181 if (maybe_js_string->ToObject(&js_string)) { | 3181 if (maybe_js_string->ToObject(&js_string)) { |
3182 SetNumberStringCache(number, String::cast(js_string)); | 3182 SetNumberStringCache(number, String::cast(js_string)); |
3183 } | 3183 } |
3184 return maybe_js_string; | 3184 return maybe_js_string; |
3185 } | 3185 } |
3186 | 3186 |
3187 | 3187 |
3188 MaybeObject* Heap::Uint32ToString(uint32_t value, | 3188 MaybeObject* Heap::Uint32ToString(uint32_t value, |
3189 bool check_number_string_cache) { | 3189 bool check_number_string_cache) { |
3190 Object* number; | 3190 Object* number; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 // Numeric strings have a different hash algorithm not known by | 3344 // Numeric strings have a different hash algorithm not known by |
3345 // LookupTwoCharsSymbolIfExists, so we skip this step for such strings. | 3345 // LookupTwoCharsSymbolIfExists, so we skip this step for such strings. |
3346 if ((!Between(c1, '0', '9') || !Between(c2, '0', '9')) && | 3346 if ((!Between(c1, '0', '9') || !Between(c2, '0', '9')) && |
3347 heap->symbol_table()->LookupTwoCharsSymbolIfExists(c1, c2, &symbol)) { | 3347 heap->symbol_table()->LookupTwoCharsSymbolIfExists(c1, c2, &symbol)) { |
3348 return symbol; | 3348 return symbol; |
3349 // Now we know the length is 2, we might as well make use of that fact | 3349 // Now we know the length is 2, we might as well make use of that fact |
3350 // when building the new string. | 3350 // when building the new string. |
3351 } else if ((c1 | c2) <= String::kMaxAsciiCharCodeU) { // We can do this | 3351 } else if ((c1 | c2) <= String::kMaxAsciiCharCodeU) { // We can do this |
3352 ASSERT(IsPowerOf2(String::kMaxAsciiCharCodeU + 1)); // because of this. | 3352 ASSERT(IsPowerOf2(String::kMaxAsciiCharCodeU + 1)); // because of this. |
3353 Object* result; | 3353 Object* result; |
3354 { MaybeObject* maybe_result = heap->AllocateRawAsciiString(2); | 3354 { MaybeObject* maybe_result = heap->AllocateRawOneByteString(2); |
3355 if (!maybe_result->ToObject(&result)) return maybe_result; | 3355 if (!maybe_result->ToObject(&result)) return maybe_result; |
3356 } | 3356 } |
3357 char* dest = SeqOneByteString::cast(result)->GetChars(); | 3357 char* dest = SeqOneByteString::cast(result)->GetChars(); |
3358 dest[0] = c1; | 3358 dest[0] = c1; |
3359 dest[1] = c2; | 3359 dest[1] = c2; |
3360 return result; | 3360 return result; |
3361 } else { | 3361 } else { |
3362 Object* result; | 3362 Object* result; |
3363 { MaybeObject* maybe_result = heap->AllocateRawTwoByteString(2); | 3363 { MaybeObject* maybe_result = heap->AllocateRawTwoByteString(2); |
3364 if (!maybe_result->ToObject(&result)) return maybe_result; | 3364 if (!maybe_result->ToObject(&result)) return maybe_result; |
(...skipping 21 matching lines...) Expand all Loading... |
3386 | 3386 |
3387 // Optimization for 2-byte strings often used as keys in a decompression | 3387 // Optimization for 2-byte strings often used as keys in a decompression |
3388 // dictionary. Check whether we already have the string in the symbol | 3388 // dictionary. Check whether we already have the string in the symbol |
3389 // table to prevent creation of many unneccesary strings. | 3389 // table to prevent creation of many unneccesary strings. |
3390 if (length == 2) { | 3390 if (length == 2) { |
3391 unsigned c1 = first->Get(0); | 3391 unsigned c1 = first->Get(0); |
3392 unsigned c2 = second->Get(0); | 3392 unsigned c2 = second->Get(0); |
3393 return MakeOrFindTwoCharacterString(this, c1, c2); | 3393 return MakeOrFindTwoCharacterString(this, c1, c2); |
3394 } | 3394 } |
3395 | 3395 |
3396 bool first_is_ascii = first->IsAsciiRepresentation(); | 3396 bool first_is_ascii = first->IsOneByteRepresentation(); |
3397 bool second_is_ascii = second->IsAsciiRepresentation(); | 3397 bool second_is_ascii = second->IsOneByteRepresentation(); |
3398 bool is_ascii = first_is_ascii && second_is_ascii; | 3398 bool is_ascii = first_is_ascii && second_is_ascii; |
3399 | 3399 |
3400 // Make sure that an out of memory exception is thrown if the length | 3400 // Make sure that an out of memory exception is thrown if the length |
3401 // of the new cons string is too large. | 3401 // of the new cons string is too large. |
3402 if (length > String::kMaxLength || length < 0) { | 3402 if (length > String::kMaxLength || length < 0) { |
3403 isolate()->context()->mark_out_of_memory(); | 3403 isolate()->context()->mark_out_of_memory(); |
3404 return Failure::OutOfMemoryException(); | 3404 return Failure::OutOfMemoryException(); |
3405 } | 3405 } |
3406 | 3406 |
3407 bool is_ascii_data_in_two_byte_string = false; | 3407 bool is_ascii_data_in_two_byte_string = false; |
3408 if (!is_ascii) { | 3408 if (!is_ascii) { |
3409 // At least one of the strings uses two-byte representation so we | 3409 // At least one of the strings uses two-byte representation so we |
3410 // can't use the fast case code for short ASCII strings below, but | 3410 // can't use the fast case code for short ASCII strings below, but |
3411 // we can try to save memory if all chars actually fit in ASCII. | 3411 // we can try to save memory if all chars actually fit in ASCII. |
3412 is_ascii_data_in_two_byte_string = | 3412 is_ascii_data_in_two_byte_string = |
3413 first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); | 3413 first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); |
3414 if (is_ascii_data_in_two_byte_string) { | 3414 if (is_ascii_data_in_two_byte_string) { |
3415 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); | 3415 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); |
3416 } | 3416 } |
3417 } | 3417 } |
3418 | 3418 |
3419 // If the resulting string is small make a flat string. | 3419 // If the resulting string is small make a flat string. |
3420 if (length < ConsString::kMinLength) { | 3420 if (length < ConsString::kMinLength) { |
3421 // Note that neither of the two inputs can be a slice because: | 3421 // Note that neither of the two inputs can be a slice because: |
3422 STATIC_ASSERT(ConsString::kMinLength <= SlicedString::kMinLength); | 3422 STATIC_ASSERT(ConsString::kMinLength <= SlicedString::kMinLength); |
3423 ASSERT(first->IsFlat()); | 3423 ASSERT(first->IsFlat()); |
3424 ASSERT(second->IsFlat()); | 3424 ASSERT(second->IsFlat()); |
3425 if (is_ascii) { | 3425 if (is_ascii) { |
3426 Object* result; | 3426 Object* result; |
3427 { MaybeObject* maybe_result = AllocateRawAsciiString(length); | 3427 { MaybeObject* maybe_result = AllocateRawOneByteString(length); |
3428 if (!maybe_result->ToObject(&result)) return maybe_result; | 3428 if (!maybe_result->ToObject(&result)) return maybe_result; |
3429 } | 3429 } |
3430 // Copy the characters into the new object. | 3430 // Copy the characters into the new object. |
3431 char* dest = SeqOneByteString::cast(result)->GetChars(); | 3431 char* dest = SeqOneByteString::cast(result)->GetChars(); |
3432 // Copy first part. | 3432 // Copy first part. |
3433 const char* src; | 3433 const char* src; |
3434 if (first->IsExternalString()) { | 3434 if (first->IsExternalString()) { |
3435 src = ExternalAsciiString::cast(first)->GetChars(); | 3435 src = ExternalAsciiString::cast(first)->GetChars(); |
3436 } else { | 3436 } else { |
3437 src = SeqOneByteString::cast(first)->GetChars(); | 3437 src = SeqOneByteString::cast(first)->GetChars(); |
3438 } | 3438 } |
3439 for (int i = 0; i < first_length; i++) *dest++ = src[i]; | 3439 for (int i = 0; i < first_length; i++) *dest++ = src[i]; |
3440 // Copy second part. | 3440 // Copy second part. |
3441 if (second->IsExternalString()) { | 3441 if (second->IsExternalString()) { |
3442 src = ExternalAsciiString::cast(second)->GetChars(); | 3442 src = ExternalAsciiString::cast(second)->GetChars(); |
3443 } else { | 3443 } else { |
3444 src = SeqOneByteString::cast(second)->GetChars(); | 3444 src = SeqOneByteString::cast(second)->GetChars(); |
3445 } | 3445 } |
3446 for (int i = 0; i < second_length; i++) *dest++ = src[i]; | 3446 for (int i = 0; i < second_length; i++) *dest++ = src[i]; |
3447 return result; | 3447 return result; |
3448 } else { | 3448 } else { |
3449 if (is_ascii_data_in_two_byte_string) { | 3449 if (is_ascii_data_in_two_byte_string) { |
3450 Object* result; | 3450 Object* result; |
3451 { MaybeObject* maybe_result = AllocateRawAsciiString(length); | 3451 { MaybeObject* maybe_result = AllocateRawOneByteString(length); |
3452 if (!maybe_result->ToObject(&result)) return maybe_result; | 3452 if (!maybe_result->ToObject(&result)) return maybe_result; |
3453 } | 3453 } |
3454 // Copy the characters into the new object. | 3454 // Copy the characters into the new object. |
3455 char* dest = SeqOneByteString::cast(result)->GetChars(); | 3455 char* dest = SeqOneByteString::cast(result)->GetChars(); |
3456 String::WriteToFlat(first, dest, 0, first_length); | 3456 String::WriteToFlat(first, dest, 0, first_length); |
3457 String::WriteToFlat(second, dest + first_length, 0, second_length); | 3457 String::WriteToFlat(second, dest + first_length, 0, second_length); |
3458 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); | 3458 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); |
3459 return result; | 3459 return result; |
3460 } | 3460 } |
3461 | 3461 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3512 buffer = buffer->TryFlattenGetString(); | 3512 buffer = buffer->TryFlattenGetString(); |
3513 | 3513 |
3514 if (!FLAG_string_slices || | 3514 if (!FLAG_string_slices || |
3515 !buffer->IsFlat() || | 3515 !buffer->IsFlat() || |
3516 length < SlicedString::kMinLength || | 3516 length < SlicedString::kMinLength || |
3517 pretenure == TENURED) { | 3517 pretenure == TENURED) { |
3518 Object* result; | 3518 Object* result; |
3519 // WriteToFlat takes care of the case when an indirect string has a | 3519 // WriteToFlat takes care of the case when an indirect string has a |
3520 // different encoding from its underlying string. These encodings may | 3520 // different encoding from its underlying string. These encodings may |
3521 // differ because of externalization. | 3521 // differ because of externalization. |
3522 bool is_ascii = buffer->IsAsciiRepresentation(); | 3522 bool is_ascii = buffer->IsOneByteRepresentation(); |
3523 { MaybeObject* maybe_result = is_ascii | 3523 { MaybeObject* maybe_result = is_ascii |
3524 ? AllocateRawAsciiString(length, pretenure) | 3524 ? AllocateRawOneByteString(length, pretenure) |
3525 : AllocateRawTwoByteString(length, pretenure); | 3525 : AllocateRawTwoByteString(length, pretenure); |
3526 if (!maybe_result->ToObject(&result)) return maybe_result; | 3526 if (!maybe_result->ToObject(&result)) return maybe_result; |
3527 } | 3527 } |
3528 String* string_result = String::cast(result); | 3528 String* string_result = String::cast(result); |
3529 // Copy the characters into the new object. | 3529 // Copy the characters into the new object. |
3530 if (is_ascii) { | 3530 if (is_ascii) { |
3531 ASSERT(string_result->IsAsciiRepresentation()); | 3531 ASSERT(string_result->IsOneByteRepresentation()); |
3532 char* dest = SeqOneByteString::cast(string_result)->GetChars(); | 3532 char* dest = SeqOneByteString::cast(string_result)->GetChars(); |
3533 String::WriteToFlat(buffer, dest, start, end); | 3533 String::WriteToFlat(buffer, dest, start, end); |
3534 } else { | 3534 } else { |
3535 ASSERT(string_result->IsTwoByteRepresentation()); | 3535 ASSERT(string_result->IsTwoByteRepresentation()); |
3536 uc16* dest = SeqTwoByteString::cast(string_result)->GetChars(); | 3536 uc16* dest = SeqTwoByteString::cast(string_result)->GetChars(); |
3537 String::WriteToFlat(buffer, dest, start, end); | 3537 String::WriteToFlat(buffer, dest, start, end); |
3538 } | 3538 } |
3539 return result; | 3539 return result; |
3540 } | 3540 } |
3541 | 3541 |
3542 ASSERT(buffer->IsFlat()); | 3542 ASSERT(buffer->IsFlat()); |
3543 #if VERIFY_HEAP | 3543 #if VERIFY_HEAP |
3544 if (FLAG_verify_heap) { | 3544 if (FLAG_verify_heap) { |
3545 buffer->StringVerify(); | 3545 buffer->StringVerify(); |
3546 } | 3546 } |
3547 #endif | 3547 #endif |
3548 | 3548 |
3549 Object* result; | 3549 Object* result; |
3550 // When slicing an indirect string we use its encoding for a newly created | 3550 // When slicing an indirect string we use its encoding for a newly created |
3551 // slice and don't check the encoding of the underlying string. This is safe | 3551 // slice and don't check the encoding of the underlying string. This is safe |
3552 // even if the encodings are different because of externalization. If an | 3552 // even if the encodings are different because of externalization. If an |
3553 // indirect ASCII string is pointing to a two-byte string, the two-byte char | 3553 // indirect ASCII string is pointing to a two-byte string, the two-byte char |
3554 // codes of the underlying string must still fit into ASCII (because | 3554 // codes of the underlying string must still fit into ASCII (because |
3555 // externalization must not change char codes). | 3555 // externalization must not change char codes). |
3556 { Map* map = buffer->IsAsciiRepresentation() | 3556 { Map* map = buffer->IsOneByteRepresentation() |
3557 ? sliced_ascii_string_map() | 3557 ? sliced_ascii_string_map() |
3558 : sliced_string_map(); | 3558 : sliced_string_map(); |
3559 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 3559 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
3560 if (!maybe_result->ToObject(&result)) return maybe_result; | 3560 if (!maybe_result->ToObject(&result)) return maybe_result; |
3561 } | 3561 } |
3562 | 3562 |
3563 AssertNoAllocation no_gc; | 3563 AssertNoAllocation no_gc; |
3564 SlicedString* sliced_string = SlicedString::cast(result); | 3564 SlicedString* sliced_string = SlicedString::cast(result); |
3565 sliced_string->set_length(length); | 3565 sliced_string->set_length(length); |
3566 sliced_string->set_hash_field(String::kEmptyHashField); | 3566 sliced_string->set_hash_field(String::kEmptyHashField); |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4552 | 4552 |
4553 // Reset the map for the object. | 4553 // Reset the map for the object. |
4554 object->set_map(constructor->initial_map()); | 4554 object->set_map(constructor->initial_map()); |
4555 | 4555 |
4556 // Reinitialize the object from the constructor map. | 4556 // Reinitialize the object from the constructor map. |
4557 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); | 4557 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); |
4558 return object; | 4558 return object; |
4559 } | 4559 } |
4560 | 4560 |
4561 | 4561 |
4562 MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string, | 4562 MaybeObject* Heap::AllocateStringFromOneByte(Vector<const char> string, |
4563 PretenureFlag pretenure) { | 4563 PretenureFlag pretenure) { |
4564 int length = string.length(); | 4564 int length = string.length(); |
4565 if (length == 1) { | 4565 if (length == 1) { |
4566 return Heap::LookupSingleCharacterStringFromCode(string[0]); | 4566 return Heap::LookupSingleCharacterStringFromCode(string[0]); |
4567 } | 4567 } |
4568 Object* result; | 4568 Object* result; |
4569 { MaybeObject* maybe_result = | 4569 { MaybeObject* maybe_result = |
4570 AllocateRawAsciiString(string.length(), pretenure); | 4570 AllocateRawOneByteString(string.length(), pretenure); |
4571 if (!maybe_result->ToObject(&result)) return maybe_result; | 4571 if (!maybe_result->ToObject(&result)) return maybe_result; |
4572 } | 4572 } |
4573 | 4573 |
4574 // Copy the characters into the new object. | 4574 // Copy the characters into the new object. |
4575 CopyChars(SeqOneByteString::cast(result)->GetChars(), string.start(), length); | 4575 CopyChars(SeqOneByteString::cast(result)->GetChars(), string.start(), length); |
4576 return result; | 4576 return result; |
4577 } | 4577 } |
4578 | 4578 |
4579 | 4579 |
4580 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, | 4580 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4618 | 4618 |
4619 | 4619 |
4620 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, | 4620 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, |
4621 PretenureFlag pretenure) { | 4621 PretenureFlag pretenure) { |
4622 // Check if the string is an ASCII string. | 4622 // Check if the string is an ASCII string. |
4623 Object* result; | 4623 Object* result; |
4624 int length = string.length(); | 4624 int length = string.length(); |
4625 const uc16* start = string.start(); | 4625 const uc16* start = string.start(); |
4626 | 4626 |
4627 if (String::IsAscii(start, length)) { | 4627 if (String::IsAscii(start, length)) { |
4628 MaybeObject* maybe_result = AllocateRawAsciiString(length, pretenure); | 4628 MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure); |
4629 if (!maybe_result->ToObject(&result)) return maybe_result; | 4629 if (!maybe_result->ToObject(&result)) return maybe_result; |
4630 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length); | 4630 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length); |
4631 } else { // It's not an ASCII string. | 4631 } else { // It's not an ASCII string. |
4632 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure); | 4632 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure); |
4633 if (!maybe_result->ToObject(&result)) return maybe_result; | 4633 if (!maybe_result->ToObject(&result)) return maybe_result; |
4634 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length); | 4634 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length); |
4635 } | 4635 } |
4636 return result; | 4636 return result; |
4637 } | 4637 } |
4638 | 4638 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4719 answer->Set(i++, unibrow::Utf16::LeadSurrogate(character)); | 4719 answer->Set(i++, unibrow::Utf16::LeadSurrogate(character)); |
4720 answer->Set(i++, unibrow::Utf16::TrailSurrogate(character)); | 4720 answer->Set(i++, unibrow::Utf16::TrailSurrogate(character)); |
4721 } else { | 4721 } else { |
4722 answer->Set(i++, character); | 4722 answer->Set(i++, character); |
4723 } | 4723 } |
4724 } | 4724 } |
4725 return answer; | 4725 return answer; |
4726 } | 4726 } |
4727 | 4727 |
4728 | 4728 |
4729 MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) { | 4729 MaybeObject* Heap::AllocateRawOneByteString(int length, |
| 4730 PretenureFlag pretenure) { |
4730 if (length < 0 || length > SeqOneByteString::kMaxLength) { | 4731 if (length < 0 || length > SeqOneByteString::kMaxLength) { |
4731 return Failure::OutOfMemoryException(); | 4732 return Failure::OutOfMemoryException(); |
4732 } | 4733 } |
4733 | 4734 |
4734 int size = SeqOneByteString::SizeFor(length); | 4735 int size = SeqOneByteString::SizeFor(length); |
4735 ASSERT(size <= SeqOneByteString::kMaxSize); | 4736 ASSERT(size <= SeqOneByteString::kMaxSize); |
4736 | 4737 |
4737 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 4738 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
4738 AllocationSpace retry_space = OLD_DATA_SPACE; | 4739 AllocationSpace retry_space = OLD_DATA_SPACE; |
4739 | 4740 |
(...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7504 static_cast<int>(object_sizes_last_time_[index])); | 7505 static_cast<int>(object_sizes_last_time_[index])); |
7505 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7506 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7506 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7507 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7507 | 7508 |
7508 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7509 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7509 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7510 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7510 ClearObjectStats(); | 7511 ClearObjectStats(); |
7511 } | 7512 } |
7512 | 7513 |
7513 } } // namespace v8::internal | 7514 } } // namespace v8::internal |
OLD | NEW |