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