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

Side by Side Diff: src/heap/heap.cc

Issue 2381843002: Add Smi::Zero and replace all Smi::FromInt(0) calls (Closed)
Patch Set: Mark Smi::kZero as V8_EXPORT_PRIVATE Created 4 years, 2 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
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/heap/heap-inl.h » ('j') | 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 "src/heap/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/ast/context-slot-cache.h" 9 #include "src/ast/context-slot-cache.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // easier if you can define it as part of the build environment. 163 // easier if you can define it as part of the build environment.
164 #if defined(V8_MAX_SEMISPACE_SIZE) 164 #if defined(V8_MAX_SEMISPACE_SIZE)
165 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 165 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
166 #endif 166 #endif
167 167
168 // Ensure old_generation_size_ is a multiple of kPageSize. 168 // Ensure old_generation_size_ is a multiple of kPageSize.
169 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0); 169 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0);
170 170
171 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); 171 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
172 set_native_contexts_list(NULL); 172 set_native_contexts_list(NULL);
173 set_allocation_sites_list(Smi::FromInt(0)); 173 set_allocation_sites_list(Smi::kZero);
174 set_encountered_weak_collections(Smi::FromInt(0)); 174 set_encountered_weak_collections(Smi::kZero);
175 set_encountered_weak_cells(Smi::FromInt(0)); 175 set_encountered_weak_cells(Smi::kZero);
176 set_encountered_transition_arrays(Smi::FromInt(0)); 176 set_encountered_transition_arrays(Smi::kZero);
177 // Put a dummy entry in the remembered pages so we can find the list the 177 // Put a dummy entry in the remembered pages so we can find the list the
178 // minidump even if there are no real unmapped pages. 178 // minidump even if there are no real unmapped pages.
179 RememberUnmappedPage(NULL, false); 179 RememberUnmappedPage(NULL, false);
180 } 180 }
181 181
182 182
183 intptr_t Heap::Capacity() { 183 intptr_t Heap::Capacity() {
184 if (!HasBeenSetUp()) return 0; 184 if (!HasBeenSetUp()) return 0;
185 185
186 return new_space_->Capacity() + OldGenerationCapacity(); 186 return new_space_->Capacity() + OldGenerationCapacity();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // a stack trace that has already been preprocessed. Guard against this. 735 // a stack trace that has already been preprocessed. Guard against this.
736 if (!maybe_code->IsAbstractCode()) break; 736 if (!maybe_code->IsAbstractCode()) break;
737 AbstractCode* abstract_code = AbstractCode::cast(maybe_code); 737 AbstractCode* abstract_code = AbstractCode::cast(maybe_code);
738 int offset = Smi::cast(elements->get(j + 3))->value(); 738 int offset = Smi::cast(elements->get(j + 3))->value();
739 int pos = abstract_code->SourcePosition(offset); 739 int pos = abstract_code->SourcePosition(offset);
740 elements->set(j + 2, Smi::FromInt(pos)); 740 elements->set(j + 2, Smi::FromInt(pos));
741 } 741 }
742 } 742 }
743 // We must not compact the weak fixed list here, as we may be in the middle 743 // We must not compact the weak fixed list here, as we may be in the middle
744 // of writing to it, when the GC triggered. Instead, we reset the root value. 744 // of writing to it, when the GC triggered. Instead, we reset the root value.
745 set_weak_stack_trace_list(Smi::FromInt(0)); 745 set_weak_stack_trace_list(Smi::kZero);
746 } 746 }
747 747
748 748
749 class GCCallbacksScope { 749 class GCCallbacksScope {
750 public: 750 public:
751 explicit GCCallbacksScope(Heap* heap) : heap_(heap) { 751 explicit GCCallbacksScope(Heap* heap) : heap_(heap) {
752 heap_->gc_callbacks_depth_++; 752 heap_->gc_callbacks_depth_++;
753 } 753 }
754 ~GCCallbacksScope() { heap_->gc_callbacks_depth_--; } 754 ~GCCallbacksScope() { heap_->gc_callbacks_depth_--; }
755 755
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 reinterpret_cast<Map*>(result)->clear_unused(); 2054 reinterpret_cast<Map*>(result)->clear_unused();
2055 reinterpret_cast<Map*>(result) 2055 reinterpret_cast<Map*>(result)
2056 ->set_inobject_properties_or_constructor_function_index(0); 2056 ->set_inobject_properties_or_constructor_function_index(0);
2057 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); 2057 reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
2058 reinterpret_cast<Map*>(result)->set_bit_field(0); 2058 reinterpret_cast<Map*>(result)->set_bit_field(0);
2059 reinterpret_cast<Map*>(result)->set_bit_field2(0); 2059 reinterpret_cast<Map*>(result)->set_bit_field2(0);
2060 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | 2060 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
2061 Map::OwnsDescriptors::encode(true) | 2061 Map::OwnsDescriptors::encode(true) |
2062 Map::ConstructionCounter::encode(Map::kNoSlackTracking); 2062 Map::ConstructionCounter::encode(Map::kNoSlackTracking);
2063 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); 2063 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3);
2064 reinterpret_cast<Map*>(result)->set_weak_cell_cache(Smi::FromInt(0)); 2064 reinterpret_cast<Map*>(result)->set_weak_cell_cache(Smi::kZero);
2065 return result; 2065 return result;
2066 } 2066 }
2067 2067
2068 2068
2069 AllocationResult Heap::AllocateMap(InstanceType instance_type, 2069 AllocationResult Heap::AllocateMap(InstanceType instance_type,
2070 int instance_size, 2070 int instance_size,
2071 ElementsKind elements_kind) { 2071 ElementsKind elements_kind) {
2072 HeapObject* result = nullptr; 2072 HeapObject* result = nullptr;
2073 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE); 2073 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE);
2074 if (!allocation.To(&result)) return allocation; 2074 if (!allocation.To(&result)) return allocation;
2075 2075
2076 isolate()->counters()->maps_created()->Increment(); 2076 isolate()->counters()->maps_created()->Increment();
2077 result->set_map_no_write_barrier(meta_map()); 2077 result->set_map_no_write_barrier(meta_map());
2078 Map* map = Map::cast(result); 2078 Map* map = Map::cast(result);
2079 map->set_instance_type(instance_type); 2079 map->set_instance_type(instance_type);
2080 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); 2080 map->set_prototype(null_value(), SKIP_WRITE_BARRIER);
2081 map->set_constructor_or_backpointer(null_value(), SKIP_WRITE_BARRIER); 2081 map->set_constructor_or_backpointer(null_value(), SKIP_WRITE_BARRIER);
2082 map->set_instance_size(instance_size); 2082 map->set_instance_size(instance_size);
2083 map->clear_unused(); 2083 map->clear_unused();
2084 map->set_inobject_properties_or_constructor_function_index(0); 2084 map->set_inobject_properties_or_constructor_function_index(0);
2085 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); 2085 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER);
2086 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2086 map->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2087 SKIP_WRITE_BARRIER); 2087 SKIP_WRITE_BARRIER);
2088 map->set_weak_cell_cache(Smi::FromInt(0)); 2088 map->set_weak_cell_cache(Smi::kZero);
2089 map->set_raw_transitions(Smi::FromInt(0)); 2089 map->set_raw_transitions(Smi::kZero);
2090 map->set_unused_property_fields(0); 2090 map->set_unused_property_fields(0);
2091 map->set_instance_descriptors(empty_descriptor_array()); 2091 map->set_instance_descriptors(empty_descriptor_array());
2092 if (FLAG_unbox_double_fields) { 2092 if (FLAG_unbox_double_fields) {
2093 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2093 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2094 } 2094 }
2095 // Must be called only after |instance_type|, |instance_size| and 2095 // Must be called only after |instance_type|, |instance_size| and
2096 // |layout_descriptor| are set. 2096 // |layout_descriptor| are set.
2097 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); 2097 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map));
2098 map->set_bit_field(0); 2098 map->set_bit_field(0);
2099 map->set_bit_field2(1 << Map::kIsExtensible); 2099 map->set_bit_field2(1 << Map::kIsExtensible);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 , 2151 ,
2152 STRUCT_LIST(STRUCT_TABLE_ELEMENT) 2152 STRUCT_LIST(STRUCT_TABLE_ELEMENT)
2153 #undef STRUCT_TABLE_ELEMENT 2153 #undef STRUCT_TABLE_ELEMENT
2154 }; 2154 };
2155 2155
2156 namespace { 2156 namespace {
2157 2157
2158 void FinalizePartialMap(Heap* heap, Map* map) { 2158 void FinalizePartialMap(Heap* heap, Map* map) {
2159 map->set_code_cache(heap->empty_fixed_array()); 2159 map->set_code_cache(heap->empty_fixed_array());
2160 map->set_dependent_code(DependentCode::cast(heap->empty_fixed_array())); 2160 map->set_dependent_code(DependentCode::cast(heap->empty_fixed_array()));
2161 map->set_raw_transitions(Smi::FromInt(0)); 2161 map->set_raw_transitions(Smi::kZero);
2162 map->set_instance_descriptors(heap->empty_descriptor_array()); 2162 map->set_instance_descriptors(heap->empty_descriptor_array());
2163 if (FLAG_unbox_double_fields) { 2163 if (FLAG_unbox_double_fields) {
2164 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2164 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2165 } 2165 }
2166 map->set_prototype(heap->null_value()); 2166 map->set_prototype(heap->null_value());
2167 map->set_constructor_or_backpointer(heap->null_value()); 2167 map->set_constructor_or_backpointer(heap->null_value());
2168 } 2168 }
2169 2169
2170 } // namespace 2170 } // namespace
2171 2171
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 STATIC_ASSERT(PropertyCell::kSize <= kMaxRegularHeapObjectSize); 2486 STATIC_ASSERT(PropertyCell::kSize <= kMaxRegularHeapObjectSize);
2487 2487
2488 HeapObject* result = nullptr; 2488 HeapObject* result = nullptr;
2489 AllocationResult allocation = AllocateRaw(size, OLD_SPACE); 2489 AllocationResult allocation = AllocateRaw(size, OLD_SPACE);
2490 if (!allocation.To(&result)) return allocation; 2490 if (!allocation.To(&result)) return allocation;
2491 2491
2492 result->set_map_no_write_barrier(global_property_cell_map()); 2492 result->set_map_no_write_barrier(global_property_cell_map());
2493 PropertyCell* cell = PropertyCell::cast(result); 2493 PropertyCell* cell = PropertyCell::cast(result);
2494 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2494 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2495 SKIP_WRITE_BARRIER); 2495 SKIP_WRITE_BARRIER);
2496 cell->set_property_details(PropertyDetails(Smi::FromInt(0))); 2496 cell->set_property_details(PropertyDetails(Smi::kZero));
2497 cell->set_value(the_hole_value()); 2497 cell->set_value(the_hole_value());
2498 return result; 2498 return result;
2499 } 2499 }
2500 2500
2501 2501
2502 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { 2502 AllocationResult Heap::AllocateWeakCell(HeapObject* value) {
2503 int size = WeakCell::kSize; 2503 int size = WeakCell::kSize;
2504 STATIC_ASSERT(WeakCell::kSize <= kMaxRegularHeapObjectSize); 2504 STATIC_ASSERT(WeakCell::kSize <= kMaxRegularHeapObjectSize);
2505 HeapObject* result = nullptr; 2505 HeapObject* result = nullptr;
2506 { 2506 {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize)); 2616 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize));
2617 2617
2618 // Allocate 2618 // Allocate
2619 2619
2620 // Finish initializing oddballs after creating the string table. 2620 // Finish initializing oddballs after creating the string table.
2621 Oddball::Initialize(isolate(), factory->undefined_value(), "undefined", 2621 Oddball::Initialize(isolate(), factory->undefined_value(), "undefined",
2622 factory->nan_value(), "undefined", Oddball::kUndefined); 2622 factory->nan_value(), "undefined", Oddball::kUndefined);
2623 2623
2624 // Initialize the null_value. 2624 // Initialize the null_value.
2625 Oddball::Initialize(isolate(), factory->null_value(), "null", 2625 Oddball::Initialize(isolate(), factory->null_value(), "null",
2626 handle(Smi::FromInt(0), isolate()), "object", 2626 handle(Smi::kZero, isolate()), "object", Oddball::kNull);
2627 Oddball::kNull);
2628 2627
2629 // Initialize the_hole_value. 2628 // Initialize the_hole_value.
2630 Oddball::Initialize(isolate(), factory->the_hole_value(), "hole", 2629 Oddball::Initialize(isolate(), factory->the_hole_value(), "hole",
2631 factory->hole_nan_value(), "undefined", 2630 factory->hole_nan_value(), "undefined",
2632 Oddball::kTheHole); 2631 Oddball::kTheHole);
2633 2632
2634 // Initialize the true_value. 2633 // Initialize the true_value.
2635 Oddball::Initialize(isolate(), factory->true_value(), "true", 2634 Oddball::Initialize(isolate(), factory->true_value(), "true",
2636 handle(Smi::FromInt(1), isolate()), "boolean", 2635 handle(Smi::FromInt(1), isolate()), "boolean",
2637 Oddball::kTrue); 2636 Oddball::kTrue);
2638 2637
2639 // Initialize the false_value. 2638 // Initialize the false_value.
2640 Oddball::Initialize(isolate(), factory->false_value(), "false", 2639 Oddball::Initialize(isolate(), factory->false_value(), "false",
2641 handle(Smi::FromInt(0), isolate()), "boolean", 2640 handle(Smi::kZero, isolate()), "boolean",
2642 Oddball::kFalse); 2641 Oddball::kFalse);
2643 2642
2644 set_uninitialized_value( 2643 set_uninitialized_value(
2645 *factory->NewOddball(factory->uninitialized_map(), "uninitialized", 2644 *factory->NewOddball(factory->uninitialized_map(), "uninitialized",
2646 handle(Smi::FromInt(-1), isolate()), "undefined", 2645 handle(Smi::FromInt(-1), isolate()), "undefined",
2647 Oddball::kUninitialized)); 2646 Oddball::kUninitialized));
2648 2647
2649 set_arguments_marker( 2648 set_arguments_marker(
2650 *factory->NewOddball(factory->arguments_marker_map(), "arguments_marker", 2649 *factory->NewOddball(factory->arguments_marker_map(), "arguments_marker",
2651 handle(Smi::FromInt(-4), isolate()), "undefined", 2650 handle(Smi::FromInt(-4), isolate()), "undefined",
(...skipping 25 matching lines...) Expand all
2677 for (unsigned i = 0; i < arraysize(constant_string_table); i++) { 2676 for (unsigned i = 0; i < arraysize(constant_string_table); i++) {
2678 Handle<String> str = 2677 Handle<String> str =
2679 factory->InternalizeUtf8String(constant_string_table[i].contents); 2678 factory->InternalizeUtf8String(constant_string_table[i].contents);
2680 roots_[constant_string_table[i].index] = *str; 2679 roots_[constant_string_table[i].index] = *str;
2681 } 2680 }
2682 2681
2683 // Create the code_stubs dictionary. The initial size is set to avoid 2682 // Create the code_stubs dictionary. The initial size is set to avoid
2684 // expanding the dictionary during bootstrapping. 2683 // expanding the dictionary during bootstrapping.
2685 set_code_stubs(*UnseededNumberDictionary::New(isolate(), 128)); 2684 set_code_stubs(*UnseededNumberDictionary::New(isolate(), 128));
2686 2685
2687 set_instanceof_cache_function(Smi::FromInt(0)); 2686 set_instanceof_cache_function(Smi::kZero);
2688 set_instanceof_cache_map(Smi::FromInt(0)); 2687 set_instanceof_cache_map(Smi::kZero);
2689 set_instanceof_cache_answer(Smi::FromInt(0)); 2688 set_instanceof_cache_answer(Smi::kZero);
2690 2689
2691 { 2690 {
2692 HandleScope scope(isolate()); 2691 HandleScope scope(isolate());
2693 #define SYMBOL_INIT(name) \ 2692 #define SYMBOL_INIT(name) \
2694 { \ 2693 { \
2695 Handle<String> name##d = factory->NewStringFromStaticChars(#name); \ 2694 Handle<String> name##d = factory->NewStringFromStaticChars(#name); \
2696 Handle<Symbol> symbol(isolate()->factory()->NewPrivateSymbol()); \ 2695 Handle<Symbol> symbol(isolate()->factory()->NewPrivateSymbol()); \
2697 symbol->set_name(*name##d); \ 2696 symbol->set_name(*name##d); \
2698 roots_[k##name##RootIndex] = *symbol; \ 2697 roots_[k##name##RootIndex] = *symbol; \
2699 } 2698 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 2747
2749 set_extra_natives_source_cache( 2748 set_extra_natives_source_cache(
2750 *factory->NewFixedArray(ExtraNatives::GetBuiltinsCount())); 2749 *factory->NewFixedArray(ExtraNatives::GetBuiltinsCount()));
2751 2750
2752 set_experimental_extra_natives_source_cache( 2751 set_experimental_extra_natives_source_cache(
2753 *factory->NewFixedArray(ExperimentalExtraNatives::GetBuiltinsCount())); 2752 *factory->NewFixedArray(ExperimentalExtraNatives::GetBuiltinsCount()));
2754 2753
2755 set_undefined_cell(*factory->NewCell(factory->undefined_value())); 2754 set_undefined_cell(*factory->NewCell(factory->undefined_value()));
2756 2755
2757 // The symbol registry is initialized lazily. 2756 // The symbol registry is initialized lazily.
2758 set_symbol_registry(Smi::FromInt(0)); 2757 set_symbol_registry(Smi::kZero);
2759 2758
2760 // Microtask queue uses the empty fixed array as a sentinel for "empty". 2759 // Microtask queue uses the empty fixed array as a sentinel for "empty".
2761 // Number of queued microtasks stored in Isolate::pending_microtask_count(). 2760 // Number of queued microtasks stored in Isolate::pending_microtask_count().
2762 set_microtask_queue(empty_fixed_array()); 2761 set_microtask_queue(empty_fixed_array());
2763 2762
2764 { 2763 {
2765 StaticFeedbackVectorSpec spec; 2764 StaticFeedbackVectorSpec spec;
2766 FeedbackVectorSlot slot = spec.AddLoadICSlot(); 2765 FeedbackVectorSlot slot = spec.AddLoadICSlot();
2767 DCHECK_EQ(slot, FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)); 2766 DCHECK_EQ(slot, FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot));
2768 2767
(...skipping 27 matching lines...) Expand all
2796 // functions that don't need actual type feedback slots. Note however 2795 // functions that don't need actual type feedback slots. Note however
2797 // that all these functions will share the same invocation count, but 2796 // that all these functions will share the same invocation count, but
2798 // that shouldn't matter since we only use the invocation count to 2797 // that shouldn't matter since we only use the invocation count to
2799 // relativize the absolute call counts, but we can only have call counts 2798 // relativize the absolute call counts, but we can only have call counts
2800 // if we have actual feedback slots. 2799 // if we have actual feedback slots.
2801 Handle<FixedArray> empty_type_feedback_vector = factory->NewFixedArray( 2800 Handle<FixedArray> empty_type_feedback_vector = factory->NewFixedArray(
2802 TypeFeedbackVector::kReservedIndexCount, TENURED); 2801 TypeFeedbackVector::kReservedIndexCount, TENURED);
2803 empty_type_feedback_vector->set(TypeFeedbackVector::kMetadataIndex, 2802 empty_type_feedback_vector->set(TypeFeedbackVector::kMetadataIndex,
2804 empty_fixed_array()); 2803 empty_fixed_array());
2805 empty_type_feedback_vector->set(TypeFeedbackVector::kInvocationCountIndex, 2804 empty_type_feedback_vector->set(TypeFeedbackVector::kInvocationCountIndex,
2806 Smi::FromInt(0)); 2805 Smi::kZero);
2807 set_empty_type_feedback_vector(*empty_type_feedback_vector); 2806 set_empty_type_feedback_vector(*empty_type_feedback_vector);
2808 2807
2809 // We use a canonical empty LiteralsArray for all functions that neither 2808 // We use a canonical empty LiteralsArray for all functions that neither
2810 // have literals nor need a TypeFeedbackVector (besides the invocation 2809 // have literals nor need a TypeFeedbackVector (besides the invocation
2811 // count special slot). 2810 // count special slot).
2812 Handle<FixedArray> empty_literals_array = 2811 Handle<FixedArray> empty_literals_array =
2813 factory->NewFixedArray(1, TENURED); 2812 factory->NewFixedArray(1, TENURED);
2814 empty_literals_array->set(0, *empty_type_feedback_vector); 2813 empty_literals_array->set(0, *empty_type_feedback_vector);
2815 set_empty_literals_array(*empty_literals_array); 2814 set_empty_literals_array(*empty_literals_array);
2816 } 2815 }
(...skipping 23 matching lines...) Expand all
2840 set_retained_maps(ArrayList::cast(empty_fixed_array())); 2839 set_retained_maps(ArrayList::cast(empty_fixed_array()));
2841 2840
2842 set_weak_object_to_code_table( 2841 set_weak_object_to_code_table(
2843 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, 2842 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY,
2844 TENURED)); 2843 TENURED));
2845 2844
2846 set_weak_new_space_object_to_code_list( 2845 set_weak_new_space_object_to_code_list(
2847 ArrayList::cast(*(factory->NewFixedArray(16, TENURED)))); 2846 ArrayList::cast(*(factory->NewFixedArray(16, TENURED))));
2848 weak_new_space_object_to_code_list()->SetLength(0); 2847 weak_new_space_object_to_code_list()->SetLength(0);
2849 2848
2850 set_script_list(Smi::FromInt(0)); 2849 set_script_list(Smi::kZero);
2851 2850
2852 Handle<SeededNumberDictionary> slow_element_dictionary = 2851 Handle<SeededNumberDictionary> slow_element_dictionary =
2853 SeededNumberDictionary::New(isolate(), 0, TENURED); 2852 SeededNumberDictionary::New(isolate(), 0, TENURED);
2854 slow_element_dictionary->set_requires_slow_elements(); 2853 slow_element_dictionary->set_requires_slow_elements();
2855 set_empty_slow_element_dictionary(*slow_element_dictionary); 2854 set_empty_slow_element_dictionary(*slow_element_dictionary);
2856 2855
2857 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); 2856 set_materialized_objects(*factory->NewFixedArray(0, TENURED));
2858 2857
2859 // Handling of script id generation is in Heap::NextScriptId(). 2858 // Handling of script id generation is in Heap::NextScriptId().
2860 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); 2859 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
2861 set_next_template_serial_number(Smi::FromInt(0)); 2860 set_next_template_serial_number(Smi::kZero);
2862 2861
2863 // Allocate the empty script. 2862 // Allocate the empty script.
2864 Handle<Script> script = factory->NewScript(factory->empty_string()); 2863 Handle<Script> script = factory->NewScript(factory->empty_string());
2865 script->set_type(Script::TYPE_NATIVE); 2864 script->set_type(Script::TYPE_NATIVE);
2866 set_empty_script(*script); 2865 set_empty_script(*script);
2867 2866
2868 Handle<PropertyCell> cell = factory->NewPropertyCell(); 2867 Handle<PropertyCell> cell = factory->NewPropertyCell();
2869 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); 2868 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid));
2870 set_array_protector(*cell); 2869 set_array_protector(*cell);
2871 2870
(...skipping 12 matching lines...) Expand all
2884 Handle<Cell> species_cell = factory->NewCell( 2883 Handle<Cell> species_cell = factory->NewCell(
2885 handle(Smi::FromInt(Isolate::kArrayProtectorValid), isolate())); 2884 handle(Smi::FromInt(Isolate::kArrayProtectorValid), isolate()));
2886 set_species_protector(*species_cell); 2885 set_species_protector(*species_cell);
2887 2886
2888 cell = factory->NewPropertyCell(); 2887 cell = factory->NewPropertyCell();
2889 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); 2888 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid));
2890 set_string_length_protector(*cell); 2889 set_string_length_protector(*cell);
2891 2890
2892 set_serialized_templates(empty_fixed_array()); 2891 set_serialized_templates(empty_fixed_array());
2893 2892
2894 set_weak_stack_trace_list(Smi::FromInt(0)); 2893 set_weak_stack_trace_list(Smi::kZero);
2895 2894
2896 set_noscript_shared_function_infos(Smi::FromInt(0)); 2895 set_noscript_shared_function_infos(Smi::kZero);
2897 2896
2898 // Initialize keyed lookup cache. 2897 // Initialize keyed lookup cache.
2899 isolate_->keyed_lookup_cache()->Clear(); 2898 isolate_->keyed_lookup_cache()->Clear();
2900 2899
2901 // Initialize context slot cache. 2900 // Initialize context slot cache.
2902 isolate_->context_slot_cache()->Clear(); 2901 isolate_->context_slot_cache()->Clear();
2903 2902
2904 // Initialize descriptor cache. 2903 // Initialize descriptor cache.
2905 isolate_->descriptor_lookup_cache()->Clear(); 2904 isolate_->descriptor_lookup_cache()->Clear();
2906 2905
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 int size = FixedTypedArrayBase::kHeaderSize; 3287 int size = FixedTypedArrayBase::kHeaderSize;
3289 AllocationSpace space = SelectSpace(pretenure); 3288 AllocationSpace space = SelectSpace(pretenure);
3290 HeapObject* result = nullptr; 3289 HeapObject* result = nullptr;
3291 { 3290 {
3292 AllocationResult allocation = AllocateRaw(size, space); 3291 AllocationResult allocation = AllocateRaw(size, space);
3293 if (!allocation.To(&result)) return allocation; 3292 if (!allocation.To(&result)) return allocation;
3294 } 3293 }
3295 3294
3296 result->set_map_no_write_barrier(MapForFixedTypedArray(array_type)); 3295 result->set_map_no_write_barrier(MapForFixedTypedArray(array_type));
3297 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(result); 3296 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(result);
3298 elements->set_base_pointer(Smi::FromInt(0), SKIP_WRITE_BARRIER); 3297 elements->set_base_pointer(Smi::kZero, SKIP_WRITE_BARRIER);
3299 elements->set_external_pointer(external_pointer, SKIP_WRITE_BARRIER); 3298 elements->set_external_pointer(external_pointer, SKIP_WRITE_BARRIER);
3300 elements->set_length(length); 3299 elements->set_length(length);
3301 return elements; 3300 return elements;
3302 } 3301 }
3303 3302
3304 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, 3303 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size,
3305 ElementsKind* element_kind) { 3304 ElementsKind* element_kind) {
3306 switch (array_type) { 3305 switch (array_type) {
3307 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 3306 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
3308 case kExternal##Type##Array: \ 3307 case kExternal##Type##Array: \
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3372 OnAllocationEvent(result, object_size); 3371 OnAllocationEvent(result, object_size);
3373 } 3372 }
3374 } 3373 }
3375 3374
3376 result->set_map_no_write_barrier(code_map()); 3375 result->set_map_no_write_barrier(code_map());
3377 Code* code = Code::cast(result); 3376 Code* code = Code::cast(result);
3378 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment)); 3377 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment));
3379 DCHECK(!memory_allocator()->code_range()->valid() || 3378 DCHECK(!memory_allocator()->code_range()->valid() ||
3380 memory_allocator()->code_range()->contains(code->address()) || 3379 memory_allocator()->code_range()->contains(code->address()) ||
3381 object_size <= code_space()->AreaSize()); 3380 object_size <= code_space()->AreaSize());
3382 code->set_gc_metadata(Smi::FromInt(0)); 3381 code->set_gc_metadata(Smi::kZero);
3383 code->set_ic_age(global_ic_age_); 3382 code->set_ic_age(global_ic_age_);
3384 return code; 3383 return code;
3385 } 3384 }
3386 3385
3387 3386
3388 AllocationResult Heap::CopyCode(Code* code) { 3387 AllocationResult Heap::CopyCode(Code* code) {
3389 AllocationResult allocation; 3388 AllocationResult allocation;
3390 3389
3391 HeapObject* result = nullptr; 3390 HeapObject* result = nullptr;
3392 // Allocate an object the same size as the code object. 3391 // Allocate an object the same size as the code object.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 } 3468 }
3470 3469
3471 3470
3472 void Heap::InitializeJSObjectFromMap(JSObject* obj, FixedArray* properties, 3471 void Heap::InitializeJSObjectFromMap(JSObject* obj, FixedArray* properties,
3473 Map* map) { 3472 Map* map) {
3474 obj->set_properties(properties); 3473 obj->set_properties(properties);
3475 obj->initialize_elements(); 3474 obj->initialize_elements();
3476 // TODO(1240798): Initialize the object's body using valid initial values 3475 // TODO(1240798): Initialize the object's body using valid initial values
3477 // according to the object's initial map. For example, if the map's 3476 // according to the object's initial map. For example, if the map's
3478 // instance type is JS_ARRAY_TYPE, the length field should be initialized 3477 // instance type is JS_ARRAY_TYPE, the length field should be initialized
3479 // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a 3478 // to a number (e.g. Smi::kZero) and the elements initialized to a
3480 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object 3479 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object
3481 // verification code has to cope with (temporarily) invalid objects. See 3480 // verification code has to cope with (temporarily) invalid objects. See
3482 // for example, JSArray::JSArrayVerify). 3481 // for example, JSArray::JSArrayVerify).
3483 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize); 3482 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize);
3484 } 3483 }
3485 3484
3486 3485
3487 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) { 3486 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) {
3488 if (start_offset == map->instance_size()) return; 3487 if (start_offset == map->instance_size()) return;
3489 DCHECK_LT(start_offset, map->instance_size()); 3488 DCHECK_LT(start_offset, map->instance_size());
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
5549 5548
5550 // Set up the special root array entries containing the stack limits. 5549 // Set up the special root array entries containing the stack limits.
5551 // These are actually addresses, but the tag makes the GC ignore it. 5550 // These are actually addresses, but the tag makes the GC ignore it.
5552 roots_[kStackLimitRootIndex] = reinterpret_cast<Object*>( 5551 roots_[kStackLimitRootIndex] = reinterpret_cast<Object*>(
5553 (isolate_->stack_guard()->jslimit() & ~kSmiTagMask) | kSmiTag); 5552 (isolate_->stack_guard()->jslimit() & ~kSmiTagMask) | kSmiTag);
5554 roots_[kRealStackLimitRootIndex] = reinterpret_cast<Object*>( 5553 roots_[kRealStackLimitRootIndex] = reinterpret_cast<Object*>(
5555 (isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag); 5554 (isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag);
5556 } 5555 }
5557 5556
5558 void Heap::ClearStackLimits() { 5557 void Heap::ClearStackLimits() {
5559 roots_[kStackLimitRootIndex] = Smi::FromInt(0); 5558 roots_[kStackLimitRootIndex] = Smi::kZero;
5560 roots_[kRealStackLimitRootIndex] = Smi::FromInt(0); 5559 roots_[kRealStackLimitRootIndex] = Smi::kZero;
5561 } 5560 }
5562 5561
5563 void Heap::PrintAlloctionsHash() { 5562 void Heap::PrintAlloctionsHash() {
5564 uint32_t hash = StringHasher::GetHashCore(raw_allocations_hash_); 5563 uint32_t hash = StringHasher::GetHashCore(raw_allocations_hash_);
5565 PrintF("\n### Allocations = %u, hash = 0x%08x\n", allocations_count(), hash); 5564 PrintF("\n### Allocations = %u, hash = 0x%08x\n", allocations_count(), hash);
5566 } 5565 }
5567 5566
5568 5567
5569 void Heap::NotifyDeserializationComplete() { 5568 void Heap::NotifyDeserializationComplete() {
5570 DCHECK_EQ(0, gc_count()); 5569 DCHECK_EQ(0, gc_count());
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
6518 } 6517 }
6519 6518
6520 6519
6521 // static 6520 // static
6522 int Heap::GetStaticVisitorIdForMap(Map* map) { 6521 int Heap::GetStaticVisitorIdForMap(Map* map) {
6523 return StaticVisitorBase::GetVisitorId(map); 6522 return StaticVisitorBase::GetVisitorId(map);
6524 } 6523 }
6525 6524
6526 } // namespace internal 6525 } // namespace internal
6527 } // namespace v8 6526 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698