| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #elif defined(V8_TARGET_ARCH_X64) | 75 #elif defined(V8_TARGET_ARCH_X64) |
| 76 #define LUMP_OF_MEMORY (2 * MB) | 76 #define LUMP_OF_MEMORY (2 * MB) |
| 77 code_range_size_(512*MB), | 77 code_range_size_(512*MB), |
| 78 #else | 78 #else |
| 79 #define LUMP_OF_MEMORY MB | 79 #define LUMP_OF_MEMORY MB |
| 80 code_range_size_(0), | 80 code_range_size_(0), |
| 81 #endif | 81 #endif |
| 82 reserved_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | 82 reserved_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), |
| 83 max_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), | 83 max_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), |
| 84 initial_semispace_size_(Max(LUMP_OF_MEMORY, Page::kPageSize)), | 84 initial_semispace_size_(Max(LUMP_OF_MEMORY, Page::kPageSize)), |
| 85 max_old_generation_size_(1024ul * LUMP_OF_MEMORY), | 85 max_old_generation_size_(1400ul * LUMP_OF_MEMORY), |
| 86 max_executable_size_(256l * LUMP_OF_MEMORY), | 86 max_executable_size_(256l * LUMP_OF_MEMORY), |
| 87 | 87 |
| 88 // Variables set based on semispace_size_ and old_generation_size_ in | 88 // Variables set based on semispace_size_ and old_generation_size_ in |
| 89 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) | 89 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) |
| 90 // Will be 4 * reserved_semispace_size_ to ensure that young | 90 // Will be 4 * reserved_semispace_size_ to ensure that young |
| 91 // generation can be aligned to its size. | 91 // generation can be aligned to its size. |
| 92 survived_since_last_expansion_(0), | 92 survived_since_last_expansion_(0), |
| 93 sweep_generation_(0), | 93 sweep_generation_(0), |
| 94 always_allocate_scope_depth_(0), | 94 always_allocate_scope_depth_(0), |
| 95 linear_allocation_scope_depth_(0), | 95 linear_allocation_scope_depth_(0), |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 contexts_disposed_ = 0; | 818 contexts_disposed_ = 0; |
| 819 } | 819 } |
| 820 | 820 |
| 821 | 821 |
| 822 void Heap::MarkCompactPrologue() { | 822 void Heap::MarkCompactPrologue() { |
| 823 // At any old GC clear the keyed lookup cache to enable collection of unused | 823 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 824 // maps. | 824 // maps. |
| 825 isolate_->keyed_lookup_cache()->Clear(); | 825 isolate_->keyed_lookup_cache()->Clear(); |
| 826 isolate_->context_slot_cache()->Clear(); | 826 isolate_->context_slot_cache()->Clear(); |
| 827 isolate_->descriptor_lookup_cache()->Clear(); | 827 isolate_->descriptor_lookup_cache()->Clear(); |
| 828 StringSplitCache::Clear(string_split_cache()); |
| 828 | 829 |
| 829 isolate_->compilation_cache()->MarkCompactPrologue(); | 830 isolate_->compilation_cache()->MarkCompactPrologue(); |
| 830 | 831 |
| 831 CompletelyClearInstanceofCache(); | 832 CompletelyClearInstanceofCache(); |
| 832 | 833 |
| 833 // TODO(1605) select heuristic for flushing NumberString cache with | 834 // TODO(1605) select heuristic for flushing NumberString cache with |
| 834 // FlushNumberStringCache | 835 // FlushNumberStringCache |
| 835 if (FLAG_cleanup_code_caches_at_gc) { | 836 if (FLAG_cleanup_code_caches_at_gc) { |
| 836 polymorphic_code_cache()->set_cache(undefined_value()); | 837 polymorphic_code_cache()->set_cache(undefined_value()); |
| 837 } | 838 } |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); | 1341 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); |
| 1341 | 1342 |
| 1342 table_.Register(kVisitGlobalContext, | 1343 table_.Register(kVisitGlobalContext, |
| 1343 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1344 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 1344 template VisitSpecialized<Context::kSize>); | 1345 template VisitSpecialized<Context::kSize>); |
| 1345 | 1346 |
| 1346 table_.Register(kVisitConsString, | 1347 table_.Register(kVisitConsString, |
| 1347 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1348 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 1348 template VisitSpecialized<ConsString::kSize>); | 1349 template VisitSpecialized<ConsString::kSize>); |
| 1349 | 1350 |
| 1351 table_.Register(kVisitSlicedString, |
| 1352 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 1353 template VisitSpecialized<SlicedString::kSize>); |
| 1354 |
| 1350 table_.Register(kVisitSharedFunctionInfo, | 1355 table_.Register(kVisitSharedFunctionInfo, |
| 1351 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1356 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 1352 template VisitSpecialized<SharedFunctionInfo::kSize>); | 1357 template VisitSpecialized<SharedFunctionInfo::kSize>); |
| 1353 | 1358 |
| 1354 table_.Register(kVisitJSWeakMap, | 1359 table_.Register(kVisitJSWeakMap, |
| 1355 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1360 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 1356 Visit); | 1361 Visit); |
| 1357 | 1362 |
| 1358 table_.Register(kVisitJSRegExp, | 1363 table_.Register(kVisitJSRegExp, |
| 1359 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1364 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 | 2294 |
| 2290 if (InitializeNumberStringCache()->IsFailure()) return false; | 2295 if (InitializeNumberStringCache()->IsFailure()) return false; |
| 2291 | 2296 |
| 2292 // Allocate cache for single character ASCII strings. | 2297 // Allocate cache for single character ASCII strings. |
| 2293 { MaybeObject* maybe_obj = | 2298 { MaybeObject* maybe_obj = |
| 2294 AllocateFixedArray(String::kMaxAsciiCharCode + 1, TENURED); | 2299 AllocateFixedArray(String::kMaxAsciiCharCode + 1, TENURED); |
| 2295 if (!maybe_obj->ToObject(&obj)) return false; | 2300 if (!maybe_obj->ToObject(&obj)) return false; |
| 2296 } | 2301 } |
| 2297 set_single_character_string_cache(FixedArray::cast(obj)); | 2302 set_single_character_string_cache(FixedArray::cast(obj)); |
| 2298 | 2303 |
| 2304 // Allocate cache for string split. |
| 2305 { MaybeObject* maybe_obj = |
| 2306 AllocateFixedArray(StringSplitCache::kStringSplitCacheSize, TENURED); |
| 2307 if (!maybe_obj->ToObject(&obj)) return false; |
| 2308 } |
| 2309 set_string_split_cache(FixedArray::cast(obj)); |
| 2310 |
| 2299 // Allocate cache for external strings pointing to native source code. | 2311 // Allocate cache for external strings pointing to native source code. |
| 2300 { MaybeObject* maybe_obj = AllocateFixedArray(Natives::GetBuiltinsCount()); | 2312 { MaybeObject* maybe_obj = AllocateFixedArray(Natives::GetBuiltinsCount()); |
| 2301 if (!maybe_obj->ToObject(&obj)) return false; | 2313 if (!maybe_obj->ToObject(&obj)) return false; |
| 2302 } | 2314 } |
| 2303 set_natives_source_cache(FixedArray::cast(obj)); | 2315 set_natives_source_cache(FixedArray::cast(obj)); |
| 2304 | 2316 |
| 2305 // Handling of script id generation is in FACTORY->NewScript. | 2317 // Handling of script id generation is in FACTORY->NewScript. |
| 2306 set_last_script_id(undefined_value()); | 2318 set_last_script_id(undefined_value()); |
| 2307 | 2319 |
| 2308 // Initialize keyed lookup cache. | 2320 // Initialize keyed lookup cache. |
| 2309 isolate_->keyed_lookup_cache()->Clear(); | 2321 isolate_->keyed_lookup_cache()->Clear(); |
| 2310 | 2322 |
| 2311 // Initialize context slot cache. | 2323 // Initialize context slot cache. |
| 2312 isolate_->context_slot_cache()->Clear(); | 2324 isolate_->context_slot_cache()->Clear(); |
| 2313 | 2325 |
| 2314 // Initialize descriptor cache. | 2326 // Initialize descriptor cache. |
| 2315 isolate_->descriptor_lookup_cache()->Clear(); | 2327 isolate_->descriptor_lookup_cache()->Clear(); |
| 2316 | 2328 |
| 2317 // Initialize compilation cache. | 2329 // Initialize compilation cache. |
| 2318 isolate_->compilation_cache()->Clear(); | 2330 isolate_->compilation_cache()->Clear(); |
| 2319 | 2331 |
| 2320 return true; | 2332 return true; |
| 2321 } | 2333 } |
| 2322 | 2334 |
| 2323 | 2335 |
| 2336 Object* StringSplitCache::Lookup( |
| 2337 FixedArray* cache, String* string, String* pattern) { |
| 2338 if (!string->IsSymbol() || !pattern->IsSymbol()) return Smi::FromInt(0); |
| 2339 uint32_t hash = string->Hash(); |
| 2340 uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & |
| 2341 ~(kArrayEntriesPerCacheEntry - 1)); |
| 2342 if (cache->get(index + kStringOffset) == string && |
| 2343 cache->get(index + kPatternOffset) == pattern) { |
| 2344 return cache->get(index + kArrayOffset); |
| 2345 } |
| 2346 index = ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); |
| 2347 if (cache->get(index + kStringOffset) == string && |
| 2348 cache->get(index + kPatternOffset) == pattern) { |
| 2349 return cache->get(index + kArrayOffset); |
| 2350 } |
| 2351 return Smi::FromInt(0); |
| 2352 } |
| 2353 |
| 2354 |
| 2355 void StringSplitCache::Enter(Heap* heap, |
| 2356 FixedArray* cache, |
| 2357 String* string, |
| 2358 String* pattern, |
| 2359 FixedArray* array) { |
| 2360 if (!string->IsSymbol() || !pattern->IsSymbol()) return; |
| 2361 uint32_t hash = string->Hash(); |
| 2362 uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & |
| 2363 ~(kArrayEntriesPerCacheEntry - 1)); |
| 2364 if (cache->get(index + kStringOffset) == Smi::FromInt(0)) { |
| 2365 cache->set(index + kStringOffset, string); |
| 2366 cache->set(index + kPatternOffset, pattern); |
| 2367 cache->set(index + kArrayOffset, array); |
| 2368 } else { |
| 2369 uint32_t index2 = |
| 2370 ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); |
| 2371 if (cache->get(index2 + kStringOffset) == Smi::FromInt(0)) { |
| 2372 cache->set(index2 + kStringOffset, string); |
| 2373 cache->set(index2 + kPatternOffset, pattern); |
| 2374 cache->set(index2 + kArrayOffset, array); |
| 2375 } else { |
| 2376 cache->set(index2 + kStringOffset, Smi::FromInt(0)); |
| 2377 cache->set(index2 + kPatternOffset, Smi::FromInt(0)); |
| 2378 cache->set(index2 + kArrayOffset, Smi::FromInt(0)); |
| 2379 cache->set(index + kStringOffset, string); |
| 2380 cache->set(index + kPatternOffset, pattern); |
| 2381 cache->set(index + kArrayOffset, array); |
| 2382 } |
| 2383 } |
| 2384 if (array->length() < 100) { // Limit how many new symbols we want to make. |
| 2385 for (int i = 0; i < array->length(); i++) { |
| 2386 String* str = String::cast(array->get(i)); |
| 2387 Object* symbol; |
| 2388 MaybeObject* maybe_symbol = heap->LookupSymbol(str); |
| 2389 if (maybe_symbol->ToObject(&symbol)) { |
| 2390 array->set(i, symbol); |
| 2391 } |
| 2392 } |
| 2393 } |
| 2394 array->set_map(heap->fixed_cow_array_map()); |
| 2395 } |
| 2396 |
| 2397 |
| 2398 void StringSplitCache::Clear(FixedArray* cache) { |
| 2399 for (int i = 0; i < kStringSplitCacheSize; i++) { |
| 2400 cache->set(i, Smi::FromInt(0)); |
| 2401 } |
| 2402 } |
| 2403 |
| 2404 |
| 2324 MaybeObject* Heap::InitializeNumberStringCache() { | 2405 MaybeObject* Heap::InitializeNumberStringCache() { |
| 2325 // Compute the size of the number string cache based on the max heap size. | 2406 // Compute the size of the number string cache based on the max heap size. |
| 2326 // max_semispace_size_ == 512 KB => number_string_cache_size = 32. | 2407 // max_semispace_size_ == 512 KB => number_string_cache_size = 32. |
| 2327 // max_semispace_size_ == 8 MB => number_string_cache_size = 16KB. | 2408 // max_semispace_size_ == 8 MB => number_string_cache_size = 16KB. |
| 2328 int number_string_cache_size = max_semispace_size_ / 512; | 2409 int number_string_cache_size = max_semispace_size_ / 512; |
| 2329 number_string_cache_size = Max(32, Min(16*KB, number_string_cache_size)); | 2410 number_string_cache_size = Max(32, Min(16*KB, number_string_cache_size)); |
| 2330 Object* obj; | 2411 Object* obj; |
| 2331 MaybeObject* maybe_obj = | 2412 MaybeObject* maybe_obj = |
| 2332 AllocateFixedArray(number_string_cache_size * 2, TENURED); | 2413 AllocateFixedArray(number_string_cache_size * 2, TENURED); |
| 2333 if (maybe_obj->ToObject(&obj)) set_number_string_cache(FixedArray::cast(obj)); | 2414 if (maybe_obj->ToObject(&obj)) set_number_string_cache(FixedArray::cast(obj)); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 // we can try to save memory if all chars actually fit in ascii. | 2715 // we can try to save memory if all chars actually fit in ascii. |
| 2635 is_ascii_data_in_two_byte_string = | 2716 is_ascii_data_in_two_byte_string = |
| 2636 first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); | 2717 first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); |
| 2637 if (is_ascii_data_in_two_byte_string) { | 2718 if (is_ascii_data_in_two_byte_string) { |
| 2638 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); | 2719 isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); |
| 2639 } | 2720 } |
| 2640 } | 2721 } |
| 2641 | 2722 |
| 2642 // If the resulting string is small make a flat string. | 2723 // If the resulting string is small make a flat string. |
| 2643 if (length < String::kMinNonFlatLength) { | 2724 if (length < String::kMinNonFlatLength) { |
| 2725 // Note that neither of the two inputs can be a slice because: |
| 2726 STATIC_ASSERT(String::kMinNonFlatLength <= SlicedString::kMinLength); |
| 2644 ASSERT(first->IsFlat()); | 2727 ASSERT(first->IsFlat()); |
| 2645 ASSERT(second->IsFlat()); | 2728 ASSERT(second->IsFlat()); |
| 2646 if (is_ascii) { | 2729 if (is_ascii) { |
| 2647 Object* result; | 2730 Object* result; |
| 2648 { MaybeObject* maybe_result = AllocateRawAsciiString(length); | 2731 { MaybeObject* maybe_result = AllocateRawAsciiString(length); |
| 2649 if (!maybe_result->ToObject(&result)) return maybe_result; | 2732 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2650 } | 2733 } |
| 2651 // Copy the characters into the new object. | 2734 // Copy the characters into the new object. |
| 2652 char* dest = SeqAsciiString::cast(result)->GetChars(); | 2735 char* dest = SeqAsciiString::cast(result)->GetChars(); |
| 2653 // Copy first part. | 2736 // Copy first part. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2725 // dictionary. Check whether we already have the string in the symbol | 2808 // dictionary. Check whether we already have the string in the symbol |
| 2726 // table to prevent creation of many unneccesary strings. | 2809 // table to prevent creation of many unneccesary strings. |
| 2727 unsigned c1 = buffer->Get(start); | 2810 unsigned c1 = buffer->Get(start); |
| 2728 unsigned c2 = buffer->Get(start + 1); | 2811 unsigned c2 = buffer->Get(start + 1); |
| 2729 return MakeOrFindTwoCharacterString(this, c1, c2); | 2812 return MakeOrFindTwoCharacterString(this, c1, c2); |
| 2730 } | 2813 } |
| 2731 | 2814 |
| 2732 // Make an attempt to flatten the buffer to reduce access time. | 2815 // Make an attempt to flatten the buffer to reduce access time. |
| 2733 buffer = buffer->TryFlattenGetString(); | 2816 buffer = buffer->TryFlattenGetString(); |
| 2734 | 2817 |
| 2818 // TODO(1626): For now slicing external strings is not supported. However, |
| 2819 // a flat cons string can have an external string as first part in some cases. |
| 2820 // Therefore we have to single out this case as well. |
| 2821 if (!FLAG_string_slices || |
| 2822 (buffer->IsConsString() && |
| 2823 (!buffer->IsFlat() || |
| 2824 !ConsString::cast(buffer)->first()->IsSeqString())) || |
| 2825 buffer->IsExternalString() || |
| 2826 length < SlicedString::kMinLength || |
| 2827 pretenure == TENURED) { |
| 2828 Object* result; |
| 2829 { MaybeObject* maybe_result = buffer->IsAsciiRepresentation() |
| 2830 ? AllocateRawAsciiString(length, pretenure) |
| 2831 : AllocateRawTwoByteString(length, pretenure); |
| 2832 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2833 } |
| 2834 String* string_result = String::cast(result); |
| 2835 // Copy the characters into the new object. |
| 2836 if (buffer->IsAsciiRepresentation()) { |
| 2837 ASSERT(string_result->IsAsciiRepresentation()); |
| 2838 char* dest = SeqAsciiString::cast(string_result)->GetChars(); |
| 2839 String::WriteToFlat(buffer, dest, start, end); |
| 2840 } else { |
| 2841 ASSERT(string_result->IsTwoByteRepresentation()); |
| 2842 uc16* dest = SeqTwoByteString::cast(string_result)->GetChars(); |
| 2843 String::WriteToFlat(buffer, dest, start, end); |
| 2844 } |
| 2845 return result; |
| 2846 } |
| 2847 |
| 2848 ASSERT(buffer->IsFlat()); |
| 2849 ASSERT(!buffer->IsExternalString()); |
| 2850 #if DEBUG |
| 2851 buffer->StringVerify(); |
| 2852 #endif |
| 2853 |
| 2735 Object* result; | 2854 Object* result; |
| 2736 { MaybeObject* maybe_result = buffer->IsAsciiRepresentation() | 2855 { Map* map = buffer->IsAsciiRepresentation() |
| 2737 ? AllocateRawAsciiString(length, pretenure ) | 2856 ? sliced_ascii_string_map() |
| 2738 : AllocateRawTwoByteString(length, pretenure); | 2857 : sliced_string_map(); |
| 2858 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
| 2739 if (!maybe_result->ToObject(&result)) return maybe_result; | 2859 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2740 } | 2860 } |
| 2741 String* string_result = String::cast(result); | 2861 |
| 2742 // Copy the characters into the new object. | 2862 AssertNoAllocation no_gc; |
| 2743 if (buffer->IsAsciiRepresentation()) { | 2863 SlicedString* sliced_string = SlicedString::cast(result); |
| 2744 ASSERT(string_result->IsAsciiRepresentation()); | 2864 sliced_string->set_length(length); |
| 2745 char* dest = SeqAsciiString::cast(string_result)->GetChars(); | 2865 sliced_string->set_hash_field(String::kEmptyHashField); |
| 2746 String::WriteToFlat(buffer, dest, start, end); | 2866 if (buffer->IsConsString()) { |
| 2867 ConsString* cons = ConsString::cast(buffer); |
| 2868 ASSERT(cons->second()->length() == 0); |
| 2869 sliced_string->set_parent(cons->first()); |
| 2870 sliced_string->set_offset(start); |
| 2871 } else if (buffer->IsSlicedString()) { |
| 2872 // Prevent nesting sliced strings. |
| 2873 SlicedString* parent_slice = SlicedString::cast(buffer); |
| 2874 sliced_string->set_parent(parent_slice->parent()); |
| 2875 sliced_string->set_offset(start + parent_slice->offset()); |
| 2747 } else { | 2876 } else { |
| 2748 ASSERT(string_result->IsTwoByteRepresentation()); | 2877 sliced_string->set_parent(buffer); |
| 2749 uc16* dest = SeqTwoByteString::cast(string_result)->GetChars(); | 2878 sliced_string->set_offset(start); |
| 2750 String::WriteToFlat(buffer, dest, start, end); | |
| 2751 } | 2879 } |
| 2752 | 2880 ASSERT(sliced_string->parent()->IsSeqString()); |
| 2753 return result; | 2881 return result; |
| 2754 } | 2882 } |
| 2755 | 2883 |
| 2756 | 2884 |
| 2757 MaybeObject* Heap::AllocateExternalStringFromAscii( | 2885 MaybeObject* Heap::AllocateExternalStringFromAscii( |
| 2758 ExternalAsciiString::Resource* resource) { | 2886 ExternalAsciiString::Resource* resource) { |
| 2759 size_t length = resource->length(); | 2887 size_t length = resource->length(); |
| 2760 if (length > static_cast<size_t>(String::kMaxLength)) { | 2888 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2761 isolate()->context()->mark_out_of_memory(); | 2889 isolate()->context()->mark_out_of_memory(); |
| 2762 return Failure::OutOfMemoryException(); | 2890 return Failure::OutOfMemoryException(); |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3565 object->set_map(constructor->initial_map()); | 3693 object->set_map(constructor->initial_map()); |
| 3566 | 3694 |
| 3567 // Reinitialize the object from the constructor map. | 3695 // Reinitialize the object from the constructor map. |
| 3568 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); | 3696 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); |
| 3569 return object; | 3697 return object; |
| 3570 } | 3698 } |
| 3571 | 3699 |
| 3572 | 3700 |
| 3573 MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string, | 3701 MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string, |
| 3574 PretenureFlag pretenure) { | 3702 PretenureFlag pretenure) { |
| 3703 if (string.length() == 1) { |
| 3704 return Heap::LookupSingleCharacterStringFromCode(string[0]); |
| 3705 } |
| 3575 Object* result; | 3706 Object* result; |
| 3576 { MaybeObject* maybe_result = | 3707 { MaybeObject* maybe_result = |
| 3577 AllocateRawAsciiString(string.length(), pretenure); | 3708 AllocateRawAsciiString(string.length(), pretenure); |
| 3578 if (!maybe_result->ToObject(&result)) return maybe_result; | 3709 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3579 } | 3710 } |
| 3580 | 3711 |
| 3581 // Copy the characters into the new object. | 3712 // Copy the characters into the new object. |
| 3582 SeqAsciiString* string_result = SeqAsciiString::cast(result); | 3713 SeqAsciiString* string_result = SeqAsciiString::cast(result); |
| 3583 for (int i = 0; i < string.length(); i++) { | 3714 for (int i = 0; i < string.length(); i++) { |
| 3584 string_result->SeqAsciiStringSet(i, string[i]); | 3715 string_result->SeqAsciiStringSet(i, string[i]); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 context->set_global(previous->global()); | 4235 context->set_global(previous->global()); |
| 4105 return context; | 4236 return context; |
| 4106 } | 4237 } |
| 4107 | 4238 |
| 4108 | 4239 |
| 4109 MaybeObject* Heap::AllocateBlockContext(JSFunction* function, | 4240 MaybeObject* Heap::AllocateBlockContext(JSFunction* function, |
| 4110 Context* previous, | 4241 Context* previous, |
| 4111 SerializedScopeInfo* scope_info) { | 4242 SerializedScopeInfo* scope_info) { |
| 4112 Object* result; | 4243 Object* result; |
| 4113 { MaybeObject* maybe_result = | 4244 { MaybeObject* maybe_result = |
| 4114 AllocateFixedArray(scope_info->NumberOfContextSlots()); | 4245 AllocateFixedArrayWithHoles(scope_info->NumberOfContextSlots()); |
| 4115 if (!maybe_result->ToObject(&result)) return maybe_result; | 4246 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 4116 } | 4247 } |
| 4117 // TODO(keuchel): properly initialize context slots. | |
| 4118 Context* context = reinterpret_cast<Context*>(result); | 4248 Context* context = reinterpret_cast<Context*>(result); |
| 4119 context->set_map(block_context_map()); | 4249 context->set_map(block_context_map()); |
| 4120 context->set_closure(function); | 4250 context->set_closure(function); |
| 4121 context->set_previous(previous); | 4251 context->set_previous(previous); |
| 4122 context->set_extension(scope_info); | 4252 context->set_extension(scope_info); |
| 4123 context->set_global(previous->global()); | 4253 context->set_global(previous->global()); |
| 4124 return context; | 4254 return context; |
| 4125 } | 4255 } |
| 4126 | 4256 |
| 4127 | 4257 |
| (...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6117 } | 6247 } |
| 6118 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6248 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
| 6119 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6249 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
| 6120 next = chunk->next_chunk(); | 6250 next = chunk->next_chunk(); |
| 6121 isolate_->memory_allocator()->Free(chunk); | 6251 isolate_->memory_allocator()->Free(chunk); |
| 6122 } | 6252 } |
| 6123 chunks_queued_for_free_ = NULL; | 6253 chunks_queued_for_free_ = NULL; |
| 6124 } | 6254 } |
| 6125 | 6255 |
| 6126 } } // namespace v8::internal | 6256 } } // namespace v8::internal |
| OLD | NEW |