| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 previous_survival_rate_trend_(Heap::STABLE), | 127 previous_survival_rate_trend_(Heap::STABLE), |
| 128 survival_rate_trend_(Heap::STABLE), | 128 survival_rate_trend_(Heap::STABLE), |
| 129 max_gc_pause_(0.0), | 129 max_gc_pause_(0.0), |
| 130 total_gc_time_ms_(0.0), | 130 total_gc_time_ms_(0.0), |
| 131 max_alive_after_gc_(0), | 131 max_alive_after_gc_(0), |
| 132 min_in_mutator_(kMaxInt), | 132 min_in_mutator_(kMaxInt), |
| 133 alive_after_last_gc_(0), | 133 alive_after_last_gc_(0), |
| 134 last_gc_end_timestamp_(0.0), | 134 last_gc_end_timestamp_(0.0), |
| 135 marking_time_(0.0), | 135 marking_time_(0.0), |
| 136 sweeping_time_(0.0), | 136 sweeping_time_(0.0), |
| 137 mark_compact_collector_(this), |
| 137 store_buffer_(this), | 138 store_buffer_(this), |
| 138 marking_(this), | 139 marking_(this), |
| 139 incremental_marking_(this), | 140 incremental_marking_(this), |
| 140 number_idle_notifications_(0), | 141 number_idle_notifications_(0), |
| 141 last_idle_notification_gc_count_(0), | 142 last_idle_notification_gc_count_(0), |
| 142 last_idle_notification_gc_count_init_(false), | 143 last_idle_notification_gc_count_init_(false), |
| 143 mark_sweeps_since_idle_round_started_(0), | 144 mark_sweeps_since_idle_round_started_(0), |
| 144 gc_count_at_last_idle_gc_(0), | 145 gc_count_at_last_idle_gc_(0), |
| 145 scavenges_since_last_idle_round_(kIdleScavengeThreshold), | 146 scavenges_since_last_idle_round_(kIdleScavengeThreshold), |
| 146 full_codegen_bytes_generated_(0), | 147 full_codegen_bytes_generated_(0), |
| 147 crankshaft_codegen_bytes_generated_(0), | 148 crankshaft_codegen_bytes_generated_(0), |
| 148 gcs_since_last_deopt_(0), | 149 gcs_since_last_deopt_(0), |
| 149 #ifdef VERIFY_HEAP | 150 #ifdef VERIFY_HEAP |
| 150 no_weak_object_verification_scope_depth_(0), | 151 no_weak_object_verification_scope_depth_(0), |
| 151 #endif | 152 #endif |
| 152 allocation_sites_scratchpad_length(0), | 153 allocation_sites_scratchpad_length(0), |
| 153 promotion_queue_(this), | 154 promotion_queue_(this), |
| 154 configured_(false), | 155 configured_(false), |
| 156 external_string_table_(this), |
| 155 chunks_queued_for_free_(NULL), | 157 chunks_queued_for_free_(NULL), |
| 156 relocation_mutex_(NULL) { | 158 relocation_mutex_(NULL) { |
| 157 // Allow build-time customization of the max semispace size. Building | 159 // Allow build-time customization of the max semispace size. Building |
| 158 // V8 with snapshots and a non-default max semispace size is much | 160 // V8 with snapshots and a non-default max semispace size is much |
| 159 // easier if you can define it as part of the build environment. | 161 // easier if you can define it as part of the build environment. |
| 160 #if defined(V8_MAX_SEMISPACE_SIZE) | 162 #if defined(V8_MAX_SEMISPACE_SIZE) |
| 161 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 163 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
| 162 #endif | 164 #endif |
| 163 | 165 |
| 164 // Ensure old_generation_size_ is a multiple of kPageSize. | 166 // Ensure old_generation_size_ is a multiple of kPageSize. |
| 165 ASSERT(MB >= Page::kPageSize); | 167 ASSERT(MB >= Page::kPageSize); |
| 166 | 168 |
| 167 intptr_t max_virtual = OS::MaxVirtualMemory(); | 169 intptr_t max_virtual = OS::MaxVirtualMemory(); |
| 168 | 170 |
| 169 if (max_virtual > 0) { | 171 if (max_virtual > 0) { |
| 170 if (code_range_size_ > 0) { | 172 if (code_range_size_ > 0) { |
| 171 // Reserve no more than 1/8 of the memory for the code range. | 173 // Reserve no more than 1/8 of the memory for the code range. |
| 172 code_range_size_ = Min(code_range_size_, max_virtual >> 3); | 174 code_range_size_ = Min(code_range_size_, max_virtual >> 3); |
| 173 } | 175 } |
| 174 } | 176 } |
| 175 | 177 |
| 176 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 178 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
| 177 native_contexts_list_ = NULL; | 179 native_contexts_list_ = NULL; |
| 178 array_buffers_list_ = Smi::FromInt(0); | 180 array_buffers_list_ = Smi::FromInt(0); |
| 179 allocation_sites_list_ = Smi::FromInt(0); | 181 allocation_sites_list_ = Smi::FromInt(0); |
| 180 mark_compact_collector_.heap_ = this; | |
| 181 external_string_table_.heap_ = this; | |
| 182 // Put a dummy entry in the remembered pages so we can find the list the | 182 // Put a dummy entry in the remembered pages so we can find the list the |
| 183 // minidump even if there are no real unmapped pages. | 183 // minidump even if there are no real unmapped pages. |
| 184 RememberUnmappedPage(NULL, false); | 184 RememberUnmappedPage(NULL, false); |
| 185 | 185 |
| 186 ClearObjectStats(true); | 186 ClearObjectStats(true); |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 intptr_t Heap::Capacity() { | 190 intptr_t Heap::Capacity() { |
| 191 if (!HasBeenSetUp()) return 0; | 191 if (!HasBeenSetUp()) return 0; |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 bool record_slots) { | 1979 bool record_slots) { |
| 1980 Object* allocation_site_obj = | 1980 Object* allocation_site_obj = |
| 1981 VisitWeakList<AllocationSite>(this, | 1981 VisitWeakList<AllocationSite>(this, |
| 1982 allocation_sites_list(), | 1982 allocation_sites_list(), |
| 1983 retainer, record_slots); | 1983 retainer, record_slots); |
| 1984 set_allocation_sites_list(allocation_site_obj); | 1984 set_allocation_sites_list(allocation_site_obj); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 | 1987 |
| 1988 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { | 1988 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { |
| 1989 ASSERT(AllowCodeDependencyChange::IsAllowed()); | |
| 1990 DisallowHeapAllocation no_allocation_scope; | 1989 DisallowHeapAllocation no_allocation_scope; |
| 1991 Object* cur = allocation_sites_list(); | 1990 Object* cur = allocation_sites_list(); |
| 1992 bool marked = false; | 1991 bool marked = false; |
| 1993 while (cur->IsAllocationSite()) { | 1992 while (cur->IsAllocationSite()) { |
| 1994 AllocationSite* casted = AllocationSite::cast(cur); | 1993 AllocationSite* casted = AllocationSite::cast(cur); |
| 1995 if (casted->GetPretenureMode() == flag) { | 1994 if (casted->GetPretenureMode() == flag) { |
| 1996 casted->ResetPretenureDecision(); | 1995 casted->ResetPretenureDecision(); |
| 1997 bool got_marked = casted->dependent_code()->MarkCodeForDeoptimization( | 1996 bool got_marked = casted->dependent_code()->MarkCodeForDeoptimization( |
| 1998 isolate_, | 1997 isolate_, |
| 1999 DependentCode::kAllocationSiteTenuringChangedGroup); | 1998 DependentCode::kAllocationSiteTenuringChangedGroup); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 LoggingAndProfiling logging_and_profiling_mode> | 2141 LoggingAndProfiling logging_and_profiling_mode> |
| 2143 class ScavengingVisitor : public StaticVisitorBase { | 2142 class ScavengingVisitor : public StaticVisitorBase { |
| 2144 public: | 2143 public: |
| 2145 static void Initialize() { | 2144 static void Initialize() { |
| 2146 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); | 2145 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); |
| 2147 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); | 2146 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); |
| 2148 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); | 2147 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); |
| 2149 table_.Register(kVisitByteArray, &EvacuateByteArray); | 2148 table_.Register(kVisitByteArray, &EvacuateByteArray); |
| 2150 table_.Register(kVisitFixedArray, &EvacuateFixedArray); | 2149 table_.Register(kVisitFixedArray, &EvacuateFixedArray); |
| 2151 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); | 2150 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); |
| 2151 table_.Register(kVisitFixedTypedArray, &EvacuateFixedTypedArray); |
| 2152 table_.Register(kVisitFixedFloat64Array, &EvacuateFixedFloat64Array); |
| 2152 | 2153 |
| 2153 table_.Register(kVisitNativeContext, | 2154 table_.Register(kVisitNativeContext, |
| 2154 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 2155 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 2155 template VisitSpecialized<Context::kSize>); | 2156 template VisitSpecialized<Context::kSize>); |
| 2156 | 2157 |
| 2157 table_.Register(kVisitConsString, | 2158 table_.Register(kVisitConsString, |
| 2158 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 2159 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
| 2159 template VisitSpecialized<ConsString::kSize>); | 2160 template VisitSpecialized<ConsString::kSize>); |
| 2160 | 2161 |
| 2161 table_.Register(kVisitSlicedString, | 2162 table_.Register(kVisitSlicedString, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2382 static inline void EvacuateFixedDoubleArray(Map* map, | 2383 static inline void EvacuateFixedDoubleArray(Map* map, |
| 2383 HeapObject** slot, | 2384 HeapObject** slot, |
| 2384 HeapObject* object) { | 2385 HeapObject* object) { |
| 2385 int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); | 2386 int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); |
| 2386 int object_size = FixedDoubleArray::SizeFor(length); | 2387 int object_size = FixedDoubleArray::SizeFor(length); |
| 2387 EvacuateObject<DATA_OBJECT, kDoubleAlignment>( | 2388 EvacuateObject<DATA_OBJECT, kDoubleAlignment>( |
| 2388 map, slot, object, object_size); | 2389 map, slot, object, object_size); |
| 2389 } | 2390 } |
| 2390 | 2391 |
| 2391 | 2392 |
| 2393 static inline void EvacuateFixedTypedArray(Map* map, |
| 2394 HeapObject** slot, |
| 2395 HeapObject* object) { |
| 2396 int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size(); |
| 2397 EvacuateObject<DATA_OBJECT, kObjectAlignment>( |
| 2398 map, slot, object, object_size); |
| 2399 } |
| 2400 |
| 2401 |
| 2402 static inline void EvacuateFixedFloat64Array(Map* map, |
| 2403 HeapObject** slot, |
| 2404 HeapObject* object) { |
| 2405 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); |
| 2406 EvacuateObject<DATA_OBJECT, kDoubleAlignment>( |
| 2407 map, slot, object, object_size); |
| 2408 } |
| 2409 |
| 2410 |
| 2392 static inline void EvacuateByteArray(Map* map, | 2411 static inline void EvacuateByteArray(Map* map, |
| 2393 HeapObject** slot, | 2412 HeapObject** slot, |
| 2394 HeapObject* object) { | 2413 HeapObject* object) { |
| 2395 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 2414 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
| 2396 EvacuateObject<DATA_OBJECT, kObjectAlignment>( | 2415 EvacuateObject<DATA_OBJECT, kObjectAlignment>( |
| 2397 map, slot, object, object_size); | 2416 map, slot, object, object_size); |
| 2398 } | 2417 } |
| 2399 | 2418 |
| 2400 | 2419 |
| 2401 static inline void EvacuateSeqOneByteString(Map* map, | 2420 static inline void EvacuateSeqOneByteString(Map* map, |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 | 2790 |
| 2772 fixed_array_map()->set_prototype(null_value()); | 2791 fixed_array_map()->set_prototype(null_value()); |
| 2773 fixed_array_map()->set_constructor(null_value()); | 2792 fixed_array_map()->set_constructor(null_value()); |
| 2774 | 2793 |
| 2775 oddball_map()->set_prototype(null_value()); | 2794 oddball_map()->set_prototype(null_value()); |
| 2776 oddball_map()->set_constructor(null_value()); | 2795 oddball_map()->set_constructor(null_value()); |
| 2777 | 2796 |
| 2778 constant_pool_array_map()->set_prototype(null_value()); | 2797 constant_pool_array_map()->set_prototype(null_value()); |
| 2779 constant_pool_array_map()->set_constructor(null_value()); | 2798 constant_pool_array_map()->set_constructor(null_value()); |
| 2780 | 2799 |
| 2781 { MaybeObject* maybe_obj = | 2800 { // Map allocation |
| 2782 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2801 #define ALLOCATE_MAP(instance_type, size, field_name) \ |
| 2783 if (!maybe_obj->ToObject(&obj)) return false; | 2802 { Map* map; \ |
| 2784 } | 2803 if (!AllocateMap((instance_type), size)->To(&map)) return false; \ |
| 2785 set_fixed_cow_array_map(Map::cast(obj)); | 2804 set_##field_name##_map(map); \ |
| 2786 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2805 } |
| 2787 | 2806 |
| 2788 { MaybeObject* maybe_obj = | 2807 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ |
| 2789 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2808 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) |
| 2790 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2791 } | |
| 2792 set_scope_info_map(Map::cast(obj)); | |
| 2793 | 2809 |
| 2794 { MaybeObject* maybe_obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize); | 2810 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) |
| 2795 if (!maybe_obj->ToObject(&obj)) return false; | 2811 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
| 2796 } | |
| 2797 set_heap_number_map(Map::cast(obj)); | |
| 2798 | 2812 |
| 2799 { MaybeObject* maybe_obj = AllocateMap(SYMBOL_TYPE, Symbol::kSize); | 2813 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) |
| 2800 if (!maybe_obj->ToObject(&obj)) return false; | 2814 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) |
| 2801 } | 2815 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) |
| 2802 set_symbol_map(Map::cast(obj)); | 2816 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) |
| 2803 | 2817 |
| 2804 { MaybeObject* maybe_obj = AllocateMap(FOREIGN_TYPE, Foreign::kSize); | 2818 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { |
| 2805 if (!maybe_obj->ToObject(&obj)) return false; | 2819 const StringTypeTable& entry = string_type_table[i]; |
| 2806 } | 2820 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); |
| 2807 set_foreign_map(Map::cast(obj)); | 2821 if (!maybe_obj->ToObject(&obj)) return false; |
| 2822 } |
| 2823 roots_[entry.index] = Map::cast(obj); |
| 2824 } |
| 2808 | 2825 |
| 2809 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { | 2826 ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string) |
| 2810 const StringTypeTable& entry = string_type_table[i]; | 2827 undetectable_string_map()->set_is_undetectable(); |
| 2811 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); | 2828 |
| 2812 if (!maybe_obj->ToObject(&obj)) return false; | 2829 ALLOCATE_VARSIZE_MAP(ASCII_STRING_TYPE, undetectable_ascii_string); |
| 2830 undetectable_ascii_string_map()->set_is_undetectable(); |
| 2831 |
| 2832 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) |
| 2833 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
| 2834 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
| 2835 |
| 2836 #define ALLOCATE_EXTERNAL_ARRAY_MAP(TYPE, type) \ |
| 2837 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \ |
| 2838 external_##type##_array) |
| 2839 |
| 2840 ALLOCATE_EXTERNAL_ARRAY_MAP(PIXEL, pixel) |
| 2841 ALLOCATE_EXTERNAL_ARRAY_MAP(BYTE, byte) |
| 2842 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_BYTE, unsigned_byte) |
| 2843 ALLOCATE_EXTERNAL_ARRAY_MAP(SHORT, short) // NOLINT |
| 2844 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_SHORT, unsigned_short) |
| 2845 ALLOCATE_EXTERNAL_ARRAY_MAP(INT, int) |
| 2846 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_INT, unsigned_int) |
| 2847 ALLOCATE_EXTERNAL_ARRAY_MAP(FLOAT, float) |
| 2848 ALLOCATE_EXTERNAL_ARRAY_MAP(DOUBLE, double) |
| 2849 #undef ALLOCATE_EXTERNAL_ARRAY_MAP |
| 2850 |
| 2851 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_ARRAY_TYPE, fixed_uint8_array) |
| 2852 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
| 2853 fixed_uint8_clamped_array) |
| 2854 ALLOCATE_VARSIZE_MAP(FIXED_INT8_ARRAY_TYPE, fixed_int8_array) |
| 2855 ALLOCATE_VARSIZE_MAP(FIXED_UINT16_ARRAY_TYPE, fixed_uint16_array) |
| 2856 ALLOCATE_VARSIZE_MAP(FIXED_INT16_ARRAY_TYPE, fixed_int16_array) |
| 2857 ALLOCATE_VARSIZE_MAP(FIXED_UINT32_ARRAY_TYPE, fixed_uint32_array) |
| 2858 ALLOCATE_VARSIZE_MAP(FIXED_INT32_ARRAY_TYPE, fixed_int32_array) |
| 2859 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT32_ARRAY_TYPE, fixed_float32_array) |
| 2860 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT64_ARRAY_TYPE, fixed_float64_array) |
| 2861 |
| 2862 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, non_strict_arguments_elements) |
| 2863 |
| 2864 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) |
| 2865 |
| 2866 ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell) |
| 2867 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell) |
| 2868 ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler) |
| 2869 ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler) |
| 2870 |
| 2871 |
| 2872 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { |
| 2873 const StructTable& entry = struct_table[i]; |
| 2874 Map* map; |
| 2875 if (!AllocateMap(entry.type, entry.size)->To(&map)) |
| 2876 return false; |
| 2877 roots_[entry.index] = map; |
| 2813 } | 2878 } |
| 2814 roots_[entry.index] = Map::cast(obj); | 2879 |
| 2880 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table) |
| 2881 |
| 2882 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context) |
| 2883 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, catch_context) |
| 2884 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, with_context) |
| 2885 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, block_context) |
| 2886 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, module_context) |
| 2887 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, global_context) |
| 2888 |
| 2889 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, native_context) |
| 2890 native_context_map()->set_dictionary_map(true); |
| 2891 native_context_map()->set_visitor_id( |
| 2892 StaticVisitorBase::kVisitNativeContext); |
| 2893 |
| 2894 ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize, |
| 2895 shared_function_info) |
| 2896 |
| 2897 ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize, |
| 2898 message_object) |
| 2899 ALLOCATE_MAP(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize, |
| 2900 external) |
| 2901 external_map()->set_is_extensible(false); |
| 2902 #undef ALLOCATE_VARSIZE_MAP |
| 2903 #undef ALLOCATE_MAP |
| 2815 } | 2904 } |
| 2816 | 2905 |
| 2817 { MaybeObject* maybe_obj = AllocateMap(STRING_TYPE, kVariableSizeSentinel); | 2906 { // Empty arrays |
| 2818 if (!maybe_obj->ToObject(&obj)) return false; | 2907 { ByteArray* byte_array; |
| 2908 if (!AllocateByteArray(0, TENURED)->To(&byte_array)) return false; |
| 2909 set_empty_byte_array(byte_array); |
| 2910 } |
| 2911 |
| 2912 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type) \ |
| 2913 { ExternalArray* obj; \ |
| 2914 if (!AllocateEmptyExternalArray(kExternal##Type##Array)->To(&obj)) \ |
| 2915 return false; \ |
| 2916 set_empty_external_##type##_array(obj); \ |
| 2917 } |
| 2918 |
| 2919 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Byte, byte) |
| 2920 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedByte, unsigned_byte) |
| 2921 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Short, short) // NOLINT |
| 2922 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedShort, unsigned_short) |
| 2923 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Int, int) |
| 2924 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedInt, unsigned_int) |
| 2925 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Float, float) |
| 2926 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Double, double) |
| 2927 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Pixel, pixel) |
| 2928 #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY |
| 2819 } | 2929 } |
| 2820 set_undetectable_string_map(Map::cast(obj)); | |
| 2821 Map::cast(obj)->set_is_undetectable(); | |
| 2822 | |
| 2823 { MaybeObject* maybe_obj = | |
| 2824 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); | |
| 2825 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2826 } | |
| 2827 set_undetectable_ascii_string_map(Map::cast(obj)); | |
| 2828 Map::cast(obj)->set_is_undetectable(); | |
| 2829 | |
| 2830 { MaybeObject* maybe_obj = | |
| 2831 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | |
| 2832 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2833 } | |
| 2834 set_fixed_double_array_map(Map::cast(obj)); | |
| 2835 | |
| 2836 { MaybeObject* maybe_obj = | |
| 2837 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | |
| 2838 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2839 } | |
| 2840 set_byte_array_map(Map::cast(obj)); | |
| 2841 | |
| 2842 { MaybeObject* maybe_obj = | |
| 2843 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); | |
| 2844 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2845 } | |
| 2846 set_free_space_map(Map::cast(obj)); | |
| 2847 | |
| 2848 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); | |
| 2849 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2850 } | |
| 2851 set_empty_byte_array(ByteArray::cast(obj)); | |
| 2852 | |
| 2853 { MaybeObject* maybe_obj = | |
| 2854 AllocateMap(EXTERNAL_PIXEL_ARRAY_TYPE, ExternalArray::kAlignedSize); | |
| 2855 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2856 } | |
| 2857 set_external_pixel_array_map(Map::cast(obj)); | |
| 2858 | |
| 2859 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_BYTE_ARRAY_TYPE, | |
| 2860 ExternalArray::kAlignedSize); | |
| 2861 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2862 } | |
| 2863 set_external_byte_array_map(Map::cast(obj)); | |
| 2864 | |
| 2865 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | |
| 2866 ExternalArray::kAlignedSize); | |
| 2867 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2868 } | |
| 2869 set_external_unsigned_byte_array_map(Map::cast(obj)); | |
| 2870 | |
| 2871 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_SHORT_ARRAY_TYPE, | |
| 2872 ExternalArray::kAlignedSize); | |
| 2873 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2874 } | |
| 2875 set_external_short_array_map(Map::cast(obj)); | |
| 2876 | |
| 2877 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | |
| 2878 ExternalArray::kAlignedSize); | |
| 2879 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2880 } | |
| 2881 set_external_unsigned_short_array_map(Map::cast(obj)); | |
| 2882 | |
| 2883 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_INT_ARRAY_TYPE, | |
| 2884 ExternalArray::kAlignedSize); | |
| 2885 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2886 } | |
| 2887 set_external_int_array_map(Map::cast(obj)); | |
| 2888 | |
| 2889 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | |
| 2890 ExternalArray::kAlignedSize); | |
| 2891 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2892 } | |
| 2893 set_external_unsigned_int_array_map(Map::cast(obj)); | |
| 2894 | |
| 2895 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_FLOAT_ARRAY_TYPE, | |
| 2896 ExternalArray::kAlignedSize); | |
| 2897 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2898 } | |
| 2899 set_external_float_array_map(Map::cast(obj)); | |
| 2900 | |
| 2901 { MaybeObject* maybe_obj = | |
| 2902 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 2903 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2904 } | |
| 2905 set_non_strict_arguments_elements_map(Map::cast(obj)); | |
| 2906 | |
| 2907 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_DOUBLE_ARRAY_TYPE, | |
| 2908 ExternalArray::kAlignedSize); | |
| 2909 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2910 } | |
| 2911 set_external_double_array_map(Map::cast(obj)); | |
| 2912 | |
| 2913 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalByteArray); | |
| 2914 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2915 } | |
| 2916 set_empty_external_byte_array(ExternalArray::cast(obj)); | |
| 2917 | |
| 2918 { MaybeObject* maybe_obj = | |
| 2919 AllocateEmptyExternalArray(kExternalUnsignedByteArray); | |
| 2920 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2921 } | |
| 2922 set_empty_external_unsigned_byte_array(ExternalArray::cast(obj)); | |
| 2923 | |
| 2924 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalShortArray); | |
| 2925 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2926 } | |
| 2927 set_empty_external_short_array(ExternalArray::cast(obj)); | |
| 2928 | |
| 2929 { MaybeObject* maybe_obj = AllocateEmptyExternalArray( | |
| 2930 kExternalUnsignedShortArray); | |
| 2931 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2932 } | |
| 2933 set_empty_external_unsigned_short_array(ExternalArray::cast(obj)); | |
| 2934 | |
| 2935 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalIntArray); | |
| 2936 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2937 } | |
| 2938 set_empty_external_int_array(ExternalArray::cast(obj)); | |
| 2939 | |
| 2940 { MaybeObject* maybe_obj = | |
| 2941 AllocateEmptyExternalArray(kExternalUnsignedIntArray); | |
| 2942 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2943 } | |
| 2944 set_empty_external_unsigned_int_array(ExternalArray::cast(obj)); | |
| 2945 | |
| 2946 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalFloatArray); | |
| 2947 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2948 } | |
| 2949 set_empty_external_float_array(ExternalArray::cast(obj)); | |
| 2950 | |
| 2951 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalDoubleArray); | |
| 2952 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2953 } | |
| 2954 set_empty_external_double_array(ExternalArray::cast(obj)); | |
| 2955 | |
| 2956 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray); | |
| 2957 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2958 } | |
| 2959 set_empty_external_pixel_array(ExternalArray::cast(obj)); | |
| 2960 | |
| 2961 { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel); | |
| 2962 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2963 } | |
| 2964 set_code_map(Map::cast(obj)); | |
| 2965 | |
| 2966 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize); | |
| 2967 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2968 } | |
| 2969 set_cell_map(Map::cast(obj)); | |
| 2970 | |
| 2971 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE, | |
| 2972 PropertyCell::kSize); | |
| 2973 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2974 } | |
| 2975 set_global_property_cell_map(Map::cast(obj)); | |
| 2976 | |
| 2977 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); | |
| 2978 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2979 } | |
| 2980 set_one_pointer_filler_map(Map::cast(obj)); | |
| 2981 | |
| 2982 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); | |
| 2983 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2984 } | |
| 2985 set_two_pointer_filler_map(Map::cast(obj)); | |
| 2986 | |
| 2987 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { | |
| 2988 const StructTable& entry = struct_table[i]; | |
| 2989 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); | |
| 2990 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2991 } | |
| 2992 roots_[entry.index] = Map::cast(obj); | |
| 2993 } | |
| 2994 | |
| 2995 { MaybeObject* maybe_obj = | |
| 2996 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 2997 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2998 } | |
| 2999 set_hash_table_map(Map::cast(obj)); | |
| 3000 | |
| 3001 { MaybeObject* maybe_obj = | |
| 3002 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3003 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3004 } | |
| 3005 set_function_context_map(Map::cast(obj)); | |
| 3006 | |
| 3007 { MaybeObject* maybe_obj = | |
| 3008 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3009 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3010 } | |
| 3011 set_catch_context_map(Map::cast(obj)); | |
| 3012 | |
| 3013 { MaybeObject* maybe_obj = | |
| 3014 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3015 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3016 } | |
| 3017 set_with_context_map(Map::cast(obj)); | |
| 3018 | |
| 3019 { MaybeObject* maybe_obj = | |
| 3020 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3021 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3022 } | |
| 3023 set_block_context_map(Map::cast(obj)); | |
| 3024 | |
| 3025 { MaybeObject* maybe_obj = | |
| 3026 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3027 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3028 } | |
| 3029 set_module_context_map(Map::cast(obj)); | |
| 3030 | |
| 3031 { MaybeObject* maybe_obj = | |
| 3032 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3033 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3034 } | |
| 3035 set_global_context_map(Map::cast(obj)); | |
| 3036 | |
| 3037 { MaybeObject* maybe_obj = | |
| 3038 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
| 3039 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3040 } | |
| 3041 Map* native_context_map = Map::cast(obj); | |
| 3042 native_context_map->set_dictionary_map(true); | |
| 3043 native_context_map->set_visitor_id(StaticVisitorBase::kVisitNativeContext); | |
| 3044 set_native_context_map(native_context_map); | |
| 3045 | |
| 3046 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, | |
| 3047 SharedFunctionInfo::kAlignedSize); | |
| 3048 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3049 } | |
| 3050 set_shared_function_info_map(Map::cast(obj)); | |
| 3051 | |
| 3052 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, | |
| 3053 JSMessageObject::kSize); | |
| 3054 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3055 } | |
| 3056 set_message_object_map(Map::cast(obj)); | |
| 3057 | |
| 3058 Map* external_map; | |
| 3059 { MaybeObject* maybe_obj = | |
| 3060 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); | |
| 3061 if (!maybe_obj->To(&external_map)) return false; | |
| 3062 } | |
| 3063 external_map->set_is_extensible(false); | |
| 3064 set_external_map(external_map); | |
| 3065 | |
| 3066 ASSERT(!InNewSpace(empty_fixed_array())); | 2930 ASSERT(!InNewSpace(empty_fixed_array())); |
| 3067 return true; | 2931 return true; |
| 3068 } | 2932 } |
| 3069 | 2933 |
| 3070 | 2934 |
| 3071 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 2935 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
| 3072 // Statically ensure that it is safe to allocate heap numbers in paged | 2936 // Statically ensure that it is safe to allocate heap numbers in paged |
| 3073 // spaces. | 2937 // spaces. |
| 3074 int size = HeapNumber::kSize; | 2938 int size = HeapNumber::kSize; |
| 3075 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 2939 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3108 MaybeObject* maybe_result = | 2972 MaybeObject* maybe_result = |
| 3109 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE); | 2973 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE); |
| 3110 if (!maybe_result->ToObject(&result)) return maybe_result; | 2974 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3111 | 2975 |
| 3112 HeapObject::cast(result)->set_map_no_write_barrier( | 2976 HeapObject::cast(result)->set_map_no_write_barrier( |
| 3113 global_property_cell_map()); | 2977 global_property_cell_map()); |
| 3114 PropertyCell* cell = PropertyCell::cast(result); | 2978 PropertyCell* cell = PropertyCell::cast(result); |
| 3115 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2979 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
| 3116 SKIP_WRITE_BARRIER); | 2980 SKIP_WRITE_BARRIER); |
| 3117 cell->set_value(the_hole_value()); | 2981 cell->set_value(the_hole_value()); |
| 3118 cell->set_type(Type::None()); | 2982 cell->set_type(HeapType::None()); |
| 3119 return result; | 2983 return result; |
| 3120 } | 2984 } |
| 3121 | 2985 |
| 3122 | 2986 |
| 3123 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { | 2987 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { |
| 3124 Box* result; | 2988 Box* result; |
| 3125 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); | 2989 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); |
| 3126 if (!maybe_result->To(&result)) return maybe_result; | 2990 if (!maybe_result->To(&result)) return maybe_result; |
| 3127 result->set_value(value); | 2991 result->set_value(value); |
| 3128 return result; | 2992 return result; |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 // number string cache. | 3560 // number string cache. |
| 3697 AllocateFullSizeNumberStringCache(); | 3561 AllocateFullSizeNumberStringCache(); |
| 3698 return; | 3562 return; |
| 3699 } | 3563 } |
| 3700 number_string_cache()->set(hash * 2, number); | 3564 number_string_cache()->set(hash * 2, number); |
| 3701 number_string_cache()->set(hash * 2 + 1, string); | 3565 number_string_cache()->set(hash * 2 + 1, string); |
| 3702 } | 3566 } |
| 3703 | 3567 |
| 3704 | 3568 |
| 3705 MaybeObject* Heap::NumberToString(Object* number, | 3569 MaybeObject* Heap::NumberToString(Object* number, |
| 3706 bool check_number_string_cache, | 3570 bool check_number_string_cache) { |
| 3707 PretenureFlag pretenure) { | |
| 3708 isolate_->counters()->number_to_string_runtime()->Increment(); | 3571 isolate_->counters()->number_to_string_runtime()->Increment(); |
| 3709 if (check_number_string_cache) { | 3572 if (check_number_string_cache) { |
| 3710 Object* cached = GetNumberStringCache(number); | 3573 Object* cached = GetNumberStringCache(number); |
| 3711 if (cached != undefined_value()) { | 3574 if (cached != undefined_value()) { |
| 3712 return cached; | 3575 return cached; |
| 3713 } | 3576 } |
| 3714 } | 3577 } |
| 3715 | 3578 |
| 3716 char arr[100]; | 3579 char arr[100]; |
| 3717 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 3580 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 3718 const char* str; | 3581 const char* str; |
| 3719 if (number->IsSmi()) { | 3582 if (number->IsSmi()) { |
| 3720 int num = Smi::cast(number)->value(); | 3583 int num = Smi::cast(number)->value(); |
| 3721 str = IntToCString(num, buffer); | 3584 str = IntToCString(num, buffer); |
| 3722 } else { | 3585 } else { |
| 3723 double num = HeapNumber::cast(number)->value(); | 3586 double num = HeapNumber::cast(number)->value(); |
| 3724 str = DoubleToCString(num, buffer); | 3587 str = DoubleToCString(num, buffer); |
| 3725 } | 3588 } |
| 3726 | 3589 |
| 3727 Object* js_string; | 3590 Object* js_string; |
| 3591 |
| 3592 // We tenure the allocated string since it is referenced from the |
| 3593 // number-string cache which lives in the old space. |
| 3728 MaybeObject* maybe_js_string = | 3594 MaybeObject* maybe_js_string = |
| 3729 AllocateStringFromOneByte(CStrVector(str), pretenure); | 3595 AllocateStringFromOneByte(CStrVector(str), TENURED); |
| 3730 if (maybe_js_string->ToObject(&js_string)) { | 3596 if (maybe_js_string->ToObject(&js_string)) { |
| 3731 SetNumberStringCache(number, String::cast(js_string)); | 3597 SetNumberStringCache(number, String::cast(js_string)); |
| 3732 } | 3598 } |
| 3733 return maybe_js_string; | 3599 return maybe_js_string; |
| 3734 } | 3600 } |
| 3735 | 3601 |
| 3736 | 3602 |
| 3737 MaybeObject* Heap::Uint32ToString(uint32_t value, | 3603 MaybeObject* Heap::Uint32ToString(uint32_t value, |
| 3738 bool check_number_string_cache) { | 3604 bool check_number_string_cache) { |
| 3739 Object* number; | 3605 Object* number; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3769 return kExternalDoubleArrayMapRootIndex; | 3635 return kExternalDoubleArrayMapRootIndex; |
| 3770 case kExternalPixelArray: | 3636 case kExternalPixelArray: |
| 3771 return kExternalPixelArrayMapRootIndex; | 3637 return kExternalPixelArrayMapRootIndex; |
| 3772 default: | 3638 default: |
| 3773 UNREACHABLE(); | 3639 UNREACHABLE(); |
| 3774 return kUndefinedValueRootIndex; | 3640 return kUndefinedValueRootIndex; |
| 3775 } | 3641 } |
| 3776 } | 3642 } |
| 3777 | 3643 |
| 3778 | 3644 |
| 3645 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { |
| 3646 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); |
| 3647 } |
| 3648 |
| 3649 |
| 3650 Heap::RootListIndex Heap::RootIndexForFixedTypedArray( |
| 3651 ExternalArrayType array_type) { |
| 3652 switch (array_type) { |
| 3653 case kExternalByteArray: |
| 3654 return kFixedInt8ArrayMapRootIndex; |
| 3655 case kExternalUnsignedByteArray: |
| 3656 return kFixedUint8ArrayMapRootIndex; |
| 3657 case kExternalShortArray: |
| 3658 return kFixedInt16ArrayMapRootIndex; |
| 3659 case kExternalUnsignedShortArray: |
| 3660 return kFixedUint16ArrayMapRootIndex; |
| 3661 case kExternalIntArray: |
| 3662 return kFixedInt32ArrayMapRootIndex; |
| 3663 case kExternalUnsignedIntArray: |
| 3664 return kFixedUint32ArrayMapRootIndex; |
| 3665 case kExternalFloatArray: |
| 3666 return kFixedFloat32ArrayMapRootIndex; |
| 3667 case kExternalDoubleArray: |
| 3668 return kFixedFloat64ArrayMapRootIndex; |
| 3669 case kExternalPixelArray: |
| 3670 return kFixedUint8ClampedArrayMapRootIndex; |
| 3671 default: |
| 3672 UNREACHABLE(); |
| 3673 return kUndefinedValueRootIndex; |
| 3674 } |
| 3675 } |
| 3676 |
| 3677 |
| 3779 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( | 3678 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( |
| 3780 ElementsKind elementsKind) { | 3679 ElementsKind elementsKind) { |
| 3781 switch (elementsKind) { | 3680 switch (elementsKind) { |
| 3782 case EXTERNAL_BYTE_ELEMENTS: | 3681 case EXTERNAL_BYTE_ELEMENTS: |
| 3783 return kEmptyExternalByteArrayRootIndex; | 3682 return kEmptyExternalByteArrayRootIndex; |
| 3784 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3683 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3785 return kEmptyExternalUnsignedByteArrayRootIndex; | 3684 return kEmptyExternalUnsignedByteArrayRootIndex; |
| 3786 case EXTERNAL_SHORT_ELEMENTS: | 3685 case EXTERNAL_SHORT_ELEMENTS: |
| 3787 return kEmptyExternalShortArrayRootIndex; | 3686 return kEmptyExternalShortArrayRootIndex; |
| 3788 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3687 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3958 | 3857 |
| 3959 | 3858 |
| 3960 MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { | 3859 MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { |
| 3961 if (code <= String::kMaxOneByteCharCode) { | 3860 if (code <= String::kMaxOneByteCharCode) { |
| 3962 Object* value = single_character_string_cache()->get(code); | 3861 Object* value = single_character_string_cache()->get(code); |
| 3963 if (value != undefined_value()) return value; | 3862 if (value != undefined_value()) return value; |
| 3964 | 3863 |
| 3965 uint8_t buffer[1]; | 3864 uint8_t buffer[1]; |
| 3966 buffer[0] = static_cast<uint8_t>(code); | 3865 buffer[0] = static_cast<uint8_t>(code); |
| 3967 Object* result; | 3866 Object* result; |
| 3968 MaybeObject* maybe_result = | 3867 OneByteStringKey key(Vector<const uint8_t>(buffer, 1), HashSeed()); |
| 3969 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1)); | 3868 MaybeObject* maybe_result = InternalizeStringWithKey(&key); |
| 3970 | 3869 |
| 3971 if (!maybe_result->ToObject(&result)) return maybe_result; | 3870 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3972 single_character_string_cache()->set(code, result); | 3871 single_character_string_cache()->set(code, result); |
| 3973 return result; | 3872 return result; |
| 3974 } | 3873 } |
| 3975 | 3874 |
| 3976 SeqTwoByteString* result; | 3875 SeqTwoByteString* result; |
| 3977 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); | 3876 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); |
| 3978 if (!maybe_result->To<SeqTwoByteString>(&result)) return maybe_result; | 3877 if (!maybe_result->To<SeqTwoByteString>(&result)) return maybe_result; |
| 3979 } | 3878 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4027 | 3926 |
| 4028 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( | 3927 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( |
| 4029 MapForExternalArrayType(array_type)); | 3928 MapForExternalArrayType(array_type)); |
| 4030 reinterpret_cast<ExternalArray*>(result)->set_length(length); | 3929 reinterpret_cast<ExternalArray*>(result)->set_length(length); |
| 4031 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( | 3930 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( |
| 4032 external_pointer); | 3931 external_pointer); |
| 4033 | 3932 |
| 4034 return result; | 3933 return result; |
| 4035 } | 3934 } |
| 4036 | 3935 |
| 3936 static void ForFixedTypedArray(ExternalArrayType array_type, |
| 3937 int* element_size, |
| 3938 ElementsKind* element_kind) { |
| 3939 switch (array_type) { |
| 3940 case kExternalUnsignedByteArray: |
| 3941 *element_size = 1; |
| 3942 *element_kind = UINT8_ELEMENTS; |
| 3943 return; |
| 3944 case kExternalByteArray: |
| 3945 *element_size = 1; |
| 3946 *element_kind = INT8_ELEMENTS; |
| 3947 return; |
| 3948 case kExternalUnsignedShortArray: |
| 3949 *element_size = 2; |
| 3950 *element_kind = UINT16_ELEMENTS; |
| 3951 return; |
| 3952 case kExternalShortArray: |
| 3953 *element_size = 2; |
| 3954 *element_kind = INT16_ELEMENTS; |
| 3955 return; |
| 3956 case kExternalUnsignedIntArray: |
| 3957 *element_size = 4; |
| 3958 *element_kind = UINT32_ELEMENTS; |
| 3959 return; |
| 3960 case kExternalIntArray: |
| 3961 *element_size = 4; |
| 3962 *element_kind = INT32_ELEMENTS; |
| 3963 return; |
| 3964 case kExternalFloatArray: |
| 3965 *element_size = 4; |
| 3966 *element_kind = FLOAT32_ELEMENTS; |
| 3967 return; |
| 3968 case kExternalDoubleArray: |
| 3969 *element_size = 8; |
| 3970 *element_kind = FLOAT64_ELEMENTS; |
| 3971 return; |
| 3972 case kExternalPixelArray: |
| 3973 *element_size = 1; |
| 3974 *element_kind = UINT8_CLAMPED_ELEMENTS; |
| 3975 return; |
| 3976 default: |
| 3977 *element_size = 0; // Bogus |
| 3978 *element_kind = UINT8_ELEMENTS; // Bogus |
| 3979 UNREACHABLE(); |
| 3980 } |
| 3981 } |
| 3982 |
| 3983 |
| 3984 MaybeObject* Heap::AllocateFixedTypedArray(int length, |
| 3985 ExternalArrayType array_type, |
| 3986 PretenureFlag pretenure) { |
| 3987 int element_size; |
| 3988 ElementsKind elements_kind; |
| 3989 ForFixedTypedArray(array_type, &element_size, &elements_kind); |
| 3990 int size = OBJECT_POINTER_ALIGN( |
| 3991 length * element_size + FixedTypedArrayBase::kDataOffset); |
| 3992 #ifndef V8_HOST_ARCH_64_BIT |
| 3993 if (array_type == kExternalDoubleArray) { |
| 3994 size += kPointerSize; |
| 3995 } |
| 3996 #endif |
| 3997 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 3998 |
| 3999 HeapObject* object; |
| 4000 MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4001 if (!maybe_object->To(&object)) return maybe_object; |
| 4002 |
| 4003 if (array_type == kExternalDoubleArray) { |
| 4004 object = EnsureDoubleAligned(this, object, size); |
| 4005 } |
| 4006 |
| 4007 FixedTypedArrayBase* elements = |
| 4008 reinterpret_cast<FixedTypedArrayBase*>(object); |
| 4009 elements->set_map(MapForFixedTypedArray(array_type)); |
| 4010 elements->set_length(length); |
| 4011 return elements; |
| 4012 } |
| 4013 |
| 4037 | 4014 |
| 4038 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 4015 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
| 4039 Code::Flags flags, | 4016 Code::Flags flags, |
| 4040 Handle<Object> self_reference, | 4017 Handle<Object> self_reference, |
| 4041 bool immovable, | 4018 bool immovable, |
| 4042 bool crankshafted, | 4019 bool crankshafted, |
| 4043 int prologue_offset) { | 4020 int prologue_offset) { |
| 4044 // Allocate ByteArray before the Code object, so that we do not risk | 4021 // Allocate ByteArray before the Code object, so that we do not risk |
| 4045 // leaving uninitialized Code object (and breaking the heap). | 4022 // leaving uninitialized Code object (and breaking the heap). |
| 4046 ByteArray* reloc_info; | 4023 ByteArray* reloc_info; |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4764 // Allocate the backing storage for the properties. | 4741 // Allocate the backing storage for the properties. |
| 4765 int prop_size = map->unused_property_fields() - map->inobject_properties(); | 4742 int prop_size = map->unused_property_fields() - map->inobject_properties(); |
| 4766 Object* properties; | 4743 Object* properties; |
| 4767 maybe = AllocateFixedArray(prop_size, TENURED); | 4744 maybe = AllocateFixedArray(prop_size, TENURED); |
| 4768 if (!maybe->ToObject(&properties)) return maybe; | 4745 if (!maybe->ToObject(&properties)) return maybe; |
| 4769 | 4746 |
| 4770 // Functions require some allocation, which might fail here. | 4747 // Functions require some allocation, which might fail here. |
| 4771 SharedFunctionInfo* shared = NULL; | 4748 SharedFunctionInfo* shared = NULL; |
| 4772 if (type == JS_FUNCTION_TYPE) { | 4749 if (type == JS_FUNCTION_TYPE) { |
| 4773 String* name; | 4750 String* name; |
| 4774 maybe = | 4751 OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"), |
| 4775 InternalizeOneByteString(STATIC_ASCII_VECTOR("<freezing call trap>")); | 4752 HashSeed()); |
| 4753 maybe = InternalizeStringWithKey(&key); |
| 4776 if (!maybe->To<String>(&name)) return maybe; | 4754 if (!maybe->To<String>(&name)) return maybe; |
| 4777 maybe = AllocateSharedFunctionInfo(name); | 4755 maybe = AllocateSharedFunctionInfo(name); |
| 4778 if (!maybe->To<SharedFunctionInfo>(&shared)) return maybe; | 4756 if (!maybe->To<SharedFunctionInfo>(&shared)) return maybe; |
| 4779 } | 4757 } |
| 4780 | 4758 |
| 4781 // Because of possible retries of this function after failure, | 4759 // Because of possible retries of this function after failure, |
| 4782 // we must NOT fail after this point, where we have changed the type! | 4760 // we must NOT fail after this point, where we have changed the type! |
| 4783 | 4761 |
| 4784 // Reset the map for the object. | 4762 // Reset the map for the object. |
| 4785 object->set_map(map); | 4763 object->set_map(map); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5640 AdvanceIdleIncrementalMarking(step_size); | 5618 AdvanceIdleIncrementalMarking(step_size); |
| 5641 } | 5619 } |
| 5642 | 5620 |
| 5643 // After context disposal there is likely a lot of garbage remaining, reset | 5621 // After context disposal there is likely a lot of garbage remaining, reset |
| 5644 // the idle notification counters in order to trigger more incremental GCs | 5622 // the idle notification counters in order to trigger more incremental GCs |
| 5645 // on subsequent idle notifications. | 5623 // on subsequent idle notifications. |
| 5646 StartIdleRound(); | 5624 StartIdleRound(); |
| 5647 return false; | 5625 return false; |
| 5648 } | 5626 } |
| 5649 | 5627 |
| 5650 if (!FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { | 5628 if (!FLAG_incremental_marking || Serializer::enabled()) { |
| 5651 return IdleGlobalGC(); | 5629 return IdleGlobalGC(); |
| 5652 } | 5630 } |
| 5653 | 5631 |
| 5654 // By doing small chunks of GC work in each IdleNotification, | 5632 // By doing small chunks of GC work in each IdleNotification, |
| 5655 // perform a round of incremental GCs and after that wait until | 5633 // perform a round of incremental GCs and after that wait until |
| 5656 // the mutator creates enough garbage to justify a new round. | 5634 // the mutator creates enough garbage to justify a new round. |
| 5657 // An incremental GC progresses as follows: | 5635 // An incremental GC progresses as follows: |
| 5658 // 1. many incremental marking steps, | 5636 // 1. many incremental marking steps, |
| 5659 // 2. one old space mark-sweep-compact, | 5637 // 2. one old space mark-sweep-compact, |
| 5660 // 3. many lazy sweep steps. | 5638 // 3. many lazy sweep steps. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5898 code_space_->Verify(&no_dirty_regions_visitor); | 5876 code_space_->Verify(&no_dirty_regions_visitor); |
| 5899 cell_space_->Verify(&no_dirty_regions_visitor); | 5877 cell_space_->Verify(&no_dirty_regions_visitor); |
| 5900 property_cell_space_->Verify(&no_dirty_regions_visitor); | 5878 property_cell_space_->Verify(&no_dirty_regions_visitor); |
| 5901 | 5879 |
| 5902 lo_space_->Verify(); | 5880 lo_space_->Verify(); |
| 5903 } | 5881 } |
| 5904 #endif | 5882 #endif |
| 5905 | 5883 |
| 5906 | 5884 |
| 5907 MaybeObject* Heap::InternalizeUtf8String(Vector<const char> string) { | 5885 MaybeObject* Heap::InternalizeUtf8String(Vector<const char> string) { |
| 5886 Utf8StringKey key(string, HashSeed()); |
| 5887 return InternalizeStringWithKey(&key); |
| 5888 } |
| 5889 |
| 5890 |
| 5891 MaybeObject* Heap::InternalizeString(String* string) { |
| 5892 if (string->IsInternalizedString()) return string; |
| 5908 Object* result = NULL; | 5893 Object* result = NULL; |
| 5909 Object* new_table; | 5894 Object* new_table; |
| 5910 { MaybeObject* maybe_new_table = | 5895 { MaybeObject* maybe_new_table = |
| 5911 string_table()->LookupUtf8String(string, &result); | 5896 string_table()->LookupString(string, &result); |
| 5912 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | 5897 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; |
| 5913 } | 5898 } |
| 5914 // Can't use set_string_table because StringTable::cast knows that | 5899 // Can't use set_string_table because StringTable::cast knows that |
| 5915 // StringTable is a singleton and checks for identity. | |
| 5916 roots_[kStringTableRootIndex] = new_table; | |
| 5917 ASSERT(result != NULL); | |
| 5918 return result; | |
| 5919 } | |
| 5920 | |
| 5921 | |
| 5922 MaybeObject* Heap::InternalizeOneByteString(Vector<const uint8_t> string) { | |
| 5923 Object* result = NULL; | |
| 5924 Object* new_table; | |
| 5925 { MaybeObject* maybe_new_table = | |
| 5926 string_table()->LookupOneByteString(string, &result); | |
| 5927 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | |
| 5928 } | |
| 5929 // Can't use set_string_table because StringTable::cast knows that | |
| 5930 // StringTable is a singleton and checks for identity. | |
| 5931 roots_[kStringTableRootIndex] = new_table; | |
| 5932 ASSERT(result != NULL); | |
| 5933 return result; | |
| 5934 } | |
| 5935 | |
| 5936 | |
| 5937 MaybeObject* Heap::InternalizeOneByteString(Handle<SeqOneByteString> string, | |
| 5938 int from, | |
| 5939 int length) { | |
| 5940 Object* result = NULL; | |
| 5941 Object* new_table; | |
| 5942 { MaybeObject* maybe_new_table = | |
| 5943 string_table()->LookupSubStringOneByteString(string, | |
| 5944 from, | |
| 5945 length, | |
| 5946 &result); | |
| 5947 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | |
| 5948 } | |
| 5949 // Can't use set_string_table because StringTable::cast knows that | |
| 5950 // StringTable is a singleton and checks for identity. | 5900 // StringTable is a singleton and checks for identity. |
| 5951 roots_[kStringTableRootIndex] = new_table; | 5901 roots_[kStringTableRootIndex] = new_table; |
| 5952 ASSERT(result != NULL); | 5902 ASSERT(result != NULL); |
| 5953 return result; | 5903 return result; |
| 5954 } | 5904 } |
| 5955 | 5905 |
| 5956 | 5906 |
| 5957 MaybeObject* Heap::InternalizeTwoByteString(Vector<const uc16> string) { | 5907 bool Heap::InternalizeStringIfExists(String* string, String** result) { |
| 5908 if (string->IsInternalizedString()) { |
| 5909 *result = string; |
| 5910 return true; |
| 5911 } |
| 5912 return string_table()->LookupStringIfExists(string, result); |
| 5913 } |
| 5914 |
| 5915 |
| 5916 MaybeObject* Heap::InternalizeStringWithKey(HashTableKey* key) { |
| 5958 Object* result = NULL; | 5917 Object* result = NULL; |
| 5959 Object* new_table; | 5918 Object* new_table; |
| 5960 { MaybeObject* maybe_new_table = | 5919 { MaybeObject* maybe_new_table = |
| 5961 string_table()->LookupTwoByteString(string, &result); | 5920 string_table()->LookupKey(key, &result); |
| 5962 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | 5921 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; |
| 5963 } | 5922 } |
| 5964 // Can't use set_string_table because StringTable::cast knows that | 5923 // Can't use set_string_table because StringTable::cast knows that |
| 5965 // StringTable is a singleton and checks for identity. | |
| 5966 roots_[kStringTableRootIndex] = new_table; | |
| 5967 ASSERT(result != NULL); | |
| 5968 return result; | |
| 5969 } | |
| 5970 | |
| 5971 | |
| 5972 MaybeObject* Heap::InternalizeString(String* string) { | |
| 5973 if (string->IsInternalizedString()) return string; | |
| 5974 Object* result = NULL; | |
| 5975 Object* new_table; | |
| 5976 { MaybeObject* maybe_new_table = | |
| 5977 string_table()->LookupString(string, &result); | |
| 5978 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; | |
| 5979 } | |
| 5980 // Can't use set_string_table because StringTable::cast knows that | |
| 5981 // StringTable is a singleton and checks for identity. | 5924 // StringTable is a singleton and checks for identity. |
| 5982 roots_[kStringTableRootIndex] = new_table; | 5925 roots_[kStringTableRootIndex] = new_table; |
| 5983 ASSERT(result != NULL); | 5926 ASSERT(result != NULL); |
| 5984 return result; | 5927 return result; |
| 5985 } | 5928 } |
| 5986 | 5929 |
| 5987 | 5930 |
| 5988 bool Heap::InternalizeStringIfExists(String* string, String** result) { | |
| 5989 if (string->IsInternalizedString()) { | |
| 5990 *result = string; | |
| 5991 return true; | |
| 5992 } | |
| 5993 return string_table()->LookupStringIfExists(string, result); | |
| 5994 } | |
| 5995 | |
| 5996 | |
| 5997 void Heap::ZapFromSpace() { | 5931 void Heap::ZapFromSpace() { |
| 5998 NewSpacePageIterator it(new_space_.FromSpaceStart(), | 5932 NewSpacePageIterator it(new_space_.FromSpaceStart(), |
| 5999 new_space_.FromSpaceEnd()); | 5933 new_space_.FromSpaceEnd()); |
| 6000 while (it.has_next()) { | 5934 while (it.has_next()) { |
| 6001 NewSpacePage* page = it.next(); | 5935 NewSpacePage* page = it.next(); |
| 6002 for (Address cursor = page->area_start(), limit = page->area_end(); | 5936 for (Address cursor = page->area_start(), limit = page->area_end(); |
| 6003 cursor < limit; | 5937 cursor < limit; |
| 6004 cursor += kPointerSize) { | 5938 cursor += kPointerSize) { |
| 6005 Memory::Address_at(cursor) = kFromSpaceZapValue; | 5939 Memory::Address_at(cursor) = kFromSpaceZapValue; |
| 6006 } | 5940 } |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6596 } else { | 6530 } else { |
| 6597 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); | 6531 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); |
| 6598 } | 6532 } |
| 6599 } | 6533 } |
| 6600 | 6534 |
| 6601 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 6535 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
| 6602 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 6536 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
| 6603 | 6537 |
| 6604 store_buffer()->SetUp(); | 6538 store_buffer()->SetUp(); |
| 6605 | 6539 |
| 6540 mark_compact_collector()->SetUp(); |
| 6541 |
| 6606 if (FLAG_concurrent_recompilation) relocation_mutex_ = new Mutex; | 6542 if (FLAG_concurrent_recompilation) relocation_mutex_ = new Mutex; |
| 6607 | 6543 |
| 6608 return true; | 6544 return true; |
| 6609 } | 6545 } |
| 6610 | 6546 |
| 6611 | 6547 |
| 6612 bool Heap::CreateHeapObjects() { | 6548 bool Heap::CreateHeapObjects() { |
| 6613 // Create initial maps. | 6549 // Create initial maps. |
| 6614 if (!CreateInitialMaps()) return false; | 6550 if (!CreateInitialMaps()) return false; |
| 6615 if (!CreateApiObjects()) return false; | 6551 if (!CreateApiObjects()) return false; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6820 } | 6756 } |
| 6821 | 6757 |
| 6822 | 6758 |
| 6823 void Heap::EnsureWeakObjectToCodeTable() { | 6759 void Heap::EnsureWeakObjectToCodeTable() { |
| 6824 if (!weak_object_to_code_table()->IsHashTable()) { | 6760 if (!weak_object_to_code_table()->IsHashTable()) { |
| 6825 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); | 6761 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); |
| 6826 } | 6762 } |
| 6827 } | 6763 } |
| 6828 | 6764 |
| 6829 | 6765 |
| 6766 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
| 6767 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); |
| 6768 } |
| 6769 |
| 6830 #ifdef DEBUG | 6770 #ifdef DEBUG |
| 6831 | 6771 |
| 6832 class PrintHandleVisitor: public ObjectVisitor { | 6772 class PrintHandleVisitor: public ObjectVisitor { |
| 6833 public: | 6773 public: |
| 6834 void VisitPointers(Object** start, Object** end) { | 6774 void VisitPointers(Object** start, Object** end) { |
| 6835 for (Object** p = start; p < end; p++) | 6775 for (Object** p = start; p < end; p++) |
| 6836 PrintF(" handle %p to %p\n", | 6776 PrintF(" handle %p to %p\n", |
| 6837 reinterpret_cast<void*>(p), | 6777 reinterpret_cast<void*>(p), |
| 6838 reinterpret_cast<void*>(*p)); | 6778 reinterpret_cast<void*>(*p)); |
| 6839 } | 6779 } |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7805 static_cast<int>(object_sizes_last_time_[index])); | 7745 static_cast<int>(object_sizes_last_time_[index])); |
| 7806 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7746 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7807 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7747 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7808 | 7748 |
| 7809 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7749 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7810 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7750 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7811 ClearObjectStats(); | 7751 ClearObjectStats(); |
| 7812 } | 7752 } |
| 7813 | 7753 |
| 7814 } } // namespace v8::internal | 7754 } } // namespace v8::internal |
| OLD | NEW |