| 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 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 set_null_value(Oddball::cast(obj)); | 2492 set_null_value(Oddball::cast(obj)); |
| 2493 Oddball::cast(obj)->set_kind(Oddball::kNull); | 2493 Oddball::cast(obj)->set_kind(Oddball::kNull); |
| 2494 | 2494 |
| 2495 { MaybeObject* maybe_obj = Allocate(undefined_map(), OLD_POINTER_SPACE); | 2495 { MaybeObject* maybe_obj = Allocate(undefined_map(), OLD_POINTER_SPACE); |
| 2496 if (!maybe_obj->ToObject(&obj)) return false; | 2496 if (!maybe_obj->ToObject(&obj)) return false; |
| 2497 } | 2497 } |
| 2498 set_undefined_value(Oddball::cast(obj)); | 2498 set_undefined_value(Oddball::cast(obj)); |
| 2499 Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 2499 Oddball::cast(obj)->set_kind(Oddball::kUndefined); |
| 2500 ASSERT(!InNewSpace(undefined_value())); | 2500 ASSERT(!InNewSpace(undefined_value())); |
| 2501 | 2501 |
| 2502 // Set preliminary exception sentinel value before actually initializing it. |
| 2503 set_exception(null_value()); |
| 2504 |
| 2502 // Allocate the empty descriptor array. | 2505 // Allocate the empty descriptor array. |
| 2503 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); | 2506 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); |
| 2504 if (!maybe_obj->ToObject(&obj)) return false; | 2507 if (!maybe_obj->ToObject(&obj)) return false; |
| 2505 } | 2508 } |
| 2506 set_empty_descriptor_array(DescriptorArray::cast(obj)); | 2509 set_empty_descriptor_array(DescriptorArray::cast(obj)); |
| 2507 | 2510 |
| 2508 // Allocate the constant pool array. | 2511 // Allocate the constant pool array. |
| 2509 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray(); | 2512 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray(); |
| 2510 if (!maybe_obj->ToObject(&obj)) return false; | 2513 if (!maybe_obj->ToObject(&obj)) return false; |
| 2511 } | 2514 } |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 decoder(isolate_->unicode_cache()->utf8_decoder()); | 3968 decoder(isolate_->unicode_cache()->utf8_decoder()); |
| 3966 decoder->Reset(string.start() + non_ascii_start, | 3969 decoder->Reset(string.start() + non_ascii_start, |
| 3967 string.length() - non_ascii_start); | 3970 string.length() - non_ascii_start); |
| 3968 int utf16_length = decoder->Utf16Length(); | 3971 int utf16_length = decoder->Utf16Length(); |
| 3969 ASSERT(utf16_length > 0); | 3972 ASSERT(utf16_length > 0); |
| 3970 // Allocate string. | 3973 // Allocate string. |
| 3971 Object* result; | 3974 Object* result; |
| 3972 { | 3975 { |
| 3973 int chars = non_ascii_start + utf16_length; | 3976 int chars = non_ascii_start + utf16_length; |
| 3974 MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure); | 3977 MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure); |
| 3975 if (!maybe_result->ToObject(&result)) return maybe_result; | 3978 if (!maybe_result->ToObject(&result) || result->IsException()) { |
| 3979 return maybe_result; |
| 3980 } |
| 3976 } | 3981 } |
| 3977 // Convert and copy the characters into the new object. | 3982 // Convert and copy the characters into the new object. |
| 3978 SeqTwoByteString* twobyte = SeqTwoByteString::cast(result); | 3983 SeqTwoByteString* twobyte = SeqTwoByteString::cast(result); |
| 3979 // Copy ascii portion. | 3984 // Copy ascii portion. |
| 3980 uint16_t* data = twobyte->GetChars(); | 3985 uint16_t* data = twobyte->GetChars(); |
| 3981 if (non_ascii_start != 0) { | 3986 if (non_ascii_start != 0) { |
| 3982 const char* ascii_data = string.start(); | 3987 const char* ascii_data = string.start(); |
| 3983 for (int i = 0; i < non_ascii_start; i++) { | 3988 for (int i = 0; i < non_ascii_start; i++) { |
| 3984 *data++ = *ascii_data++; | 3989 *data++ = *ascii_data++; |
| 3985 } | 3990 } |
| 3986 } | 3991 } |
| 3987 // Now write the remainder. | 3992 // Now write the remainder. |
| 3988 decoder->WriteUtf16(data, utf16_length); | 3993 decoder->WriteUtf16(data, utf16_length); |
| 3989 return result; | 3994 return result; |
| 3990 } | 3995 } |
| 3991 | 3996 |
| 3992 | 3997 |
| 3993 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, | 3998 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, |
| 3994 PretenureFlag pretenure) { | 3999 PretenureFlag pretenure) { |
| 3995 // Check if the string is an ASCII string. | 4000 // Check if the string is an ASCII string. |
| 3996 Object* result; | 4001 Object* result; |
| 3997 int length = string.length(); | 4002 int length = string.length(); |
| 3998 const uc16* start = string.start(); | 4003 const uc16* start = string.start(); |
| 3999 | 4004 |
| 4000 if (String::IsOneByte(start, length)) { | 4005 if (String::IsOneByte(start, length)) { |
| 4001 MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure); | 4006 MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure); |
| 4002 if (!maybe_result->ToObject(&result)) return maybe_result; | 4007 if (!maybe_result->ToObject(&result) || result->IsException()) { |
| 4008 return maybe_result; |
| 4009 } |
| 4003 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length); | 4010 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length); |
| 4004 } else { // It's not a one byte string. | 4011 } else { // It's not a one byte string. |
| 4005 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure); | 4012 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure); |
| 4006 if (!maybe_result->ToObject(&result)) return maybe_result; | 4013 if (!maybe_result->ToObject(&result) || result->IsException()) { |
| 4014 return maybe_result; |
| 4015 } |
| 4007 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length); | 4016 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length); |
| 4008 } | 4017 } |
| 4009 return result; | 4018 return result; |
| 4010 } | 4019 } |
| 4011 | 4020 |
| 4012 | 4021 |
| 4013 Map* Heap::InternalizedStringMapForString(String* string) { | 4022 Map* Heap::InternalizedStringMapForString(String* string) { |
| 4014 // If the string is in new space it cannot be used as internalized. | 4023 // If the string is in new space it cannot be used as internalized. |
| 4015 if (InNewSpace(string)) return NULL; | 4024 if (InNewSpace(string)) return NULL; |
| 4016 | 4025 |
| (...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6724 static_cast<int>(object_sizes_last_time_[index])); | 6733 static_cast<int>(object_sizes_last_time_[index])); |
| 6725 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6734 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6726 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6735 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6727 | 6736 |
| 6728 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6737 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6729 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6738 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6730 ClearObjectStats(); | 6739 ClearObjectStats(); |
| 6731 } | 6740 } |
| 6732 | 6741 |
| 6733 } } // namespace v8::internal | 6742 } } // namespace v8::internal |
| OLD | NEW |