Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/setup-isolate.h"
6 :
7 : #include "src/accessors.h"
8 : #include "src/compilation-cache.h"
9 : #include "src/contexts.h"
10 : #include "src/heap-symbols.h"
11 : #include "src/heap/factory.h"
12 : #include "src/heap/heap-inl.h"
13 : #include "src/ic/handler-configuration.h"
14 : #include "src/interpreter/interpreter.h"
15 : #include "src/isolate.h"
16 : #include "src/layout-descriptor.h"
17 : #include "src/lookup-cache.h"
18 : #include "src/objects-inl.h"
19 : #include "src/objects/arguments.h"
20 : #include "src/objects/cell-inl.h"
21 : #include "src/objects/data-handler.h"
22 : #include "src/objects/debug-objects.h"
23 : #include "src/objects/descriptor-array.h"
24 : #include "src/objects/dictionary.h"
25 : #include "src/objects/foreign.h"
26 : #include "src/objects/heap-number.h"
27 : #include "src/objects/instance-type-inl.h"
28 : #include "src/objects/js-generator.h"
29 : #include "src/objects/js-weak-refs.h"
30 : #include "src/objects/literal-objects-inl.h"
31 : #include "src/objects/map.h"
32 : #include "src/objects/microtask.h"
33 : #include "src/objects/module.h"
34 : #include "src/objects/oddball-inl.h"
35 : #include "src/objects/promise.h"
36 : #include "src/objects/script.h"
37 : #include "src/objects/shared-function-info.h"
38 : #include "src/objects/smi.h"
39 : #include "src/objects/stack-frame-info.h"
40 : #include "src/objects/string.h"
41 : #include "src/regexp/jsregexp.h"
42 : #include "src/wasm/wasm-objects.h"
43 :
44 : namespace v8 {
45 : namespace internal {
46 :
47 56 : bool SetupIsolateDelegate::SetupHeapInternal(Heap* heap) {
48 56 : return heap->CreateHeapObjects();
49 : }
50 :
51 56 : bool Heap::CreateHeapObjects() {
52 : // Create initial maps.
53 56 : if (!CreateInitialMaps()) return false;
54 56 : CreateApiObjects();
55 :
56 : // Create initial objects
57 56 : CreateInitialObjects();
58 56 : CreateInternalAccessorInfoObjects();
59 112 : CHECK_EQ(0u, gc_count_);
60 :
61 56 : set_native_contexts_list(ReadOnlyRoots(this).undefined_value());
62 56 : set_allocation_sites_list(ReadOnlyRoots(this).undefined_value());
63 :
64 56 : return true;
65 : }
66 :
67 : const Heap::StringTypeTable Heap::string_type_table[] = {
68 : #define STRING_TYPE_ELEMENT(type, size, name, CamelName) \
69 : {type, size, RootIndex::k##CamelName##Map},
70 : STRING_TYPE_LIST(STRING_TYPE_ELEMENT)
71 : #undef STRING_TYPE_ELEMENT
72 : };
73 :
74 : const Heap::ConstantStringTable Heap::constant_string_table[] = {
75 : {"", RootIndex::kempty_string},
76 : #define CONSTANT_STRING_ELEMENT(_, name, contents) \
77 : {contents, RootIndex::k##name},
78 : INTERNALIZED_STRING_LIST_GENERATOR(CONSTANT_STRING_ELEMENT, /* not used */)
79 : #undef CONSTANT_STRING_ELEMENT
80 : };
81 :
82 : const Heap::StructTable Heap::struct_table[] = {
83 : #define STRUCT_TABLE_ELEMENT(TYPE, Name, name) \
84 : {TYPE, Name::kSize, RootIndex::k##Name##Map},
85 : STRUCT_LIST(STRUCT_TABLE_ELEMENT)
86 : #undef STRUCT_TABLE_ELEMENT
87 :
88 : #define ALLOCATION_SITE_ELEMENT(_, TYPE, Name, Size, name) \
89 : {TYPE, Name::kSize##Size, RootIndex::k##Name##Size##Map},
90 : ALLOCATION_SITE_LIST(ALLOCATION_SITE_ELEMENT, /* not used */)
91 : #undef ALLOCATION_SITE_ELEMENT
92 :
93 : #define DATA_HANDLER_ELEMENT(_, TYPE, Name, Size, name) \
94 : {TYPE, Name::kSizeWithData##Size, RootIndex::k##Name##Size##Map},
95 : DATA_HANDLER_LIST(DATA_HANDLER_ELEMENT, /* not used */)
96 : #undef DATA_HANDLER_ELEMENT
97 : };
98 :
99 5880 : AllocationResult Heap::AllocateMap(InstanceType instance_type,
100 : int instance_size,
101 : ElementsKind elements_kind,
102 : int inobject_properties) {
103 : STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
104 11760 : bool is_js_object = InstanceTypeChecker::IsJSObject(instance_type);
105 : DCHECK_IMPLIES(is_js_object &&
106 : !Map::CanHaveFastTransitionableElementsKind(instance_type),
107 : IsDictionaryElementsKind(elements_kind) ||
108 : IsTerminalElementsKind(elements_kind));
109 5880 : HeapObject result;
110 : // JSObjects have maps with a mutable prototype_validity_cell, so they cannot
111 : // go in RO_SPACE.
112 : AllocationResult allocation =
113 5880 : AllocateRaw(Map::kSize, is_js_object ? MAP_SPACE : RO_SPACE);
114 5880 : if (!allocation.To(&result)) return allocation;
115 :
116 : result->set_map_after_allocation(ReadOnlyRoots(this).meta_map(),
117 5880 : SKIP_WRITE_BARRIER);
118 : Map map = isolate()->factory()->InitializeMap(
119 : Map::cast(result), instance_type, instance_size, elements_kind,
120 11760 : inobject_properties);
121 :
122 5880 : return map;
123 : }
124 :
125 2912 : AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
126 : int instance_size) {
127 2912 : Object result;
128 2912 : AllocationResult allocation = AllocateRaw(Map::kSize, RO_SPACE);
129 2912 : if (!allocation.To(&result)) return allocation;
130 : // Map::cast cannot be used due to uninitialized map field.
131 2912 : Map map = Map::unchecked_cast(result);
132 2912 : map->set_map_after_allocation(
133 : Map::unchecked_cast(isolate()->root(RootIndex::kMetaMap)),
134 5824 : SKIP_WRITE_BARRIER);
135 2912 : map->set_instance_type(instance_type);
136 2912 : map->set_instance_size(instance_size);
137 : // Initialize to only containing tagged fields.
138 : if (FLAG_unbox_double_fields) {
139 2912 : map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
140 : }
141 : // GetVisitorId requires a properly initialized LayoutDescriptor.
142 2912 : map->set_visitor_id(Map::GetVisitorId(map));
143 2912 : map->set_inobject_properties_start_or_constructor_function_index(0);
144 : DCHECK(!map->IsJSObjectMap());
145 2912 : map->set_prototype_validity_cell(Smi::FromInt(Map::kPrototypeChainValid));
146 2912 : map->SetInObjectUnusedPropertyFields(0);
147 2912 : map->set_bit_field(0);
148 2912 : map->set_bit_field2(0);
149 : DCHECK(!map->is_in_retained_map_list());
150 5824 : int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
151 5824 : Map::OwnsDescriptorsBit::encode(true) |
152 5824 : Map::ConstructionCounterBits::encode(Map::kNoSlackTracking);
153 2912 : map->set_bit_field3(bit_field3);
154 2912 : map->set_elements_kind(TERMINAL_FAST_ELEMENTS_KIND);
155 2912 : return map;
156 : }
157 :
158 2912 : void Heap::FinalizePartialMap(Map map) {
159 : ReadOnlyRoots roots(this);
160 5824 : map->set_dependent_code(DependentCode::cast(roots.empty_weak_fixed_array()));
161 2912 : map->set_raw_transitions(MaybeObject::FromSmi(Smi::zero()));
162 2912 : map->SetInstanceDescriptors(isolate(), roots.empty_descriptor_array(), 0);
163 : if (FLAG_unbox_double_fields) {
164 2912 : map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
165 : }
166 2912 : map->set_prototype(roots.null_value());
167 2912 : map->set_constructor_or_backpointer(roots.null_value());
168 2912 : }
169 :
170 392 : AllocationResult Heap::Allocate(Map map, AllocationSpace space) {
171 : DCHECK(map->instance_type() != MAP_TYPE);
172 392 : int size = map->instance_size();
173 392 : HeapObject result;
174 392 : AllocationResult allocation = AllocateRaw(size, space);
175 392 : if (!allocation.To(&result)) return allocation;
176 : // New space objects are allocated white.
177 : WriteBarrierMode write_barrier_mode =
178 392 : space == NEW_SPACE ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER;
179 392 : result->set_map_after_allocation(map, write_barrier_mode);
180 392 : return result;
181 : }
182 :
183 616 : AllocationResult Heap::AllocateEmptyFixedTypedArray(
184 : ExternalArrayType array_type) {
185 616 : int size = OBJECT_POINTER_ALIGN(FixedTypedArrayBase::kDataOffset);
186 :
187 616 : HeapObject object;
188 : AllocationResult allocation = AllocateRaw(
189 : size, RO_SPACE,
190 616 : array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned);
191 616 : if (!allocation.To(&object)) return allocation;
192 :
193 : object->set_map_after_allocation(
194 : ReadOnlyRoots(this).MapForFixedTypedArray(array_type),
195 616 : SKIP_WRITE_BARRIER);
196 616 : FixedTypedArrayBase elements = FixedTypedArrayBase::cast(object);
197 616 : elements->set_base_pointer(elements, SKIP_WRITE_BARRIER);
198 : elements->set_external_pointer(
199 : reinterpret_cast<void*>(
200 1232 : ExternalReference::fixed_typed_array_base_data_offset().address()),
201 616 : SKIP_WRITE_BARRIER);
202 616 : elements->set_length(0);
203 616 : return elements;
204 : }
205 :
206 56 : bool Heap::CreateInitialMaps() {
207 56 : HeapObject obj;
208 : {
209 56 : AllocationResult allocation = AllocatePartialMap(MAP_TYPE, Map::kSize);
210 56 : if (!allocation.To(&obj)) return false;
211 : }
212 : // Map::cast cannot be used due to uninitialized map field.
213 56 : Map new_meta_map = Map::unchecked_cast(obj);
214 56 : set_meta_map(new_meta_map);
215 56 : new_meta_map->set_map_after_allocation(new_meta_map);
216 :
217 : ReadOnlyRoots roots(this);
218 : { // Partial map allocation
219 : #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \
220 : { \
221 : Map map; \
222 : if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \
223 : set_##field_name##_map(map); \
224 : }
225 :
226 56 : ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array);
227 56 : ALLOCATE_PARTIAL_MAP(WEAK_FIXED_ARRAY_TYPE, kVariableSizeSentinel,
228 : weak_fixed_array);
229 56 : ALLOCATE_PARTIAL_MAP(WEAK_ARRAY_LIST_TYPE, kVariableSizeSentinel,
230 : weak_array_list);
231 56 : ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel,
232 : fixed_cow_array)
233 : DCHECK_NE(roots.fixed_array_map(), roots.fixed_cow_array_map());
234 :
235 56 : ALLOCATE_PARTIAL_MAP(DESCRIPTOR_ARRAY_TYPE, kVariableSizeSentinel,
236 : descriptor_array)
237 :
238 56 : ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined);
239 56 : ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null);
240 56 : ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole);
241 :
242 : #undef ALLOCATE_PARTIAL_MAP
243 : }
244 :
245 : // Allocate the empty array.
246 : {
247 56 : AllocationResult alloc = AllocateRaw(FixedArray::SizeFor(0), RO_SPACE);
248 56 : if (!alloc.To(&obj)) return false;
249 56 : obj->set_map_after_allocation(roots.fixed_array_map(), SKIP_WRITE_BARRIER);
250 56 : FixedArray::cast(obj)->set_length(0);
251 : }
252 56 : set_empty_fixed_array(FixedArray::cast(obj));
253 :
254 : {
255 56 : AllocationResult alloc = AllocateRaw(WeakFixedArray::SizeFor(0), RO_SPACE);
256 56 : if (!alloc.To(&obj)) return false;
257 : obj->set_map_after_allocation(roots.weak_fixed_array_map(),
258 56 : SKIP_WRITE_BARRIER);
259 56 : WeakFixedArray::cast(obj)->set_length(0);
260 : }
261 56 : set_empty_weak_fixed_array(WeakFixedArray::cast(obj));
262 :
263 : {
264 : AllocationResult allocation =
265 56 : AllocateRaw(WeakArrayList::SizeForCapacity(0), RO_SPACE);
266 56 : if (!allocation.To(&obj)) return false;
267 : obj->set_map_after_allocation(roots.weak_array_list_map(),
268 56 : SKIP_WRITE_BARRIER);
269 56 : WeakArrayList::cast(obj)->set_capacity(0);
270 56 : WeakArrayList::cast(obj)->set_length(0);
271 : }
272 56 : set_empty_weak_array_list(WeakArrayList::cast(obj));
273 :
274 : {
275 56 : AllocationResult allocation = Allocate(roots.null_map(), RO_SPACE);
276 56 : if (!allocation.To(&obj)) return false;
277 : }
278 56 : set_null_value(Oddball::cast(obj));
279 56 : Oddball::cast(obj)->set_kind(Oddball::kNull);
280 :
281 : {
282 56 : AllocationResult allocation = Allocate(roots.undefined_map(), RO_SPACE);
283 56 : if (!allocation.To(&obj)) return false;
284 : }
285 56 : set_undefined_value(Oddball::cast(obj));
286 56 : Oddball::cast(obj)->set_kind(Oddball::kUndefined);
287 : DCHECK(!InYoungGeneration(roots.undefined_value()));
288 : {
289 56 : AllocationResult allocation = Allocate(roots.the_hole_map(), RO_SPACE);
290 56 : if (!allocation.To(&obj)) return false;
291 : }
292 56 : set_the_hole_value(Oddball::cast(obj));
293 56 : Oddball::cast(obj)->set_kind(Oddball::kTheHole);
294 :
295 : // Set preliminary exception sentinel value before actually initializing it.
296 56 : set_exception(roots.null_value());
297 :
298 : // Setup the struct maps first (needed for the EnumCache).
299 2464 : for (unsigned i = 0; i < arraysize(struct_table); i++) {
300 2408 : const StructTable& entry = struct_table[i];
301 2408 : Map map;
302 2408 : if (!AllocatePartialMap(entry.type, entry.size).To(&map)) return false;
303 4816 : roots_table()[entry.index] = map->ptr();
304 : }
305 :
306 : // Allocate the empty enum cache.
307 : {
308 56 : AllocationResult allocation = Allocate(roots.tuple2_map(), RO_SPACE);
309 56 : if (!allocation.To(&obj)) return false;
310 : }
311 56 : set_empty_enum_cache(EnumCache::cast(obj));
312 56 : EnumCache::cast(obj)->set_keys(roots.empty_fixed_array());
313 56 : EnumCache::cast(obj)->set_indices(roots.empty_fixed_array());
314 :
315 : // Allocate the empty descriptor array.
316 : {
317 56 : int size = DescriptorArray::SizeFor(0);
318 56 : if (!AllocateRaw(size, RO_SPACE).To(&obj)) return false;
319 : obj->set_map_after_allocation(roots.descriptor_array_map(),
320 56 : SKIP_WRITE_BARRIER);
321 56 : DescriptorArray array = DescriptorArray::cast(obj);
322 112 : array->Initialize(roots.empty_enum_cache(), roots.undefined_value(), 0, 0);
323 : }
324 56 : set_empty_descriptor_array(DescriptorArray::cast(obj));
325 :
326 : // Fix the instance_descriptors for the existing maps.
327 56 : FinalizePartialMap(roots.meta_map());
328 56 : FinalizePartialMap(roots.fixed_array_map());
329 56 : FinalizePartialMap(roots.weak_fixed_array_map());
330 56 : FinalizePartialMap(roots.weak_array_list_map());
331 56 : FinalizePartialMap(roots.fixed_cow_array_map());
332 56 : FinalizePartialMap(roots.descriptor_array_map());
333 56 : FinalizePartialMap(roots.undefined_map());
334 56 : roots.undefined_map()->set_is_undetectable(true);
335 56 : FinalizePartialMap(roots.null_map());
336 56 : roots.null_map()->set_is_undetectable(true);
337 56 : FinalizePartialMap(roots.the_hole_map());
338 2464 : for (unsigned i = 0; i < arraysize(struct_table); ++i) {
339 2408 : const StructTable& entry = struct_table[i];
340 7224 : FinalizePartialMap(Map::cast(Object(roots_table()[entry.index])));
341 : }
342 :
343 : { // Map allocation
344 : #define ALLOCATE_MAP(instance_type, size, field_name) \
345 : { \
346 : Map map; \
347 : if (!AllocateMap((instance_type), size).To(&map)) return false; \
348 : set_##field_name##_map(map); \
349 : }
350 :
351 : #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
352 : ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name)
353 :
354 : #define ALLOCATE_PRIMITIVE_MAP(instance_type, size, field_name, \
355 : constructor_function_index) \
356 : { \
357 : ALLOCATE_MAP((instance_type), (size), field_name); \
358 : roots.field_name##_map()->SetConstructorFunctionIndex( \
359 : (constructor_function_index)); \
360 : }
361 :
362 56 : ALLOCATE_VARSIZE_MAP(SCOPE_INFO_TYPE, scope_info)
363 56 : ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, module_info)
364 56 : ALLOCATE_VARSIZE_MAP(FEEDBACK_VECTOR_TYPE, feedback_vector)
365 112 : ALLOCATE_PRIMITIVE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number,
366 : Context::NUMBER_FUNCTION_INDEX)
367 56 : ALLOCATE_MAP(MUTABLE_HEAP_NUMBER_TYPE, MutableHeapNumber::kSize,
368 : mutable_heap_number)
369 112 : ALLOCATE_PRIMITIVE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol,
370 : Context::SYMBOL_FUNCTION_INDEX)
371 56 : ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign)
372 :
373 112 : ALLOCATE_PRIMITIVE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean,
374 : Context::BOOLEAN_FUNCTION_INDEX);
375 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized);
376 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker);
377 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception);
378 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
379 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, optimized_out);
380 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, stale_register);
381 56 : ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, self_reference_marker);
382 56 : ALLOCATE_VARSIZE_MAP(BIGINT_TYPE, bigint);
383 :
384 1288 : for (unsigned i = 0; i < arraysize(string_type_table); i++) {
385 1232 : const StringTypeTable& entry = string_type_table[i];
386 1232 : Map map;
387 1232 : if (!AllocateMap(entry.type, entry.size).To(&map)) return false;
388 1232 : map->SetConstructorFunctionIndex(Context::STRING_FUNCTION_INDEX);
389 : // Mark cons string maps as unstable, because their objects can change
390 : // maps during GC.
391 1232 : if (StringShape(entry.type).IsCons()) map->mark_unstable();
392 2464 : roots_table()[entry.index] = map->ptr();
393 : }
394 :
395 : { // Create a separate external one byte string map for native sources.
396 56 : Map map;
397 : AllocationResult allocation =
398 : AllocateMap(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE,
399 56 : ExternalOneByteString::kUncachedSize);
400 56 : if (!allocation.To(&map)) return false;
401 56 : map->SetConstructorFunctionIndex(Context::STRING_FUNCTION_INDEX);
402 56 : set_native_source_string_map(map);
403 : }
404 :
405 56 : ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array)
406 56 : roots.fixed_double_array_map()->set_elements_kind(HOLEY_DOUBLE_ELEMENTS);
407 56 : ALLOCATE_VARSIZE_MAP(FEEDBACK_METADATA_TYPE, feedback_metadata)
408 56 : ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
409 56 : ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array)
410 56 : ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space)
411 56 : ALLOCATE_VARSIZE_MAP(PROPERTY_ARRAY_TYPE, property_array)
412 56 : ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_HASH_MAP_TYPE, small_ordered_hash_map)
413 56 : ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_HASH_SET_TYPE, small_ordered_hash_set)
414 56 : ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_NAME_DICTIONARY_TYPE,
415 : small_ordered_name_dictionary)
416 :
417 : #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype) \
418 : ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, fixed_##type##_array)
419 :
420 56 : TYPED_ARRAYS(ALLOCATE_FIXED_TYPED_ARRAY_MAP)
421 : #undef ALLOCATE_FIXED_TYPED_ARRAY_MAP
422 :
423 56 : ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements)
424 :
425 56 : ALLOCATE_VARSIZE_MAP(CODE_TYPE, code)
426 :
427 56 : ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell);
428 : {
429 : // The invalid_prototype_validity_cell is needed for JSObject maps.
430 56 : Smi value = Smi::FromInt(Map::kPrototypeChainInvalid);
431 56 : AllocationResult alloc = AllocateRaw(Cell::kSize, OLD_SPACE);
432 56 : if (!alloc.To(&obj)) return false;
433 56 : obj->set_map_after_allocation(roots.cell_map(), SKIP_WRITE_BARRIER);
434 56 : Cell::cast(obj)->set_value(value);
435 56 : set_invalid_prototype_validity_cell(Cell::cast(obj));
436 : }
437 :
438 56 : ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell)
439 56 : ALLOCATE_MAP(FILLER_TYPE, kTaggedSize, one_pointer_filler)
440 56 : ALLOCATE_MAP(FILLER_TYPE, 2 * kTaggedSize, two_pointer_filler)
441 :
442 : // The "no closures" and "one closure" FeedbackCell maps need
443 : // to be marked unstable because their objects can change maps.
444 56 : ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, no_closures_cell)
445 56 : roots.no_closures_cell_map()->mark_unstable();
446 56 : ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, one_closure_cell)
447 56 : roots.one_closure_cell_map()->mark_unstable();
448 56 : ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, many_closures_cell)
449 56 : ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, no_feedback_cell)
450 56 : roots.no_feedback_cell_map()->mark_unstable();
451 :
452 56 : ALLOCATE_VARSIZE_MAP(TRANSITION_ARRAY_TYPE, transition_array)
453 :
454 56 : ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, hash_table)
455 56 : ALLOCATE_VARSIZE_MAP(ORDERED_HASH_MAP_TYPE, ordered_hash_map)
456 56 : ALLOCATE_VARSIZE_MAP(ORDERED_HASH_SET_TYPE, ordered_hash_set)
457 56 : ALLOCATE_VARSIZE_MAP(ORDERED_NAME_DICTIONARY_TYPE, ordered_name_dictionary)
458 56 : ALLOCATE_VARSIZE_MAP(NAME_DICTIONARY_TYPE, name_dictionary)
459 56 : ALLOCATE_VARSIZE_MAP(GLOBAL_DICTIONARY_TYPE, global_dictionary)
460 56 : ALLOCATE_VARSIZE_MAP(NUMBER_DICTIONARY_TYPE, number_dictionary)
461 56 : ALLOCATE_VARSIZE_MAP(SIMPLE_NUMBER_DICTIONARY_TYPE,
462 : simple_number_dictionary)
463 56 : ALLOCATE_VARSIZE_MAP(STRING_TABLE_TYPE, string_table)
464 :
465 56 : ALLOCATE_VARSIZE_MAP(EMBEDDER_DATA_ARRAY_TYPE, embedder_data_array)
466 56 : ALLOCATE_VARSIZE_MAP(EPHEMERON_HASH_TABLE_TYPE, ephemeron_hash_table)
467 :
468 56 : ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, array_list)
469 :
470 56 : ALLOCATE_VARSIZE_MAP(FUNCTION_CONTEXT_TYPE, function_context)
471 56 : ALLOCATE_VARSIZE_MAP(CATCH_CONTEXT_TYPE, catch_context)
472 56 : ALLOCATE_VARSIZE_MAP(WITH_CONTEXT_TYPE, with_context)
473 56 : ALLOCATE_VARSIZE_MAP(DEBUG_EVALUATE_CONTEXT_TYPE, debug_evaluate_context)
474 56 : ALLOCATE_VARSIZE_MAP(AWAIT_CONTEXT_TYPE, await_context)
475 56 : ALLOCATE_VARSIZE_MAP(BLOCK_CONTEXT_TYPE, block_context)
476 56 : ALLOCATE_VARSIZE_MAP(MODULE_CONTEXT_TYPE, module_context)
477 56 : ALLOCATE_VARSIZE_MAP(EVAL_CONTEXT_TYPE, eval_context)
478 56 : ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TYPE, script_context)
479 56 : ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TABLE_TYPE, script_context_table)
480 :
481 56 : ALLOCATE_VARSIZE_MAP(OBJECT_BOILERPLATE_DESCRIPTION_TYPE,
482 : object_boilerplate_description)
483 :
484 56 : ALLOCATE_MAP(NATIVE_CONTEXT_TYPE, NativeContext::kSize, native_context)
485 :
486 56 : ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
487 : side_effect_call_handler_info)
488 56 : ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
489 : side_effect_free_call_handler_info)
490 56 : ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
491 : next_call_side_effect_free_call_handler_info)
492 :
493 56 : ALLOCATE_VARSIZE_MAP(PREPARSE_DATA_TYPE, preparse_data)
494 56 : ALLOCATE_MAP(UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE,
495 : UncompiledDataWithoutPreparseData::kSize,
496 : uncompiled_data_without_preparse_data)
497 56 : ALLOCATE_MAP(UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE,
498 : UncompiledDataWithPreparseData::kSize,
499 : uncompiled_data_with_preparse_data)
500 : #if V8_SFI_HAS_UNIQUE_ID
501 : ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE,
502 : SharedFunctionInfoWithID::kAlignedSize, shared_function_info)
503 : #else
504 56 : ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize,
505 : shared_function_info)
506 : #endif
507 :
508 56 : ALLOCATE_MAP(CODE_DATA_CONTAINER_TYPE, CodeDataContainer::kSize,
509 : code_data_container)
510 :
511 56 : ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell)
512 :
513 56 : ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize, message_object)
514 56 : ALLOCATE_MAP(JS_OBJECT_TYPE,
515 : JSObject::kHeaderSizeForEmbedderFields + kEmbedderDataSlotSize,
516 : external)
517 56 : external_map()->set_is_extensible(false);
518 : #undef ALLOCATE_PRIMITIVE_MAP
519 : #undef ALLOCATE_VARSIZE_MAP
520 : #undef ALLOCATE_MAP
521 : }
522 :
523 : {
524 56 : AllocationResult alloc = AllocateRaw(FixedArray::SizeFor(0), RO_SPACE);
525 56 : if (!alloc.To(&obj)) return false;
526 56 : obj->set_map_after_allocation(roots.scope_info_map(), SKIP_WRITE_BARRIER);
527 56 : FixedArray::cast(obj)->set_length(0);
528 : }
529 56 : set_empty_scope_info(ScopeInfo::cast(obj));
530 :
531 : {
532 : // Empty boilerplate needs a field for literal_flags
533 56 : AllocationResult alloc = AllocateRaw(FixedArray::SizeFor(1), RO_SPACE);
534 56 : if (!alloc.To(&obj)) return false;
535 : obj->set_map_after_allocation(roots.object_boilerplate_description_map(),
536 56 : SKIP_WRITE_BARRIER);
537 :
538 56 : FixedArray::cast(obj)->set_length(1);
539 : FixedArray::cast(obj)->set(ObjectBoilerplateDescription::kLiteralTypeOffset,
540 56 : Smi::kZero);
541 : }
542 : set_empty_object_boilerplate_description(
543 56 : ObjectBoilerplateDescription::cast(obj));
544 :
545 : {
546 : // Empty array boilerplate description
547 : AllocationResult alloc =
548 56 : Allocate(roots.array_boilerplate_description_map(), RO_SPACE);
549 56 : if (!alloc.To(&obj)) return false;
550 :
551 : ArrayBoilerplateDescription::cast(obj)->set_constant_elements(
552 112 : roots.empty_fixed_array());
553 : ArrayBoilerplateDescription::cast(obj)->set_elements_kind(
554 56 : ElementsKind::PACKED_SMI_ELEMENTS);
555 : }
556 : set_empty_array_boilerplate_description(
557 56 : ArrayBoilerplateDescription::cast(obj));
558 :
559 : {
560 56 : AllocationResult allocation = Allocate(roots.boolean_map(), RO_SPACE);
561 56 : if (!allocation.To(&obj)) return false;
562 : }
563 56 : set_true_value(Oddball::cast(obj));
564 56 : Oddball::cast(obj)->set_kind(Oddball::kTrue);
565 :
566 : {
567 56 : AllocationResult allocation = Allocate(roots.boolean_map(), RO_SPACE);
568 56 : if (!allocation.To(&obj)) return false;
569 : }
570 56 : set_false_value(Oddball::cast(obj));
571 56 : Oddball::cast(obj)->set_kind(Oddball::kFalse);
572 :
573 : // Empty arrays.
574 : {
575 56 : if (!AllocateRaw(ByteArray::SizeFor(0), RO_SPACE).To(&obj)) return false;
576 56 : obj->set_map_after_allocation(roots.byte_array_map(), SKIP_WRITE_BARRIER);
577 56 : ByteArray::cast(obj)->set_length(0);
578 56 : set_empty_byte_array(ByteArray::cast(obj));
579 : }
580 :
581 : {
582 56 : if (!AllocateRaw(FixedArray::SizeFor(0), RO_SPACE).To(&obj)) {
583 0 : return false;
584 : }
585 : obj->set_map_after_allocation(roots.property_array_map(),
586 56 : SKIP_WRITE_BARRIER);
587 56 : PropertyArray::cast(obj)->initialize_length(0);
588 56 : set_empty_property_array(PropertyArray::cast(obj));
589 : }
590 :
591 : #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype) \
592 : { \
593 : FixedTypedArrayBase obj; \
594 : if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) { \
595 : return false; \
596 : } \
597 : set_empty_fixed_##type##_array(obj); \
598 : }
599 :
600 56 : TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY)
601 : #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY
602 :
603 : DCHECK(!InYoungGeneration(roots.empty_fixed_array()));
604 :
605 : roots.bigint_map()->SetConstructorFunctionIndex(
606 56 : Context::BIGINT_FUNCTION_INDEX);
607 :
608 56 : return true;
609 : }
610 :
611 56 : void Heap::CreateApiObjects() {
612 56 : Isolate* isolate = this->isolate();
613 56 : HandleScope scope(isolate);
614 :
615 112 : set_message_listeners(*TemplateList::New(isolate, 2));
616 :
617 : Handle<InterceptorInfo> info = Handle<InterceptorInfo>::cast(
618 56 : isolate->factory()->NewStruct(INTERCEPTOR_INFO_TYPE, TENURED_READ_ONLY));
619 56 : info->set_flags(0);
620 56 : set_noop_interceptor_info(*info);
621 56 : }
622 :
623 56 : void Heap::CreateInitialObjects() {
624 56 : HandleScope scope(isolate());
625 56 : Factory* factory = isolate()->factory();
626 : ReadOnlyRoots roots(this);
627 :
628 : // The -0 value must be set before NewNumber works.
629 112 : set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED_READ_ONLY));
630 : DCHECK(std::signbit(roots.minus_zero_value()->Number()));
631 :
632 : set_nan_value(*factory->NewHeapNumber(
633 112 : std::numeric_limits<double>::quiet_NaN(), TENURED_READ_ONLY));
634 : set_hole_nan_value(
635 112 : *factory->NewHeapNumberFromBits(kHoleNanInt64, TENURED_READ_ONLY));
636 112 : set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED_READ_ONLY));
637 : set_minus_infinity_value(
638 112 : *factory->NewHeapNumber(-V8_INFINITY, TENURED_READ_ONLY));
639 :
640 112 : set_hash_seed(*factory->NewByteArray(kInt64Size, TENURED_READ_ONLY));
641 56 : InitializeHashSeed();
642 :
643 : // There's no "current microtask" in the beginning.
644 56 : set_current_microtask(roots.undefined_value());
645 :
646 56 : set_dirty_js_finalization_groups(roots.undefined_value());
647 56 : set_weak_refs_keep_during_job(roots.undefined_value());
648 :
649 : // Allocate cache for single character one byte strings.
650 : set_single_character_string_cache(
651 112 : *factory->NewFixedArray(String::kMaxOneByteCharCode + 1, TENURED));
652 :
653 : // Allocate initial string table.
654 112 : set_string_table(*StringTable::New(isolate(), kInitialStringTableSize));
655 :
656 15848 : for (unsigned i = 0; i < arraysize(constant_string_table); i++) {
657 : Handle<String> str =
658 15792 : factory->InternalizeUtf8String(constant_string_table[i].contents);
659 47376 : roots_table()[constant_string_table[i].index] = str->ptr();
660 : }
661 :
662 : // Allocate
663 :
664 : // Finish initializing oddballs after creating the string table.
665 : Oddball::Initialize(isolate(), factory->undefined_value(), "undefined",
666 112 : factory->nan_value(), "undefined", Oddball::kUndefined);
667 :
668 : // Initialize the null_value.
669 : Oddball::Initialize(isolate(), factory->null_value(), "null",
670 112 : handle(Smi::kZero, isolate()), "object", Oddball::kNull);
671 :
672 : // Initialize the_hole_value.
673 : Oddball::Initialize(isolate(), factory->the_hole_value(), "hole",
674 : factory->hole_nan_value(), "undefined",
675 112 : Oddball::kTheHole);
676 :
677 : // Initialize the true_value.
678 : Oddball::Initialize(isolate(), factory->true_value(), "true",
679 : handle(Smi::FromInt(1), isolate()), "boolean",
680 112 : Oddball::kTrue);
681 :
682 : // Initialize the false_value.
683 : Oddball::Initialize(isolate(), factory->false_value(), "false",
684 : handle(Smi::kZero, isolate()), "boolean",
685 112 : Oddball::kFalse);
686 :
687 : set_uninitialized_value(
688 : *factory->NewOddball(factory->uninitialized_map(), "uninitialized",
689 : handle(Smi::FromInt(-1), isolate()), "undefined",
690 168 : Oddball::kUninitialized));
691 :
692 : set_arguments_marker(
693 : *factory->NewOddball(factory->arguments_marker_map(), "arguments_marker",
694 : handle(Smi::FromInt(-4), isolate()), "undefined",
695 168 : Oddball::kArgumentsMarker));
696 :
697 : set_termination_exception(*factory->NewOddball(
698 : factory->termination_exception_map(), "termination_exception",
699 168 : handle(Smi::FromInt(-3), isolate()), "undefined", Oddball::kOther));
700 :
701 : set_exception(*factory->NewOddball(factory->exception_map(), "exception",
702 : handle(Smi::FromInt(-5), isolate()),
703 168 : "undefined", Oddball::kException));
704 :
705 : set_optimized_out(*factory->NewOddball(factory->optimized_out_map(),
706 : "optimized_out",
707 : handle(Smi::FromInt(-6), isolate()),
708 168 : "undefined", Oddball::kOptimizedOut));
709 :
710 : set_stale_register(
711 : *factory->NewOddball(factory->stale_register_map(), "stale_register",
712 : handle(Smi::FromInt(-7), isolate()), "undefined",
713 168 : Oddball::kStaleRegister));
714 :
715 : // Initialize the self-reference marker.
716 : set_self_reference_marker(
717 112 : *factory->NewSelfReferenceMarker(TENURED_READ_ONLY));
718 :
719 56 : set_interpreter_entry_trampoline_for_profiling(roots.undefined_value());
720 :
721 : {
722 56 : HandleScope scope(isolate());
723 : #define SYMBOL_INIT(_, name) \
724 : { \
725 : Handle<Symbol> symbol( \
726 : isolate()->factory()->NewPrivateSymbol(TENURED_READ_ONLY)); \
727 : roots_table()[RootIndex::k##name] = symbol->ptr(); \
728 : }
729 3304 : PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
730 : #undef SYMBOL_INIT
731 : }
732 :
733 : {
734 56 : HandleScope scope(isolate());
735 : #define SYMBOL_INIT(_, name, description) \
736 : Handle<Symbol> name = factory->NewSymbol(TENURED_READ_ONLY); \
737 : Handle<String> name##d = factory->InternalizeUtf8String(#description); \
738 : name->set_name(*name##d); \
739 : roots_table()[RootIndex::k##name] = name->ptr();
740 2520 : PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
741 : #undef SYMBOL_INIT
742 :
743 : #define SYMBOL_INIT(_, name, description) \
744 : Handle<Symbol> name = factory->NewSymbol(TENURED_READ_ONLY); \
745 : Handle<String> name##d = factory->InternalizeUtf8String(#description); \
746 : name->set_is_well_known_symbol(true); \
747 : name->set_name(*name##d); \
748 : roots_table()[RootIndex::k##name] = name->ptr();
749 896 : WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
750 : #undef SYMBOL_INIT
751 :
752 : // Mark "Interesting Symbols" appropriately.
753 56 : to_string_tag_symbol->set_is_interesting_symbol(true);
754 : }
755 :
756 : Handle<NameDictionary> empty_property_dictionary = NameDictionary::New(
757 56 : isolate(), 1, TENURED_READ_ONLY, USE_CUSTOM_MINIMUM_CAPACITY);
758 : DCHECK(!empty_property_dictionary->HasSufficientCapacityToAdd(1));
759 56 : set_empty_property_dictionary(*empty_property_dictionary);
760 :
761 56 : set_public_symbol_table(*empty_property_dictionary);
762 56 : set_api_symbol_table(*empty_property_dictionary);
763 56 : set_api_private_symbol_table(*empty_property_dictionary);
764 :
765 : set_number_string_cache(
766 112 : *factory->NewFixedArray(kInitialNumberStringCacheSize * 2, TENURED));
767 :
768 : // Allocate cache for string split and regexp-multiple.
769 : set_string_split_cache(*factory->NewFixedArray(
770 112 : RegExpResultsCache::kRegExpResultsCacheSize, TENURED));
771 : set_regexp_multiple_cache(*factory->NewFixedArray(
772 112 : RegExpResultsCache::kRegExpResultsCacheSize, TENURED));
773 :
774 : // Allocate FeedbackCell for builtins.
775 : Handle<FeedbackCell> many_closures_cell =
776 112 : factory->NewManyClosuresCell(factory->undefined_value());
777 56 : set_many_closures_cell(*many_closures_cell);
778 :
779 : // Allocate FeedbackCell for cases where we don't collect feedback.
780 56 : Handle<FeedbackCell> no_feedback_cell = factory->NewNoFeedbackCell();
781 56 : set_no_feedback_cell(*no_feedback_cell);
782 :
783 : {
784 : Handle<FixedArray> empty_sloppy_arguments_elements =
785 56 : factory->NewFixedArray(2, TENURED_READ_ONLY);
786 112 : empty_sloppy_arguments_elements->set_map_after_allocation(
787 56 : roots.sloppy_arguments_elements_map(), SKIP_WRITE_BARRIER);
788 56 : set_empty_sloppy_arguments_elements(*empty_sloppy_arguments_elements);
789 : }
790 :
791 56 : set_detached_contexts(roots.empty_weak_array_list());
792 56 : set_retained_maps(roots.empty_weak_array_list());
793 56 : set_retaining_path_targets(roots.empty_weak_array_list());
794 :
795 56 : set_feedback_vectors_for_profiling_tools(roots.undefined_value());
796 :
797 56 : set_script_list(roots.empty_weak_array_list());
798 :
799 : Handle<NumberDictionary> slow_element_dictionary = NumberDictionary::New(
800 56 : isolate(), 1, TENURED_READ_ONLY, USE_CUSTOM_MINIMUM_CAPACITY);
801 : DCHECK(!slow_element_dictionary->HasSufficientCapacityToAdd(1));
802 56 : slow_element_dictionary->set_requires_slow_elements();
803 56 : set_empty_slow_element_dictionary(*slow_element_dictionary);
804 :
805 112 : set_materialized_objects(*factory->NewFixedArray(0, TENURED));
806 :
807 : // Handling of script id generation is in Heap::NextScriptId().
808 56 : set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
809 56 : set_last_debugging_id(Smi::FromInt(DebugInfo::kNoDebuggingId));
810 56 : set_next_template_serial_number(Smi::zero());
811 :
812 : // Allocate the empty OrderedHashMap.
813 : Handle<FixedArray> empty_ordered_hash_map = factory->NewFixedArray(
814 56 : OrderedHashMap::HashTableStartIndex(), TENURED_READ_ONLY);
815 112 : empty_ordered_hash_map->set_map_no_write_barrier(
816 168 : *factory->ordered_hash_map_map());
817 448 : for (int i = 0; i < empty_ordered_hash_map->length(); ++i) {
818 168 : empty_ordered_hash_map->set(i, Smi::kZero);
819 : }
820 56 : set_empty_ordered_hash_map(*empty_ordered_hash_map);
821 :
822 : // Allocate the empty OrderedHashSet.
823 : Handle<FixedArray> empty_ordered_hash_set = factory->NewFixedArray(
824 56 : OrderedHashSet::HashTableStartIndex(), TENURED_READ_ONLY);
825 112 : empty_ordered_hash_set->set_map_no_write_barrier(
826 168 : *factory->ordered_hash_set_map());
827 448 : for (int i = 0; i < empty_ordered_hash_set->length(); ++i) {
828 168 : empty_ordered_hash_set->set(i, Smi::kZero);
829 : }
830 56 : set_empty_ordered_hash_set(*empty_ordered_hash_set);
831 :
832 : // Allocate the empty FeedbackMetadata.
833 : Handle<FeedbackMetadata> empty_feedback_metadata =
834 56 : factory->NewFeedbackMetadata(0, TENURED_READ_ONLY);
835 56 : set_empty_feedback_metadata(*empty_feedback_metadata);
836 :
837 : // Allocate the empty script.
838 56 : Handle<Script> script = factory->NewScript(factory->empty_string());
839 56 : script->set_type(Script::TYPE_NATIVE);
840 : // This is used for exceptions thrown with no stack frames. Such exceptions
841 : // can be shared everywhere.
842 56 : script->set_origin_options(ScriptOriginOptions(true, false));
843 56 : set_empty_script(*script);
844 :
845 : Handle<Cell> array_constructor_cell = factory->NewCell(
846 112 : handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
847 56 : set_array_constructor_protector(*array_constructor_cell);
848 :
849 112 : Handle<PropertyCell> cell = factory->NewPropertyCell(factory->empty_string());
850 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
851 56 : set_no_elements_protector(*cell);
852 :
853 112 : cell = factory->NewPropertyCell(factory->empty_string(), TENURED_READ_ONLY);
854 112 : cell->set_value(roots.the_hole_value());
855 56 : set_empty_property_cell(*cell);
856 :
857 112 : cell = factory->NewPropertyCell(factory->empty_string());
858 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
859 56 : set_array_iterator_protector(*cell);
860 :
861 112 : cell = factory->NewPropertyCell(factory->empty_string());
862 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
863 56 : set_map_iterator_protector(*cell);
864 :
865 112 : cell = factory->NewPropertyCell(factory->empty_string());
866 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
867 56 : set_set_iterator_protector(*cell);
868 :
869 : Handle<Cell> is_concat_spreadable_cell = factory->NewCell(
870 112 : handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
871 56 : set_is_concat_spreadable_protector(*is_concat_spreadable_cell);
872 :
873 112 : cell = factory->NewPropertyCell(factory->empty_string());
874 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
875 56 : set_array_species_protector(*cell);
876 :
877 112 : cell = factory->NewPropertyCell(factory->empty_string());
878 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
879 56 : set_typed_array_species_protector(*cell);
880 :
881 112 : cell = factory->NewPropertyCell(factory->empty_string());
882 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
883 56 : set_promise_species_protector(*cell);
884 :
885 112 : cell = factory->NewPropertyCell(factory->empty_string());
886 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
887 56 : set_regexp_species_protector(*cell);
888 :
889 112 : cell = factory->NewPropertyCell(factory->empty_string());
890 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
891 56 : set_string_iterator_protector(*cell);
892 :
893 : Handle<Cell> string_length_overflow_cell = factory->NewCell(
894 112 : handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
895 56 : set_string_length_protector(*string_length_overflow_cell);
896 :
897 112 : cell = factory->NewPropertyCell(factory->empty_string());
898 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
899 56 : set_array_buffer_detaching_protector(*cell);
900 :
901 112 : cell = factory->NewPropertyCell(factory->empty_string());
902 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
903 56 : set_promise_hook_protector(*cell);
904 :
905 : Handle<Cell> promise_resolve_cell = factory->NewCell(
906 112 : handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
907 56 : set_promise_resolve_protector(*promise_resolve_cell);
908 :
909 112 : cell = factory->NewPropertyCell(factory->empty_string());
910 112 : cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
911 56 : set_promise_then_protector(*cell);
912 :
913 56 : set_serialized_objects(roots.empty_fixed_array());
914 56 : set_serialized_global_proxy_sizes(roots.empty_fixed_array());
915 :
916 56 : set_noscript_shared_function_infos(roots.empty_weak_array_list());
917 :
918 : set_off_heap_trampoline_relocation_info(
919 112 : *Builtins::GenerateOffHeapTrampolineRelocInfo(isolate_));
920 :
921 : // Evaluate the hash values which will then be cached in the strings.
922 112 : isolate()->factory()->zero_string()->Hash();
923 112 : isolate()->factory()->one_string()->Hash();
924 :
925 : // Initialize builtins constants table.
926 56 : set_builtins_constants_table(roots.empty_fixed_array());
927 :
928 : // Initialize descriptor cache.
929 56 : isolate_->descriptor_lookup_cache()->Clear();
930 :
931 : // Initialize compilation cache.
932 56 : isolate_->compilation_cache()->Clear();
933 56 : }
934 :
935 56 : void Heap::CreateInternalAccessorInfoObjects() {
936 56 : Isolate* isolate = this->isolate();
937 56 : HandleScope scope(isolate);
938 : Handle<AccessorInfo> accessor_info;
939 :
940 : #define INIT_ACCESSOR_INFO(_, accessor_name, AccessorName, ...) \
941 : accessor_info = Accessors::Make##AccessorName##Info(isolate); \
942 : roots_table()[RootIndex::k##AccessorName##Accessor] = accessor_info->ptr();
943 1288 : ACCESSOR_INFO_LIST_GENERATOR(INIT_ACCESSOR_INFO, /* not used */)
944 : #undef INIT_ACCESSOR_INFO
945 :
946 : #define INIT_SIDE_EFFECT_FLAG(_, accessor_name, AccessorName, GetterType, \
947 : SetterType) \
948 : AccessorInfo::cast( \
949 : Object(roots_table()[RootIndex::k##AccessorName##Accessor])) \
950 : ->set_getter_side_effect_type(SideEffectType::GetterType); \
951 : AccessorInfo::cast( \
952 : Object(roots_table()[RootIndex::k##AccessorName##Accessor])) \
953 : ->set_setter_side_effect_type(SideEffectType::SetterType);
954 2464 : ACCESSOR_INFO_LIST_GENERATOR(INIT_SIDE_EFFECT_FLAG, /* not used */)
955 : #undef INIT_SIDE_EFFECT_FLAG
956 56 : }
957 :
958 : } // namespace internal
959 86739 : } // namespace v8
|