Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: src/heap.cc

Issue 255003002: Make CreateInitialObjects more concise. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "api.h" 8 #include "api.h"
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "codegen.h" 10 #include "codegen.h"
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } 2390 }
2391 #ifdef DEBUG 2391 #ifdef DEBUG
2392 MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address()); 2392 MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address());
2393 ASSERT(chunk->owner()->identity() == space); 2393 ASSERT(chunk->owner()->identity() == space);
2394 #endif 2394 #endif
2395 CreateFillerObjectAt(allocation->address(), size); 2395 CreateFillerObjectAt(allocation->address(), size);
2396 return allocation; 2396 return allocation;
2397 } 2397 }
2398 2398
2399 2399
2400 MaybeObject* Heap::AllocatePolymorphicCodeCache() {
2401 return AllocateStruct(POLYMORPHIC_CODE_CACHE_TYPE);
2402 }
2403
2404
2405 const Heap::StringTypeTable Heap::string_type_table[] = { 2400 const Heap::StringTypeTable Heap::string_type_table[] = {
2406 #define STRING_TYPE_ELEMENT(type, size, name, camel_name) \ 2401 #define STRING_TYPE_ELEMENT(type, size, name, camel_name) \
2407 {type, size, k##camel_name##MapRootIndex}, 2402 {type, size, k##camel_name##MapRootIndex},
2408 STRING_TYPE_LIST(STRING_TYPE_ELEMENT) 2403 STRING_TYPE_LIST(STRING_TYPE_ELEMENT)
2409 #undef STRING_TYPE_ELEMENT 2404 #undef STRING_TYPE_ELEMENT
2410 }; 2405 };
2411 2406
2412 2407
2413 const Heap::ConstantStringTable Heap::constant_string_table[] = { 2408 const Heap::ConstantStringTable Heap::constant_string_table[] = {
2414 #define CONSTANT_STRING_ELEMENT(name, contents) \ 2409 #define CONSTANT_STRING_ELEMENT(name, contents) \
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 global_property_cell_map()); 2709 global_property_cell_map());
2715 PropertyCell* cell = PropertyCell::cast(result); 2710 PropertyCell* cell = PropertyCell::cast(result);
2716 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2711 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2717 SKIP_WRITE_BARRIER); 2712 SKIP_WRITE_BARRIER);
2718 cell->set_value(the_hole_value()); 2713 cell->set_value(the_hole_value());
2719 cell->set_type(HeapType::None()); 2714 cell->set_type(HeapType::None());
2720 return result; 2715 return result;
2721 } 2716 }
2722 2717
2723 2718
2724 bool Heap::CreateApiObjects() { 2719 void Heap::CreateApiObjects() {
2725 Object* obj; 2720 HandleScope scope(isolate());
2721 Factory* factory = isolate()->factory();
2722 Handle<Map> new_neander_map =
2723 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
2726 2724
2727 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
2728 if (!maybe_obj->ToObject(&obj)) return false;
2729 }
2730 // Don't use Smi-only elements optimizations for objects with the neander 2725 // Don't use Smi-only elements optimizations for objects with the neander
2731 // map. There are too many cases where element values are set directly with a 2726 // map. There are too many cases where element values are set directly with a
2732 // bottleneck to trap the Smi-only -> fast elements transition, and there 2727 // bottleneck to trap the Smi-only -> fast elements transition, and there
2733 // appears to be no benefit for optimize this case. 2728 // appears to be no benefit for optimize this case.
2734 Map* new_neander_map = Map::cast(obj);
2735 new_neander_map->set_elements_kind(TERMINAL_FAST_ELEMENTS_KIND); 2729 new_neander_map->set_elements_kind(TERMINAL_FAST_ELEMENTS_KIND);
2736 set_neander_map(new_neander_map); 2730 set_neander_map(*new_neander_map);
2737 2731
2738 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map()); 2732 Handle<JSObject> listeners = factory->NewNeanderObject();
2739 if (!maybe_obj->ToObject(&obj)) return false; 2733 Handle<FixedArray> elements = factory->NewFixedArray(2);
2740 } 2734 elements->set(0, Smi::FromInt(0));
2741 Object* elements; 2735 listeners->set_elements(*elements);
2742 { MaybeObject* maybe_elements = AllocateFixedArray(2); 2736 set_message_listeners(*listeners);
2743 if (!maybe_elements->ToObject(&elements)) return false;
2744 }
2745 FixedArray::cast(elements)->set(0, Smi::FromInt(0));
2746 JSObject::cast(obj)->set_elements(FixedArray::cast(elements));
2747 set_message_listeners(JSObject::cast(obj));
2748
2749 return true;
2750 } 2737 }
2751 2738
2752 2739
2753 void Heap::CreateJSEntryStub() { 2740 void Heap::CreateJSEntryStub() {
2754 JSEntryStub stub(isolate()); 2741 JSEntryStub stub(isolate());
2755 set_js_entry_code(*stub.GetCode()); 2742 set_js_entry_code(*stub.GetCode());
2756 } 2743 }
2757 2744
2758 2745
2759 void Heap::CreateJSConstructEntryStub() { 2746 void Heap::CreateJSConstructEntryStub() {
(...skipping 25 matching lines...) Expand all
2785 // } 2772 // }
2786 // { JSConstructEntryStub stub; 2773 // { JSConstructEntryStub stub;
2787 // js_construct_entry_code_ = *stub.GetCode(); 2774 // js_construct_entry_code_ = *stub.GetCode();
2788 // } 2775 // }
2789 // To workaround the problem, make separate functions without inlining. 2776 // To workaround the problem, make separate functions without inlining.
2790 Heap::CreateJSEntryStub(); 2777 Heap::CreateJSEntryStub();
2791 Heap::CreateJSConstructEntryStub(); 2778 Heap::CreateJSConstructEntryStub();
2792 } 2779 }
2793 2780
2794 2781
2795 bool Heap::CreateInitialObjects() { 2782 void Heap::CreateInitialObjects() {
2796 HandleScope scope(isolate()); 2783 HandleScope scope(isolate());
2797 Factory* factory = isolate()->factory(); 2784 Factory* factory = isolate()->factory();
2798 2785
2799 // The -0 value must be set before NumberFromDouble works. 2786 // The -0 value must be set before NumberFromDouble works.
2800 set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED)); 2787 set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED));
2801 ASSERT(std::signbit(minus_zero_value()->Number()) != 0); 2788 ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
2802 2789
2803 set_nan_value(*factory->NewHeapNumber(OS::nan_value(), TENURED)); 2790 set_nan_value(*factory->NewHeapNumber(OS::nan_value(), TENURED));
2804 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED)); 2791 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED));
2805 2792
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 "exception", 2854 "exception",
2868 handle(Smi::FromInt(-5), isolate()), 2855 handle(Smi::FromInt(-5), isolate()),
2869 Oddball::kException)); 2856 Oddball::kException));
2870 2857
2871 for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) { 2858 for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
2872 Handle<String> str = 2859 Handle<String> str =
2873 factory->InternalizeUtf8String(constant_string_table[i].contents); 2860 factory->InternalizeUtf8String(constant_string_table[i].contents);
2874 roots_[constant_string_table[i].index] = *str; 2861 roots_[constant_string_table[i].index] = *str;
2875 } 2862 }
2876 2863
2877 Object* obj;
2878
2879 // Allocate the hidden string which is used to identify the hidden properties 2864 // Allocate the hidden string which is used to identify the hidden properties
2880 // in JSObjects. The hash code has a special value so that it will not match 2865 // in JSObjects. The hash code has a special value so that it will not match
2881 // the empty string when searching for the property. It cannot be part of the 2866 // the empty string when searching for the property. It cannot be part of the
2882 // loop above because it needs to be allocated manually with the special 2867 // loop above because it needs to be allocated manually with the special
2883 // hash code in place. The hash code for the hidden_string is zero to ensure 2868 // hash code in place. The hash code for the hidden_string is zero to ensure
2884 // that it will always be at the first entry in property descriptors. 2869 // that it will always be at the first entry in property descriptors.
2885 { MaybeObject* maybe_obj = AllocateOneByteInternalizedString( 2870 hidden_string_ = *factory->NewOneByteInternalizedString(
2886 OneByteVector("", 0), String::kEmptyStringHash); 2871 OneByteVector("", 0), String::kEmptyStringHash);
2887 if (!maybe_obj->ToObject(&obj)) return false;
2888 }
2889 hidden_string_ = String::cast(obj);
2890 2872
2891 // Create the code_stubs dictionary. The initial size is set to avoid 2873 // Create the code_stubs dictionary. The initial size is set to avoid
2892 // expanding the dictionary during bootstrapping. 2874 // expanding the dictionary during bootstrapping.
2893 set_code_stubs(*UnseededNumberDictionary::New(isolate(), 128)); 2875 set_code_stubs(*UnseededNumberDictionary::New(isolate(), 128));
2894 2876
2895 // Create the non_monomorphic_cache used in stub-cache.cc. The initial size 2877 // Create the non_monomorphic_cache used in stub-cache.cc. The initial size
2896 // is set to avoid expanding the dictionary during bootstrapping. 2878 // is set to avoid expanding the dictionary during bootstrapping.
2897 set_non_monomorphic_cache(*UnseededNumberDictionary::New(isolate(), 64)); 2879 set_non_monomorphic_cache(*UnseededNumberDictionary::New(isolate(), 64));
2898 2880
2899 { MaybeObject* maybe_obj = AllocatePolymorphicCodeCache(); 2881 set_polymorphic_code_cache(PolymorphicCodeCache::cast(
2900 if (!maybe_obj->ToObject(&obj)) return false; 2882 *factory->NewStruct(POLYMORPHIC_CODE_CACHE_TYPE)));
2901 }
2902 set_polymorphic_code_cache(PolymorphicCodeCache::cast(obj));
2903 2883
2904 set_instanceof_cache_function(Smi::FromInt(0)); 2884 set_instanceof_cache_function(Smi::FromInt(0));
2905 set_instanceof_cache_map(Smi::FromInt(0)); 2885 set_instanceof_cache_map(Smi::FromInt(0));
2906 set_instanceof_cache_answer(Smi::FromInt(0)); 2886 set_instanceof_cache_answer(Smi::FromInt(0));
2907 2887
2908 CreateFixedStubs(); 2888 CreateFixedStubs();
2909 2889
2910 // Allocate the dictionary of intrinsic function names. 2890 // Allocate the dictionary of intrinsic function names.
2911 { 2891 Handle<NameDictionary> intrinsic_names =
2912 Handle<NameDictionary> function_names = 2892 NameDictionary::New(isolate(), Runtime::kNumFunctions);
2913 NameDictionary::New(isolate(), Runtime::kNumFunctions); 2893 Runtime::InitializeIntrinsicFunctionNames(isolate(), intrinsic_names);
2914 Runtime::InitializeIntrinsicFunctionNames(isolate(), function_names); 2894 set_intrinsic_function_names(*intrinsic_names);
2915 set_intrinsic_function_names(*function_names);
2916 }
2917 2895
2918 { MaybeObject* maybe_obj = AllocateInitialNumberStringCache(); 2896 set_number_string_cache(*factory->NewFixedArray(
2919 if (!maybe_obj->ToObject(&obj)) return false; 2897 kInitialNumberStringCacheSize * 2, TENURED));
2920 }
2921 set_number_string_cache(FixedArray::cast(obj));
2922 2898
2923 // Allocate cache for single character one byte strings. 2899 // Allocate cache for single character one byte strings.
2924 { MaybeObject* maybe_obj = 2900 set_single_character_string_cache(*factory->NewFixedArray(
2925 AllocateFixedArray(String::kMaxOneByteCharCode + 1, TENURED); 2901 String::kMaxOneByteCharCode + 1, TENURED));
2926 if (!maybe_obj->ToObject(&obj)) return false;
2927 }
2928 set_single_character_string_cache(FixedArray::cast(obj));
2929 2902
2930 // Allocate cache for string split. 2903 // Allocate cache for string split and regexp-multiple.
2931 { MaybeObject* maybe_obj = AllocateFixedArray( 2904 set_string_split_cache(*factory->NewFixedArray(
2932 RegExpResultsCache::kRegExpResultsCacheSize, TENURED); 2905 RegExpResultsCache::kRegExpResultsCacheSize, TENURED));
2933 if (!maybe_obj->ToObject(&obj)) return false; 2906 set_regexp_multiple_cache(*factory->NewFixedArray(
2934 } 2907 RegExpResultsCache::kRegExpResultsCacheSize, TENURED));
2935 set_string_split_cache(FixedArray::cast(obj));
2936
2937 { MaybeObject* maybe_obj = AllocateFixedArray(
2938 RegExpResultsCache::kRegExpResultsCacheSize, TENURED);
2939 if (!maybe_obj->ToObject(&obj)) return false;
2940 }
2941 set_regexp_multiple_cache(FixedArray::cast(obj));
2942 2908
2943 // Allocate cache for external strings pointing to native source code. 2909 // Allocate cache for external strings pointing to native source code.
2944 { MaybeObject* maybe_obj = AllocateFixedArray(Natives::GetBuiltinsCount()); 2910 set_natives_source_cache(*factory->NewFixedArray(
2945 if (!maybe_obj->ToObject(&obj)) return false; 2911 Natives::GetBuiltinsCount()));
2946 }
2947 set_natives_source_cache(FixedArray::cast(obj));
2948 2912
2949 { MaybeObject* maybe_obj = AllocateCell(undefined_value()); 2913 set_undefined_cell(*factory->NewCell(factory->undefined_value()));
2950 if (!maybe_obj->ToObject(&obj)) return false;
2951 }
2952 set_undefined_cell(Cell::cast(obj));
2953 2914
2954 // The symbol registry is initialized lazily. 2915 // The symbol registry is initialized lazily.
2955 set_symbol_registry(undefined_value()); 2916 set_symbol_registry(undefined_value());
2956 2917
2957 // Allocate object to hold object observation state. 2918 // Allocate object to hold object observation state.
2958 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 2919 set_observation_state(*factory->NewJSObjectFromMap(
2959 if (!maybe_obj->ToObject(&obj)) return false; 2920 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)));
2960 }
2961 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj));
2962 if (!maybe_obj->ToObject(&obj)) return false;
2963 }
2964 set_observation_state(JSObject::cast(obj));
2965 2921
2966 // Allocate object to hold object microtask state. 2922 // Allocate object to hold object microtask state.
2967 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 2923 set_microtask_state(*factory->NewJSObjectFromMap(
2968 if (!maybe_obj->ToObject(&obj)) return false; 2924 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)));
2969 }
2970 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj));
2971 if (!maybe_obj->ToObject(&obj)) return false;
2972 }
2973 set_microtask_state(JSObject::cast(obj));
2974 2925
2975 { MaybeObject* maybe_obj = AllocateSymbol(); 2926 set_frozen_symbol(*factory->NewPrivateSymbol());
2976 if (!maybe_obj->ToObject(&obj)) return false; 2927 set_nonexistent_symbol(*factory->NewPrivateSymbol());
2977 } 2928 set_elements_transition_symbol(*factory->NewPrivateSymbol());
2978 Symbol::cast(obj)->set_is_private(true); 2929 set_uninitialized_symbol(*factory->NewPrivateSymbol());
2979 set_frozen_symbol(Symbol::cast(obj)); 2930 set_megamorphic_symbol(*factory->NewPrivateSymbol());
2931 set_observed_symbol(*factory->NewPrivateSymbol());
2980 2932
2981 { MaybeObject* maybe_obj = AllocateSymbol(); 2933 Handle<SeededNumberDictionary> slow_element_dictionary =
2982 if (!maybe_obj->ToObject(&obj)) return false; 2934 SeededNumberDictionary::New(isolate(), 0, TENURED);
2983 } 2935 slow_element_dictionary->set_requires_slow_elements();
2984 Symbol::cast(obj)->set_is_private(true); 2936 set_empty_slow_element_dictionary(*slow_element_dictionary);
2985 set_nonexistent_symbol(Symbol::cast(obj));
2986 2937
2987 { MaybeObject* maybe_obj = AllocateSymbol(); 2938 set_materialized_objects(*factory->NewFixedArray(0, TENURED));
2988 if (!maybe_obj->ToObject(&obj)) return false;
2989 }
2990 Symbol::cast(obj)->set_is_private(true);
2991 set_elements_transition_symbol(Symbol::cast(obj));
2992
2993 { MaybeObject* maybe_obj = AllocateSymbol();
2994 if (!maybe_obj->ToObject(&obj)) return false;
2995 }
2996 Symbol::cast(obj)->set_is_private(true);
2997 set_uninitialized_symbol(Symbol::cast(obj));
2998
2999 { MaybeObject* maybe_obj = AllocateSymbol();
3000 if (!maybe_obj->ToObject(&obj)) return false;
3001 }
3002 Symbol::cast(obj)->set_is_private(true);
3003 set_megamorphic_symbol(Symbol::cast(obj));
3004
3005 {
3006 Handle<SeededNumberDictionary> dict =
3007 SeededNumberDictionary::New(isolate(), 0, TENURED);
3008 dict->set_requires_slow_elements();
3009 set_empty_slow_element_dictionary(*dict);
3010 }
3011
3012 { MaybeObject* maybe_obj = AllocateSymbol();
3013 if (!maybe_obj->ToObject(&obj)) return false;
3014 }
3015 Symbol::cast(obj)->set_is_private(true);
3016 set_observed_symbol(Symbol::cast(obj));
3017
3018 { MaybeObject* maybe_obj = AllocateFixedArray(0, TENURED);
3019 if (!maybe_obj->ToObject(&obj)) return false;
3020 }
3021 set_materialized_objects(FixedArray::cast(obj));
3022 2939
3023 // Handling of script id generation is in Factory::NewScript. 2940 // Handling of script id generation is in Factory::NewScript.
3024 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); 2941 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
3025 2942
3026 { MaybeObject* maybe_obj = AllocateAllocationSitesScratchpad(); 2943 set_allocation_sites_scratchpad(*factory->NewFixedArray(
3027 if (!maybe_obj->ToObject(&obj)) return false; 2944 kAllocationSiteScratchpadSize, TENURED));
3028 }
3029 set_allocation_sites_scratchpad(FixedArray::cast(obj));
3030 InitializeAllocationSitesScratchpad(); 2945 InitializeAllocationSitesScratchpad();
3031 2946
3032 // Initialize keyed lookup cache. 2947 // Initialize keyed lookup cache.
3033 isolate_->keyed_lookup_cache()->Clear(); 2948 isolate_->keyed_lookup_cache()->Clear();
3034 2949
3035 // Initialize context slot cache. 2950 // Initialize context slot cache.
3036 isolate_->context_slot_cache()->Clear(); 2951 isolate_->context_slot_cache()->Clear();
3037 2952
3038 // Initialize descriptor cache. 2953 // Initialize descriptor cache.
3039 isolate_->descriptor_lookup_cache()->Clear(); 2954 isolate_->descriptor_lookup_cache()->Clear();
3040 2955
3041 // Initialize compilation cache. 2956 // Initialize compilation cache.
3042 isolate_->compilation_cache()->Clear(); 2957 isolate_->compilation_cache()->Clear();
3043
3044 return true;
3045 } 2958 }
3046 2959
3047 2960
3048 bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) { 2961 bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {
3049 RootListIndex writable_roots[] = { 2962 RootListIndex writable_roots[] = {
3050 kStoreBufferTopRootIndex, 2963 kStoreBufferTopRootIndex,
3051 kStackLimitRootIndex, 2964 kStackLimitRootIndex,
3052 kNumberStringCacheRootIndex, 2965 kNumberStringCacheRootIndex,
3053 kInstanceofCacheFunctionRootIndex, 2966 kInstanceofCacheFunctionRootIndex,
3054 kInstanceofCacheMapRootIndex, 2967 kInstanceofCacheMapRootIndex,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 } 3081 }
3169 3082
3170 3083
3171 void RegExpResultsCache::Clear(FixedArray* cache) { 3084 void RegExpResultsCache::Clear(FixedArray* cache) {
3172 for (int i = 0; i < kRegExpResultsCacheSize; i++) { 3085 for (int i = 0; i < kRegExpResultsCacheSize; i++) {
3173 cache->set(i, Smi::FromInt(0)); 3086 cache->set(i, Smi::FromInt(0));
3174 } 3087 }
3175 } 3088 }
3176 3089
3177 3090
3178 MaybeObject* Heap::AllocateInitialNumberStringCache() {
3179 MaybeObject* maybe_obj =
3180 AllocateFixedArray(kInitialNumberStringCacheSize * 2, TENURED);
3181 return maybe_obj;
3182 }
3183
3184
3185 int Heap::FullSizeNumberStringCacheLength() { 3091 int Heap::FullSizeNumberStringCacheLength() {
3186 // Compute the size of the number string cache based on the max newspace size. 3092 // Compute the size of the number string cache based on the max newspace size.
3187 // The number string cache has a minimum size based on twice the initial cache 3093 // The number string cache has a minimum size based on twice the initial cache
3188 // size to ensure that it is bigger after being made 'full size'. 3094 // size to ensure that it is bigger after being made 'full size'.
3189 int number_string_cache_size = max_semispace_size_ / 512; 3095 int number_string_cache_size = max_semispace_size_ / 512;
3190 number_string_cache_size = Max(kInitialNumberStringCacheSize * 2, 3096 number_string_cache_size = Max(kInitialNumberStringCacheSize * 2,
3191 Min(0x4000, number_string_cache_size)); 3097 Min(0x4000, number_string_cache_size));
3192 // There is a string and a number per entry so the length is twice the number 3098 // There is a string and a number per entry so the length is twice the number
3193 // of entries. 3099 // of entries.
3194 return number_string_cache_size * 2; 3100 return number_string_cache_size * 2;
3195 } 3101 }
3196 3102
3197 3103
3198 void Heap::FlushNumberStringCache() { 3104 void Heap::FlushNumberStringCache() {
3199 // Flush the number to string cache. 3105 // Flush the number to string cache.
3200 int len = number_string_cache()->length(); 3106 int len = number_string_cache()->length();
3201 for (int i = 0; i < len; i++) { 3107 for (int i = 0; i < len; i++) {
3202 number_string_cache()->set_undefined(i); 3108 number_string_cache()->set_undefined(i);
3203 } 3109 }
3204 } 3110 }
3205 3111
3206 3112
3207 MaybeObject* Heap::AllocateAllocationSitesScratchpad() {
3208 MaybeObject* maybe_obj =
3209 AllocateFixedArray(kAllocationSiteScratchpadSize, TENURED);
3210 return maybe_obj;
3211 }
3212
3213
3214 void Heap::FlushAllocationSitesScratchpad() { 3113 void Heap::FlushAllocationSitesScratchpad() {
3215 for (int i = 0; i < allocation_sites_scratchpad_length_; i++) { 3114 for (int i = 0; i < allocation_sites_scratchpad_length_; i++) {
3216 allocation_sites_scratchpad()->set_undefined(i); 3115 allocation_sites_scratchpad()->set_undefined(i);
3217 } 3116 }
3218 allocation_sites_scratchpad_length_ = 0; 3117 allocation_sites_scratchpad_length_ = 0;
3219 } 3118 }
3220 3119
3221 3120
3222 void Heap::InitializeAllocationSitesScratchpad() { 3121 void Heap::InitializeAllocationSitesScratchpad() {
3223 ASSERT(allocation_sites_scratchpad()->length() == 3122 ASSERT(allocation_sites_scratchpad()->length() ==
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
5412 5311
5413 mark_compact_collector()->SetUp(); 5312 mark_compact_collector()->SetUp();
5414 5313
5415 return true; 5314 return true;
5416 } 5315 }
5417 5316
5418 5317
5419 bool Heap::CreateHeapObjects() { 5318 bool Heap::CreateHeapObjects() {
5420 // Create initial maps. 5319 // Create initial maps.
5421 if (!CreateInitialMaps()) return false; 5320 if (!CreateInitialMaps()) return false;
5422 if (!CreateApiObjects()) return false; 5321 CreateApiObjects();
5423 5322
5424 // Create initial objects 5323 // Create initial objects
5425 if (!CreateInitialObjects()) return false; 5324 CreateInitialObjects();
5426 CHECK_EQ(0, gc_count_); 5325 CHECK_EQ(0, gc_count_);
5427 5326
5428 native_contexts_list_ = undefined_value(); 5327 native_contexts_list_ = undefined_value();
5429 array_buffers_list_ = undefined_value(); 5328 array_buffers_list_ = undefined_value();
5430 allocation_sites_list_ = undefined_value(); 5329 allocation_sites_list_ = undefined_value();
5431 weak_object_to_code_table_ = undefined_value(); 5330 weak_object_to_code_table_ = undefined_value();
5432 return true; 5331 return true;
5433 } 5332 }
5434 5333
5435 5334
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
6607 static_cast<int>(object_sizes_last_time_[index])); 6506 static_cast<int>(object_sizes_last_time_[index]));
6608 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6507 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6609 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6508 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6610 6509
6611 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6510 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6612 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6511 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6613 ClearObjectStats(); 6512 ClearObjectStats();
6614 } 6513 }
6615 6514
6616 } } // namespace v8::internal 6515 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698