| 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 4954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 | 4965 |
| 4966 | 4966 |
| 4967 template<bool is_one_byte, typename T> | 4967 template<bool is_one_byte, typename T> |
| 4968 MaybeObject* Heap::AllocateInternalizedStringImpl( | 4968 MaybeObject* Heap::AllocateInternalizedStringImpl( |
| 4969 T t, int chars, uint32_t hash_field) { | 4969 T t, int chars, uint32_t hash_field) { |
| 4970 ASSERT(chars >= 0); | 4970 ASSERT(chars >= 0); |
| 4971 // Compute map and object size. | 4971 // Compute map and object size. |
| 4972 int size; | 4972 int size; |
| 4973 Map* map; | 4973 Map* map; |
| 4974 | 4974 |
| 4975 if (chars > String::kMaxLength) { |
| 4976 return Failure::OutOfMemoryException(0x9); |
| 4977 } |
| 4975 if (is_one_byte) { | 4978 if (is_one_byte) { |
| 4976 if (chars > SeqOneByteString::kMaxLength) { | |
| 4977 return Failure::OutOfMemoryException(0x9); | |
| 4978 } | |
| 4979 map = ascii_internalized_string_map(); | 4979 map = ascii_internalized_string_map(); |
| 4980 size = SeqOneByteString::SizeFor(chars); | 4980 size = SeqOneByteString::SizeFor(chars); |
| 4981 } else { | 4981 } else { |
| 4982 if (chars > SeqTwoByteString::kMaxLength) { | |
| 4983 return Failure::OutOfMemoryException(0xa); | |
| 4984 } | |
| 4985 map = internalized_string_map(); | 4982 map = internalized_string_map(); |
| 4986 size = SeqTwoByteString::SizeFor(chars); | 4983 size = SeqTwoByteString::SizeFor(chars); |
| 4987 } | 4984 } |
| 4988 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); | 4985 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); |
| 4989 | 4986 |
| 4990 // Allocate string. | 4987 // Allocate string. |
| 4991 Object* result; | 4988 Object* result; |
| 4992 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); | 4989 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4993 if (!maybe_result->ToObject(&result)) return maybe_result; | 4990 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 4994 } | 4991 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5016 template | 5013 template |
| 5017 MaybeObject* Heap::AllocateInternalizedStringImpl<false>( | 5014 MaybeObject* Heap::AllocateInternalizedStringImpl<false>( |
| 5018 String*, int, uint32_t); | 5015 String*, int, uint32_t); |
| 5019 template | 5016 template |
| 5020 MaybeObject* Heap::AllocateInternalizedStringImpl<false>( | 5017 MaybeObject* Heap::AllocateInternalizedStringImpl<false>( |
| 5021 Vector<const char>, int, uint32_t); | 5018 Vector<const char>, int, uint32_t); |
| 5022 | 5019 |
| 5023 | 5020 |
| 5024 MaybeObject* Heap::AllocateRawOneByteString(int length, | 5021 MaybeObject* Heap::AllocateRawOneByteString(int length, |
| 5025 PretenureFlag pretenure) { | 5022 PretenureFlag pretenure) { |
| 5026 if (length < 0 || length > SeqOneByteString::kMaxLength) { | 5023 if (length < 0 || length > String::kMaxLength) { |
| 5027 return Failure::OutOfMemoryException(0xb); | 5024 return Failure::OutOfMemoryException(0xb); |
| 5028 } | 5025 } |
| 5029 int size = SeqOneByteString::SizeFor(length); | 5026 int size = SeqOneByteString::SizeFor(length); |
| 5030 ASSERT(size <= SeqOneByteString::kMaxSize); | 5027 ASSERT(size <= SeqOneByteString::kMaxSize); |
| 5031 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 5028 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 5032 | 5029 |
| 5033 Object* result; | 5030 Object* result; |
| 5034 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); | 5031 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 5035 if (!maybe_result->ToObject(&result)) return maybe_result; | 5032 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5036 } | 5033 } |
| 5037 | 5034 |
| 5038 // Partially initialize the object. | 5035 // Partially initialize the object. |
| 5039 HeapObject::cast(result)->set_map_no_write_barrier(ascii_string_map()); | 5036 HeapObject::cast(result)->set_map_no_write_barrier(ascii_string_map()); |
| 5040 String::cast(result)->set_length(length); | 5037 String::cast(result)->set_length(length); |
| 5041 String::cast(result)->set_hash_field(String::kEmptyHashField); | 5038 String::cast(result)->set_hash_field(String::kEmptyHashField); |
| 5042 ASSERT_EQ(size, HeapObject::cast(result)->Size()); | 5039 ASSERT_EQ(size, HeapObject::cast(result)->Size()); |
| 5043 | 5040 |
| 5044 return result; | 5041 return result; |
| 5045 } | 5042 } |
| 5046 | 5043 |
| 5047 | 5044 |
| 5048 MaybeObject* Heap::AllocateRawTwoByteString(int length, | 5045 MaybeObject* Heap::AllocateRawTwoByteString(int length, |
| 5049 PretenureFlag pretenure) { | 5046 PretenureFlag pretenure) { |
| 5050 if (length < 0 || length > SeqTwoByteString::kMaxLength) { | 5047 if (length < 0 || length > String::kMaxLength) { |
| 5051 return Failure::OutOfMemoryException(0xc); | 5048 return Failure::OutOfMemoryException(0xc); |
| 5052 } | 5049 } |
| 5053 int size = SeqTwoByteString::SizeFor(length); | 5050 int size = SeqTwoByteString::SizeFor(length); |
| 5054 ASSERT(size <= SeqTwoByteString::kMaxSize); | 5051 ASSERT(size <= SeqTwoByteString::kMaxSize); |
| 5055 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 5052 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 5056 | 5053 |
| 5057 Object* result; | 5054 Object* result; |
| 5058 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); | 5055 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 5059 if (!maybe_result->ToObject(&result)) return maybe_result; | 5056 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5060 } | 5057 } |
| (...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7804 static_cast<int>(object_sizes_last_time_[index])); | 7801 static_cast<int>(object_sizes_last_time_[index])); |
| 7805 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7802 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7806 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7803 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7807 | 7804 |
| 7808 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7805 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7809 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7806 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7810 ClearObjectStats(); | 7807 ClearObjectStats(); |
| 7811 } | 7808 } |
| 7812 | 7809 |
| 7813 } } // namespace v8::internal | 7810 } } // namespace v8::internal |
| OLD | NEW |