| 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 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); |
| 1305 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), | |
| 1306 new_size - size); | |
| 1307 } | |
| 1308 return true; | 1305 return true; |
| 1309 } | 1306 } |
| 1310 | 1307 |
| 1311 | 1308 |
| 1312 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { | 1309 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { |
| 1313 #ifdef ENABLE_SLOW_ASSERTS | 1310 #ifdef ENABLE_SLOW_ASSERTS |
| 1314 if (FLAG_enable_slow_asserts) { | 1311 if (FLAG_enable_slow_asserts) { |
| 1315 // Assert that the resource and the string are equivalent. | 1312 // Assert that the resource and the string are equivalent. |
| 1316 ASSERT(static_cast<size_t>(this->length()) == resource->length()); | 1313 ASSERT(static_cast<size_t>(this->length()) == resource->length()); |
| 1317 if (this->IsTwoByteRepresentation()) { | 1314 if (this->IsTwoByteRepresentation()) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 is_internalized ? heap->external_ascii_internalized_string_map() | 1350 is_internalized ? heap->external_ascii_internalized_string_map() |
| 1354 : heap->external_ascii_string_map()); | 1351 : heap->external_ascii_string_map()); |
| 1355 } | 1352 } |
| 1356 ExternalAsciiString* self = ExternalAsciiString::cast(this); | 1353 ExternalAsciiString* self = ExternalAsciiString::cast(this); |
| 1357 self->set_resource(resource); | 1354 self->set_resource(resource); |
| 1358 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1355 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
| 1359 | 1356 |
| 1360 // Fill the remainder of the string with dead wood. | 1357 // Fill the remainder of the string with dead wood. |
| 1361 int new_size = this->Size(); // Byte size of the external String object. | 1358 int new_size = this->Size(); // Byte size of the external String object. |
| 1362 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1359 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
| 1363 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 1360 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); |
| 1364 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), | |
| 1365 new_size - size); | |
| 1366 } | |
| 1367 return true; | 1361 return true; |
| 1368 } | 1362 } |
| 1369 | 1363 |
| 1370 | 1364 |
| 1371 void String::StringShortPrint(StringStream* accumulator) { | 1365 void String::StringShortPrint(StringStream* accumulator) { |
| 1372 int len = length(); | 1366 int len = length(); |
| 1373 if (len > kMaxShortPrintLength) { | 1367 if (len > kMaxShortPrintLength) { |
| 1374 accumulator->Add("<Very long string[%u]>", len); | 1368 accumulator->Add("<Very long string[%u]>", len); |
| 1375 return; | 1369 return; |
| 1376 } | 1370 } |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 case kInteger32: return "i"; | 2249 case kInteger32: return "i"; |
| 2256 case kHeapObject: return "h"; | 2250 case kHeapObject: return "h"; |
| 2257 case kExternal: return "x"; | 2251 case kExternal: return "x"; |
| 2258 default: | 2252 default: |
| 2259 UNREACHABLE(); | 2253 UNREACHABLE(); |
| 2260 return NULL; | 2254 return NULL; |
| 2261 } | 2255 } |
| 2262 } | 2256 } |
| 2263 | 2257 |
| 2264 | 2258 |
| 2265 enum RightTrimMode { FROM_GC, FROM_MUTATOR }; | |
| 2266 | |
| 2267 | |
| 2268 static void ZapEndOfFixedArray(Address new_end, int to_trim) { | 2259 static void ZapEndOfFixedArray(Address new_end, int to_trim) { |
| 2269 // If we are doing a big trim in old space then we zap the space. | 2260 // If we are doing a big trim in old space then we zap the space. |
| 2270 Object** zap = reinterpret_cast<Object**>(new_end); | 2261 Object** zap = reinterpret_cast<Object**>(new_end); |
| 2271 zap++; // Header of filler must be at least one word so skip that. | 2262 zap++; // Header of filler must be at least one word so skip that. |
| 2272 for (int i = 1; i < to_trim; i++) { | 2263 for (int i = 1; i < to_trim; i++) { |
| 2273 *zap++ = Smi::FromInt(0); | 2264 *zap++ = Smi::FromInt(0); |
| 2274 } | 2265 } |
| 2275 } | 2266 } |
| 2276 | 2267 |
| 2277 | 2268 |
| 2278 template<RightTrimMode trim_mode> | 2269 template<Heap::InvocationMode mode> |
| 2279 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { | 2270 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { |
| 2280 ASSERT(elms->map() != heap->fixed_cow_array_map()); | 2271 ASSERT(elms->map() != heap->fixed_cow_array_map()); |
| 2281 // For now this trick is only applied to fixed arrays in new and paged space. | 2272 // For now this trick is only applied to fixed arrays in new and paged space. |
| 2282 ASSERT(!heap->lo_space()->Contains(elms)); | 2273 ASSERT(!heap->lo_space()->Contains(elms)); |
| 2283 | 2274 |
| 2284 const int len = elms->length(); | 2275 const int len = elms->length(); |
| 2285 | 2276 |
| 2286 ASSERT(to_trim < len); | 2277 ASSERT(to_trim < len); |
| 2287 | 2278 |
| 2288 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); | 2279 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); |
| 2289 | 2280 |
| 2290 if (trim_mode != FROM_GC || Heap::ShouldZapGarbage()) { | 2281 if (mode != Heap::FROM_GC || Heap::ShouldZapGarbage()) { |
| 2291 ZapEndOfFixedArray(new_end, to_trim); | 2282 ZapEndOfFixedArray(new_end, to_trim); |
| 2292 } | 2283 } |
| 2293 | 2284 |
| 2294 int size_delta = to_trim * kPointerSize; | 2285 int size_delta = to_trim * kPointerSize; |
| 2295 | 2286 |
| 2296 // Technically in new space this write might be omitted (except for | 2287 // Technically in new space this write might be omitted (except for |
| 2297 // debug mode which iterates through the heap), but to play safer | 2288 // debug mode which iterates through the heap), but to play safer |
| 2298 // we still do it. | 2289 // we still do it. |
| 2299 heap->CreateFillerObjectAt(new_end, size_delta); | 2290 heap->CreateFillerObjectAt(new_end, size_delta); |
| 2300 | 2291 |
| 2301 elms->set_length(len - to_trim); | 2292 elms->set_length(len - to_trim); |
| 2302 | 2293 |
| 2303 // Maintain marking consistency for IncrementalMarking. | 2294 heap->AdjustLiveBytes(elms->address(), -size_delta, mode); |
| 2304 if (Marking::IsBlack(Marking::MarkBitFrom(elms))) { | |
| 2305 if (trim_mode == FROM_GC) { | |
| 2306 MemoryChunk::IncrementLiveBytesFromGC(elms->address(), -size_delta); | |
| 2307 } else { | |
| 2308 MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); | |
| 2309 } | |
| 2310 } | |
| 2311 | 2295 |
| 2312 // The array may not be moved during GC, | 2296 // The array may not be moved during GC, |
| 2313 // and size has to be adjusted nevertheless. | 2297 // and size has to be adjusted nevertheless. |
| 2314 HeapProfiler* profiler = heap->isolate()->heap_profiler(); | 2298 HeapProfiler* profiler = heap->isolate()->heap_profiler(); |
| 2315 if (profiler->is_tracking_allocations()) { | 2299 if (profiler->is_tracking_allocations()) { |
| 2316 profiler->UpdateObjectSizeEvent(elms->address(), elms->Size()); | 2300 profiler->UpdateObjectSizeEvent(elms->address(), elms->Size()); |
| 2317 } | 2301 } |
| 2318 } | 2302 } |
| 2319 | 2303 |
| 2320 | 2304 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 // Create filler object past the new instance size. | 2432 // Create filler object past the new instance size. |
| 2449 int new_instance_size = new_map->instance_size(); | 2433 int new_instance_size = new_map->instance_size(); |
| 2450 int instance_size_delta = old_map->instance_size() - new_instance_size; | 2434 int instance_size_delta = old_map->instance_size() - new_instance_size; |
| 2451 ASSERT(instance_size_delta >= 0); | 2435 ASSERT(instance_size_delta >= 0); |
| 2452 Address address = object->address() + new_instance_size; | 2436 Address address = object->address() + new_instance_size; |
| 2453 isolate->heap()->CreateFillerObjectAt(address, instance_size_delta); | 2437 isolate->heap()->CreateFillerObjectAt(address, instance_size_delta); |
| 2454 | 2438 |
| 2455 // If there are properties in the new backing store, trim it to the correct | 2439 // If there are properties in the new backing store, trim it to the correct |
| 2456 // size and install the backing store into the object. | 2440 // size and install the backing store into the object. |
| 2457 if (external > 0) { | 2441 if (external > 0) { |
| 2458 RightTrimFixedArray<FROM_MUTATOR>(isolate->heap(), *array, inobject); | 2442 RightTrimFixedArray<Heap::FROM_MUTATOR>(isolate->heap(), *array, inobject); |
| 2459 object->set_properties(*array); | 2443 object->set_properties(*array); |
| 2460 } | 2444 } |
| 2461 | 2445 |
| 2462 object->set_map(*new_map); | 2446 object->set_map(*new_map); |
| 2463 } | 2447 } |
| 2464 | 2448 |
| 2465 | 2449 |
| 2466 Handle<TransitionArray> Map::AddTransition(Handle<Map> map, | 2450 Handle<TransitionArray> Map::AddTransition(Handle<Map> map, |
| 2467 Handle<Name> key, | 2451 Handle<Name> key, |
| 2468 Handle<Map> target, | 2452 Handle<Map> target, |
| (...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4636 Handle<Map> new_map = NormalizedMapCache::Get(cache, object, mode); | 4620 Handle<Map> new_map = NormalizedMapCache::Get(cache, object, mode); |
| 4637 ASSERT(new_map->is_dictionary_map()); | 4621 ASSERT(new_map->is_dictionary_map()); |
| 4638 | 4622 |
| 4639 // From here on we cannot fail and we shouldn't GC anymore. | 4623 // From here on we cannot fail and we shouldn't GC anymore. |
| 4640 DisallowHeapAllocation no_allocation; | 4624 DisallowHeapAllocation no_allocation; |
| 4641 | 4625 |
| 4642 // Resize the object in the heap if necessary. | 4626 // Resize the object in the heap if necessary. |
| 4643 int new_instance_size = new_map->instance_size(); | 4627 int new_instance_size = new_map->instance_size(); |
| 4644 int instance_size_delta = map->instance_size() - new_instance_size; | 4628 int instance_size_delta = map->instance_size() - new_instance_size; |
| 4645 ASSERT(instance_size_delta >= 0); | 4629 ASSERT(instance_size_delta >= 0); |
| 4646 isolate->heap()->CreateFillerObjectAt(object->address() + new_instance_size, | 4630 Heap* heap = isolate->heap(); |
| 4647 instance_size_delta); | 4631 heap->CreateFillerObjectAt(object->address() + new_instance_size, |
| 4648 if (Marking::IsBlack(Marking::MarkBitFrom(*object))) { | 4632 instance_size_delta); |
| 4649 MemoryChunk::IncrementLiveBytesFromMutator(object->address(), | 4633 heap->AdjustLiveBytes(object->address(), |
| 4650 -instance_size_delta); | 4634 -instance_size_delta, |
| 4651 } | 4635 Heap::FROM_MUTATOR); |
| 4652 | 4636 |
| 4653 object->set_map(*new_map); | 4637 object->set_map(*new_map); |
| 4654 map->NotifyLeafMapLayoutChange(); | 4638 map->NotifyLeafMapLayoutChange(); |
| 4655 | 4639 |
| 4656 object->set_properties(*dictionary); | 4640 object->set_properties(*dictionary); |
| 4657 | 4641 |
| 4658 isolate->counters()->props_to_dictionary()->Increment(); | 4642 isolate->counters()->props_to_dictionary()->Increment(); |
| 4659 | 4643 |
| 4660 #ifdef DEBUG | 4644 #ifdef DEBUG |
| 4661 if (FLAG_trace_normalization) { | 4645 if (FLAG_trace_normalization) { |
| (...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7872 cache->set(EntryToIndex(entry), obj); | 7856 cache->set(EntryToIndex(entry), obj); |
| 7873 cache->set(EntryToIndex(entry) + 1, code); | 7857 cache->set(EntryToIndex(entry) + 1, code); |
| 7874 cache->ElementAdded(); | 7858 cache->ElementAdded(); |
| 7875 return cache; | 7859 return cache; |
| 7876 } | 7860 } |
| 7877 | 7861 |
| 7878 | 7862 |
| 7879 void FixedArray::Shrink(int new_length) { | 7863 void FixedArray::Shrink(int new_length) { |
| 7880 ASSERT(0 <= new_length && new_length <= length()); | 7864 ASSERT(0 <= new_length && new_length <= length()); |
| 7881 if (new_length < length()) { | 7865 if (new_length < length()) { |
| 7882 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), this, length() - new_length); | 7866 RightTrimFixedArray<Heap::FROM_MUTATOR>( |
| 7867 GetHeap(), this, length() - new_length); |
| 7883 } | 7868 } |
| 7884 } | 7869 } |
| 7885 | 7870 |
| 7886 | 7871 |
| 7887 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 7872 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
| 7888 ElementsAccessor* accessor = array->GetElementsAccessor(); | 7873 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 7889 MaybeObject* maybe_result = | 7874 MaybeObject* maybe_result = |
| 7890 accessor->AddElementsToFixedArray(array, array, this); | 7875 accessor->AddElementsToFixedArray(array, array, this); |
| 7891 FixedArray* result; | 7876 FixedArray* result; |
| 7892 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; | 7877 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9210 NewSpace* newspace = heap->new_space(); | 9195 NewSpace* newspace = heap->new_space(); |
| 9211 if (newspace->Contains(start_of_string) && | 9196 if (newspace->Contains(start_of_string) && |
| 9212 newspace->top() == start_of_string + old_size) { | 9197 newspace->top() == start_of_string + old_size) { |
| 9213 // Last allocated object in new space. Simply lower allocation top. | 9198 // Last allocated object in new space. Simply lower allocation top. |
| 9214 newspace->set_top(start_of_string + new_size); | 9199 newspace->set_top(start_of_string + new_size); |
| 9215 } else { | 9200 } else { |
| 9216 // Sizes are pointer size aligned, so that we can use filler objects | 9201 // Sizes are pointer size aligned, so that we can use filler objects |
| 9217 // that are a multiple of pointer size. | 9202 // that are a multiple of pointer size. |
| 9218 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | 9203 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
| 9219 } | 9204 } |
| 9220 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) { | 9205 heap->AdjustLiveBytes(start_of_string, -delta, Heap::FROM_MUTATOR); |
| 9221 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); | |
| 9222 } | |
| 9223 | |
| 9224 | 9206 |
| 9225 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9207 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
| 9226 return string; | 9208 return string; |
| 9227 } | 9209 } |
| 9228 | 9210 |
| 9229 | 9211 |
| 9230 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 9212 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
| 9231 // For array indexes mix the length into the hash as an array index could | 9213 // For array indexes mix the length into the hash as an array index could |
| 9232 // be zero. | 9214 // be zero. |
| 9233 ASSERT(length > 0); | 9215 ASSERT(length > 0); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9319 int live_enum = map->EnumLength(); | 9301 int live_enum = map->EnumLength(); |
| 9320 if (live_enum == kInvalidEnumCacheSentinel) { | 9302 if (live_enum == kInvalidEnumCacheSentinel) { |
| 9321 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); | 9303 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); |
| 9322 } | 9304 } |
| 9323 if (live_enum == 0) return descriptors->ClearEnumCache(); | 9305 if (live_enum == 0) return descriptors->ClearEnumCache(); |
| 9324 | 9306 |
| 9325 FixedArray* enum_cache = descriptors->GetEnumCache(); | 9307 FixedArray* enum_cache = descriptors->GetEnumCache(); |
| 9326 | 9308 |
| 9327 int to_trim = enum_cache->length() - live_enum; | 9309 int to_trim = enum_cache->length() - live_enum; |
| 9328 if (to_trim <= 0) return; | 9310 if (to_trim <= 0) return; |
| 9329 RightTrimFixedArray<FROM_GC>(heap, descriptors->GetEnumCache(), to_trim); | 9311 RightTrimFixedArray<Heap::FROM_GC>( |
| 9312 heap, descriptors->GetEnumCache(), to_trim); |
| 9330 | 9313 |
| 9331 if (!descriptors->HasEnumIndicesCache()) return; | 9314 if (!descriptors->HasEnumIndicesCache()) return; |
| 9332 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); | 9315 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); |
| 9333 RightTrimFixedArray<FROM_GC>(heap, enum_indices_cache, to_trim); | 9316 RightTrimFixedArray<Heap::FROM_GC>(heap, enum_indices_cache, to_trim); |
| 9334 } | 9317 } |
| 9335 | 9318 |
| 9336 | 9319 |
| 9337 static void TrimDescriptorArray(Heap* heap, | 9320 static void TrimDescriptorArray(Heap* heap, |
| 9338 Map* map, | 9321 Map* map, |
| 9339 DescriptorArray* descriptors, | 9322 DescriptorArray* descriptors, |
| 9340 int number_of_own_descriptors) { | 9323 int number_of_own_descriptors) { |
| 9341 int number_of_descriptors = descriptors->number_of_descriptors_storage(); | 9324 int number_of_descriptors = descriptors->number_of_descriptors_storage(); |
| 9342 int to_trim = number_of_descriptors - number_of_own_descriptors; | 9325 int to_trim = number_of_descriptors - number_of_own_descriptors; |
| 9343 if (to_trim == 0) return; | 9326 if (to_trim == 0) return; |
| 9344 | 9327 |
| 9345 RightTrimFixedArray<FROM_GC>( | 9328 RightTrimFixedArray<Heap::FROM_GC>( |
| 9346 heap, descriptors, to_trim * DescriptorArray::kDescriptorSize); | 9329 heap, descriptors, to_trim * DescriptorArray::kDescriptorSize); |
| 9347 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); | 9330 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); |
| 9348 | 9331 |
| 9349 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors); | 9332 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors); |
| 9350 descriptors->Sort(); | 9333 descriptors->Sort(); |
| 9351 } | 9334 } |
| 9352 | 9335 |
| 9353 | 9336 |
| 9354 // Clear a possible back pointer in case the transition leads to a dead map. | 9337 // Clear a possible back pointer in case the transition leads to a dead map. |
| 9355 // Return true in case a back pointer has been cleared and false otherwise. | 9338 // Return true in case a back pointer has been cleared and false otherwise. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9409 TrimDescriptorArray(heap, this, descriptors, number_of_own_descriptors); | 9392 TrimDescriptorArray(heap, this, descriptors, number_of_own_descriptors); |
| 9410 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); | 9393 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); |
| 9411 set_owns_descriptors(true); | 9394 set_owns_descriptors(true); |
| 9412 } else { | 9395 } else { |
| 9413 ASSERT(descriptors == GetHeap()->empty_descriptor_array()); | 9396 ASSERT(descriptors == GetHeap()->empty_descriptor_array()); |
| 9414 } | 9397 } |
| 9415 } | 9398 } |
| 9416 | 9399 |
| 9417 int trim = t->number_of_transitions() - transition_index; | 9400 int trim = t->number_of_transitions() - transition_index; |
| 9418 if (trim > 0) { | 9401 if (trim > 0) { |
| 9419 RightTrimFixedArray<FROM_GC>(heap, t, t->IsSimpleTransition() | 9402 RightTrimFixedArray<Heap::FROM_GC>(heap, t, t->IsSimpleTransition() |
| 9420 ? trim : trim * TransitionArray::kTransitionSize); | 9403 ? trim : trim * TransitionArray::kTransitionSize); |
| 9421 } | 9404 } |
| 9422 } | 9405 } |
| 9423 | 9406 |
| 9424 | 9407 |
| 9425 int Map::Hash() { | 9408 int Map::Hash() { |
| 9426 // For performance reasons we only hash the 3 most variable fields of a map: | 9409 // For performance reasons we only hash the 3 most variable fields of a map: |
| 9427 // constructor, prototype and bit_field2. | 9410 // constructor, prototype and bit_field2. |
| 9428 | 9411 |
| 9429 // Shift away the tag. | 9412 // Shift away the tag. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9667 code_map->set(dst + kLiteralsOffset, | 9650 code_map->set(dst + kLiteralsOffset, |
| 9668 code_map->get(src + kLiteralsOffset)); | 9651 code_map->get(src + kLiteralsOffset)); |
| 9669 code_map->set(dst + kOsrAstIdOffset, | 9652 code_map->set(dst + kOsrAstIdOffset, |
| 9670 code_map->get(src + kOsrAstIdOffset)); | 9653 code_map->get(src + kOsrAstIdOffset)); |
| 9671 } | 9654 } |
| 9672 dst += kEntryLength; | 9655 dst += kEntryLength; |
| 9673 } | 9656 } |
| 9674 } | 9657 } |
| 9675 if (dst != length) { | 9658 if (dst != length) { |
| 9676 // Always trim even when array is cleared because of heap verifier. | 9659 // Always trim even when array is cleared because of heap verifier. |
| 9677 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst); | 9660 RightTrimFixedArray<Heap::FROM_MUTATOR>(GetHeap(), code_map, length - dst); |
| 9678 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); | 9661 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); |
| 9679 } | 9662 } |
| 9680 } | 9663 } |
| 9681 | 9664 |
| 9682 | 9665 |
| 9683 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 9666 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
| 9684 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9667 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 9685 ASSERT(shrink_by % kEntryLength == 0); | 9668 ASSERT(shrink_by % kEntryLength == 0); |
| 9686 ASSERT(shrink_by <= code_map->length() - kEntriesStart); | 9669 ASSERT(shrink_by <= code_map->length() - kEntriesStart); |
| 9687 // Always trim even when array is cleared because of heap verifier. | 9670 // Always trim even when array is cleared because of heap verifier. |
| 9688 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); | 9671 RightTrimFixedArray<Heap::FROM_GC>(GetHeap(), code_map, shrink_by); |
| 9689 if (code_map->length() == kEntriesStart) { | 9672 if (code_map->length() == kEntriesStart) { |
| 9690 ClearOptimizedCodeMap(); | 9673 ClearOptimizedCodeMap(); |
| 9691 } | 9674 } |
| 9692 } | 9675 } |
| 9693 | 9676 |
| 9694 | 9677 |
| 9695 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { | 9678 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { |
| 9696 if (object->IsGlobalObject()) return; | 9679 if (object->IsGlobalObject()) return; |
| 9697 | 9680 |
| 9698 // Make sure prototypes are fast objects and their maps have the bit set | 9681 // Make sure prototypes are fast objects and their maps have the bit set |
| (...skipping 6830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16529 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16512 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16530 static const char* error_messages_[] = { | 16513 static const char* error_messages_[] = { |
| 16531 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16514 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16532 }; | 16515 }; |
| 16533 #undef ERROR_MESSAGES_TEXTS | 16516 #undef ERROR_MESSAGES_TEXTS |
| 16534 return error_messages_[reason]; | 16517 return error_messages_[reason]; |
| 16535 } | 16518 } |
| 16536 | 16519 |
| 16537 | 16520 |
| 16538 } } // namespace v8::internal | 16521 } } // namespace v8::internal |
| OLD | NEW |