OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1294 ? heap->external_string_with_one_byte_data_map() | 1294 ? heap->external_string_with_one_byte_data_map() |
1295 : heap->external_string_map())); | 1295 : heap->external_string_map())); |
1296 } | 1296 } |
1297 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); | 1297 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); |
1298 self->set_resource(resource); | 1298 self->set_resource(resource); |
1299 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1299 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1300 | 1300 |
1301 // Fill the remainder of the string with dead wood. | 1301 // Fill the remainder of the string with dead wood. |
1302 int new_size = this->Size(); // Byte size of the external String object. | 1302 int new_size = this->Size(); // Byte size of the external String object. |
1303 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1303 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1304 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 1304 if (heap->incremental_marking()->IsMarking() && |
1305 Marking::IsBlack(Marking::MarkBitFrom(this))) { | |
1305 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), | 1306 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), |
1306 new_size - size); | 1307 new_size - size); |
1307 } | 1308 } |
1308 return true; | 1309 return true; |
1309 } | 1310 } |
1310 | 1311 |
1311 | 1312 |
1312 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { | 1313 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { |
1313 #ifdef ENABLE_SLOW_ASSERTS | 1314 #ifdef ENABLE_SLOW_ASSERTS |
1314 if (FLAG_enable_slow_asserts) { | 1315 if (FLAG_enable_slow_asserts) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 is_internalized ? heap->external_ascii_internalized_string_map() | 1354 is_internalized ? heap->external_ascii_internalized_string_map() |
1354 : heap->external_ascii_string_map()); | 1355 : heap->external_ascii_string_map()); |
1355 } | 1356 } |
1356 ExternalAsciiString* self = ExternalAsciiString::cast(this); | 1357 ExternalAsciiString* self = ExternalAsciiString::cast(this); |
1357 self->set_resource(resource); | 1358 self->set_resource(resource); |
1358 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1359 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1359 | 1360 |
1360 // Fill the remainder of the string with dead wood. | 1361 // Fill the remainder of the string with dead wood. |
1361 int new_size = this->Size(); // Byte size of the external String object. | 1362 int new_size = this->Size(); // Byte size of the external String object. |
1362 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1363 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1363 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 1364 if (heap->incremental_marking()->IsMarking() && |
1365 Marking::IsBlack(Marking::MarkBitFrom(this))) { | |
1364 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), | 1366 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), |
1365 new_size - size); | 1367 new_size - size); |
1366 } | 1368 } |
1367 return true; | 1369 return true; |
1368 } | 1370 } |
1369 | 1371 |
1370 | 1372 |
1371 void String::StringShortPrint(StringStream* accumulator) { | 1373 void String::StringShortPrint(StringStream* accumulator) { |
1372 int len = length(); | 1374 int len = length(); |
1373 if (len > kMaxShortPrintLength) { | 1375 if (len > kMaxShortPrintLength) { |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2269 // If we are doing a big trim in old space then we zap the space. | 2271 // If we are doing a big trim in old space then we zap the space. |
2270 Object** zap = reinterpret_cast<Object**>(new_end); | 2272 Object** zap = reinterpret_cast<Object**>(new_end); |
2271 zap++; // Header of filler must be at least one word so skip that. | 2273 zap++; // Header of filler must be at least one word so skip that. |
2272 for (int i = 1; i < to_trim; i++) { | 2274 for (int i = 1; i < to_trim; i++) { |
2273 *zap++ = Smi::FromInt(0); | 2275 *zap++ = Smi::FromInt(0); |
2274 } | 2276 } |
2275 } | 2277 } |
2276 | 2278 |
2277 | 2279 |
2278 template<RightTrimMode trim_mode> | 2280 template<RightTrimMode trim_mode> |
2279 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { | 2281 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { |
Michael Starzinger
2014/03/19 09:30:35
As discussed offline: There also is access to the
Hannes Payer (out of office)
2014/03/19 11:27:51
Done.
| |
2280 ASSERT(elms->map() != heap->fixed_cow_array_map()); | 2282 ASSERT(elms->map() != heap->fixed_cow_array_map()); |
2281 // For now this trick is only applied to fixed arrays in new and paged space. | 2283 // For now this trick is only applied to fixed arrays in new and paged space. |
2282 ASSERT(!heap->lo_space()->Contains(elms)); | 2284 ASSERT(!heap->lo_space()->Contains(elms)); |
2283 | 2285 |
2284 const int len = elms->length(); | 2286 const int len = elms->length(); |
2285 | 2287 |
2286 ASSERT(to_trim < len); | 2288 ASSERT(to_trim < len); |
2287 | 2289 |
2288 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); | 2290 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); |
2289 | 2291 |
2290 if (trim_mode != FROM_GC || Heap::ShouldZapGarbage()) { | 2292 if (trim_mode != FROM_GC || Heap::ShouldZapGarbage()) { |
2291 ZapEndOfFixedArray(new_end, to_trim); | 2293 ZapEndOfFixedArray(new_end, to_trim); |
2292 } | 2294 } |
2293 | 2295 |
2294 int size_delta = to_trim * kPointerSize; | 2296 int size_delta = to_trim * kPointerSize; |
2295 | 2297 |
2296 // Technically in new space this write might be omitted (except for | 2298 // Technically in new space this write might be omitted (except for |
2297 // debug mode which iterates through the heap), but to play safer | 2299 // debug mode which iterates through the heap), but to play safer |
2298 // we still do it. | 2300 // we still do it. |
2299 heap->CreateFillerObjectAt(new_end, size_delta); | 2301 heap->CreateFillerObjectAt(new_end, size_delta); |
2300 | 2302 |
2301 elms->set_length(len - to_trim); | 2303 elms->set_length(len - to_trim); |
2302 | 2304 |
2303 // Maintain marking consistency for IncrementalMarking. | 2305 // Maintain marking consistency for IncrementalMarking. |
2304 if (Marking::IsBlack(Marking::MarkBitFrom(elms))) { | 2306 if (heap->incremental_marking()->IsMarking() && |
2307 Marking::IsBlack(Marking::MarkBitFrom(elms))) { | |
Michael Starzinger
2014/03/19 09:30:35
As discussed offline: I am not sure distinguishing
Hannes Payer (out of office)
2014/03/19 11:27:51
Done.
| |
2305 if (trim_mode == FROM_GC) { | 2308 if (trim_mode == FROM_GC) { |
2306 MemoryChunk::IncrementLiveBytesFromGC(elms->address(), -size_delta); | 2309 MemoryChunk::IncrementLiveBytesFromGC(elms->address(), -size_delta); |
2307 } else { | 2310 } else { |
2308 MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); | 2311 MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); |
2309 } | 2312 } |
2310 } | 2313 } |
2311 | 2314 |
2312 // The array may not be moved during GC, | 2315 // The array may not be moved during GC, |
2313 // and size has to be adjusted nevertheless. | 2316 // and size has to be adjusted nevertheless. |
2314 HeapProfiler* profiler = heap->isolate()->heap_profiler(); | 2317 HeapProfiler* profiler = heap->isolate()->heap_profiler(); |
(...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4636 Handle<Map> new_map = NormalizedMapCache::Get(cache, object, mode); | 4639 Handle<Map> new_map = NormalizedMapCache::Get(cache, object, mode); |
4637 ASSERT(new_map->is_dictionary_map()); | 4640 ASSERT(new_map->is_dictionary_map()); |
4638 | 4641 |
4639 // From here on we cannot fail and we shouldn't GC anymore. | 4642 // From here on we cannot fail and we shouldn't GC anymore. |
4640 DisallowHeapAllocation no_allocation; | 4643 DisallowHeapAllocation no_allocation; |
4641 | 4644 |
4642 // Resize the object in the heap if necessary. | 4645 // Resize the object in the heap if necessary. |
4643 int new_instance_size = new_map->instance_size(); | 4646 int new_instance_size = new_map->instance_size(); |
4644 int instance_size_delta = map->instance_size() - new_instance_size; | 4647 int instance_size_delta = map->instance_size() - new_instance_size; |
4645 ASSERT(instance_size_delta >= 0); | 4648 ASSERT(instance_size_delta >= 0); |
4646 isolate->heap()->CreateFillerObjectAt(object->address() + new_instance_size, | 4649 Heap* heap = isolate->heap(); |
4647 instance_size_delta); | 4650 heap->CreateFillerObjectAt(object->address() + new_instance_size, |
4648 if (Marking::IsBlack(Marking::MarkBitFrom(*object))) { | 4651 instance_size_delta); |
4652 if (heap->incremental_marking()->IsMarking() && | |
4653 Marking::IsBlack(Marking::MarkBitFrom(*object))) { | |
4649 MemoryChunk::IncrementLiveBytesFromMutator(object->address(), | 4654 MemoryChunk::IncrementLiveBytesFromMutator(object->address(), |
4650 -instance_size_delta); | 4655 -instance_size_delta); |
4651 } | 4656 } |
4652 | 4657 |
4653 object->set_map(*new_map); | 4658 object->set_map(*new_map); |
4654 map->NotifyLeafMapLayoutChange(); | 4659 map->NotifyLeafMapLayoutChange(); |
4655 | 4660 |
4656 object->set_properties(*dictionary); | 4661 object->set_properties(*dictionary); |
4657 | 4662 |
4658 isolate->counters()->props_to_dictionary()->Increment(); | 4663 isolate->counters()->props_to_dictionary()->Increment(); |
(...skipping 4551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9210 NewSpace* newspace = heap->new_space(); | 9215 NewSpace* newspace = heap->new_space(); |
9211 if (newspace->Contains(start_of_string) && | 9216 if (newspace->Contains(start_of_string) && |
9212 newspace->top() == start_of_string + old_size) { | 9217 newspace->top() == start_of_string + old_size) { |
9213 // Last allocated object in new space. Simply lower allocation top. | 9218 // Last allocated object in new space. Simply lower allocation top. |
9214 newspace->set_top(start_of_string + new_size); | 9219 newspace->set_top(start_of_string + new_size); |
9215 } else { | 9220 } else { |
9216 // Sizes are pointer size aligned, so that we can use filler objects | 9221 // Sizes are pointer size aligned, so that we can use filler objects |
9217 // that are a multiple of pointer size. | 9222 // that are a multiple of pointer size. |
9218 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | 9223 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
9219 } | 9224 } |
9220 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) { | 9225 if (heap->incremental_marking()->IsMarking() && |
9226 Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) { | |
9221 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); | 9227 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); |
9222 } | 9228 } |
9223 | 9229 |
9224 | 9230 |
9225 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9231 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9226 return string; | 9232 return string; |
9227 } | 9233 } |
9228 | 9234 |
9229 | 9235 |
9230 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 9236 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
(...skipping 7298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16529 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16535 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16530 static const char* error_messages_[] = { | 16536 static const char* error_messages_[] = { |
16531 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16537 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16532 }; | 16538 }; |
16533 #undef ERROR_MESSAGES_TEXTS | 16539 #undef ERROR_MESSAGES_TEXTS |
16534 return error_messages_[reason]; | 16540 return error_messages_[reason]; |
16535 } | 16541 } |
16536 | 16542 |
16537 | 16543 |
16538 } } // namespace v8::internal | 16544 } } // namespace v8::internal |
OLD | NEW |