Line data Source code
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
3 : // found in the LICENSE file.
4 : //
5 : // Review notes:
6 : //
7 : // - The use of macros in these inline functions may seem superfluous
8 : // but it is absolutely needed to make sure gcc generates optimal
9 : // code. gcc is not happy when attempting to inline too deep.
10 : //
11 :
12 : #ifndef V8_OBJECTS_INL_H_
13 : #define V8_OBJECTS_INL_H_
14 :
15 : #include "src/base/atomicops.h"
16 : #include "src/base/bits.h"
17 : #include "src/builtins/builtins.h"
18 : #include "src/contexts-inl.h"
19 : #include "src/conversions-inl.h"
20 : #include "src/factory.h"
21 : #include "src/feedback-vector-inl.h"
22 : #include "src/field-index-inl.h"
23 : #include "src/field-type.h"
24 : #include "src/handles-inl.h"
25 : #include "src/heap/heap-inl.h"
26 : #include "src/heap/heap.h"
27 : #include "src/isolate-inl.h"
28 : #include "src/isolate.h"
29 : #include "src/keys.h"
30 : #include "src/layout-descriptor-inl.h"
31 : #include "src/lookup-cache-inl.h"
32 : #include "src/lookup.h"
33 : #include "src/objects.h"
34 : #include "src/objects/literal-objects.h"
35 : #include "src/objects/module-info.h"
36 : #include "src/objects/regexp-match-info.h"
37 : #include "src/objects/scope-info.h"
38 : #include "src/property.h"
39 : #include "src/prototype.h"
40 : #include "src/transitions-inl.h"
41 : #include "src/v8memory.h"
42 :
43 : // Has to be the last include (doesn't have include guards):
44 : #include "src/objects/object-macros.h"
45 :
46 : namespace v8 {
47 : namespace internal {
48 :
49 0 : PropertyDetails::PropertyDetails(Smi* smi) {
50 3155947257 : value_ = smi->value();
51 0 : }
52 :
53 :
54 5376023 : Smi* PropertyDetails::AsSmi() const {
55 : // Ensure the upper 2 bits have the same value by sign extending it. This is
56 : // necessary to be able to use the 31st bit of the property details.
57 479332596 : int value = value_ << 1;
58 484708619 : return Smi::FromInt(value >> 1);
59 : }
60 :
61 :
62 24292 : int PropertyDetails::field_width_in_words() const {
63 : DCHECK(location() == kField);
64 : if (!FLAG_unbox_double_fields) return 1;
65 : if (kDoubleSize == kPointerSize) return 1;
66 : return representation().IsDouble() ? kDoubleSize / kPointerSize : 1;
67 : }
68 :
69 : #define INT_ACCESSORS(holder, name, offset) \
70 : int holder::name() const { return READ_INT_FIELD(this, offset); } \
71 : void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); }
72 :
73 : #define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
74 : set_condition) \
75 : type* holder::name() const { \
76 : DCHECK(get_condition); \
77 : return type::cast(READ_FIELD(this, offset)); \
78 : } \
79 : void holder::set_##name(type* value, WriteBarrierMode mode) { \
80 : DCHECK(set_condition); \
81 : WRITE_FIELD(this, offset, value); \
82 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
83 : }
84 : #define ACCESSORS_CHECKED(holder, name, type, offset, condition) \
85 : ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition)
86 :
87 : #define ACCESSORS(holder, name, type, offset) \
88 : ACCESSORS_CHECKED(holder, name, type, offset, true)
89 :
90 : // Getter that returns a Smi as an int and writes an int as a Smi.
91 : #define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
92 : int holder::name() const { \
93 : DCHECK(condition); \
94 : Object* value = READ_FIELD(this, offset); \
95 : return Smi::cast(value)->value(); \
96 : } \
97 : void holder::set_##name(int value) { \
98 : DCHECK(condition); \
99 : WRITE_FIELD(this, offset, Smi::FromInt(value)); \
100 : }
101 :
102 : #define SMI_ACCESSORS(holder, name, offset) \
103 : SMI_ACCESSORS_CHECKED(holder, name, offset, true)
104 :
105 : #define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \
106 : int holder::synchronized_##name() const { \
107 : Object* value = ACQUIRE_READ_FIELD(this, offset); \
108 : return Smi::cast(value)->value(); \
109 : } \
110 : void holder::synchronized_set_##name(int value) { \
111 : RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \
112 : }
113 :
114 : #define NOBARRIER_SMI_ACCESSORS(holder, name, offset) \
115 : int holder::nobarrier_##name() const { \
116 : Object* value = NOBARRIER_READ_FIELD(this, offset); \
117 : return Smi::cast(value)->value(); \
118 : } \
119 : void holder::nobarrier_set_##name(int value) { \
120 : NOBARRIER_WRITE_FIELD(this, offset, Smi::FromInt(value)); \
121 : }
122 :
123 : #define BOOL_GETTER(holder, field, name, offset) \
124 : bool holder::name() const { \
125 : return BooleanBit::get(field(), offset); \
126 : } \
127 :
128 :
129 : #define BOOL_ACCESSORS(holder, field, name, offset) \
130 : bool holder::name() const { \
131 : return BooleanBit::get(field(), offset); \
132 : } \
133 : void holder::set_##name(bool value) { \
134 : set_##field(BooleanBit::set(field(), offset, value)); \
135 : }
136 :
137 : #define TYPE_CHECKER(type, instancetype) \
138 : bool HeapObject::Is##type() const { \
139 : return map()->instance_type() == instancetype; \
140 : }
141 :
142 2010 : TYPE_CHECKER(BreakPointInfo, TUPLE2_TYPE)
143 36808999 : TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE)
144 54655371 : TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE)
145 256140 : TYPE_CHECKER(CallHandlerInfo, TUPLE2_TYPE)
146 17643174 : TYPE_CHECKER(Cell, CELL_TYPE)
147 1492753715 : TYPE_CHECKER(Code, CODE_TYPE)
148 1925922 : TYPE_CHECKER(ConstantElementsPair, TUPLE2_TYPE)
149 2089235 : TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
150 54140 : TYPE_CHECKER(Foreign, FOREIGN_TYPE)
151 303534 : TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
152 399290019 : TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
153 414785 : TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE)
154 381637936 : TYPE_CHECKER(JSArray, JS_ARRAY_TYPE)
155 3783273 : TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE)
156 26853956 : TYPE_CHECKER(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT_TYPE)
157 7243491 : TYPE_CHECKER(JSBoundFunction, JS_BOUND_FUNCTION_TYPE)
158 5805651 : TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
159 205269 : TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE)
160 1361614 : TYPE_CHECKER(JSDate, JS_DATE_TYPE)
161 10171091 : TYPE_CHECKER(JSError, JS_ERROR_TYPE)
162 498931743 : TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE)
163 357894061 : TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE)
164 1851229 : TYPE_CHECKER(JSMap, JS_MAP_TYPE)
165 10392549 : TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE)
166 : TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
167 : TYPE_CHECKER(JSModuleNamespace, JS_MODULE_NAMESPACE_TYPE)
168 : TYPE_CHECKER(JSPromiseCapability, JS_PROMISE_CAPABILITY_TYPE)
169 10633626 : TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
170 17749199 : TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE)
171 1734562 : TYPE_CHECKER(JSSet, JS_SET_TYPE)
172 10395224 : TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE)
173 : TYPE_CHECKER(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR_TYPE)
174 : TYPE_CHECKER(JSStringIterator, JS_STRING_ITERATOR_TYPE)
175 567626685 : TYPE_CHECKER(JSTypedArray, JS_TYPED_ARRAY_TYPE)
176 6678541 : TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
177 736901 : TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
178 667923 : TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
179 774990240 : TYPE_CHECKER(Map, MAP_TYPE)
180 201320 : TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
181 100664959 : TYPE_CHECKER(Oddball, ODDBALL_TYPE)
182 13653924 : TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
183 84441701 : TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
184 56561 : TYPE_CHECKER(SourcePositionTableWithFrameCache, TUPLE2_TYPE)
185 495119109 : TYPE_CHECKER(Symbol, SYMBOL_TYPE)
186 30787465 : TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
187 925741 : TYPE_CHECKER(TypeFeedbackInfo, TUPLE3_TYPE)
188 182965056 : TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
189 13697892 : TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE)
190 :
191 : #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \
192 : TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
193 : TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
194 : #undef TYPED_ARRAY_TYPE_CHECKER
195 :
196 : #undef TYPE_CHECKER
197 :
198 : bool HeapObject::IsFixedArrayBase() const {
199 : return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
200 : }
201 :
202 : bool HeapObject::IsFixedArray() const {
203 105566131 : InstanceType instance_type = map()->instance_type();
204 87126646 : return instance_type == FIXED_ARRAY_TYPE ||
205 9260 : instance_type == TRANSITION_ARRAY_TYPE;
206 : }
207 :
208 : bool HeapObject::IsSloppyArgumentsElements() const { return IsFixedArray(); }
209 :
210 : bool HeapObject::IsJSSloppyArgumentsObject() const {
211 : return IsJSArgumentsObject();
212 : }
213 :
214 : bool HeapObject::IsJSGeneratorObject() const {
215 53935050 : return map()->instance_type() == JS_GENERATOR_OBJECT_TYPE ||
216 : IsJSAsyncGeneratorObject();
217 : }
218 :
219 : bool HeapObject::IsBoilerplateDescription() const { return IsFixedArray(); }
220 :
221 : // External objects are not extensible, so the map check is enough.
222 : bool HeapObject::IsExternal() const {
223 6 : return map() == GetHeap()->external_map();
224 : }
225 :
226 : #define IS_TYPE_FUNCTION_DEF(type_) \
227 : bool Object::Is##type_() const { \
228 : return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
229 : }
230 8745258574 : HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
231 : #undef IS_TYPE_FUNCTION_DEF
232 :
233 : #define IS_TYPE_FUNCTION_DEF(Type, Value) \
234 : bool Object::Is##Type(Isolate* isolate) const { \
235 : return this == isolate->heap()->Value(); \
236 : } \
237 : bool HeapObject::Is##Type(Isolate* isolate) const { \
238 : return this == isolate->heap()->Value(); \
239 : }
240 2388900449 : ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
241 : #undef IS_TYPE_FUNCTION_DEF
242 :
243 : bool Object::IsNullOrUndefined(Isolate* isolate) const {
244 146369441 : Heap* heap = isolate->heap();
245 146383789 : return this == heap->null_value() || this == heap->undefined_value();
246 : }
247 :
248 : bool HeapObject::IsNullOrUndefined(Isolate* isolate) const {
249 : Heap* heap = isolate->heap();
250 : return this == heap->null_value() || this == heap->undefined_value();
251 : }
252 :
253 : bool HeapObject::IsString() const {
254 1854387899 : return map()->instance_type() < FIRST_NONSTRING_TYPE;
255 : }
256 :
257 : bool HeapObject::IsName() const {
258 221732305 : return map()->instance_type() <= LAST_NAME_TYPE;
259 : }
260 :
261 : bool HeapObject::IsUniqueName() const {
262 3686694 : return IsInternalizedString() || IsSymbol();
263 : }
264 :
265 317969 : bool Name::IsUniqueName() const {
266 : uint32_t type = map()->instance_type();
267 391052587 : return (type & (kIsNotStringMask | kIsNotInternalizedMask)) !=
268 317969 : (kStringTag | kNotInternalizedTag);
269 : }
270 :
271 : bool HeapObject::IsFunction() const {
272 : STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
273 66778071 : return map()->instance_type() >= FIRST_FUNCTION_TYPE;
274 : }
275 :
276 26152841 : bool HeapObject::IsCallable() const { return map()->is_callable(); }
277 :
278 167294 : bool HeapObject::IsConstructor() const { return map()->is_constructor(); }
279 :
280 : bool HeapObject::IsTemplateInfo() const {
281 1108362 : return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
282 : }
283 :
284 : bool HeapObject::IsInternalizedString() const {
285 276708392 : uint32_t type = map()->instance_type();
286 : STATIC_ASSERT(kNotInternalizedTag != 0);
287 276708391 : return (type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
288 956 : (kStringTag | kInternalizedTag);
289 : }
290 :
291 : bool HeapObject::IsConsString() const {
292 120232343 : if (!IsString()) return false;
293 119963302 : return StringShape(String::cast(this)).IsCons();
294 : }
295 :
296 : bool HeapObject::IsThinString() const {
297 318912019 : if (!IsString()) return false;
298 318912020 : return StringShape(String::cast(this)).IsThin();
299 : }
300 :
301 : bool HeapObject::IsSlicedString() const {
302 18415929 : if (!IsString()) return false;
303 18415929 : return StringShape(String::cast(this)).IsSliced();
304 : }
305 :
306 : bool HeapObject::IsSeqString() const {
307 301 : if (!IsString()) return false;
308 301 : return StringShape(String::cast(this)).IsSequential();
309 : }
310 :
311 : bool HeapObject::IsSeqOneByteString() const {
312 121848066 : if (!IsString()) return false;
313 235318159 : return StringShape(String::cast(this)).IsSequential() &&
314 113470095 : String::cast(this)->IsOneByteRepresentation();
315 : }
316 :
317 : bool HeapObject::IsSeqTwoByteString() const {
318 110317 : if (!IsString()) return false;
319 220449 : return StringShape(String::cast(this)).IsSequential() &&
320 110132 : String::cast(this)->IsTwoByteRepresentation();
321 : }
322 :
323 : bool HeapObject::IsExternalString() const {
324 26036428 : if (!IsString()) return false;
325 24593956 : return StringShape(String::cast(this)).IsExternal();
326 : }
327 :
328 : bool HeapObject::IsExternalOneByteString() const {
329 563474787 : if (!IsString()) return false;
330 84704563 : return StringShape(String::cast(this)).IsExternal() &&
331 1435381 : String::cast(this)->IsOneByteRepresentation();
332 : }
333 :
334 : bool HeapObject::IsExternalTwoByteString() const {
335 5267563 : if (!IsString()) return false;
336 5267657 : return StringShape(String::cast(this)).IsExternal() &&
337 95 : String::cast(this)->IsTwoByteRepresentation();
338 : }
339 :
340 509871775 : bool Object::IsNumber() const { return IsSmi() || IsHeapNumber(); }
341 :
342 : bool HeapObject::IsFiller() const {
343 545617233 : InstanceType instance_type = map()->instance_type();
344 545617233 : return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
345 : }
346 :
347 : bool HeapObject::IsFixedTypedArrayBase() const {
348 18131340 : InstanceType instance_type = map()->instance_type();
349 18131342 : return (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
350 : instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE);
351 : }
352 :
353 : bool HeapObject::IsJSReceiver() const {
354 : STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
355 393912414 : return map()->instance_type() >= FIRST_JS_RECEIVER_TYPE;
356 : }
357 :
358 : bool HeapObject::IsJSObject() const {
359 : STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
360 413327166 : return map()->IsJSObjectMap();
361 : }
362 :
363 108997282 : bool HeapObject::IsJSProxy() const { return map()->IsJSProxyMap(); }
364 :
365 : bool HeapObject::IsJSArrayIterator() const {
366 : InstanceType instance_type = map()->instance_type();
367 : return (instance_type >= FIRST_ARRAY_ITERATOR_TYPE &&
368 : instance_type <= LAST_ARRAY_ITERATOR_TYPE);
369 : }
370 :
371 : bool HeapObject::IsJSWeakCollection() const {
372 411218 : return IsJSWeakMap() || IsJSWeakSet();
373 : }
374 :
375 0 : bool HeapObject::IsJSCollection() const { return IsJSMap() || IsJSSet(); }
376 :
377 : bool HeapObject::IsDescriptorArray() const { return IsFixedArray(); }
378 :
379 : bool HeapObject::IsFrameArray() const { return IsFixedArray(); }
380 :
381 : bool HeapObject::IsArrayList() const { return IsFixedArray(); }
382 :
383 : bool HeapObject::IsRegExpMatchInfo() const { return IsFixedArray(); }
384 :
385 : bool Object::IsLayoutDescriptor() const {
386 : return IsSmi() || IsFixedTypedArrayBase();
387 : }
388 :
389 : bool HeapObject::IsFeedbackVector() const {
390 17731163 : return map() == GetHeap()->feedback_vector_map();
391 : }
392 :
393 : bool HeapObject::IsFeedbackMetadata() const { return IsFixedArray(); }
394 :
395 : bool HeapObject::IsDeoptimizationInputData() const {
396 : // Must be a fixed array.
397 : if (!IsFixedArray()) return false;
398 :
399 : // There's no sure way to detect the difference between a fixed array and
400 : // a deoptimization data array. Since this is used for asserts we can
401 : // check that the length is zero or else the fixed size plus a multiple of
402 : // the entry size.
403 : int length = FixedArray::cast(this)->length();
404 : if (length == 0) return true;
405 :
406 : length -= DeoptimizationInputData::kFirstDeoptEntryIndex;
407 : return length >= 0 && length % DeoptimizationInputData::kDeoptEntrySize == 0;
408 : }
409 :
410 : bool HeapObject::IsDeoptimizationOutputData() const {
411 : if (!IsFixedArray()) return false;
412 : // There's actually no way to see the difference between a fixed array and
413 : // a deoptimization data array. Since this is used for asserts we can check
414 : // that the length is plausible though.
415 : if (FixedArray::cast(this)->length() % 2 != 0) return false;
416 : return true;
417 : }
418 :
419 : bool HeapObject::IsHandlerTable() const {
420 : if (!IsFixedArray()) return false;
421 : // There's actually no way to see the difference between a fixed array and
422 : // a handler table array.
423 : return true;
424 : }
425 :
426 : bool HeapObject::IsTemplateList() const {
427 : if (!IsFixedArray()) return false;
428 : // There's actually no way to see the difference between a fixed array and
429 : // a template list.
430 : if (FixedArray::cast(this)->length() < 1) return false;
431 : return true;
432 : }
433 :
434 : bool HeapObject::IsDependentCode() const {
435 1050332 : if (!IsFixedArray()) return false;
436 : // There's actually no way to see the difference between a fixed array and
437 : // a dependent codes array.
438 : return true;
439 : }
440 :
441 : bool HeapObject::IsContext() const {
442 47818623 : Map* map = this->map();
443 47818624 : Heap* heap = GetHeap();
444 : return (
445 117837909 : map == heap->function_context_map() || map == heap->catch_context_map() ||
446 81784430 : map == heap->with_context_map() || map == heap->native_context_map() ||
447 35036482 : map == heap->block_context_map() || map == heap->module_context_map() ||
448 82238931 : map == heap->eval_context_map() || map == heap->script_context_map() ||
449 11194752 : map == heap->debug_evaluate_context_map());
450 : }
451 :
452 : bool HeapObject::IsNativeContext() const {
453 3134528 : return map() == GetHeap()->native_context_map();
454 : }
455 :
456 : bool HeapObject::IsScriptContextTable() const {
457 : return map() == GetHeap()->script_context_table_map();
458 : }
459 :
460 : bool HeapObject::IsScopeInfo() const {
461 2151237 : return map() == GetHeap()->scope_info_map();
462 : }
463 :
464 : bool HeapObject::IsModuleInfo() const {
465 7405 : return map() == GetHeap()->module_info_map();
466 : }
467 :
468 : template <>
469 : inline bool Is<JSFunction>(Object* obj) {
470 : return obj->IsJSFunction();
471 : }
472 :
473 : bool HeapObject::IsAbstractCode() const {
474 88243955 : return IsBytecodeArray() || IsCode();
475 : }
476 :
477 : bool HeapObject::IsStringWrapper() const {
478 4672952 : return IsJSValue() && JSValue::cast(this)->value()->IsString();
479 : }
480 :
481 : bool HeapObject::IsBoolean() const {
482 73691882 : return IsOddball() &&
483 17935570 : ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
484 : }
485 :
486 : bool HeapObject::IsJSArrayBufferView() const {
487 364934 : return IsJSDataView() || IsJSTypedArray();
488 : }
489 :
490 : template <>
491 : inline bool Is<JSArray>(Object* obj) {
492 : return obj->IsJSArray();
493 : }
494 :
495 : bool HeapObject::IsHashTable() const {
496 300700319 : return map() == GetHeap()->hash_table_map();
497 : }
498 :
499 : bool HeapObject::IsWeakHashTable() const { return IsHashTable(); }
500 :
501 : bool HeapObject::IsDictionary() const {
502 300631147 : return IsHashTable() && this != GetHeap()->string_table();
503 : }
504 :
505 : bool Object::IsNameDictionary() const { return IsDictionary(); }
506 :
507 : bool Object::IsGlobalDictionary() const { return IsDictionary(); }
508 :
509 : bool Object::IsSeededNumberDictionary() const { return IsDictionary(); }
510 :
511 : bool HeapObject::IsUnseededNumberDictionary() const {
512 41117 : return map() == GetHeap()->unseeded_number_dictionary_map();
513 : }
514 :
515 : bool HeapObject::IsStringTable() const { return IsHashTable(); }
516 :
517 : bool HeapObject::IsStringSet() const { return IsHashTable(); }
518 :
519 : bool HeapObject::IsObjectHashSet() const { return IsHashTable(); }
520 :
521 : bool HeapObject::IsNormalizedMapCache() const {
522 : return NormalizedMapCache::IsNormalizedMapCache(this);
523 : }
524 :
525 : int NormalizedMapCache::GetIndex(Handle<Map> map) {
526 1413271 : return map->Hash() % NormalizedMapCache::kEntries;
527 : }
528 :
529 : bool NormalizedMapCache::IsNormalizedMapCache(const HeapObject* obj) {
530 : if (!obj->IsFixedArray()) return false;
531 : if (FixedArray::cast(obj)->length() != NormalizedMapCache::kEntries) {
532 : return false;
533 : }
534 : #ifdef VERIFY_HEAP
535 : if (FLAG_verify_heap) {
536 : reinterpret_cast<NormalizedMapCache*>(const_cast<HeapObject*>(obj))
537 : ->NormalizedMapCacheVerify();
538 : }
539 : #endif
540 : return true;
541 : }
542 :
543 : bool HeapObject::IsCompilationCacheTable() const { return IsHashTable(); }
544 :
545 : bool HeapObject::IsCodeCacheHashTable() const { return IsHashTable(); }
546 :
547 : bool HeapObject::IsMapCache() const { return IsHashTable(); }
548 :
549 : bool HeapObject::IsObjectHashTable() const { return IsHashTable(); }
550 :
551 : bool HeapObject::IsOrderedHashTable() const {
552 : return map() == GetHeap()->ordered_hash_table_map();
553 : }
554 :
555 : bool Object::IsOrderedHashSet() const { return IsOrderedHashTable(); }
556 :
557 : bool Object::IsOrderedHashMap() const { return IsOrderedHashTable(); }
558 :
559 : bool Object::IsPrimitive() const {
560 15483296 : return IsSmi() || HeapObject::cast(this)->map()->IsPrimitiveMap();
561 : }
562 :
563 : bool HeapObject::IsJSGlobalProxy() const {
564 259758238 : bool result = map()->instance_type() == JS_GLOBAL_PROXY_TYPE;
565 : DCHECK(!result || map()->is_access_check_needed());
566 : return result;
567 : }
568 :
569 4720176 : bool HeapObject::IsUndetectable() const { return map()->is_undetectable(); }
570 :
571 : bool HeapObject::IsAccessCheckNeeded() const {
572 65796405 : if (IsJSGlobalProxy()) {
573 : const JSGlobalProxy* proxy = JSGlobalProxy::cast(this);
574 130716 : JSGlobalObject* global = proxy->GetIsolate()->context()->global_object();
575 130716 : return proxy->IsDetachedFrom(global);
576 : }
577 65665689 : return map()->is_access_check_needed();
578 : }
579 :
580 : bool HeapObject::IsStruct() const {
581 : switch (map()->instance_type()) {
582 : #define MAKE_STRUCT_CASE(NAME, Name, name) \
583 : case NAME##_TYPE: \
584 : return true;
585 : STRUCT_LIST(MAKE_STRUCT_CASE)
586 : #undef MAKE_STRUCT_CASE
587 : default:
588 : return false;
589 : }
590 : }
591 :
592 : #define MAKE_STRUCT_PREDICATE(NAME, Name, name) \
593 : bool Object::Is##Name() const { \
594 : return IsHeapObject() && HeapObject::cast(this)->Is##Name(); \
595 : } \
596 : bool HeapObject::Is##Name() const { \
597 : return map()->instance_type() == NAME##_TYPE; \
598 : }
599 1521245107 : STRUCT_LIST(MAKE_STRUCT_PREDICATE)
600 : #undef MAKE_STRUCT_PREDICATE
601 :
602 2126394 : double Object::Number() const {
603 : DCHECK(IsNumber());
604 : return IsSmi()
605 : ? static_cast<double>(reinterpret_cast<const Smi*>(this)->value())
606 448893954 : : reinterpret_cast<const HeapNumber*>(this)->value();
607 : }
608 :
609 : bool Object::IsNaN() const {
610 9314 : return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value());
611 : }
612 :
613 : bool Object::IsMinusZero() const {
614 9012 : return this->IsHeapNumber() &&
615 4273 : i::IsMinusZero(HeapNumber::cast(this)->value());
616 : }
617 :
618 : // ------------------------------------
619 : // Cast operations
620 :
621 : CAST_ACCESSOR(AbstractCode)
622 : CAST_ACCESSOR(ArrayList)
623 : CAST_ACCESSOR(BoilerplateDescription)
624 : CAST_ACCESSOR(BreakPointInfo)
625 : CAST_ACCESSOR(ByteArray)
626 : CAST_ACCESSOR(BytecodeArray)
627 : CAST_ACCESSOR(CallHandlerInfo)
628 : CAST_ACCESSOR(Cell)
629 : CAST_ACCESSOR(Code)
630 : CAST_ACCESSOR(ConsString)
631 : CAST_ACCESSOR(ConstantElementsPair)
632 : CAST_ACCESSOR(DeoptimizationInputData)
633 : CAST_ACCESSOR(DeoptimizationOutputData)
634 : CAST_ACCESSOR(DependentCode)
635 : CAST_ACCESSOR(DescriptorArray)
636 : CAST_ACCESSOR(ExternalOneByteString)
637 : CAST_ACCESSOR(ExternalString)
638 : CAST_ACCESSOR(ExternalTwoByteString)
639 : CAST_ACCESSOR(FixedArray)
640 : CAST_ACCESSOR(FixedArrayBase)
641 : CAST_ACCESSOR(FixedDoubleArray)
642 : CAST_ACCESSOR(FixedTypedArrayBase)
643 : CAST_ACCESSOR(Foreign)
644 : CAST_ACCESSOR(GlobalDictionary)
645 : CAST_ACCESSOR(HandlerTable)
646 : CAST_ACCESSOR(HeapObject)
647 : CAST_ACCESSOR(JSArgumentsObject);
648 : CAST_ACCESSOR(JSArray)
649 : CAST_ACCESSOR(JSArrayBuffer)
650 : CAST_ACCESSOR(JSArrayBufferView)
651 : CAST_ACCESSOR(JSBoundFunction)
652 : CAST_ACCESSOR(JSDataView)
653 : CAST_ACCESSOR(JSDate)
654 : CAST_ACCESSOR(JSFunction)
655 : CAST_ACCESSOR(JSGeneratorObject)
656 : CAST_ACCESSOR(JSAsyncGeneratorObject)
657 : CAST_ACCESSOR(JSGlobalObject)
658 : CAST_ACCESSOR(JSGlobalProxy)
659 : CAST_ACCESSOR(JSMap)
660 : CAST_ACCESSOR(JSMapIterator)
661 : CAST_ACCESSOR(JSMessageObject)
662 : CAST_ACCESSOR(JSModuleNamespace)
663 : CAST_ACCESSOR(JSObject)
664 : CAST_ACCESSOR(JSProxy)
665 : CAST_ACCESSOR(JSReceiver)
666 : CAST_ACCESSOR(JSRegExp)
667 : CAST_ACCESSOR(JSPromiseCapability)
668 : CAST_ACCESSOR(JSPromise)
669 : CAST_ACCESSOR(JSSet)
670 : CAST_ACCESSOR(JSSetIterator)
671 : CAST_ACCESSOR(JSSloppyArgumentsObject)
672 : CAST_ACCESSOR(JSAsyncFromSyncIterator)
673 : CAST_ACCESSOR(JSStringIterator)
674 : CAST_ACCESSOR(JSArrayIterator)
675 : CAST_ACCESSOR(JSTypedArray)
676 : CAST_ACCESSOR(JSValue)
677 : CAST_ACCESSOR(JSWeakCollection)
678 : CAST_ACCESSOR(JSWeakMap)
679 : CAST_ACCESSOR(JSWeakSet)
680 : CAST_ACCESSOR(LayoutDescriptor)
681 : CAST_ACCESSOR(Map)
682 : CAST_ACCESSOR(ModuleInfo)
683 : CAST_ACCESSOR(Name)
684 : CAST_ACCESSOR(NameDictionary)
685 : CAST_ACCESSOR(NormalizedMapCache)
686 : CAST_ACCESSOR(Object)
687 : CAST_ACCESSOR(ObjectHashTable)
688 : CAST_ACCESSOR(ObjectHashSet)
689 : CAST_ACCESSOR(Oddball)
690 : CAST_ACCESSOR(OrderedHashMap)
691 : CAST_ACCESSOR(OrderedHashSet)
692 : CAST_ACCESSOR(PropertyCell)
693 : CAST_ACCESSOR(TemplateList)
694 : CAST_ACCESSOR(RegExpMatchInfo)
695 : CAST_ACCESSOR(ScopeInfo)
696 : CAST_ACCESSOR(SeededNumberDictionary)
697 : CAST_ACCESSOR(SeqOneByteString)
698 : CAST_ACCESSOR(SeqString)
699 : CAST_ACCESSOR(SeqTwoByteString)
700 : CAST_ACCESSOR(SharedFunctionInfo)
701 : CAST_ACCESSOR(SourcePositionTableWithFrameCache)
702 : CAST_ACCESSOR(SlicedString)
703 : CAST_ACCESSOR(SloppyArgumentsElements)
704 : CAST_ACCESSOR(Smi)
705 : CAST_ACCESSOR(String)
706 : CAST_ACCESSOR(StringSet)
707 : CAST_ACCESSOR(StringTable)
708 : CAST_ACCESSOR(Struct)
709 : CAST_ACCESSOR(Symbol)
710 : CAST_ACCESSOR(TemplateInfo)
711 : CAST_ACCESSOR(ThinString)
712 : CAST_ACCESSOR(TypeFeedbackInfo)
713 : CAST_ACCESSOR(UnseededNumberDictionary)
714 : CAST_ACCESSOR(WeakCell)
715 : CAST_ACCESSOR(WeakFixedArray)
716 : CAST_ACCESSOR(WeakHashTable)
717 :
718 : #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name)
719 : STRUCT_LIST(MAKE_STRUCT_CAST)
720 : #undef MAKE_STRUCT_CAST
721 :
722 : #undef CAST_ACCESSOR
723 :
724 : bool Object::HasValidElements() {
725 : // Dictionary is covered under FixedArray.
726 : return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
727 : }
728 :
729 : bool Object::KeyEquals(Object* second) {
730 : Object* first = this;
731 : if (second->IsNumber()) {
732 : if (first->IsNumber()) return first->Number() == second->Number();
733 : Object* temp = first;
734 : first = second;
735 : second = temp;
736 : }
737 : if (first->IsNumber()) {
738 : DCHECK_LE(0, first->Number());
739 : uint32_t expected = static_cast<uint32_t>(first->Number());
740 : uint32_t index;
741 : return Name::cast(second)->AsArrayIndex(&index) && index == expected;
742 : }
743 : return Name::cast(first)->Equals(Name::cast(second));
744 : }
745 :
746 18292697 : bool Object::FilterKey(PropertyFilter filter) {
747 18292697 : if (IsSymbol()) {
748 117093 : if (filter & SKIP_SYMBOLS) return true;
749 38964 : if (Symbol::cast(this)->is_private()) return true;
750 : } else {
751 18175604 : if (filter & SKIP_STRINGS) return true;
752 : }
753 14776368 : return false;
754 : }
755 :
756 15780871 : Handle<Object> Object::NewStorageFor(Isolate* isolate, Handle<Object> object,
757 : Representation representation) {
758 15780871 : if (!representation.IsDouble()) return object;
759 2849 : Handle<HeapNumber> result = isolate->factory()->NewHeapNumber(MUTABLE);
760 2849 : if (object->IsUninitialized(isolate)) {
761 : result->set_value_as_bits(kHoleNanInt64);
762 1819 : } else if (object->IsMutableHeapNumber()) {
763 : // Ensure that all bits of the double value are preserved.
764 : result->set_value_as_bits(HeapNumber::cast(*object)->value_as_bits());
765 : } else {
766 : result->set_value(object->Number());
767 : }
768 2849 : return result;
769 : }
770 :
771 58148416 : Handle<Object> Object::WrapForRead(Isolate* isolate, Handle<Object> object,
772 : Representation representation) {
773 : DCHECK(!object->IsUninitialized(isolate));
774 58148416 : if (!representation.IsDouble()) {
775 : DCHECK(object->FitsRepresentation(representation));
776 58138789 : return object;
777 : }
778 9627 : return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value());
779 : }
780 :
781 1404264801 : StringShape::StringShape(const String* str)
782 1404264801 : : type_(str->map()->instance_type()) {
783 : set_valid();
784 : DCHECK((type_ & kIsNotStringMask) == kStringTag);
785 1404264801 : }
786 :
787 : StringShape::StringShape(Map* map) : type_(map->instance_type()) {
788 : set_valid();
789 : DCHECK((type_ & kIsNotStringMask) == kStringTag);
790 : }
791 :
792 : StringShape::StringShape(InstanceType t) : type_(static_cast<uint32_t>(t)) {
793 : set_valid();
794 : DCHECK((type_ & kIsNotStringMask) == kStringTag);
795 : }
796 :
797 : bool StringShape::IsInternalized() {
798 : DCHECK(valid());
799 : STATIC_ASSERT(kNotInternalizedTag != 0);
800 8520 : return (type_ & (kIsNotStringMask | kIsNotInternalizedMask)) ==
801 : (kStringTag | kInternalizedTag);
802 : }
803 :
804 114913639 : bool String::IsOneByteRepresentation() const {
805 : uint32_t type = map()->instance_type();
806 259153545 : return (type & kStringEncodingMask) == kOneByteStringTag;
807 : }
808 :
809 110227 : bool String::IsTwoByteRepresentation() const {
810 : uint32_t type = map()->instance_type();
811 110255 : return (type & kStringEncodingMask) == kTwoByteStringTag;
812 : }
813 :
814 6863007 : bool String::IsOneByteRepresentationUnderneath() {
815 : uint32_t type = map()->instance_type();
816 : STATIC_ASSERT(kIsIndirectStringTag != 0);
817 : STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0);
818 : DCHECK(IsFlat());
819 6863007 : switch (type & (kIsIndirectStringMask | kStringEncodingMask)) {
820 : case kOneByteStringTag:
821 : return true;
822 : case kTwoByteStringTag:
823 2579033 : return false;
824 : default: // Cons or sliced string. Need to go deeper.
825 2821 : return GetUnderlying()->IsOneByteRepresentation();
826 : }
827 : }
828 :
829 : bool String::IsTwoByteRepresentationUnderneath() {
830 : uint32_t type = map()->instance_type();
831 : STATIC_ASSERT(kIsIndirectStringTag != 0);
832 : STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0);
833 : DCHECK(IsFlat());
834 : switch (type & (kIsIndirectStringMask | kStringEncodingMask)) {
835 : case kOneByteStringTag:
836 : return false;
837 : case kTwoByteStringTag:
838 : return true;
839 : default: // Cons or sliced string. Need to go deeper.
840 : return GetUnderlying()->IsTwoByteRepresentation();
841 : }
842 : }
843 :
844 19309490 : bool String::HasOnlyOneByteChars() {
845 : uint32_t type = map()->instance_type();
846 38618795 : return (type & kOneByteDataHintMask) == kOneByteDataHintTag ||
847 19309490 : IsOneByteRepresentation();
848 : }
849 :
850 : bool StringShape::HasOnlyOneByteChars() {
851 25653 : return (type_ & kStringEncodingMask) == kOneByteStringTag ||
852 25653 : (type_ & kOneByteDataHintMask) == kOneByteDataHintTag;
853 : }
854 :
855 119963302 : bool StringShape::IsCons() {
856 170327289 : return (type_ & kStringRepresentationMask) == kConsStringTag;
857 : }
858 :
859 318912011 : bool StringShape::IsThin() {
860 319612391 : return (type_ & kStringRepresentationMask) == kThinStringTag;
861 : }
862 :
863 18415929 : bool StringShape::IsSliced() {
864 19116309 : return (type_ & kStringRepresentationMask) == kSlicedStringTag;
865 : }
866 :
867 : bool StringShape::IsIndirect() {
868 926 : return (type_ & kIsIndirectStringMask) == kIsIndirectStringTag;
869 : }
870 :
871 113130699 : bool StringShape::IsExternal() {
872 113223545 : return (type_ & kStringRepresentationMask) == kExternalStringTag;
873 : }
874 :
875 121958684 : bool StringShape::IsSequential() {
876 121958684 : return (type_ & kStringRepresentationMask) == kSeqStringTag;
877 : }
878 :
879 : StringRepresentationTag StringShape::representation_tag() {
880 377546368 : uint32_t tag = (type_ & kStringRepresentationMask);
881 : return static_cast<StringRepresentationTag>(tag);
882 : }
883 :
884 125899846 : uint32_t StringShape::encoding_tag() { return type_ & kStringEncodingMask; }
885 :
886 711884275 : uint32_t StringShape::full_representation_tag() {
887 1084356816 : return (type_ & (kStringRepresentationMask | kStringEncodingMask));
888 : }
889 :
890 : STATIC_ASSERT((kStringRepresentationMask | kStringEncodingMask) ==
891 : Internals::kFullStringRepresentationMask);
892 :
893 : STATIC_ASSERT(static_cast<uint32_t>(kStringEncodingMask) ==
894 : Internals::kStringEncodingMask);
895 :
896 : bool StringShape::IsSequentialOneByte() {
897 : return full_representation_tag() == (kSeqStringTag | kOneByteStringTag);
898 : }
899 :
900 : bool StringShape::IsSequentialTwoByte() {
901 : return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag);
902 : }
903 :
904 : bool StringShape::IsExternalOneByte() {
905 116 : return full_representation_tag() == (kExternalStringTag | kOneByteStringTag);
906 : }
907 :
908 : STATIC_ASSERT((kExternalStringTag | kOneByteStringTag) ==
909 : Internals::kExternalOneByteRepresentationTag);
910 :
911 : STATIC_ASSERT(v8::String::ONE_BYTE_ENCODING == kOneByteStringTag);
912 :
913 : bool StringShape::IsExternalTwoByte() {
914 164 : return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag);
915 : }
916 :
917 : STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) ==
918 : Internals::kExternalTwoByteRepresentationTag);
919 :
920 : STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag);
921 :
922 15603730 : uc32 FlatStringReader::Get(int index) {
923 15603730 : if (is_one_byte_) {
924 14739778 : return Get<uint8_t>(index);
925 : } else {
926 863952 : return Get<uc16>(index);
927 : }
928 : }
929 :
930 : template <typename Char>
931 38301209 : Char FlatStringReader::Get(int index) {
932 : DCHECK_EQ(is_one_byte_, sizeof(Char) == 1);
933 : DCHECK(0 <= index && index <= length_);
934 : if (sizeof(Char) == 1) {
935 53023851 : return static_cast<Char>(static_cast<const uint8_t*>(start_)[index]);
936 : } else {
937 881088 : return static_cast<Char>(static_cast<const uc16*>(start_)[index]);
938 : }
939 : }
940 :
941 : Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) {
942 : return key->AsHandle(isolate);
943 : }
944 :
945 : template <typename Char>
946 0 : class SequentialStringKey : public HashTableKey {
947 : public:
948 : explicit SequentialStringKey(Vector<const Char> string, uint32_t seed)
949 206164 : : string_(string), hash_field_(0), seed_(seed) {}
950 :
951 261937 : uint32_t Hash() override {
952 261937 : hash_field_ = StringHasher::HashSequentialString<Char>(
953 261937 : string_.start(), string_.length(), seed_);
954 :
955 261937 : uint32_t result = hash_field_ >> String::kHashShift;
956 : DCHECK(result != 0); // Ensure that the hash value of 0 is never computed.
957 261937 : return result;
958 : }
959 :
960 435600 : uint32_t HashForObject(Object* other) override {
961 435600 : return String::cast(other)->Hash();
962 : }
963 :
964 : Vector<const Char> string_;
965 : uint32_t hash_field_;
966 : uint32_t seed_;
967 : };
968 :
969 0 : class OneByteStringKey : public SequentialStringKey<uint8_t> {
970 : public:
971 : OneByteStringKey(Vector<const uint8_t> str, uint32_t seed)
972 206164 : : SequentialStringKey<uint8_t>(str, seed) {}
973 :
974 400281 : bool IsMatch(Object* string) override {
975 400281 : return String::cast(string)->IsOneByteEqualTo(string_);
976 : }
977 :
978 : Handle<Object> AsHandle(Isolate* isolate) override;
979 : };
980 :
981 0 : class SeqOneByteSubStringKey : public HashTableKey {
982 : public:
983 : SeqOneByteSubStringKey(Handle<SeqOneByteString> string, int from, int length)
984 115049 : : string_(string), from_(from), length_(length) {
985 : DCHECK(string_->IsSeqOneByteString());
986 : }
987 :
988 : // VS 2017 on official builds gives this spurious warning:
989 : // warning C4789: buffer 'key' of size 16 bytes will be overrun; 4 bytes will
990 : // be written starting at offset 16
991 : // https://bugs.chromium.org/p/v8/issues/detail?id=6068
992 : #if defined(V8_CC_MSVC)
993 : #pragma warning(push)
994 : #pragma warning(disable : 4789)
995 : #endif
996 230098 : uint32_t Hash() override {
997 : DCHECK(length_ >= 0);
998 : DCHECK(from_ + length_ <= string_->length());
999 230098 : const uint8_t* chars = string_->GetChars() + from_;
1000 : hash_field_ = StringHasher::HashSequentialString(
1001 230098 : chars, length_, string_->GetHeap()->HashSeed());
1002 230098 : uint32_t result = hash_field_ >> String::kHashShift;
1003 : DCHECK(result != 0); // Ensure that the hash value of 0 is never computed.
1004 230098 : return result;
1005 : }
1006 : #if defined(V8_CC_MSVC)
1007 : #pragma warning(pop)
1008 : #endif
1009 :
1010 62703 : uint32_t HashForObject(Object* other) override {
1011 62703 : return String::cast(other)->Hash();
1012 : }
1013 :
1014 : bool IsMatch(Object* string) override;
1015 : Handle<Object> AsHandle(Isolate* isolate) override;
1016 :
1017 : private:
1018 : Handle<SeqOneByteString> string_;
1019 : int from_;
1020 : int length_;
1021 : uint32_t hash_field_;
1022 : };
1023 :
1024 0 : class TwoByteStringKey : public SequentialStringKey<uc16> {
1025 : public:
1026 : explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed)
1027 0 : : SequentialStringKey<uc16>(str, seed) {}
1028 :
1029 0 : bool IsMatch(Object* string) override {
1030 0 : return String::cast(string)->IsTwoByteEqualTo(string_);
1031 : }
1032 :
1033 : Handle<Object> AsHandle(Isolate* isolate) override;
1034 : };
1035 :
1036 : // Utf8StringKey carries a vector of chars as key.
1037 0 : class Utf8StringKey : public HashTableKey {
1038 : public:
1039 : explicit Utf8StringKey(Vector<const char> string, uint32_t seed)
1040 24522791 : : string_(string), hash_field_(0), seed_(seed) {}
1041 :
1042 57783168 : bool IsMatch(Object* string) override {
1043 57783168 : return String::cast(string)->IsUtf8EqualTo(string_);
1044 : }
1045 :
1046 24691642 : uint32_t Hash() override {
1047 24691642 : if (hash_field_ != 0) return hash_field_ >> String::kHashShift;
1048 24522791 : hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_);
1049 24522789 : uint32_t result = hash_field_ >> String::kHashShift;
1050 : DCHECK(result != 0); // Ensure that the hash value of 0 is never computed.
1051 24522789 : return result;
1052 : }
1053 :
1054 56401 : uint32_t HashForObject(Object* other) override {
1055 56401 : return String::cast(other)->Hash();
1056 : }
1057 :
1058 168851 : Handle<Object> AsHandle(Isolate* isolate) override {
1059 168851 : if (hash_field_ == 0) Hash();
1060 : return isolate->factory()->NewInternalizedStringFromUtf8(string_, chars_,
1061 168851 : hash_field_);
1062 : }
1063 :
1064 : Vector<const char> string_;
1065 : uint32_t hash_field_;
1066 : int chars_; // Caches the number of characters when computing the hash code.
1067 : uint32_t seed_;
1068 : };
1069 :
1070 18511529 : Representation Object::OptimalRepresentation() {
1071 18511529 : if (!FLAG_track_fields) return Representation::Tagged();
1072 18511529 : if (IsSmi()) {
1073 : return Representation::Smi();
1074 27441497 : } else if (FLAG_track_double_fields && IsHeapNumber()) {
1075 : return Representation::Double();
1076 27435436 : } else if (FLAG_track_computed_fields &&
1077 : IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
1078 : return Representation::None();
1079 13277637 : } else if (FLAG_track_heap_object_fields) {
1080 : DCHECK(IsHeapObject());
1081 : return Representation::HeapObject();
1082 : } else {
1083 : return Representation::Tagged();
1084 : }
1085 : }
1086 :
1087 :
1088 15233959 : ElementsKind Object::OptimalElementsKind() {
1089 15233959 : if (IsSmi()) return FAST_SMI_ELEMENTS;
1090 3558656 : if (IsNumber()) return FAST_DOUBLE_ELEMENTS;
1091 1269899 : return FAST_ELEMENTS;
1092 : }
1093 :
1094 :
1095 67630556 : bool Object::FitsRepresentation(Representation representation) {
1096 67630556 : if (FLAG_track_fields && representation.IsSmi()) {
1097 6783629 : return IsSmi();
1098 60846927 : } else if (FLAG_track_double_fields && representation.IsDouble()) {
1099 120016 : return IsMutableHeapNumber() || IsNumber();
1100 60786919 : } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
1101 56319440 : return IsHeapObject();
1102 4467479 : } else if (FLAG_track_fields && representation.IsNone()) {
1103 : return false;
1104 : }
1105 4062543 : return true;
1106 : }
1107 :
1108 147403590 : bool Object::ToUint32(uint32_t* value) {
1109 147403590 : if (IsSmi()) {
1110 : int num = Smi::cast(this)->value();
1111 47649636 : if (num < 0) return false;
1112 47584912 : *value = static_cast<uint32_t>(num);
1113 47584912 : return true;
1114 : }
1115 99753955 : if (IsHeapNumber()) {
1116 : double num = HeapNumber::cast(this)->value();
1117 87792 : return DoubleToUint32IfEqualToSelf(num, value);
1118 : }
1119 : return false;
1120 : }
1121 :
1122 : // static
1123 14370959 : MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
1124 : Handle<Object> object,
1125 : const char* method_name) {
1126 14370959 : if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
1127 9181 : return ToObject(isolate, object, isolate->native_context(), method_name);
1128 : }
1129 :
1130 :
1131 : // static
1132 92268675 : MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
1133 92268674 : if (input->IsName()) return Handle<Name>::cast(input);
1134 4574502 : return ConvertToName(isolate, input);
1135 : }
1136 :
1137 : // static
1138 337341 : MaybeHandle<Object> Object::ToPropertyKey(Isolate* isolate,
1139 : Handle<Object> value) {
1140 592941 : if (value->IsSmi() || HeapObject::cast(*value)->IsName()) return value;
1141 744 : return ConvertToPropertyKey(isolate, value);
1142 : }
1143 :
1144 : // static
1145 5143633 : MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
1146 : ToPrimitiveHint hint) {
1147 5143633 : if (input->IsPrimitive()) return input;
1148 4513791 : return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint);
1149 : }
1150 :
1151 : // static
1152 20517910 : MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
1153 20517910 : if (input->IsNumber()) return input;
1154 2890892 : return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input);
1155 : }
1156 :
1157 : // static
1158 11216 : MaybeHandle<Object> Object::ToInteger(Isolate* isolate, Handle<Object> input) {
1159 17339574 : if (input->IsSmi()) return input;
1160 29747 : return ConvertToInteger(isolate, input);
1161 : }
1162 :
1163 : // static
1164 : MaybeHandle<Object> Object::ToInt32(Isolate* isolate, Handle<Object> input) {
1165 10635 : if (input->IsSmi()) return input;
1166 1232 : return ConvertToInt32(isolate, input);
1167 : }
1168 :
1169 : // static
1170 533162 : MaybeHandle<Object> Object::ToUint32(Isolate* isolate, Handle<Object> input) {
1171 533162 : if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate);
1172 533104 : return ConvertToUint32(isolate, input);
1173 : }
1174 :
1175 : // static
1176 29682983 : MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
1177 29682983 : if (input->IsString()) return Handle<String>::cast(input);
1178 8539968 : return ConvertToString(isolate, input);
1179 : }
1180 :
1181 : // static
1182 72668 : MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
1183 72668 : if (input->IsSmi()) {
1184 214830 : int value = std::max(Smi::cast(*input)->value(), 0);
1185 : return handle(Smi::FromInt(value), isolate);
1186 : }
1187 1058 : return ConvertToLength(isolate, input);
1188 : }
1189 :
1190 : // static
1191 24570 : MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input,
1192 : MessageTemplate::Template error_index) {
1193 44537 : if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input;
1194 5303 : return ConvertToIndex(isolate, input, error_index);
1195 : }
1196 :
1197 61270978 : bool Object::HasSpecificClassOf(String* name) {
1198 61270978 : return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
1199 : }
1200 :
1201 1731166 : MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
1202 : Handle<Name> name) {
1203 1731166 : LookupIterator it(object, name);
1204 1731166 : if (!it.IsFound()) return it.factory()->undefined_value();
1205 1574254 : return GetProperty(&it);
1206 : }
1207 :
1208 39946317 : MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
1209 : Handle<Name> name) {
1210 39946317 : LookupIterator it(receiver, name, receiver);
1211 39946318 : if (!it.IsFound()) return it.factory()->undefined_value();
1212 23169480 : return Object::GetProperty(&it);
1213 : }
1214 :
1215 3656 : MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
1216 : uint32_t index) {
1217 3656 : LookupIterator it(isolate, object, index);
1218 3656 : if (!it.IsFound()) return it.factory()->undefined_value();
1219 3626 : return GetProperty(&it);
1220 : }
1221 :
1222 150446481 : MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
1223 : Handle<JSReceiver> receiver,
1224 : uint32_t index) {
1225 : LookupIterator it(isolate, receiver, index, receiver);
1226 150446481 : if (!it.IsFound()) return it.factory()->undefined_value();
1227 72334441 : return Object::GetProperty(&it);
1228 : }
1229 :
1230 8350945 : Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
1231 : Handle<Name> name) {
1232 : LookupIterator it(object, name, object,
1233 8350945 : LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
1234 13519827 : if (!it.IsFound()) return it.factory()->undefined_value();
1235 3182063 : return GetDataProperty(&it);
1236 : }
1237 :
1238 292728 : MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
1239 : uint32_t index, Handle<Object> value,
1240 : LanguageMode language_mode) {
1241 292728 : LookupIterator it(isolate, object, index);
1242 292728 : MAYBE_RETURN_NULL(
1243 : SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED));
1244 : return value;
1245 : }
1246 :
1247 5040576 : MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
1248 : Handle<JSReceiver> receiver) {
1249 : // We don't expect access checks to be needed on JSProxy objects.
1250 : DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
1251 : PrototypeIterator iter(isolate, receiver, kStartAtReceiver,
1252 5040576 : PrototypeIterator::END_AT_NON_HIDDEN);
1253 5072017 : do {
1254 5072073 : if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>();
1255 5072017 : } while (!iter.IsAtEnd());
1256 : return PrototypeIterator::GetCurrent(iter);
1257 : }
1258 :
1259 201835 : MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
1260 : Handle<JSReceiver> receiver,
1261 : const char* name) {
1262 201835 : Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
1263 201835 : return GetProperty(receiver, str);
1264 : }
1265 :
1266 : // static
1267 1529 : MUST_USE_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys(
1268 : Handle<JSReceiver> object) {
1269 : return KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
1270 : ALL_PROPERTIES,
1271 3832 : GetKeysConversion::kConvertToString);
1272 : }
1273 :
1274 2359753 : bool JSObject::PrototypeHasNoElements(Isolate* isolate, JSObject* object) {
1275 : DisallowHeapAllocation no_gc;
1276 : HeapObject* prototype = HeapObject::cast(object->map()->prototype());
1277 2359753 : HeapObject* null = isolate->heap()->null_value();
1278 2359753 : HeapObject* empty = isolate->heap()->empty_fixed_array();
1279 9398657 : while (prototype != null) {
1280 : Map* map = prototype->map();
1281 4700041 : if (map->instance_type() <= LAST_CUSTOM_ELEMENTS_RECEIVER) return false;
1282 4696385 : if (JSObject::cast(prototype)->elements() != empty) return false;
1283 : prototype = HeapObject::cast(map->prototype());
1284 : }
1285 : return true;
1286 : }
1287 :
1288 : #define ACQUIRE_READ_FIELD(p, offset) \
1289 : reinterpret_cast<Object*>(base::Acquire_Load( \
1290 : reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
1291 :
1292 : #define NOBARRIER_READ_FIELD(p, offset) \
1293 : reinterpret_cast<Object*>(base::NoBarrier_Load( \
1294 : reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
1295 :
1296 : #define RELEASE_WRITE_FIELD(p, offset, value) \
1297 : base::Release_Store( \
1298 : reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
1299 : reinterpret_cast<base::AtomicWord>(value));
1300 :
1301 : #define NOBARRIER_WRITE_FIELD(p, offset, value) \
1302 : base::NoBarrier_Store( \
1303 : reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
1304 : reinterpret_cast<base::AtomicWord>(value));
1305 :
1306 : #define WRITE_BARRIER(heap, object, offset, value) \
1307 : heap->incremental_marking()->RecordWrite( \
1308 : object, HeapObject::RawField(object, offset), value); \
1309 : heap->RecordWrite(object, offset, value);
1310 :
1311 : #define FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(heap, array, start, length) \
1312 : do { \
1313 : heap->RecordFixedArrayElements(array, start, length); \
1314 : heap->incremental_marking()->IterateBlackObject(array); \
1315 : } while (false)
1316 :
1317 : #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \
1318 : if (mode != SKIP_WRITE_BARRIER) { \
1319 : if (mode == UPDATE_WRITE_BARRIER) { \
1320 : heap->incremental_marking()->RecordWrite( \
1321 : object, HeapObject::RawField(object, offset), value); \
1322 : } \
1323 : heap->RecordWrite(object, offset, value); \
1324 : }
1325 :
1326 : #define READ_DOUBLE_FIELD(p, offset) \
1327 : ReadDoubleValue(FIELD_ADDR_CONST(p, offset))
1328 :
1329 : #define WRITE_DOUBLE_FIELD(p, offset, value) \
1330 : WriteDoubleValue(FIELD_ADDR(p, offset), value)
1331 :
1332 : #define READ_INT_FIELD(p, offset) \
1333 : (*reinterpret_cast<const int*>(FIELD_ADDR_CONST(p, offset)))
1334 :
1335 : #define WRITE_INT_FIELD(p, offset, value) \
1336 : (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
1337 :
1338 : #define READ_INTPTR_FIELD(p, offset) \
1339 : (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset)))
1340 :
1341 : #define WRITE_INTPTR_FIELD(p, offset, value) \
1342 : (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
1343 :
1344 : #define READ_UINT8_FIELD(p, offset) \
1345 : (*reinterpret_cast<const uint8_t*>(FIELD_ADDR_CONST(p, offset)))
1346 :
1347 : #define WRITE_UINT8_FIELD(p, offset, value) \
1348 : (*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value)
1349 :
1350 : #define READ_INT8_FIELD(p, offset) \
1351 : (*reinterpret_cast<const int8_t*>(FIELD_ADDR_CONST(p, offset)))
1352 :
1353 : #define WRITE_INT8_FIELD(p, offset, value) \
1354 : (*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value)
1355 :
1356 : #define READ_UINT16_FIELD(p, offset) \
1357 : (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset)))
1358 :
1359 : #define WRITE_UINT16_FIELD(p, offset, value) \
1360 : (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value)
1361 :
1362 : #define READ_INT16_FIELD(p, offset) \
1363 : (*reinterpret_cast<const int16_t*>(FIELD_ADDR_CONST(p, offset)))
1364 :
1365 : #define WRITE_INT16_FIELD(p, offset, value) \
1366 : (*reinterpret_cast<int16_t*>(FIELD_ADDR(p, offset)) = value)
1367 :
1368 : #define READ_UINT32_FIELD(p, offset) \
1369 : (*reinterpret_cast<const uint32_t*>(FIELD_ADDR_CONST(p, offset)))
1370 :
1371 : #define WRITE_UINT32_FIELD(p, offset, value) \
1372 : (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
1373 :
1374 : #define READ_INT32_FIELD(p, offset) \
1375 : (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset)))
1376 :
1377 : #define WRITE_INT32_FIELD(p, offset, value) \
1378 : (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
1379 :
1380 : #define READ_FLOAT_FIELD(p, offset) \
1381 : (*reinterpret_cast<const float*>(FIELD_ADDR_CONST(p, offset)))
1382 :
1383 : #define WRITE_FLOAT_FIELD(p, offset, value) \
1384 : (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value)
1385 :
1386 : #define READ_UINT64_FIELD(p, offset) \
1387 : (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset)))
1388 :
1389 : #define WRITE_UINT64_FIELD(p, offset, value) \
1390 : (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value)
1391 :
1392 : #define READ_INT64_FIELD(p, offset) \
1393 : (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset)))
1394 :
1395 : #define WRITE_INT64_FIELD(p, offset, value) \
1396 : (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value)
1397 :
1398 : #define READ_BYTE_FIELD(p, offset) \
1399 : (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset)))
1400 :
1401 : #define NOBARRIER_READ_BYTE_FIELD(p, offset) \
1402 : static_cast<byte>(base::NoBarrier_Load( \
1403 : reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset))))
1404 :
1405 : #define WRITE_BYTE_FIELD(p, offset, value) \
1406 : (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value)
1407 :
1408 : #define NOBARRIER_WRITE_BYTE_FIELD(p, offset, value) \
1409 : base::NoBarrier_Store( \
1410 : reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
1411 : static_cast<base::Atomic8>(value));
1412 :
1413 42136153 : Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
1414 671123484 : return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset));
1415 : }
1416 :
1417 :
1418 : MapWord MapWord::FromMap(const Map* map) {
1419 856172372 : return MapWord(reinterpret_cast<uintptr_t>(map));
1420 : }
1421 :
1422 :
1423 : Map* MapWord::ToMap() {
1424 44683731997 : return reinterpret_cast<Map*>(value_);
1425 : }
1426 :
1427 179 : bool MapWord::IsForwardingAddress() const {
1428 634488324 : return HAS_SMI_TAG(reinterpret_cast<Object*>(value_));
1429 : }
1430 :
1431 :
1432 116355462 : MapWord MapWord::FromForwardingAddress(HeapObject* object) {
1433 117565725 : Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag;
1434 117565725 : return MapWord(reinterpret_cast<uintptr_t>(raw));
1435 : }
1436 :
1437 :
1438 88 : HeapObject* MapWord::ToForwardingAddress() {
1439 : DCHECK(IsForwardingAddress());
1440 115207098 : return HeapObject::FromAddress(reinterpret_cast<Address>(value_));
1441 : }
1442 :
1443 :
1444 : #ifdef VERIFY_HEAP
1445 : void HeapObject::VerifyObjectField(int offset) {
1446 : VerifyPointer(READ_FIELD(this, offset));
1447 : }
1448 :
1449 : void HeapObject::VerifySmiField(int offset) {
1450 : CHECK(READ_FIELD(this, offset)->IsSmi());
1451 : }
1452 : #endif
1453 :
1454 :
1455 968853525 : Heap* HeapObject::GetHeap() const {
1456 : Heap* heap = MemoryChunk::FromAddress(
1457 : reinterpret_cast<Address>(const_cast<HeapObject*>(this)))
1458 12164385575 : ->heap();
1459 : SLOW_DCHECK(heap != NULL);
1460 968853525 : return heap;
1461 : }
1462 :
1463 :
1464 838978413 : Isolate* HeapObject::GetIsolate() const {
1465 838978413 : return GetHeap()->isolate();
1466 : }
1467 :
1468 :
1469 12111299830 : Map* HeapObject::map() const {
1470 12111299830 : return map_word().ToMap();
1471 : }
1472 :
1473 :
1474 20959499 : void HeapObject::set_map(Map* value) {
1475 : set_map_word(MapWord::FromMap(value));
1476 20959499 : if (value != nullptr) {
1477 : // TODO(1600) We are passing NULL as a slot because maps can never be on
1478 : // evacuation candidate.
1479 20959460 : value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
1480 : #ifdef VERIFY_HEAP
1481 : value->GetHeap()->VerifyObjectLayoutChange(this, value);
1482 : #endif
1483 : }
1484 20959502 : }
1485 :
1486 :
1487 : Map* HeapObject::synchronized_map() {
1488 : return synchronized_map_word().ToMap();
1489 : }
1490 :
1491 :
1492 64489136 : void HeapObject::synchronized_set_map(Map* value) {
1493 : synchronized_set_map_word(MapWord::FromMap(value));
1494 64489136 : if (value != nullptr) {
1495 : // TODO(1600) We are passing NULL as a slot because maps can never be on
1496 : // evacuation candidate.
1497 64489140 : value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
1498 : #ifdef VERIFY_HEAP
1499 : value->GetHeap()->VerifyObjectLayoutChange(this, value);
1500 : #endif
1501 : }
1502 64489132 : }
1503 :
1504 :
1505 : void HeapObject::synchronized_set_map_no_write_barrier(Map* value) {
1506 : synchronized_set_map_word(MapWord::FromMap(value));
1507 : }
1508 :
1509 :
1510 : // Unsafe accessor omitting write barrier.
1511 : void HeapObject::set_map_no_write_barrier(Map* value) {
1512 : set_map_word(MapWord::FromMap(value));
1513 : }
1514 :
1515 :
1516 179 : MapWord HeapObject::map_word() const {
1517 : return MapWord(
1518 44525254310 : reinterpret_cast<uintptr_t>(NOBARRIER_READ_FIELD(this, kMapOffset)));
1519 : }
1520 :
1521 :
1522 116355462 : void HeapObject::set_map_word(MapWord map_word) {
1523 774594098 : NOBARRIER_WRITE_FIELD(
1524 : this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
1525 116355462 : }
1526 :
1527 :
1528 : MapWord HeapObject::synchronized_map_word() const {
1529 : return MapWord(
1530 633537834 : reinterpret_cast<uintptr_t>(ACQUIRE_READ_FIELD(this, kMapOffset)));
1531 : }
1532 :
1533 :
1534 : void HeapObject::synchronized_set_map_word(MapWord map_word) {
1535 64489136 : RELEASE_WRITE_FIELD(
1536 : this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
1537 : }
1538 :
1539 :
1540 1140898422 : int HeapObject::Size() {
1541 1140898422 : return SizeFromMap(map());
1542 : }
1543 :
1544 :
1545 8364 : double HeapNumber::value() const {
1546 8364 : return READ_DOUBLE_FIELD(this, kValueOffset);
1547 : }
1548 :
1549 :
1550 : void HeapNumber::set_value(double value) {
1551 : WRITE_DOUBLE_FIELD(this, kValueOffset, value);
1552 : }
1553 :
1554 : uint64_t HeapNumber::value_as_bits() const {
1555 108666 : return READ_UINT64_FIELD(this, kValueOffset);
1556 : }
1557 :
1558 : void HeapNumber::set_value_as_bits(uint64_t bits) {
1559 62708 : WRITE_UINT64_FIELD(this, kValueOffset, bits);
1560 : }
1561 :
1562 : int HeapNumber::get_exponent() {
1563 : return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >>
1564 : kExponentShift) - kExponentBias;
1565 : }
1566 :
1567 :
1568 : int HeapNumber::get_sign() {
1569 : return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
1570 : }
1571 :
1572 874466302 : ACCESSORS(JSReceiver, properties, FixedArray, kPropertiesOffset)
1573 :
1574 :
1575 : Object** FixedArray::GetFirstElementAddress() {
1576 : return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0)));
1577 : }
1578 :
1579 :
1580 : bool FixedArray::ContainsOnlySmisOrHoles() {
1581 : Object* the_hole = GetHeap()->the_hole_value();
1582 : Object** current = GetFirstElementAddress();
1583 : for (int i = 0; i < length(); ++i) {
1584 : Object* candidate = *current++;
1585 : if (!candidate->IsSmi() && candidate != the_hole) return false;
1586 : }
1587 : return true;
1588 : }
1589 :
1590 :
1591 1549515 : FixedArrayBase* JSObject::elements() const {
1592 594986650 : Object* array = READ_FIELD(this, kElementsOffset);
1593 1549515 : return static_cast<FixedArrayBase*>(array);
1594 : }
1595 :
1596 : Context* SloppyArgumentsElements::context() {
1597 : return Context::cast(get(kContextIndex));
1598 : }
1599 :
1600 : FixedArray* SloppyArgumentsElements::arguments() {
1601 : return FixedArray::cast(get(kArgumentsIndex));
1602 : }
1603 :
1604 : void SloppyArgumentsElements::set_arguments(FixedArray* arguments) {
1605 34062 : set(kArgumentsIndex, arguments);
1606 : }
1607 :
1608 : uint32_t SloppyArgumentsElements::parameter_map_length() {
1609 924771 : return length() - kParameterMapStart;
1610 : }
1611 :
1612 : Object* SloppyArgumentsElements::get_mapped_entry(uint32_t entry) {
1613 161202 : return get(entry + kParameterMapStart);
1614 : }
1615 :
1616 : void SloppyArgumentsElements::set_mapped_entry(uint32_t entry, Object* object) {
1617 834 : set(entry + kParameterMapStart, object);
1618 : }
1619 :
1620 1601164 : void AllocationSite::Initialize() {
1621 1601164 : set_transition_info(Smi::kZero);
1622 1601164 : SetElementsKind(GetInitialFastElementsKind());
1623 1601164 : set_nested_site(Smi::kZero);
1624 : set_pretenure_data(0);
1625 : set_pretenure_create_count(0);
1626 1601164 : set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
1627 1601164 : SKIP_WRITE_BARRIER);
1628 1601164 : }
1629 :
1630 :
1631 : bool AllocationSite::IsZombie() { return pretenure_decision() == kZombie; }
1632 :
1633 :
1634 : bool AllocationSite::IsMaybeTenure() {
1635 : return pretenure_decision() == kMaybeTenure;
1636 : }
1637 :
1638 :
1639 : bool AllocationSite::PretenuringDecisionMade() {
1640 : return pretenure_decision() != kUndecided;
1641 : }
1642 :
1643 :
1644 : void AllocationSite::MarkZombie() {
1645 : DCHECK(!IsZombie());
1646 328902 : Initialize();
1647 : set_pretenure_decision(kZombie);
1648 : }
1649 :
1650 :
1651 : ElementsKind AllocationSite::GetElementsKind() {
1652 : DCHECK(!SitePointsToLiteral());
1653 : int value = Smi::cast(transition_info())->value();
1654 1090771 : return ElementsKindBits::decode(value);
1655 : }
1656 :
1657 :
1658 1624795 : void AllocationSite::SetElementsKind(ElementsKind kind) {
1659 : int value = Smi::cast(transition_info())->value();
1660 3249590 : set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)),
1661 1624795 : SKIP_WRITE_BARRIER);
1662 1624795 : }
1663 :
1664 :
1665 : bool AllocationSite::CanInlineCall() {
1666 : int value = Smi::cast(transition_info())->value();
1667 1358 : return DoNotInlineBit::decode(value) == 0;
1668 : }
1669 :
1670 :
1671 3674 : void AllocationSite::SetDoNotInlineCall() {
1672 : int value = Smi::cast(transition_info())->value();
1673 7348 : set_transition_info(Smi::FromInt(DoNotInlineBit::update(value, true)),
1674 3674 : SKIP_WRITE_BARRIER);
1675 3674 : }
1676 :
1677 :
1678 651685 : bool AllocationSite::SitePointsToLiteral() {
1679 : // If transition_info is a smi, then it represents an ElementsKind
1680 : // for a constructed array. Otherwise, it must be a boilerplate
1681 : // for an object or array literal.
1682 686453 : return transition_info()->IsJSArray() || transition_info()->IsJSObject();
1683 : }
1684 :
1685 :
1686 : // Heuristic: We only need to create allocation site info if the boilerplate
1687 : // elements kind is the initial elements kind.
1688 : AllocationSiteMode AllocationSite::GetMode(
1689 : ElementsKind boilerplate_elements_kind) {
1690 1534425 : if (IsFastSmiElementsKind(boilerplate_elements_kind)) {
1691 : return TRACK_ALLOCATION_SITE;
1692 : }
1693 :
1694 : return DONT_TRACK_ALLOCATION_SITE;
1695 : }
1696 :
1697 152227118 : inline bool AllocationSite::CanTrack(InstanceType type) {
1698 152227118 : if (FLAG_turbo) {
1699 : // TurboFan doesn't care at all about String pretenuring feedback,
1700 : // so don't bother even trying to track that.
1701 92973138 : return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE;
1702 : }
1703 59253980 : if (FLAG_allocation_site_pretenuring) {
1704 118507960 : return type == JS_ARRAY_TYPE ||
1705 169661645 : type == JS_OBJECT_TYPE ||
1706 110407665 : type < FIRST_NONSTRING_TYPE;
1707 : }
1708 0 : return type == JS_ARRAY_TYPE;
1709 : }
1710 :
1711 :
1712 : AllocationSite::PretenureDecision AllocationSite::pretenure_decision() {
1713 : int value = pretenure_data();
1714 7720620 : return PretenureDecisionBits::decode(value);
1715 : }
1716 :
1717 :
1718 : void AllocationSite::set_pretenure_decision(PretenureDecision decision) {
1719 : int value = pretenure_data();
1720 663634 : set_pretenure_data(PretenureDecisionBits::update(value, decision));
1721 : }
1722 :
1723 :
1724 : bool AllocationSite::deopt_dependent_code() {
1725 : int value = pretenure_data();
1726 1021 : return DeoptDependentCodeBit::decode(value);
1727 : }
1728 :
1729 :
1730 : void AllocationSite::set_deopt_dependent_code(bool deopt) {
1731 : int value = pretenure_data();
1732 720 : set_pretenure_data(DeoptDependentCodeBit::update(value, deopt));
1733 : }
1734 :
1735 :
1736 : int AllocationSite::memento_found_count() {
1737 : int value = pretenure_data();
1738 : return MementoFoundCountBits::decode(value);
1739 : }
1740 :
1741 :
1742 : inline void AllocationSite::set_memento_found_count(int count) {
1743 : int value = pretenure_data();
1744 : // Verify that we can count more mementos than we can possibly find in one
1745 : // new space collection.
1746 : DCHECK((GetHeap()->MaxSemiSpaceSize() /
1747 : (Heap::kMinObjectSizeInWords * kPointerSize +
1748 : AllocationMemento::kSize)) < MementoFoundCountBits::kMax);
1749 : DCHECK(count < MementoFoundCountBits::kMax);
1750 3226311 : set_pretenure_data(MementoFoundCountBits::update(value, count));
1751 : }
1752 :
1753 :
1754 : int AllocationSite::memento_create_count() { return pretenure_create_count(); }
1755 :
1756 :
1757 : void AllocationSite::set_memento_create_count(int count) {
1758 : set_pretenure_create_count(count);
1759 : }
1760 :
1761 :
1762 : bool AllocationSite::IncrementMementoFoundCount(int increment) {
1763 3218597 : if (IsZombie()) return false;
1764 :
1765 : int value = memento_found_count();
1766 3218597 : set_memento_found_count(value + increment);
1767 3218597 : return memento_found_count() >= kPretenureMinimumCreated;
1768 : }
1769 :
1770 :
1771 : inline void AllocationSite::IncrementMementoCreateCount() {
1772 : DCHECK(FLAG_allocation_site_pretenuring);
1773 : int value = memento_create_count();
1774 7485930 : set_memento_create_count(value + 1);
1775 : }
1776 :
1777 :
1778 3857 : inline bool AllocationSite::MakePretenureDecision(
1779 : PretenureDecision current_decision,
1780 : double ratio,
1781 : bool maximum_size_scavenge) {
1782 : // Here we just allow state transitions from undecided or maybe tenure
1783 : // to don't tenure, maybe tenure, or tenure.
1784 3857 : if ((current_decision == kUndecided || current_decision == kMaybeTenure)) {
1785 2915 : if (ratio >= kPretenureRatio) {
1786 : // We just transition into tenure state when the semi-space was at
1787 : // maximum capacity.
1788 2143 : if (maximum_size_scavenge) {
1789 : set_deopt_dependent_code(true);
1790 : set_pretenure_decision(kTenure);
1791 : // Currently we just need to deopt when we make a state transition to
1792 : // tenure.
1793 136 : return true;
1794 : }
1795 : set_pretenure_decision(kMaybeTenure);
1796 : } else {
1797 : set_pretenure_decision(kDontTenure);
1798 : }
1799 : }
1800 : return false;
1801 : }
1802 :
1803 :
1804 3857 : inline bool AllocationSite::DigestPretenuringFeedback(
1805 : bool maximum_size_scavenge) {
1806 : bool deopt = false;
1807 : int create_count = memento_create_count();
1808 : int found_count = memento_found_count();
1809 3857 : bool minimum_mementos_created = create_count >= kPretenureMinimumCreated;
1810 : double ratio =
1811 0 : minimum_mementos_created || FLAG_trace_pretenuring_statistics ?
1812 7714 : static_cast<double>(found_count) / create_count : 0.0;
1813 : PretenureDecision current_decision = pretenure_decision();
1814 :
1815 3857 : if (minimum_mementos_created) {
1816 : deopt = MakePretenureDecision(
1817 3857 : current_decision, ratio, maximum_size_scavenge);
1818 : }
1819 :
1820 3857 : if (FLAG_trace_pretenuring_statistics) {
1821 : PrintIsolate(GetIsolate(),
1822 : "pretenuring: AllocationSite(%p): (created, found, ratio) "
1823 : "(%d, %d, %f) %s => %s\n",
1824 : static_cast<void*>(this), create_count, found_count, ratio,
1825 : PretenureDecisionName(current_decision),
1826 0 : PretenureDecisionName(pretenure_decision()));
1827 : }
1828 :
1829 : // Clear feedback calculation fields until the next gc.
1830 : set_memento_found_count(0);
1831 : set_memento_create_count(0);
1832 3857 : return deopt;
1833 : }
1834 :
1835 :
1836 3625210 : bool AllocationMemento::IsValid() {
1837 7250420 : return allocation_site()->IsAllocationSite() &&
1838 3625210 : !AllocationSite::cast(allocation_site())->IsZombie();
1839 : }
1840 :
1841 :
1842 : AllocationSite* AllocationMemento::GetAllocationSite() {
1843 : DCHECK(IsValid());
1844 : return AllocationSite::cast(allocation_site());
1845 : }
1846 :
1847 : Address AllocationMemento::GetAllocationSiteUnchecked() {
1848 : return reinterpret_cast<Address>(allocation_site());
1849 : }
1850 :
1851 189268 : void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
1852 189268 : JSObject::ValidateElements(object);
1853 : ElementsKind elements_kind = object->map()->elements_kind();
1854 189268 : if (!IsFastObjectElementsKind(elements_kind)) {
1855 0 : if (IsFastHoleyElementsKind(elements_kind)) {
1856 0 : TransitionElementsKind(object, FAST_HOLEY_ELEMENTS);
1857 : } else {
1858 0 : TransitionElementsKind(object, FAST_ELEMENTS);
1859 : }
1860 : }
1861 189268 : }
1862 :
1863 :
1864 1305287 : void JSObject::EnsureCanContainElements(Handle<JSObject> object,
1865 : Object** objects,
1866 : uint32_t count,
1867 : EnsureElementsMode mode) {
1868 : ElementsKind current_kind = object->GetElementsKind();
1869 : ElementsKind target_kind = current_kind;
1870 : {
1871 : DisallowHeapAllocation no_allocation;
1872 : DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
1873 : bool is_holey = IsFastHoleyElementsKind(current_kind);
1874 2610574 : if (current_kind == FAST_HOLEY_ELEMENTS) return;
1875 1305287 : Object* the_hole = object->GetHeap()->the_hole_value();
1876 28081506 : for (uint32_t i = 0; i < count; ++i) {
1877 26776219 : Object* current = *objects++;
1878 26776219 : if (current == the_hole) {
1879 : is_holey = true;
1880 : target_kind = GetHoleyElementsKind(target_kind);
1881 24500699 : } else if (!current->IsSmi()) {
1882 13736928 : if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
1883 1400641 : if (IsFastSmiElementsKind(target_kind)) {
1884 126 : if (is_holey) {
1885 : target_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
1886 : } else {
1887 : target_kind = FAST_DOUBLE_ELEMENTS;
1888 : }
1889 : }
1890 5763221 : } else if (is_holey) {
1891 : target_kind = FAST_HOLEY_ELEMENTS;
1892 : break;
1893 : } else {
1894 : target_kind = FAST_ELEMENTS;
1895 : }
1896 : }
1897 : }
1898 : }
1899 1305287 : if (target_kind != current_kind) {
1900 142604 : TransitionElementsKind(object, target_kind);
1901 : }
1902 : }
1903 :
1904 :
1905 141370 : void JSObject::EnsureCanContainElements(Handle<JSObject> object,
1906 : Handle<FixedArrayBase> elements,
1907 : uint32_t length,
1908 : EnsureElementsMode mode) {
1909 141370 : Heap* heap = object->GetHeap();
1910 141370 : if (elements->map() != heap->fixed_double_array_map()) {
1911 : DCHECK(elements->map() == heap->fixed_array_map() ||
1912 : elements->map() == heap->fixed_cow_array_map());
1913 141370 : if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
1914 : mode = DONT_ALLOW_DOUBLE_ELEMENTS;
1915 : }
1916 : Object** objects =
1917 141370 : Handle<FixedArray>::cast(elements)->GetFirstElementAddress();
1918 141370 : EnsureCanContainElements(object, objects, length, mode);
1919 141370 : return;
1920 : }
1921 :
1922 : DCHECK(mode == ALLOW_COPIED_DOUBLE_ELEMENTS);
1923 0 : if (object->GetElementsKind() == FAST_HOLEY_SMI_ELEMENTS) {
1924 0 : TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS);
1925 0 : } else if (object->GetElementsKind() == FAST_SMI_ELEMENTS) {
1926 : Handle<FixedDoubleArray> double_array =
1927 : Handle<FixedDoubleArray>::cast(elements);
1928 0 : for (uint32_t i = 0; i < length; ++i) {
1929 0 : if (double_array->is_the_hole(i)) {
1930 0 : TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS);
1931 : return;
1932 : }
1933 : }
1934 0 : TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
1935 : }
1936 : }
1937 :
1938 :
1939 1284602 : void JSObject::SetMapAndElements(Handle<JSObject> object,
1940 : Handle<Map> new_map,
1941 : Handle<FixedArrayBase> value) {
1942 1284602 : JSObject::MigrateToMap(object, new_map);
1943 : DCHECK((object->map()->has_fast_smi_or_object_elements() ||
1944 : (*value == object->GetHeap()->empty_fixed_array()) ||
1945 : object->map()->has_fast_string_wrapper_elements()) ==
1946 : (value->map() == object->GetHeap()->fixed_array_map() ||
1947 : value->map() == object->GetHeap()->fixed_cow_array_map()));
1948 : DCHECK((*value == object->GetHeap()->empty_fixed_array()) ||
1949 : (object->map()->has_fast_double_elements() ==
1950 : value->IsFixedDoubleArray()));
1951 1284602 : object->set_elements(*value);
1952 1284602 : }
1953 :
1954 :
1955 31091120 : void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) {
1956 31091120 : WRITE_FIELD(this, kElementsOffset, value);
1957 86662529 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode);
1958 31091119 : }
1959 :
1960 :
1961 75752317 : void JSObject::initialize_elements() {
1962 75752317 : FixedArrayBase* elements = map()->GetInitialElements();
1963 75752320 : WRITE_FIELD(this, kElementsOffset, elements);
1964 75752320 : }
1965 :
1966 :
1967 723347 : InterceptorInfo* JSObject::GetIndexedInterceptor() {
1968 723347 : return map()->GetIndexedInterceptor();
1969 : }
1970 :
1971 1796121 : InterceptorInfo* JSObject::GetNamedInterceptor() {
1972 1796121 : return map()->GetNamedInterceptor();
1973 : }
1974 :
1975 : InterceptorInfo* Map::GetNamedInterceptor() {
1976 : DCHECK(has_named_interceptor());
1977 1796121 : FunctionTemplateInfo* info = GetFunctionTemplateInfo();
1978 : return InterceptorInfo::cast(info->named_property_handler());
1979 : }
1980 :
1981 : InterceptorInfo* Map::GetIndexedInterceptor() {
1982 : DCHECK(has_indexed_interceptor());
1983 723569 : FunctionTemplateInfo* info = GetFunctionTemplateInfo();
1984 : return InterceptorInfo::cast(info->indexed_property_handler());
1985 : }
1986 :
1987 : double Oddball::to_number_raw() const {
1988 : return READ_DOUBLE_FIELD(this, kToNumberRawOffset);
1989 : }
1990 :
1991 : void Oddball::set_to_number_raw(double value) {
1992 : WRITE_DOUBLE_FIELD(this, kToNumberRawOffset, value);
1993 : }
1994 :
1995 : void Oddball::set_to_number_raw_as_bits(uint64_t bits) {
1996 86 : WRITE_UINT64_FIELD(this, kToNumberRawOffset, bits);
1997 : }
1998 :
1999 2565605 : ACCESSORS(Oddball, to_string, String, kToStringOffset)
2000 3335952 : ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
2001 3572 : ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
2002 :
2003 :
2004 17935568 : byte Oddball::kind() const {
2005 68025540 : return Smi::cast(READ_FIELD(this, kKindOffset))->value();
2006 : }
2007 :
2008 :
2009 : void Oddball::set_kind(byte value) {
2010 688 : WRITE_FIELD(this, kKindOffset, Smi::FromInt(value));
2011 : }
2012 :
2013 :
2014 : // static
2015 3334533 : Handle<Object> Oddball::ToNumber(Handle<Oddball> input) {
2016 3334533 : return handle(input->to_number(), input->GetIsolate());
2017 : }
2018 :
2019 :
2020 92400901 : ACCESSORS(Cell, value, Object, kValueOffset)
2021 12677007 : ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
2022 285471243 : ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset)
2023 122708442 : ACCESSORS(PropertyCell, value, Object, kValueOffset)
2024 :
2025 :
2026 : PropertyDetails PropertyCell::property_details() {
2027 : return PropertyDetails(Smi::cast(property_details_raw()));
2028 : }
2029 :
2030 :
2031 : void PropertyCell::set_property_details(PropertyDetails details) {
2032 29668633 : set_property_details_raw(details.AsSmi());
2033 : }
2034 :
2035 :
2036 539618432 : Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); }
2037 :
2038 :
2039 : void WeakCell::clear() {
2040 : // Either the garbage collector is clearing the cell or we are simply
2041 : // initializing the root empty weak cell.
2042 : DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT ||
2043 : this == GetHeap()->empty_weak_cell());
2044 2544885 : WRITE_FIELD(this, kValueOffset, Smi::kZero);
2045 : }
2046 :
2047 :
2048 39367624 : void WeakCell::initialize(HeapObject* val) {
2049 39367624 : WRITE_FIELD(this, kValueOffset, val);
2050 : // We just have to execute the generational barrier here because we never
2051 : // mark through a weak cell and collect evacuation candidates when we process
2052 : // all weak cells.
2053 : WriteBarrierMode mode =
2054 : ObjectMarking::IsBlack(this, MarkingState::Internal(this))
2055 : ? UPDATE_WRITE_BARRIER
2056 39367627 : : UPDATE_WEAK_WRITE_BARRIER;
2057 78853349 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kValueOffset, val, mode);
2058 39367622 : }
2059 :
2060 180847148 : bool WeakCell::cleared() const { return value() == Smi::kZero; }
2061 :
2062 146885795 : Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
2063 :
2064 :
2065 149269707 : void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
2066 149269707 : WRITE_FIELD(this, kNextOffset, val);
2067 149269707 : if (mode == UPDATE_WRITE_BARRIER) {
2068 3053880 : WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
2069 : }
2070 149269707 : }
2071 :
2072 :
2073 : void WeakCell::clear_next(Object* the_hole_value) {
2074 : DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value);
2075 93809593 : set_next(the_hole_value, SKIP_WRITE_BARRIER);
2076 : }
2077 :
2078 180847147 : bool WeakCell::next_cleared() { return next()->IsTheHole(GetIsolate()); }
2079 :
2080 38682580 : int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
2081 :
2082 :
2083 22565346 : int JSObject::GetHeaderSize(InstanceType type) {
2084 : // Check for the most common kind of JavaScript object before
2085 : // falling into the generic switch. This speeds up the internal
2086 : // field operations considerably on average.
2087 22565346 : if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2088 3542329 : switch (type) {
2089 : case JS_API_OBJECT_TYPE:
2090 : case JS_SPECIAL_API_OBJECT_TYPE:
2091 : return JSObject::kHeaderSize;
2092 : case JS_GENERATOR_OBJECT_TYPE:
2093 18006 : return JSGeneratorObject::kSize;
2094 : case JS_ASYNC_GENERATOR_OBJECT_TYPE:
2095 1736 : return JSAsyncGeneratorObject::kSize;
2096 : case JS_GLOBAL_PROXY_TYPE:
2097 12 : return JSGlobalProxy::kSize;
2098 : case JS_GLOBAL_OBJECT_TYPE:
2099 667 : return JSGlobalObject::kSize;
2100 : case JS_BOUND_FUNCTION_TYPE:
2101 18 : return JSBoundFunction::kSize;
2102 : case JS_FUNCTION_TYPE:
2103 1303743 : return JSFunction::kSize;
2104 : case JS_VALUE_TYPE:
2105 6530 : return JSValue::kSize;
2106 : case JS_DATE_TYPE:
2107 1304 : return JSDate::kSize;
2108 : case JS_ARRAY_TYPE:
2109 100752 : return JSArray::kSize;
2110 : case JS_ARRAY_BUFFER_TYPE:
2111 269010 : return JSArrayBuffer::kSize;
2112 : case JS_TYPED_ARRAY_TYPE:
2113 10200 : return JSTypedArray::kSize;
2114 : case JS_DATA_VIEW_TYPE:
2115 11442 : return JSDataView::kSize;
2116 : case JS_SET_TYPE:
2117 1461 : return JSSet::kSize;
2118 : case JS_MAP_TYPE:
2119 2035 : return JSMap::kSize;
2120 : case JS_SET_ITERATOR_TYPE:
2121 0 : return JSSetIterator::kSize;
2122 : case JS_MAP_ITERATOR_TYPE:
2123 0 : return JSMapIterator::kSize;
2124 : case JS_WEAK_MAP_TYPE:
2125 1390 : return JSWeakMap::kSize;
2126 : case JS_WEAK_SET_TYPE:
2127 628 : return JSWeakSet::kSize;
2128 : case JS_PROMISE_CAPABILITY_TYPE:
2129 0 : return JSPromiseCapability::kSize;
2130 : case JS_PROMISE_TYPE:
2131 320 : return JSPromise::kSize;
2132 : case JS_REGEXP_TYPE:
2133 121430 : return JSRegExp::kSize;
2134 : case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
2135 : return JSObject::kHeaderSize;
2136 : case JS_MESSAGE_OBJECT_TYPE:
2137 0 : return JSMessageObject::kSize;
2138 : case JS_ARGUMENTS_TYPE:
2139 3090 : return JSArgumentsObject::kHeaderSize;
2140 : case JS_ERROR_TYPE:
2141 : return JSObject::kHeaderSize;
2142 : case JS_STRING_ITERATOR_TYPE:
2143 0 : return JSStringIterator::kSize;
2144 : case JS_MODULE_NAMESPACE_TYPE:
2145 172 : return JSModuleNamespace::kHeaderSize;
2146 : default:
2147 30 : if (type >= FIRST_ARRAY_ITERATOR_TYPE &&
2148 : type <= LAST_ARRAY_ITERATOR_TYPE) {
2149 : return JSArrayIterator::kSize;
2150 : }
2151 0 : UNREACHABLE();
2152 : return 0;
2153 : }
2154 : }
2155 :
2156 : inline bool IsSpecialReceiverInstanceType(InstanceType instance_type) {
2157 832677097 : return instance_type <= LAST_SPECIAL_RECEIVER_TYPE;
2158 : }
2159 :
2160 2513887 : int JSObject::GetEmbedderFieldCount(Map* map) {
2161 : int instance_size = map->instance_size();
2162 2513887 : if (instance_size == kVariableSizeSentinel) return 0;
2163 : InstanceType instance_type = map->instance_type();
2164 2513887 : return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) -
2165 2513885 : map->GetInObjectProperties();
2166 : }
2167 :
2168 1572754 : int JSObject::GetEmbedderFieldCount() { return GetEmbedderFieldCount(map()); }
2169 :
2170 : int JSObject::GetEmbedderFieldOffset(int index) {
2171 : DCHECK(index < GetEmbedderFieldCount() && index >= 0);
2172 120 : return GetHeaderSize() + (kPointerSize * index);
2173 : }
2174 :
2175 : Object* JSObject::GetEmbedderField(int index) {
2176 : DCHECK(index < GetEmbedderFieldCount() && index >= 0);
2177 : // Internal objects do follow immediately after the header, whereas in-object
2178 : // properties are at the end of the object. Therefore there is no need
2179 : // to adjust the index here.
2180 18329612 : return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index));
2181 : }
2182 :
2183 460436 : void JSObject::SetEmbedderField(int index, Object* value) {
2184 : DCHECK(index < GetEmbedderFieldCount() && index >= 0);
2185 : // Internal objects do follow immediately after the header, whereas in-object
2186 : // properties are at the end of the object. Therefore there is no need
2187 : // to adjust the index here.
2188 460436 : int offset = GetHeaderSize() + (kPointerSize * index);
2189 460436 : WRITE_FIELD(this, offset, value);
2190 920872 : WRITE_BARRIER(GetHeap(), this, offset, value);
2191 460436 : }
2192 :
2193 : void JSObject::SetEmbedderField(int index, Smi* value) {
2194 : DCHECK(index < GetEmbedderFieldCount() && index >= 0);
2195 : // Internal objects do follow immediately after the header, whereas in-object
2196 : // properties are at the end of the object. Therefore there is no need
2197 : // to adjust the index here.
2198 551122 : int offset = GetHeaderSize() + (kPointerSize * index);
2199 551122 : WRITE_FIELD(this, offset, value);
2200 : }
2201 :
2202 :
2203 159585822 : bool JSObject::IsUnboxedDoubleField(FieldIndex index) {
2204 : if (!FLAG_unbox_double_fields) return false;
2205 159585822 : return map()->IsUnboxedDoubleField(index);
2206 : }
2207 :
2208 :
2209 194021000 : bool Map::IsUnboxedDoubleField(FieldIndex index) {
2210 : if (!FLAG_unbox_double_fields) return false;
2211 388042020 : if (index.is_hidden_field() || !index.is_inobject()) return false;
2212 117112536 : return !layout_descriptor()->IsTagged(index.property_index());
2213 : }
2214 :
2215 :
2216 : // Access fast-case object properties at index. The use of these routines
2217 : // is needed to correctly distinguish between properties stored in-object and
2218 : // properties stored in the properties array.
2219 143185706 : Object* JSObject::RawFastPropertyAt(FieldIndex index) {
2220 : DCHECK(!IsUnboxedDoubleField(index));
2221 143185706 : if (index.is_inobject()) {
2222 65614713 : return READ_FIELD(this, index.offset());
2223 : } else {
2224 77570993 : return properties()->get(index.outobject_array_index());
2225 : }
2226 : }
2227 :
2228 :
2229 : double JSObject::RawFastDoublePropertyAt(FieldIndex index) {
2230 : DCHECK(IsUnboxedDoubleField(index));
2231 79717 : return READ_DOUBLE_FIELD(this, index.offset());
2232 : }
2233 :
2234 : uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) {
2235 : DCHECK(IsUnboxedDoubleField(index));
2236 154997 : return READ_UINT64_FIELD(this, index.offset());
2237 : }
2238 :
2239 131217574 : void JSObject::RawFastPropertyAtPut(FieldIndex index, Object* value) {
2240 131217574 : if (index.is_inobject()) {
2241 : int offset = index.offset();
2242 105249686 : WRITE_FIELD(this, offset, value);
2243 210499372 : WRITE_BARRIER(GetHeap(), this, offset, value);
2244 : } else {
2245 25967888 : properties()->set(index.outobject_array_index(), value);
2246 : }
2247 131217579 : }
2248 :
2249 : void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index,
2250 : uint64_t bits) {
2251 255921 : WRITE_UINT64_FIELD(this, index.offset(), bits);
2252 : }
2253 :
2254 16426148 : void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
2255 16426148 : if (IsUnboxedDoubleField(index)) {
2256 : DCHECK(value->IsMutableHeapNumber());
2257 : // Ensure that all bits of the double value are preserved.
2258 : RawFastDoublePropertyAsBitsAtPut(index,
2259 : HeapNumber::cast(value)->value_as_bits());
2260 : } else {
2261 16426152 : RawFastPropertyAtPut(index, value);
2262 : }
2263 16426153 : }
2264 :
2265 76633742 : void JSObject::WriteToField(int descriptor, PropertyDetails details,
2266 : Object* value) {
2267 : DCHECK_EQ(kField, details.location());
2268 : DCHECK_EQ(kData, details.kind());
2269 : DisallowHeapAllocation no_gc;
2270 76633742 : FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
2271 76633746 : if (details.representation().IsDouble()) {
2272 : // Nothing more to be done.
2273 79276 : if (value->IsUninitialized(this->GetIsolate())) {
2274 850 : return;
2275 : }
2276 : // Manipulating the signaling NaN used for the hole and uninitialized
2277 : // double field sentinel in C++, e.g. with bit_cast or value()/set_value(),
2278 : // will change its value on ia32 (the x87 stack is used to return values
2279 : // and stores to the stack silently clear the signalling bit).
2280 : uint64_t bits;
2281 78426 : if (value->IsSmi()) {
2282 9361 : bits = bit_cast<uint64_t>(static_cast<double>(Smi::cast(value)->value()));
2283 : } else {
2284 : DCHECK(value->IsHeapNumber());
2285 : bits = HeapNumber::cast(value)->value_as_bits();
2286 : }
2287 78426 : if (IsUnboxedDoubleField(index)) {
2288 : RawFastDoublePropertyAsBitsAtPut(index, bits);
2289 : } else {
2290 12134 : HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index));
2291 : DCHECK(box->IsMutableHeapNumber());
2292 : box->set_value_as_bits(bits);
2293 : }
2294 : } else {
2295 76554470 : RawFastPropertyAtPut(index, value);
2296 : }
2297 : }
2298 :
2299 15576962 : int JSObject::GetInObjectPropertyOffset(int index) {
2300 15576962 : return map()->GetInObjectPropertyOffset(index);
2301 : }
2302 :
2303 :
2304 : Object* JSObject::InObjectPropertyAt(int index) {
2305 420363 : int offset = GetInObjectPropertyOffset(index);
2306 420363 : return READ_FIELD(this, offset);
2307 : }
2308 :
2309 :
2310 15153108 : Object* JSObject::InObjectPropertyAtPut(int index,
2311 : Object* value,
2312 : WriteBarrierMode mode) {
2313 : // Adjust for the number of properties stored in the object.
2314 15153108 : int offset = GetInObjectPropertyOffset(index);
2315 15153108 : WRITE_FIELD(this, offset, value);
2316 44027068 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
2317 15153108 : return value;
2318 : }
2319 :
2320 :
2321 45730477 : void JSObject::InitializeBody(Map* map, int start_offset,
2322 : Object* pre_allocated_value,
2323 : Object* filler_value) {
2324 : DCHECK(!filler_value->IsHeapObject() ||
2325 : !GetHeap()->InNewSpace(filler_value));
2326 : DCHECK(!pre_allocated_value->IsHeapObject() ||
2327 : !GetHeap()->InNewSpace(pre_allocated_value));
2328 : int size = map->instance_size();
2329 : int offset = start_offset;
2330 45730477 : if (filler_value != pre_allocated_value) {
2331 : int end_of_pre_allocated_offset =
2332 408109 : size - (map->unused_property_fields() * kPointerSize);
2333 : DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
2334 1059946 : while (offset < end_of_pre_allocated_offset) {
2335 243728 : WRITE_FIELD(this, offset, pre_allocated_value);
2336 243728 : offset += kPointerSize;
2337 : }
2338 : }
2339 159778779 : while (offset < size) {
2340 114048302 : WRITE_FIELD(this, offset, filler_value);
2341 114048302 : offset += kPointerSize;
2342 : }
2343 45730477 : }
2344 :
2345 :
2346 9127260 : bool Map::TooManyFastProperties(StoreFromKeyed store_mode) {
2347 9127260 : if (unused_property_fields() != 0) return false;
2348 2657362 : if (is_prototype_map()) return false;
2349 1839473 : int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12;
2350 : int limit = Max(minimum, GetInObjectProperties());
2351 3678946 : int external = NumberOfFields() - GetInObjectProperties();
2352 1839473 : return external > limit;
2353 : }
2354 :
2355 :
2356 : void Struct::InitializeBody(int object_size) {
2357 16537277 : Object* value = GetHeap()->undefined_value();
2358 138790293 : for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
2359 138790293 : WRITE_FIELD(this, offset, value);
2360 : }
2361 : }
2362 :
2363 7371061 : bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); }
2364 :
2365 :
2366 115041 : bool Object::ToArrayIndex(uint32_t* index) {
2367 139584463 : return Object::ToUint32(index) && *index != kMaxUInt32;
2368 : }
2369 :
2370 :
2371 : void Object::VerifyApiCallResultType() {
2372 : #if DEBUG
2373 : if (IsSmi()) return;
2374 : DCHECK(IsHeapObject());
2375 : Isolate* isolate = HeapObject::cast(this)->GetIsolate();
2376 : if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
2377 : IsUndefined(isolate) || IsTrue(isolate) || IsFalse(isolate) ||
2378 : IsNull(isolate))) {
2379 : FATAL("API call returned invalid object");
2380 : }
2381 : #endif // DEBUG
2382 : }
2383 :
2384 :
2385 135385520 : Object* FixedArray::get(int index) const {
2386 : SLOW_DCHECK(index >= 0 && index < this->length());
2387 23466094969 : return NOBARRIER_READ_FIELD(this, kHeaderSize + index * kPointerSize);
2388 : }
2389 :
2390 13135713 : Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) {
2391 13135714 : return handle(array->get(index), isolate);
2392 : }
2393 :
2394 : template <class T>
2395 4882075 : MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const {
2396 : Object* obj = get(index);
2397 4882079 : if (obj->IsUndefined(isolate)) return MaybeHandle<T>();
2398 : return Handle<T>(T::cast(obj), isolate);
2399 : }
2400 :
2401 : template <class T>
2402 331820 : Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const {
2403 : Object* obj = get(index);
2404 331820 : CHECK(!obj->IsUndefined(isolate));
2405 331820 : return Handle<T>(T::cast(obj), isolate);
2406 : }
2407 636029439 : bool FixedArray::is_the_hole(Isolate* isolate, int index) {
2408 636029439 : return get(index)->IsTheHole(isolate);
2409 : }
2410 :
2411 6294309 : void FixedArray::set(int index, Smi* value) {
2412 : DCHECK(map() != GetHeap()->fixed_cow_array_map());
2413 : DCHECK(index >= 0 && index < this->length());
2414 : DCHECK(reinterpret_cast<Object*>(value)->IsSmi());
2415 927414047 : int offset = kHeaderSize + index * kPointerSize;
2416 1210139051 : NOBARRIER_WRITE_FIELD(this, offset, value);
2417 6294309 : }
2418 :
2419 :
2420 1267402652 : void FixedArray::set(int index, Object* value) {
2421 : DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
2422 : DCHECK(IsFixedArray());
2423 : DCHECK_GE(index, 0);
2424 : DCHECK_LT(index, this->length());
2425 1267402652 : int offset = kHeaderSize + index * kPointerSize;
2426 1267402652 : NOBARRIER_WRITE_FIELD(this, offset, value);
2427 2534805332 : WRITE_BARRIER(GetHeap(), this, offset, value);
2428 1267402638 : }
2429 :
2430 :
2431 1088004 : double FixedDoubleArray::get_scalar(int index) {
2432 : DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2433 : map() != GetHeap()->fixed_array_map());
2434 : DCHECK(index >= 0 && index < this->length());
2435 : DCHECK(!is_the_hole(index));
2436 15461556 : return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
2437 : }
2438 :
2439 :
2440 : uint64_t FixedDoubleArray::get_representation(int index) {
2441 : DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2442 : map() != GetHeap()->fixed_array_map());
2443 : DCHECK(index >= 0 && index < this->length());
2444 28953458 : int offset = kHeaderSize + index * kDoubleSize;
2445 28953458 : return READ_UINT64_FIELD(this, offset);
2446 : }
2447 :
2448 14439798 : Handle<Object> FixedDoubleArray::get(FixedDoubleArray* array, int index,
2449 : Isolate* isolate) {
2450 14439798 : if (array->is_the_hole(index)) {
2451 1306236 : return isolate->factory()->the_hole_value();
2452 : } else {
2453 13133562 : return isolate->factory()->NewNumber(array->get_scalar(index));
2454 : }
2455 : }
2456 :
2457 :
2458 34897920 : void FixedDoubleArray::set(int index, double value) {
2459 : DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2460 : map() != GetHeap()->fixed_array_map());
2461 46341632 : int offset = kHeaderSize + index * kDoubleSize;
2462 46341632 : if (std::isnan(value)) {
2463 183640 : WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN());
2464 : } else {
2465 46157992 : WRITE_DOUBLE_FIELD(this, offset, value);
2466 : }
2467 : DCHECK(!is_the_hole(index));
2468 34897920 : }
2469 :
2470 : void FixedDoubleArray::set_the_hole(Isolate* isolate, int index) {
2471 : set_the_hole(index);
2472 : }
2473 :
2474 : void FixedDoubleArray::set_the_hole(int index) {
2475 : DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2476 : map() != GetHeap()->fixed_array_map());
2477 47257346 : int offset = kHeaderSize + index * kDoubleSize;
2478 47257346 : WRITE_UINT64_FIELD(this, offset, kHoleNanInt64);
2479 : }
2480 :
2481 : bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) {
2482 : return is_the_hole(index);
2483 : }
2484 :
2485 : bool FixedDoubleArray::is_the_hole(int index) {
2486 : return get_representation(index) == kHoleNanInt64;
2487 : }
2488 :
2489 :
2490 : double* FixedDoubleArray::data_start() {
2491 : return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
2492 : }
2493 :
2494 :
2495 : void FixedDoubleArray::FillWithHoles(int from, int to) {
2496 1089217 : for (int i = from; i < to; i++) {
2497 : set_the_hole(i);
2498 : }
2499 : }
2500 :
2501 :
2502 81463437 : Object* WeakFixedArray::Get(int index) const {
2503 81463437 : Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2504 81463437 : if (raw->IsSmi()) return raw;
2505 : DCHECK(raw->IsWeakCell());
2506 67406353 : return WeakCell::cast(raw)->value();
2507 : }
2508 :
2509 :
2510 : bool WeakFixedArray::IsEmptySlot(int index) const {
2511 : DCHECK(index < Length());
2512 57574813 : return Get(index)->IsSmi();
2513 : }
2514 :
2515 :
2516 : void WeakFixedArray::Clear(int index) {
2517 : FixedArray::cast(this)->set(index + kFirstIndex, Smi::kZero);
2518 : }
2519 :
2520 :
2521 : int WeakFixedArray::Length() const {
2522 31130118 : return FixedArray::cast(this)->length() - kFirstIndex;
2523 : }
2524 :
2525 :
2526 : int WeakFixedArray::last_used_index() const {
2527 : return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value();
2528 : }
2529 :
2530 :
2531 : void WeakFixedArray::set_last_used_index(int index) {
2532 : FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index));
2533 : }
2534 :
2535 :
2536 : template <class T>
2537 23791470 : T* WeakFixedArray::Iterator::Next() {
2538 23791470 : if (list_ != NULL) {
2539 : // Assert that list did not change during iteration.
2540 : DCHECK_EQ(last_used_index_, list_->last_used_index());
2541 34547286 : while (index_ < list_->Length()) {
2542 17053117 : Object* item = list_->Get(index_++);
2543 17053117 : if (item != Empty()) return T::cast(item);
2544 : }
2545 220526 : list_ = NULL;
2546 : }
2547 : return NULL;
2548 : }
2549 :
2550 2074374 : int ArrayList::Length() const {
2551 2074374 : if (FixedArray::cast(this)->length() == 0) return 0;
2552 2056532 : return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
2553 : }
2554 :
2555 :
2556 : void ArrayList::SetLength(int length) {
2557 : return FixedArray::cast(this)->set(kLengthIndex, Smi::FromInt(length));
2558 : }
2559 :
2560 : Object* ArrayList::Get(int index) const {
2561 1984721 : return FixedArray::cast(this)->get(kFirstIndex + index);
2562 : }
2563 :
2564 :
2565 : Object** ArrayList::Slot(int index) {
2566 1339666 : return data_start() + kFirstIndex + index;
2567 : }
2568 :
2569 : void ArrayList::Set(int index, Object* obj, WriteBarrierMode mode) {
2570 3273145 : FixedArray::cast(this)->set(kFirstIndex + index, obj, mode);
2571 : }
2572 :
2573 :
2574 : void ArrayList::Clear(int index, Object* undefined) {
2575 : DCHECK(undefined->IsUndefined(GetIsolate()));
2576 : FixedArray::cast(this)
2577 13598 : ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER);
2578 : }
2579 :
2580 445 : int RegExpMatchInfo::NumberOfCaptureRegisters() {
2581 : DCHECK_GE(length(), kLastMatchOverhead);
2582 : Object* obj = get(kNumberOfCapturesIndex);
2583 445 : return Smi::cast(obj)->value();
2584 : }
2585 :
2586 : void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
2587 : DCHECK_GE(length(), kLastMatchOverhead);
2588 : set(kNumberOfCapturesIndex, Smi::FromInt(value));
2589 : }
2590 :
2591 : String* RegExpMatchInfo::LastSubject() {
2592 : DCHECK_GE(length(), kLastMatchOverhead);
2593 : Object* obj = get(kLastSubjectIndex);
2594 : return String::cast(obj);
2595 : }
2596 :
2597 : void RegExpMatchInfo::SetLastSubject(String* value) {
2598 : DCHECK_GE(length(), kLastMatchOverhead);
2599 590141 : set(kLastSubjectIndex, value);
2600 : }
2601 :
2602 : Object* RegExpMatchInfo::LastInput() {
2603 : DCHECK_GE(length(), kLastMatchOverhead);
2604 : return get(kLastInputIndex);
2605 : }
2606 :
2607 : void RegExpMatchInfo::SetLastInput(Object* value) {
2608 : DCHECK_GE(length(), kLastMatchOverhead);
2609 590212 : set(kLastInputIndex, value);
2610 : }
2611 :
2612 890 : int RegExpMatchInfo::Capture(int i) {
2613 : DCHECK_LT(i, NumberOfCaptureRegisters());
2614 844228 : Object* obj = get(kFirstCaptureIndex + i);
2615 890 : return Smi::cast(obj)->value();
2616 : }
2617 :
2618 : void RegExpMatchInfo::SetCapture(int i, int value) {
2619 : DCHECK_LT(i, NumberOfCaptureRegisters());
2620 : set(kFirstCaptureIndex + i, Smi::FromInt(value));
2621 : }
2622 :
2623 84547900 : WriteBarrierMode HeapObject::GetWriteBarrierMode(
2624 : const DisallowHeapAllocation& promise) {
2625 84547900 : Heap* heap = GetHeap();
2626 84547907 : if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2627 81754264 : if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
2628 : return UPDATE_WRITE_BARRIER;
2629 : }
2630 :
2631 :
2632 : AllocationAlignment HeapObject::RequiredAlignment() {
2633 : #ifdef V8_HOST_ARCH_32_BIT
2634 : if ((IsFixedFloat64Array() || IsFixedDoubleArray()) &&
2635 : FixedArrayBase::cast(this)->length() != 0) {
2636 : return kDoubleAligned;
2637 : }
2638 : if (IsHeapNumber()) return kDoubleUnaligned;
2639 : #endif // V8_HOST_ARCH_32_BIT
2640 : return kWordAligned;
2641 : }
2642 :
2643 :
2644 1464816528 : void FixedArray::set(int index,
2645 : Object* value,
2646 : WriteBarrierMode mode) {
2647 : DCHECK_NE(map(), GetHeap()->fixed_cow_array_map());
2648 : DCHECK_GE(index, 0);
2649 : DCHECK_LT(index, this->length());
2650 1464816528 : int offset = kHeaderSize + index * kPointerSize;
2651 1464816528 : NOBARRIER_WRITE_FIELD(this, offset, value);
2652 2340261225 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
2653 1464816541 : }
2654 :
2655 :
2656 : void FixedArray::NoWriteBarrierSet(FixedArray* array,
2657 : int index,
2658 : Object* value) {
2659 : DCHECK_NE(array->map(), array->GetHeap()->fixed_cow_array_map());
2660 : DCHECK_GE(index, 0);
2661 : DCHECK_LT(index, array->length());
2662 : DCHECK(!array->GetHeap()->InNewSpace(value));
2663 368244307 : NOBARRIER_WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value);
2664 : }
2665 :
2666 343690133 : void FixedArray::set_undefined(int index) {
2667 : set_undefined(GetIsolate(), index);
2668 343690133 : }
2669 :
2670 : void FixedArray::set_undefined(Isolate* isolate, int index) {
2671 : FixedArray::NoWriteBarrierSet(this, index,
2672 343692460 : isolate->heap()->undefined_value());
2673 : }
2674 :
2675 1642 : void FixedArray::set_null(int index) { set_null(GetIsolate(), index); }
2676 :
2677 : void FixedArray::set_null(Isolate* isolate, int index) {
2678 821 : FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->null_value());
2679 : }
2680 :
2681 972 : void FixedArray::set_the_hole(int index) { set_the_hole(GetIsolate(), index); }
2682 :
2683 : void FixedArray::set_the_hole(Isolate* isolate, int index) {
2684 24536977 : FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->the_hole_value());
2685 : }
2686 :
2687 1582049 : void FixedArray::FillWithHoles(int from, int to) {
2688 : Isolate* isolate = GetIsolate();
2689 13278545 : for (int i = from; i < to; i++) {
2690 : set_the_hole(isolate, i);
2691 : }
2692 1582049 : }
2693 :
2694 :
2695 0 : Object** FixedArray::data_start() {
2696 0 : return HeapObject::RawField(this, kHeaderSize);
2697 : }
2698 :
2699 :
2700 : Object** FixedArray::RawFieldOfElementAt(int index) {
2701 : return HeapObject::RawField(this, OffsetOfElementAt(index));
2702 : }
2703 :
2704 : bool DescriptorArray::IsEmpty() {
2705 : DCHECK(length() >= kFirstIndex ||
2706 : this == GetHeap()->empty_descriptor_array());
2707 : return length() < kFirstIndex;
2708 : }
2709 :
2710 :
2711 125999356 : int DescriptorArray::number_of_descriptors() {
2712 : DCHECK(length() >= kFirstIndex || IsEmpty());
2713 : int len = length();
2714 251998712 : return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value();
2715 : }
2716 :
2717 :
2718 : int DescriptorArray::number_of_descriptors_storage() {
2719 : int len = length();
2720 15376286 : return len == 0 ? 0 : (len - kFirstIndex) / kEntrySize;
2721 : }
2722 :
2723 :
2724 15361513 : int DescriptorArray::NumberOfSlackDescriptors() {
2725 15361513 : return number_of_descriptors_storage() - number_of_descriptors();
2726 : }
2727 :
2728 :
2729 : void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) {
2730 : WRITE_FIELD(
2731 14275674 : this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors));
2732 : }
2733 :
2734 :
2735 : inline int DescriptorArray::number_of_entries() {
2736 33042169 : return number_of_descriptors();
2737 : }
2738 :
2739 :
2740 22036671 : bool DescriptorArray::HasEnumCache() {
2741 42631030 : return !IsEmpty() && !get(kEnumCacheIndex)->IsSmi();
2742 : }
2743 :
2744 :
2745 36845 : void DescriptorArray::CopyEnumCacheFrom(DescriptorArray* array) {
2746 36845 : set(kEnumCacheIndex, array->get(kEnumCacheIndex));
2747 36845 : }
2748 :
2749 :
2750 14716029 : FixedArray* DescriptorArray::GetEnumCache() {
2751 : DCHECK(HasEnumCache());
2752 : FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex));
2753 14716029 : return FixedArray::cast(bridge->get(kEnumCacheBridgeCacheIndex));
2754 : }
2755 :
2756 :
2757 12128 : bool DescriptorArray::HasEnumIndicesCache() {
2758 12128 : if (IsEmpty()) return false;
2759 : Object* object = get(kEnumCacheIndex);
2760 12128 : if (object->IsSmi()) return false;
2761 : FixedArray* bridge = FixedArray::cast(object);
2762 12128 : return !bridge->get(kEnumCacheBridgeIndicesCacheIndex)->IsSmi();
2763 : }
2764 :
2765 :
2766 12121 : FixedArray* DescriptorArray::GetEnumIndicesCache() {
2767 : DCHECK(HasEnumIndicesCache());
2768 : FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex));
2769 12121 : return FixedArray::cast(bridge->get(kEnumCacheBridgeIndicesCacheIndex));
2770 : }
2771 :
2772 :
2773 : Object** DescriptorArray::GetEnumCacheSlot() {
2774 : DCHECK(HasEnumCache());
2775 : return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
2776 : kEnumCacheOffset);
2777 : }
2778 :
2779 : // Perform a binary search in a fixed array.
2780 : template <SearchMode search_mode, typename T>
2781 43415927 : int BinarySearch(T* array, Name* name, int valid_entries,
2782 : int* out_insertion_index) {
2783 : DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == NULL);
2784 : int low = 0;
2785 43415933 : int high = array->number_of_entries() - 1;
2786 : uint32_t hash = name->hash_field();
2787 : int limit = high;
2788 :
2789 : DCHECK(low <= high);
2790 :
2791 273941791 : while (low != high) {
2792 187109931 : int mid = low + (high - low) / 2;
2793 143294394 : Name* mid_name = array->GetSortedKey(mid);
2794 : uint32_t mid_hash = mid_name->hash_field();
2795 :
2796 187109925 : if (mid_hash >= hash) {
2797 : high = mid;
2798 : } else {
2799 97073216 : low = mid + 1;
2800 : }
2801 : }
2802 :
2803 0 : for (; low <= limit; ++low) {
2804 : int sort_index = array->GetSortedKeyIndex(low);
2805 : Name* entry = array->GetKey(sort_index);
2806 : uint32_t current_hash = entry->hash_field();
2807 43415927 : if (current_hash != hash) {
2808 299759 : if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
2809 131760 : *out_insertion_index = sort_index + (current_hash > hash ? 0 : 1);
2810 : }
2811 : return T::kNotFound;
2812 : }
2813 26567263 : if (entry == name) {
2814 16493264 : if (search_mode == ALL_ENTRIES || sort_index < valid_entries) {
2815 16049466 : return sort_index;
2816 : }
2817 : return T::kNotFound;
2818 : }
2819 : }
2820 :
2821 0 : if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
2822 0 : *out_insertion_index = limit + 1;
2823 : }
2824 : return T::kNotFound;
2825 : }
2826 :
2827 :
2828 : // Perform a linear search in this fixed array. len is the number of entry
2829 : // indices that are valid.
2830 : template <SearchMode search_mode, typename T>
2831 88030890 : int LinearSearch(T* array, Name* name, int valid_entries,
2832 : int* out_insertion_index) {
2833 14269614 : if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
2834 : uint32_t hash = name->hash_field();
2835 : int len = array->number_of_entries();
2836 1883620 : for (int number = 0; number < len; number++) {
2837 : int sorted_index = array->GetSortedKeyIndex(number);
2838 : Name* entry = array->GetKey(sorted_index);
2839 : uint32_t current_hash = entry->hash_field();
2840 1698742 : if (current_hash > hash) {
2841 318923 : *out_insertion_index = sorted_index;
2842 318923 : return T::kNotFound;
2843 : }
2844 1379819 : if (entry == name) return sorted_index;
2845 : }
2846 184878 : *out_insertion_index = len;
2847 184878 : return T::kNotFound;
2848 : } else {
2849 : DCHECK_LE(valid_entries, array->number_of_entries());
2850 : DCHECK_NULL(out_insertion_index); // Not supported here.
2851 205167066 : for (int number = 0; number < valid_entries; number++) {
2852 252904345 : if (array->GetKey(number) == name) return number;
2853 : }
2854 : return T::kNotFound;
2855 : }
2856 : }
2857 :
2858 :
2859 : template <SearchMode search_mode, typename T>
2860 132968263 : int Search(T* array, Name* name, int valid_entries, int* out_insertion_index) {
2861 : SLOW_DCHECK(array->IsSortedNoDuplicates());
2862 :
2863 132968263 : if (valid_entries == 0) {
2864 191448 : if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
2865 188093 : *out_insertion_index = 0;
2866 : }
2867 : return T::kNotFound;
2868 : }
2869 :
2870 : // Fast case: do linear search for small arrays.
2871 : const int kMaxElementsForLinearSearch = 8;
2872 132776829 : if (valid_entries <= kMaxElementsForLinearSearch) {
2873 : return LinearSearch<search_mode>(array, name, valid_entries,
2874 88030891 : out_insertion_index);
2875 : }
2876 :
2877 : // Slow case: perform binary search.
2878 : return BinarySearch<search_mode>(array, name, valid_entries,
2879 44745938 : out_insertion_index);
2880 : }
2881 :
2882 :
2883 : int DescriptorArray::Search(Name* name, int valid_descriptors) {
2884 : DCHECK(name->IsUniqueName());
2885 108133443 : return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors, NULL);
2886 : }
2887 :
2888 299935168 : int DescriptorArray::SearchWithCache(Isolate* isolate, Name* name, Map* map) {
2889 : DCHECK(name->IsUniqueName());
2890 327914137 : int number_of_own_descriptors = map->NumberOfOwnDescriptors();
2891 327914170 : if (number_of_own_descriptors == 0) return kNotFound;
2892 :
2893 299935168 : DescriptorLookupCache* cache = isolate->descriptor_lookup_cache();
2894 299935173 : int number = cache->Lookup(map, name);
2895 :
2896 299935171 : if (number == DescriptorLookupCache::kAbsent) {
2897 : number = Search(name, number_of_own_descriptors);
2898 108133427 : cache->Update(map, name, number);
2899 : }
2900 :
2901 : return number;
2902 : }
2903 :
2904 : PropertyDetails Map::GetLastDescriptorDetails() {
2905 135427884 : return instance_descriptors()->GetDetails(LastAdded());
2906 : }
2907 :
2908 :
2909 : int Map::LastAdded() {
2910 : int number_of_own_descriptors = NumberOfOwnDescriptors();
2911 : DCHECK(number_of_own_descriptors > 0);
2912 237843085 : return number_of_own_descriptors - 1;
2913 : }
2914 :
2915 :
2916 329578767 : int Map::NumberOfOwnDescriptors() {
2917 329578767 : return NumberOfOwnDescriptorsBits::decode(bit_field3());
2918 : }
2919 :
2920 :
2921 : void Map::SetNumberOfOwnDescriptors(int number) {
2922 : DCHECK(number <= instance_descriptors()->number_of_descriptors());
2923 : set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number));
2924 : }
2925 :
2926 :
2927 19870 : int Map::EnumLength() { return EnumLengthBits::decode(bit_field3()); }
2928 :
2929 :
2930 : void Map::SetEnumLength(int length) {
2931 : if (length != kInvalidEnumCacheSentinel) {
2932 : DCHECK(length >= 0);
2933 : DCHECK(length == 0 || instance_descriptors()->HasEnumCache());
2934 : DCHECK(length <= NumberOfOwnDescriptors());
2935 : }
2936 : set_bit_field3(EnumLengthBits::update(bit_field3(), length));
2937 : }
2938 :
2939 :
2940 75754321 : FixedArrayBase* Map::GetInitialElements() {
2941 : FixedArrayBase* result = nullptr;
2942 75754321 : if (has_fast_elements() || has_fast_string_wrapper_elements()) {
2943 75750435 : result = GetHeap()->empty_fixed_array();
2944 3886 : } else if (has_fast_sloppy_arguments_elements()) {
2945 0 : result = GetHeap()->empty_sloppy_arguments_elements();
2946 3886 : } else if (has_fixed_typed_array_elements()) {
2947 0 : result = GetHeap()->EmptyFixedTypedArrayForMap(this);
2948 : } else {
2949 0 : UNREACHABLE();
2950 : }
2951 : DCHECK(!GetHeap()->InNewSpace(result));
2952 75754321 : return result;
2953 : }
2954 :
2955 : Object** DescriptorArray::GetKeySlot(int descriptor_number) {
2956 : DCHECK(descriptor_number < number_of_descriptors());
2957 : return RawFieldOfElementAt(ToKeyIndex(descriptor_number));
2958 : }
2959 :
2960 :
2961 : Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) {
2962 : return GetKeySlot(descriptor_number);
2963 : }
2964 :
2965 :
2966 : Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) {
2967 22332733 : return GetValueSlot(descriptor_number - 1) + 1;
2968 : }
2969 :
2970 :
2971 1139128 : Name* DescriptorArray::GetKey(int descriptor_number) {
2972 : DCHECK(descriptor_number < number_of_descriptors());
2973 1139128 : return Name::cast(get(ToKeyIndex(descriptor_number)));
2974 : }
2975 :
2976 :
2977 : int DescriptorArray::GetSortedKeyIndex(int descriptor_number) {
2978 1101834646 : return GetDetails(descriptor_number).pointer();
2979 : }
2980 :
2981 :
2982 336985680 : Name* DescriptorArray::GetSortedKey(int descriptor_number) {
2983 336985683 : return GetKey(GetSortedKeyIndex(descriptor_number));
2984 : }
2985 :
2986 :
2987 202034643 : void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) {
2988 202034643 : PropertyDetails details = GetDetails(descriptor_index);
2989 : set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi());
2990 202034643 : }
2991 :
2992 :
2993 : Object** DescriptorArray::GetValueSlot(int descriptor_number) {
2994 : DCHECK(descriptor_number < number_of_descriptors());
2995 : return RawFieldOfElementAt(ToValueIndex(descriptor_number));
2996 : }
2997 :
2998 :
2999 : int DescriptorArray::GetValueOffset(int descriptor_number) {
3000 : return OffsetOfElementAt(ToValueIndex(descriptor_number));
3001 : }
3002 :
3003 :
3004 : Object* DescriptorArray::GetValue(int descriptor_number) {
3005 : DCHECK(descriptor_number < number_of_descriptors());
3006 : return get(ToValueIndex(descriptor_number));
3007 : }
3008 :
3009 :
3010 : void DescriptorArray::SetValue(int descriptor_index, Object* value) {
3011 5113417 : set(ToValueIndex(descriptor_index), value);
3012 : }
3013 :
3014 :
3015 2799428620 : PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
3016 : DCHECK(descriptor_number < number_of_descriptors());
3017 : Object* details = get(ToDetailsIndex(descriptor_number));
3018 2799428620 : return PropertyDetails(Smi::cast(details));
3019 : }
3020 :
3021 : int DescriptorArray::GetFieldIndex(int descriptor_number) {
3022 : DCHECK(GetDetails(descriptor_number).location() == kField);
3023 219174010 : return GetDetails(descriptor_number).field_index();
3024 : }
3025 :
3026 67468751 : FieldType* DescriptorArray::GetFieldType(int descriptor_number) {
3027 : DCHECK(GetDetails(descriptor_number).location() == kField);
3028 : Object* wrapped_type = GetValue(descriptor_number);
3029 67468751 : return Map::UnwrapFieldType(wrapped_type);
3030 : }
3031 :
3032 : void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
3033 : desc->Init(handle(GetKey(descriptor_number), GetIsolate()),
3034 : handle(GetValue(descriptor_number), GetIsolate()),
3035 : GetDetails(descriptor_number));
3036 : }
3037 :
3038 175184432 : void DescriptorArray::Set(int descriptor_number, Name* key, Object* value,
3039 : PropertyDetails details) {
3040 : // Range check.
3041 : DCHECK(descriptor_number < number_of_descriptors());
3042 175184432 : set(ToKeyIndex(descriptor_number), key);
3043 175184439 : set(ToValueIndex(descriptor_number), value);
3044 : set(ToDetailsIndex(descriptor_number), details.AsSmi());
3045 175184437 : }
3046 :
3047 20360095 : void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
3048 : Name* key = *desc->GetKey();
3049 : Object* value = *desc->GetValue();
3050 20360095 : Set(descriptor_number, key, value, desc->GetDetails());
3051 20360098 : }
3052 :
3053 :
3054 14261078 : void DescriptorArray::Append(Descriptor* desc) {
3055 : DisallowHeapAllocation no_gc;
3056 14261078 : int descriptor_number = number_of_descriptors();
3057 14261082 : SetNumberOfDescriptors(descriptor_number + 1);
3058 14261082 : Set(descriptor_number, desc);
3059 :
3060 : uint32_t hash = desc->GetKey()->Hash();
3061 :
3062 : int insertion;
3063 :
3064 190250110 : for (insertion = descriptor_number; insertion > 0; --insertion) {
3065 171348672 : Name* key = GetSortedKey(insertion - 1);
3066 171348674 : if (key->Hash() <= hash) break;
3067 161727946 : SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1));
3068 : }
3069 :
3070 14261083 : SetSortedKey(insertion, descriptor_number);
3071 14261082 : }
3072 :
3073 :
3074 11109057 : void DescriptorArray::SwapSortedKeys(int first, int second) {
3075 : int first_key = GetSortedKeyIndex(first);
3076 11109057 : SetSortedKey(first, GetSortedKeyIndex(second));
3077 11109057 : SetSortedKey(second, first_key);
3078 11109057 : }
3079 :
3080 :
3081 1444 : int HashTableBase::NumberOfElements() {
3082 1444 : return Smi::cast(get(kNumberOfElementsIndex))->value();
3083 : }
3084 :
3085 :
3086 : int HashTableBase::NumberOfDeletedElements() {
3087 : return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
3088 : }
3089 :
3090 :
3091 : int HashTableBase::Capacity() {
3092 : return Smi::cast(get(kCapacityIndex))->value();
3093 : }
3094 :
3095 :
3096 69360167 : void HashTableBase::ElementAdded() {
3097 69360167 : SetNumberOfElements(NumberOfElements() + 1);
3098 69360167 : }
3099 :
3100 :
3101 6190531 : void HashTableBase::ElementRemoved() {
3102 6190531 : SetNumberOfElements(NumberOfElements() - 1);
3103 6190531 : SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
3104 6190531 : }
3105 :
3106 :
3107 53611 : void HashTableBase::ElementsRemoved(int n) {
3108 53611 : SetNumberOfElements(NumberOfElements() - n);
3109 53611 : SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
3110 53611 : }
3111 :
3112 :
3113 : // static
3114 : int HashTableBase::ComputeCapacity(int at_least_space_for) {
3115 : // Add 50% slack to make slot collisions sufficiently unlikely.
3116 : // See matching computation in HashTable::HasSufficientCapacityToAdd().
3117 : // Must be kept in sync with CodeStubAssembler::HashTableComputeCapacity().
3118 8172602 : int raw_cap = at_least_space_for + (at_least_space_for >> 1);
3119 8172602 : int capacity = base::bits::RoundUpToPowerOfTwo32(raw_cap);
3120 : return Max(capacity, kMinCapacity);
3121 : }
3122 :
3123 4531 : bool HashTableBase::IsKey(Isolate* isolate, Object* k) {
3124 494835814 : Heap* heap = isolate->heap();
3125 494835814 : return k != heap->the_hole_value() && k != heap->undefined_value();
3126 : }
3127 :
3128 : void HashTableBase::SetNumberOfElements(int nof) {
3129 : set(kNumberOfElementsIndex, Smi::FromInt(nof));
3130 : }
3131 :
3132 :
3133 : void HashTableBase::SetNumberOfDeletedElements(int nod) {
3134 : set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
3135 : }
3136 :
3137 : template <typename Key>
3138 : Map* BaseShape<Key>::GetMap(Isolate* isolate) {
3139 7051348 : return isolate->heap()->hash_table_map();
3140 : }
3141 :
3142 : template <typename Derived, typename Shape, typename Key>
3143 0 : int HashTable<Derived, Shape, Key>::FindEntry(Key key) {
3144 114374261 : return FindEntry(GetIsolate(), key);
3145 : }
3146 :
3147 :
3148 : template<typename Derived, typename Shape, typename Key>
3149 262503307 : int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) {
3150 262503309 : return FindEntry(isolate, key, HashTable::Hash(key));
3151 : }
3152 :
3153 : // Find entry for key otherwise return kNotFound.
3154 : template <typename Derived, typename Shape, typename Key>
3155 278595105 : int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
3156 : int32_t hash) {
3157 278595105 : uint32_t capacity = Capacity();
3158 278595105 : uint32_t entry = FirstProbe(hash, capacity);
3159 : uint32_t count = 1;
3160 : // EnsureCapacity will guarantee the hash table is never full.
3161 278595105 : Object* undefined = isolate->heap()->undefined_value();
3162 278595105 : Object* the_hole = isolate->heap()->the_hole_value();
3163 : while (true) {
3164 478398704 : Object* element = KeyAt(entry);
3165 : // Empty entry. Uses raw unchecked accessors because it is called by the
3166 : // string table during bootstrapping.
3167 478398704 : if (element == undefined) break;
3168 585119049 : if (element != the_hole && Shape::IsMatch(key, element)) return entry;
3169 199803599 : entry = NextProbe(entry, count++, capacity);
3170 : }
3171 199803599 : return kNotFound;
3172 : }
3173 :
3174 : template <typename Derived, typename Shape, typename Key>
3175 1818 : bool HashTable<Derived, Shape, Key>::Has(Key key) {
3176 1818 : return FindEntry(key) != kNotFound;
3177 : }
3178 :
3179 : template <typename Derived, typename Shape, typename Key>
3180 0 : bool HashTable<Derived, Shape, Key>::Has(Isolate* isolate, Key key) {
3181 0 : return FindEntry(isolate, key) != kNotFound;
3182 : }
3183 :
3184 : bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key, int32_t hash) {
3185 16034291 : return FindEntry(isolate, key, hash) != kNotFound;
3186 : }
3187 :
3188 16135 : bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key) {
3189 16135 : Object* hash = key->GetHash();
3190 16135 : if (!hash->IsSmi()) return false;
3191 16135 : return FindEntry(isolate, key, Smi::cast(hash)->value()) != kNotFound;
3192 : }
3193 :
3194 2511675 : bool StringSetShape::IsMatch(String* key, Object* value) {
3195 2511675 : return value->IsString() && key->Equals(String::cast(value));
3196 : }
3197 :
3198 : uint32_t StringSetShape::Hash(String* key) { return key->Hash(); }
3199 :
3200 24106 : uint32_t StringSetShape::HashForObject(String* key, Object* object) {
3201 48212 : return object->IsString() ? String::cast(object)->Hash() : 0;
3202 : }
3203 :
3204 8246987 : bool SeededNumberDictionary::requires_slow_elements() {
3205 : Object* max_index_object = get(kMaxNumberKeyIndex);
3206 8246987 : if (!max_index_object->IsSmi()) return false;
3207 : return 0 !=
3208 7772696 : (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask);
3209 : }
3210 :
3211 :
3212 6616350 : uint32_t SeededNumberDictionary::max_number_key() {
3213 : DCHECK(!requires_slow_elements());
3214 : Object* max_index_object = get(kMaxNumberKeyIndex);
3215 6616350 : if (!max_index_object->IsSmi()) return 0;
3216 6612680 : uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value());
3217 6612680 : return value >> kRequiresSlowElementsTagSize;
3218 : }
3219 :
3220 :
3221 : void SeededNumberDictionary::set_requires_slow_elements() {
3222 : set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
3223 : }
3224 :
3225 :
3226 : template <class T>
3227 : PodArray<T>* PodArray<T>::cast(Object* object) {
3228 : SLOW_DCHECK(object->IsByteArray());
3229 : return reinterpret_cast<PodArray<T>*>(object);
3230 : }
3231 : template <class T>
3232 : const PodArray<T>* PodArray<T>::cast(const Object* object) {
3233 : SLOW_DCHECK(object->IsByteArray());
3234 : return reinterpret_cast<const PodArray<T>*>(object);
3235 : }
3236 :
3237 : // static
3238 : template <class T>
3239 : Handle<PodArray<T>> PodArray<T>::New(Isolate* isolate, int length,
3240 : PretenureFlag pretenure) {
3241 : return Handle<PodArray<T>>::cast(
3242 27524 : isolate->factory()->NewByteArray(length * sizeof(T), pretenure));
3243 : }
3244 :
3245 : // static
3246 : template <class Traits>
3247 : STATIC_CONST_MEMBER_DEFINITION const InstanceType
3248 : FixedTypedArray<Traits>::kInstanceType;
3249 :
3250 :
3251 : template <class Traits>
3252 : FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
3253 : SLOW_DCHECK(object->IsHeapObject() &&
3254 : HeapObject::cast(object)->map()->instance_type() ==
3255 : Traits::kInstanceType);
3256 : return reinterpret_cast<FixedTypedArray<Traits>*>(object);
3257 : }
3258 :
3259 :
3260 : template <class Traits>
3261 : const FixedTypedArray<Traits>*
3262 : FixedTypedArray<Traits>::cast(const Object* object) {
3263 : SLOW_DCHECK(object->IsHeapObject() &&
3264 : HeapObject::cast(object)->map()->instance_type() ==
3265 : Traits::kInstanceType);
3266 : return reinterpret_cast<FixedTypedArray<Traits>*>(object);
3267 : }
3268 :
3269 :
3270 : #define DEFINE_DEOPT_ELEMENT_ACCESSORS(name, type) \
3271 : type* DeoptimizationInputData::name() { \
3272 : return type::cast(get(k##name##Index)); \
3273 : } \
3274 : void DeoptimizationInputData::Set##name(type* value) { \
3275 : set(k##name##Index, value); \
3276 : }
3277 :
3278 670855 : DEFINE_DEOPT_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
3279 : DEFINE_DEOPT_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
3280 670855 : DEFINE_DEOPT_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
3281 : DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrAstId, Smi)
3282 16786 : DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
3283 : DEFINE_DEOPT_ELEMENT_ACCESSORS(OptimizationId, Smi)
3284 1093020 : DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
3285 613072 : DEFINE_DEOPT_ELEMENT_ACCESSORS(WeakCellCache, Object)
3286 670853 : DEFINE_DEOPT_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>)
3287 :
3288 : #undef DEFINE_DEOPT_ELEMENT_ACCESSORS
3289 :
3290 :
3291 : #define DEFINE_DEOPT_ENTRY_ACCESSORS(name, type) \
3292 : type* DeoptimizationInputData::name(int i) { \
3293 : return type::cast(get(IndexForEntry(i) + k##name##Offset)); \
3294 : } \
3295 : void DeoptimizationInputData::Set##name(int i, type* value) { \
3296 : set(IndexForEntry(i) + k##name##Offset, value); \
3297 : }
3298 :
3299 13491850 : DEFINE_DEOPT_ENTRY_ACCESSORS(AstIdRaw, Smi)
3300 18849367 : DEFINE_DEOPT_ENTRY_ACCESSORS(TranslationIndex, Smi)
3301 13865590 : DEFINE_DEOPT_ENTRY_ACCESSORS(ArgumentsStackHeight, Smi)
3302 36570290 : DEFINE_DEOPT_ENTRY_ACCESSORS(Pc, Smi)
3303 :
3304 : #undef DEFINE_DEOPT_ENTRY_ACCESSORS
3305 :
3306 :
3307 155604 : BailoutId DeoptimizationInputData::AstId(int i) {
3308 155604 : return BailoutId(AstIdRaw(i)->value());
3309 : }
3310 :
3311 :
3312 : void DeoptimizationInputData::SetAstId(int i, BailoutId value) {
3313 6745924 : SetAstIdRaw(i, Smi::FromInt(value.ToInt()));
3314 : }
3315 :
3316 :
3317 : int DeoptimizationInputData::DeoptCount() {
3318 5129829 : return (length() - kFirstDeoptEntryIndex) / kDeoptEntrySize;
3319 : }
3320 :
3321 :
3322 570503 : int DeoptimizationOutputData::DeoptPoints() { return length() / 2; }
3323 :
3324 :
3325 24903103 : BailoutId DeoptimizationOutputData::AstId(int index) {
3326 49806206 : return BailoutId(Smi::cast(get(index * 2))->value());
3327 : }
3328 :
3329 :
3330 8420349 : void DeoptimizationOutputData::SetAstId(int index, BailoutId id) {
3331 8420349 : set(index * 2, Smi::FromInt(id.ToInt()));
3332 8420349 : }
3333 :
3334 :
3335 : Smi* DeoptimizationOutputData::PcAndState(int index) {
3336 570503 : return Smi::cast(get(1 + index * 2));
3337 : }
3338 :
3339 :
3340 : void DeoptimizationOutputData::SetPcAndState(int index, Smi* offset) {
3341 8420349 : set(1 + index * 2, offset);
3342 : }
3343 :
3344 : int HandlerTable::GetRangeStart(int index) const {
3345 1522708 : return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value();
3346 : }
3347 :
3348 38737 : int HandlerTable::GetRangeEnd(int index) const {
3349 77474 : return Smi::cast(get(index * kRangeEntrySize + kRangeEndIndex))->value();
3350 : }
3351 :
3352 38737 : int HandlerTable::GetRangeHandler(int index) const {
3353 : return HandlerOffsetField::decode(
3354 116211 : Smi::cast(get(index * kRangeEntrySize + kRangeHandlerIndex))->value());
3355 : }
3356 :
3357 38737 : int HandlerTable::GetRangeData(int index) const {
3358 77474 : return Smi::cast(get(index * kRangeEntrySize + kRangeDataIndex))->value();
3359 : }
3360 :
3361 176509 : void HandlerTable::SetRangeStart(int index, int value) {
3362 176509 : set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value));
3363 176509 : }
3364 :
3365 :
3366 176509 : void HandlerTable::SetRangeEnd(int index, int value) {
3367 176509 : set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value));
3368 176509 : }
3369 :
3370 :
3371 176509 : void HandlerTable::SetRangeHandler(int index, int offset,
3372 : CatchPrediction prediction) {
3373 176509 : int value = HandlerOffsetField::encode(offset) |
3374 176509 : HandlerPredictionField::encode(prediction);
3375 176509 : set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value));
3376 176509 : }
3377 :
3378 176509 : void HandlerTable::SetRangeData(int index, int value) {
3379 176509 : set(index * kRangeEntrySize + kRangeDataIndex, Smi::FromInt(value));
3380 176509 : }
3381 :
3382 :
3383 229725 : void HandlerTable::SetReturnOffset(int index, int value) {
3384 229725 : set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value));
3385 229725 : }
3386 :
3387 229725 : void HandlerTable::SetReturnHandler(int index, int offset) {
3388 229725 : int value = HandlerOffsetField::encode(offset);
3389 229725 : set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value));
3390 229725 : }
3391 :
3392 : int HandlerTable::NumberOfRangeEntries() const {
3393 14329222 : return length() / kRangeEntrySize;
3394 : }
3395 :
3396 : template <typename Derived, typename Shape, typename Key>
3397 : HashTable<Derived, Shape, Key>*
3398 0 : HashTable<Derived, Shape, Key>::cast(Object* obj) {
3399 : SLOW_DCHECK(obj->IsHashTable());
3400 0 : return reinterpret_cast<HashTable*>(obj);
3401 : }
3402 :
3403 :
3404 : template <typename Derived, typename Shape, typename Key>
3405 : const HashTable<Derived, Shape, Key>*
3406 0 : HashTable<Derived, Shape, Key>::cast(const Object* obj) {
3407 : SLOW_DCHECK(obj->IsHashTable());
3408 0 : return reinterpret_cast<const HashTable*>(obj);
3409 : }
3410 :
3411 :
3412 2045286580 : SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3413 372133979 : SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3414 :
3415 2262765 : SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
3416 146411703 : NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
3417 :
3418 25747488476 : SMI_ACCESSORS(String, length, kLengthOffset)
3419 469474131 : SYNCHRONIZED_SMI_ACCESSORS(String, length, kLengthOffset)
3420 :
3421 :
3422 : int FreeSpace::Size() { return size(); }
3423 :
3424 :
3425 : FreeSpace* FreeSpace::next() {
3426 : DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
3427 : (!GetHeap()->deserialization_complete() && map() == NULL));
3428 : DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
3429 : return reinterpret_cast<FreeSpace*>(
3430 2375857 : Memory::Address_at(address() + kNextOffset));
3431 : }
3432 :
3433 :
3434 : void FreeSpace::set_next(FreeSpace* next) {
3435 : DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
3436 : (!GetHeap()->deserialization_complete() && map() == NULL));
3437 : DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
3438 : base::NoBarrier_Store(
3439 : reinterpret_cast<base::AtomicWord*>(address() + kNextOffset),
3440 35108610 : reinterpret_cast<base::AtomicWord>(next));
3441 : }
3442 :
3443 :
3444 4198 : FreeSpace* FreeSpace::cast(HeapObject* o) {
3445 : SLOW_DCHECK(!o->GetHeap()->deserialization_complete() || o->IsFreeSpace());
3446 4198 : return reinterpret_cast<FreeSpace*>(o);
3447 : }
3448 :
3449 :
3450 66085 : uint32_t Name::hash_field() {
3451 1546233852 : return READ_UINT32_FIELD(this, kHashFieldOffset);
3452 : }
3453 :
3454 :
3455 : void Name::set_hash_field(uint32_t value) {
3456 258543202 : WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
3457 : #if V8_HOST_ARCH_64_BIT
3458 : #if V8_TARGET_LITTLE_ENDIAN
3459 258543202 : WRITE_UINT32_FIELD(this, kHashFieldSlot + kIntSize, 0);
3460 : #else
3461 : WRITE_UINT32_FIELD(this, kHashFieldSlot, 0);
3462 : #endif
3463 : #endif
3464 : }
3465 :
3466 :
3467 143793 : bool Name::Equals(Name* other) {
3468 143793 : if (other == this) return true;
3469 188471 : if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
3470 94567 : this->IsSymbol() || other->IsSymbol()) {
3471 : return false;
3472 : }
3473 15 : return String::cast(this)->SlowEquals(String::cast(other));
3474 : }
3475 :
3476 :
3477 1401030 : bool Name::Equals(Handle<Name> one, Handle<Name> two) {
3478 1401030 : if (one.is_identical_to(two)) return true;
3479 2284252 : if ((one->IsInternalizedString() && two->IsInternalizedString()) ||
3480 1142156 : one->IsSymbol() || two->IsSymbol()) {
3481 : return false;
3482 : }
3483 : return String::SlowEquals(Handle<String>::cast(one),
3484 30 : Handle<String>::cast(two));
3485 : }
3486 :
3487 :
3488 1505159 : ACCESSORS(Symbol, name, Object, kNameOffset)
3489 42926480 : SMI_ACCESSORS(Symbol, flags, kFlagsOffset)
3490 2240 : BOOL_ACCESSORS(Symbol, flags, is_private, kPrivateBit)
3491 : BOOL_ACCESSORS(Symbol, flags, is_well_known_symbol, kWellKnownSymbolBit)
3492 : BOOL_ACCESSORS(Symbol, flags, is_public, kPublicBit)
3493 :
3494 132151924 : bool String::Equals(String* other) {
3495 132151924 : if (other == this) return true;
3496 217702054 : if (this->IsInternalizedString() && other->IsInternalizedString()) {
3497 : return false;
3498 : }
3499 35260274 : return SlowEquals(other);
3500 : }
3501 :
3502 :
3503 7223046 : bool String::Equals(Handle<String> one, Handle<String> two) {
3504 7223046 : if (one.is_identical_to(two)) return true;
3505 7768020 : if (one->IsInternalizedString() && two->IsInternalizedString()) {
3506 : return false;
3507 : }
3508 6240760 : return SlowEquals(one, two);
3509 : }
3510 :
3511 :
3512 81636753 : Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) {
3513 81636752 : if (string->IsConsString()) {
3514 : Handle<ConsString> cons = Handle<ConsString>::cast(string);
3515 6153984 : if (cons->IsFlat()) {
3516 : string = handle(cons->first());
3517 : } else {
3518 5838673 : return SlowFlatten(cons, pretenure);
3519 : }
3520 : }
3521 75798072 : if (string->IsThinString()) {
3522 : string = handle(Handle<ThinString>::cast(string)->actual());
3523 : DCHECK(!string->IsConsString());
3524 : }
3525 75798072 : return string;
3526 : }
3527 :
3528 :
3529 : uint16_t String::Get(int index) {
3530 : DCHECK(index >= 0 && index < length());
3531 711884274 : switch (StringShape(this).full_representation_tag()) {
3532 : case kSeqStringTag | kOneByteStringTag:
3533 669062216 : return SeqOneByteString::cast(this)->SeqOneByteStringGet(index);
3534 : case kSeqStringTag | kTwoByteStringTag:
3535 32117543 : return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
3536 : case kConsStringTag | kOneByteStringTag:
3537 : case kConsStringTag | kTwoByteStringTag:
3538 4308780 : return ConsString::cast(this)->ConsStringGet(index);
3539 : case kExternalStringTag | kOneByteStringTag:
3540 4569721 : return ExternalOneByteString::cast(this)->ExternalOneByteStringGet(index);
3541 : case kExternalStringTag | kTwoByteStringTag:
3542 8878 : return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
3543 : case kSlicedStringTag | kOneByteStringTag:
3544 : case kSlicedStringTag | kTwoByteStringTag:
3545 1816876 : return SlicedString::cast(this)->SlicedStringGet(index);
3546 : case kThinStringTag | kOneByteStringTag:
3547 : case kThinStringTag | kTwoByteStringTag:
3548 258 : return ThinString::cast(this)->ThinStringGet(index);
3549 : default:
3550 : break;
3551 : }
3552 :
3553 0 : UNREACHABLE();
3554 : return 0;
3555 : }
3556 :
3557 :
3558 0 : void String::Set(int index, uint16_t value) {
3559 : DCHECK(index >= 0 && index < length());
3560 : DCHECK(StringShape(this).IsSequential());
3561 :
3562 : return this->IsOneByteRepresentation()
3563 : ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value)
3564 0 : : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value);
3565 : }
3566 :
3567 :
3568 6659596 : bool String::IsFlat() {
3569 6659596 : if (!StringShape(this).IsCons()) return true;
3570 6628559 : return ConsString::cast(this)->second()->length() == 0;
3571 : }
3572 :
3573 :
3574 : String* String::GetUnderlying() {
3575 : // Giving direct access to underlying string only makes sense if the
3576 : // wrapping string is already flattened.
3577 : DCHECK(this->IsFlat());
3578 : DCHECK(StringShape(this).IsIndirect());
3579 : STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset);
3580 : STATIC_ASSERT(ConsString::kFirstOffset == ThinString::kActualOffset);
3581 : const int kUnderlyingOffset = SlicedString::kParentOffset;
3582 2821 : return String::cast(READ_FIELD(this, kUnderlyingOffset));
3583 : }
3584 :
3585 :
3586 : template<class Visitor>
3587 134732640 : ConsString* String::VisitFlat(Visitor* visitor,
3588 : String* string,
3589 : const int offset) {
3590 : int slice_offset = offset;
3591 : const int length = string->length();
3592 : DCHECK(offset <= length);
3593 : while (true) {
3594 : int32_t type = string->map()->instance_type();
3595 134919046 : switch (type & (kStringRepresentationMask | kStringEncodingMask)) {
3596 : case kSeqStringTag | kOneByteStringTag:
3597 227705888 : visitor->VisitOneByteString(
3598 113852944 : SeqOneByteString::cast(string)->GetChars() + slice_offset,
3599 : length - offset);
3600 113852949 : return NULL;
3601 :
3602 : case kSeqStringTag | kTwoByteStringTag:
3603 25559854 : visitor->VisitTwoByteString(
3604 12779927 : SeqTwoByteString::cast(string)->GetChars() + slice_offset,
3605 : length - offset);
3606 12779927 : return NULL;
3607 :
3608 : case kExternalStringTag | kOneByteStringTag:
3609 3836 : visitor->VisitOneByteString(
3610 : ExternalOneByteString::cast(string)->GetChars() + slice_offset,
3611 : length - offset);
3612 1918 : return NULL;
3613 :
3614 : case kExternalStringTag | kTwoByteStringTag:
3615 43114 : visitor->VisitTwoByteString(
3616 : ExternalTwoByteString::cast(string)->GetChars() + slice_offset,
3617 : length - offset);
3618 21557 : return NULL;
3619 :
3620 : case kSlicedStringTag | kOneByteStringTag:
3621 : case kSlicedStringTag | kTwoByteStringTag: {
3622 : SlicedString* slicedString = SlicedString::cast(string);
3623 179651 : slice_offset += slicedString->offset();
3624 : string = slicedString->parent();
3625 179651 : continue;
3626 : }
3627 :
3628 : case kConsStringTag | kOneByteStringTag:
3629 : case kConsStringTag | kTwoByteStringTag:
3630 47532 : return ConsString::cast(string);
3631 :
3632 : case kThinStringTag | kOneByteStringTag:
3633 : case kThinStringTag | kTwoByteStringTag:
3634 : string = ThinString::cast(string)->actual();
3635 6755 : continue;
3636 :
3637 : default:
3638 0 : UNREACHABLE();
3639 : return NULL;
3640 : }
3641 : }
3642 : }
3643 :
3644 :
3645 : template <>
3646 : inline Vector<const uint8_t> String::GetCharVector() {
3647 2598676 : String::FlatContent flat = GetFlatContent();
3648 : DCHECK(flat.IsOneByte());
3649 2598676 : return flat.ToOneByteVector();
3650 : }
3651 :
3652 :
3653 : template <>
3654 : inline Vector<const uc16> String::GetCharVector() {
3655 1320415 : String::FlatContent flat = GetFlatContent();
3656 : DCHECK(flat.IsTwoByte());
3657 1320415 : return flat.ToUC16Vector();
3658 : }
3659 :
3660 : uint32_t String::ToValidIndex(Object* number) {
3661 9854 : uint32_t index = PositiveNumberToUint32(number);
3662 9854 : uint32_t length_value = static_cast<uint32_t>(length());
3663 9854 : if (index > length_value) return length_value;
3664 : return index;
3665 : }
3666 :
3667 2424700453 : uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
3668 : DCHECK(index >= 0 && index < length());
3669 2514704483 : return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
3670 : }
3671 :
3672 :
3673 303549731 : void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) {
3674 : DCHECK(index >= 0 && index < length() && value <= kMaxOneByteCharCode);
3675 1472850501 : WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize,
3676 1472850501 : static_cast<byte>(value));
3677 303549731 : }
3678 :
3679 :
3680 : Address SeqOneByteString::GetCharsAddress() {
3681 : return FIELD_ADDR(this, kHeaderSize);
3682 : }
3683 :
3684 :
3685 49538 : uint8_t* SeqOneByteString::GetChars() {
3686 49538 : return reinterpret_cast<uint8_t*>(GetCharsAddress());
3687 : }
3688 :
3689 :
3690 : Address SeqTwoByteString::GetCharsAddress() {
3691 : return FIELD_ADDR(this, kHeaderSize);
3692 : }
3693 :
3694 :
3695 91408 : uc16* SeqTwoByteString::GetChars() {
3696 91408 : return reinterpret_cast<uc16*>(FIELD_ADDR(this, kHeaderSize));
3697 : }
3698 :
3699 :
3700 32117543 : uint16_t SeqTwoByteString::SeqTwoByteStringGet(int index) {
3701 : DCHECK(index >= 0 && index < length());
3702 32117543 : return READ_UINT16_FIELD(this, kHeaderSize + index * kShortSize);
3703 : }
3704 :
3705 :
3706 2279171 : void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) {
3707 : DCHECK(index >= 0 && index < length());
3708 26025083 : WRITE_UINT16_FIELD(this, kHeaderSize + index * kShortSize, value);
3709 2279171 : }
3710 :
3711 :
3712 6558695 : int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) {
3713 6558695 : return SizeFor(length());
3714 : }
3715 :
3716 :
3717 8514287 : int SeqOneByteString::SeqOneByteStringSize(InstanceType instance_type) {
3718 8514287 : return SizeFor(length());
3719 : }
3720 :
3721 :
3722 : String* SlicedString::parent() {
3723 5854608 : return String::cast(READ_FIELD(this, kParentOffset));
3724 : }
3725 :
3726 :
3727 3593410 : void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
3728 : DCHECK(parent->IsSeqString() || parent->IsExternalString());
3729 3593410 : WRITE_FIELD(this, kParentOffset, parent);
3730 10780230 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode);
3731 3593410 : }
3732 :
3733 :
3734 9448012 : SMI_ACCESSORS(SlicedString, offset, kOffsetOffset)
3735 :
3736 :
3737 : String* ConsString::first() {
3738 23870927983 : return String::cast(READ_FIELD(this, kFirstOffset));
3739 : }
3740 :
3741 :
3742 : Object* ConsString::unchecked_first() {
3743 925906 : return READ_FIELD(this, kFirstOffset);
3744 : }
3745 :
3746 :
3747 30771693 : void ConsString::set_first(String* value, WriteBarrierMode mode) {
3748 30771693 : WRITE_FIELD(this, kFirstOffset, value);
3749 44532935 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kFirstOffset, value, mode);
3750 30771693 : }
3751 :
3752 :
3753 : String* ConsString::second() {
3754 210726804 : return String::cast(READ_FIELD(this, kSecondOffset));
3755 : }
3756 :
3757 :
3758 : Object* ConsString::unchecked_second() {
3759 55049349 : return READ_FIELD(this, kSecondOffset);
3760 : }
3761 :
3762 :
3763 30771693 : void ConsString::set_second(String* value, WriteBarrierMode mode) {
3764 30771693 : WRITE_FIELD(this, kSecondOffset, value);
3765 44532935 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode);
3766 30771693 : }
3767 :
3768 30084754 : ACCESSORS(ThinString, actual, String, kActualOffset);
3769 :
3770 : bool ExternalString::is_short() {
3771 : InstanceType type = map()->instance_type();
3772 1025442 : return (type & kShortExternalStringMask) == kShortExternalStringTag;
3773 : }
3774 :
3775 :
3776 : const ExternalOneByteString::Resource* ExternalOneByteString::resource() {
3777 6578069 : return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
3778 : }
3779 :
3780 :
3781 1002272 : void ExternalOneByteString::update_data_cache() {
3782 2004543 : if (is_short()) return;
3783 : const char** data_field =
3784 : reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset));
3785 8446 : *data_field = resource()->data();
3786 : }
3787 :
3788 :
3789 : void ExternalOneByteString::set_resource(
3790 : const ExternalOneByteString::Resource* resource) {
3791 : DCHECK(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize));
3792 : *reinterpret_cast<const Resource**>(
3793 1002291 : FIELD_ADDR(this, kResourceOffset)) = resource;
3794 1002279 : if (resource != NULL) update_data_cache();
3795 : }
3796 :
3797 :
3798 : const uint8_t* ExternalOneByteString::GetChars() {
3799 5540291 : return reinterpret_cast<const uint8_t*>(resource()->data());
3800 : }
3801 :
3802 :
3803 4569721 : uint16_t ExternalOneByteString::ExternalOneByteStringGet(int index) {
3804 : DCHECK(index >= 0 && index < length());
3805 4569721 : return GetChars()[index];
3806 : }
3807 :
3808 :
3809 : const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() {
3810 397390 : return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
3811 : }
3812 :
3813 :
3814 23170 : void ExternalTwoByteString::update_data_cache() {
3815 46340 : if (is_short()) return;
3816 : const uint16_t** data_field =
3817 : reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset));
3818 22993 : *data_field = resource()->data();
3819 : }
3820 :
3821 :
3822 : void ExternalTwoByteString::set_resource(
3823 : const ExternalTwoByteString::Resource* resource) {
3824 : *reinterpret_cast<const Resource**>(
3825 23170 : FIELD_ADDR(this, kResourceOffset)) = resource;
3826 23170 : if (resource != NULL) update_data_cache();
3827 : }
3828 :
3829 :
3830 : const uint16_t* ExternalTwoByteString::GetChars() {
3831 374345 : return resource()->data();
3832 : }
3833 :
3834 :
3835 8878 : uint16_t ExternalTwoByteString::ExternalTwoByteStringGet(int index) {
3836 : DCHECK(index >= 0 && index < length());
3837 8878 : return GetChars()[index];
3838 : }
3839 :
3840 :
3841 : const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData(
3842 : unsigned start) {
3843 82 : return GetChars() + start;
3844 : }
3845 :
3846 :
3847 69523438 : int ConsStringIterator::OffsetForDepth(int depth) { return depth & kDepthMask; }
3848 :
3849 :
3850 : void ConsStringIterator::PushLeft(ConsString* string) {
3851 23687723207 : frames_[depth_++ & kDepthMask] = string;
3852 : }
3853 :
3854 :
3855 : void ConsStringIterator::PushRight(ConsString* string) {
3856 : // Inplace update.
3857 15955258 : frames_[(depth_-1) & kDepthMask] = string;
3858 : }
3859 :
3860 :
3861 : void ConsStringIterator::AdjustMaximumDepth() {
3862 21185516 : if (depth_ > maximum_depth_) maximum_depth_ = depth_;
3863 : }
3864 :
3865 :
3866 : void ConsStringIterator::Pop() {
3867 : DCHECK(depth_ > 0);
3868 : DCHECK(depth_ <= maximum_depth_);
3869 55943140 : depth_--;
3870 : }
3871 :
3872 :
3873 72203962 : uint16_t StringCharacterStream::GetNext() {
3874 : DCHECK(buffer8_ != NULL && end_ != NULL);
3875 : // Advance cursor if needed.
3876 72203962 : if (buffer8_ == end_) HasMore();
3877 : DCHECK(buffer8_ < end_);
3878 72203962 : return is_one_byte_ ? *buffer8_++ : *buffer16_++;
3879 : }
3880 :
3881 :
3882 162 : StringCharacterStream::StringCharacterStream(String* string, int offset)
3883 5577423 : : is_one_byte_(false) {
3884 5577423 : Reset(string, offset);
3885 162 : }
3886 :
3887 :
3888 3387190 : void StringCharacterStream::Reset(String* string, int offset) {
3889 3387190 : buffer8_ = NULL;
3890 3387190 : end_ = NULL;
3891 3387190 : ConsString* cons_string = String::VisitFlat(this, string, offset);
3892 3387190 : iter_.Reset(cons_string, offset);
3893 3387190 : if (cons_string != NULL) {
3894 44928 : string = iter_.Next(&offset);
3895 44928 : if (string != NULL) String::VisitFlat(this, string, offset);
3896 : }
3897 3387190 : }
3898 :
3899 :
3900 78002898 : bool StringCharacterStream::HasMore() {
3901 78002898 : if (buffer8_ != end_) return true;
3902 : int offset;
3903 7564099 : String* string = iter_.Next(&offset);
3904 : DCHECK_EQ(offset, 0);
3905 7564099 : if (string == NULL) return false;
3906 99328 : String::VisitFlat(this, string);
3907 : DCHECK(buffer8_ != end_);
3908 99328 : return true;
3909 : }
3910 :
3911 :
3912 : void StringCharacterStream::VisitOneByteString(
3913 : const uint8_t* chars, int length) {
3914 3486473 : is_one_byte_ = true;
3915 3486473 : buffer8_ = chars;
3916 3486473 : end_ = chars + length;
3917 : }
3918 :
3919 :
3920 : void StringCharacterStream::VisitTwoByteString(
3921 : const uint16_t* chars, int length) {
3922 45 : is_one_byte_ = false;
3923 45 : buffer16_ = chars;
3924 45 : end_ = reinterpret_cast<const uint8_t*>(chars + length);
3925 : }
3926 :
3927 :
3928 3775096 : int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); }
3929 :
3930 : byte ByteArray::get(int index) {
3931 : DCHECK(index >= 0 && index < this->length());
3932 480004217 : return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
3933 : }
3934 :
3935 : void ByteArray::set(int index, byte value) {
3936 : DCHECK(index >= 0 && index < this->length());
3937 1698845 : WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
3938 : }
3939 :
3940 : void ByteArray::copy_in(int index, const byte* buffer, int length) {
3941 : DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
3942 : index + length <= this->length());
3943 147787 : byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
3944 3616 : memcpy(dst_addr, buffer, length);
3945 : }
3946 :
3947 : void ByteArray::copy_out(int index, byte* buffer, int length) {
3948 : DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
3949 : index + length <= this->length());
3950 3310 : const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
3951 : memcpy(buffer, src_addr, length);
3952 : }
3953 :
3954 : int ByteArray::get_int(int index) {
3955 : DCHECK(index >= 0 && index < this->length() / kIntSize);
3956 4829 : return READ_INT_FIELD(this, kHeaderSize + index * kIntSize);
3957 : }
3958 :
3959 : void ByteArray::set_int(int index, int value) {
3960 : DCHECK(index >= 0 && index < this->length() / kIntSize);
3961 951 : WRITE_INT_FIELD(this, kHeaderSize + index * kIntSize, value);
3962 : }
3963 :
3964 : ByteArray* ByteArray::FromDataStartAddress(Address address) {
3965 : DCHECK_TAG_ALIGNED(address);
3966 : return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
3967 : }
3968 :
3969 :
3970 48426 : int ByteArray::ByteArraySize() { return SizeFor(this->length()); }
3971 :
3972 :
3973 : Address ByteArray::GetDataStartAddress() {
3974 : return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
3975 : }
3976 :
3977 :
3978 65553 : byte BytecodeArray::get(int index) {
3979 : DCHECK(index >= 0 && index < this->length());
3980 232238932 : return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
3981 : }
3982 :
3983 :
3984 : void BytecodeArray::set(int index, byte value) {
3985 : DCHECK(index >= 0 && index < this->length());
3986 14671509 : WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
3987 : }
3988 :
3989 :
3990 : void BytecodeArray::set_frame_size(int frame_size) {
3991 : DCHECK_GE(frame_size, 0);
3992 : DCHECK(IsAligned(frame_size, static_cast<unsigned>(kPointerSize)));
3993 2113321 : WRITE_INT_FIELD(this, kFrameSizeOffset, frame_size);
3994 : }
3995 :
3996 :
3997 : int BytecodeArray::frame_size() const {
3998 19718860 : return READ_INT_FIELD(this, kFrameSizeOffset);
3999 : }
4000 :
4001 :
4002 37547 : int BytecodeArray::register_count() const {
4003 19709370 : return frame_size() / kPointerSize;
4004 : }
4005 :
4006 :
4007 : void BytecodeArray::set_parameter_count(int number_of_parameters) {
4008 : DCHECK_GE(number_of_parameters, 0);
4009 : // Parameter count is stored as the size on stack of the parameters to allow
4010 : // it to be used directly by generated code.
4011 2113321 : WRITE_INT_FIELD(this, kParameterSizeOffset,
4012 2113321 : (number_of_parameters << kPointerSizeLog2));
4013 : }
4014 :
4015 : int BytecodeArray::interrupt_budget() const {
4016 9490 : return READ_INT_FIELD(this, kInterruptBudgetOffset);
4017 : }
4018 :
4019 : void BytecodeArray::set_interrupt_budget(int interrupt_budget) {
4020 : DCHECK_GE(interrupt_budget, 0);
4021 2113315 : WRITE_INT_FIELD(this, kInterruptBudgetOffset, interrupt_budget);
4022 : }
4023 :
4024 : int BytecodeArray::osr_loop_nesting_level() const {
4025 17921 : return READ_INT8_FIELD(this, kOSRNestingLevelOffset);
4026 : }
4027 :
4028 : void BytecodeArray::set_osr_loop_nesting_level(int depth) {
4029 : DCHECK(0 <= depth && depth <= AbstractCode::kMaxLoopNestingMarker);
4030 : STATIC_ASSERT(AbstractCode::kMaxLoopNestingMarker < kMaxInt8);
4031 2127582 : WRITE_INT8_FIELD(this, kOSRNestingLevelOffset, depth);
4032 : }
4033 :
4034 : BytecodeArray::Age BytecodeArray::bytecode_age() const {
4035 2200638 : return static_cast<Age>(READ_INT8_FIELD(this, kBytecodeAgeOffset));
4036 : }
4037 :
4038 : void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) {
4039 : DCHECK_GE(age, kFirstBytecodeAge);
4040 : DCHECK_LE(age, kLastBytecodeAge);
4041 : STATIC_ASSERT(kLastBytecodeAge <= kMaxInt8);
4042 3518523 : WRITE_INT8_FIELD(this, kBytecodeAgeOffset, static_cast<int8_t>(age));
4043 : }
4044 :
4045 0 : int BytecodeArray::parameter_count() const {
4046 : // Parameter count is stored as the size on stack of the parameters to allow
4047 : // it to be used directly by generated code.
4048 1817083 : return READ_INT_FIELD(this, kParameterSizeOffset) >> kPointerSizeLog2;
4049 : }
4050 :
4051 10704264 : ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
4052 25813134 : ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset)
4053 18957677 : ACCESSORS(BytecodeArray, source_position_table, Object,
4054 : kSourcePositionTableOffset)
4055 :
4056 0 : Address BytecodeArray::GetFirstBytecodeAddress() {
4057 0 : return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
4058 : }
4059 :
4060 6224918 : ByteArray* BytecodeArray::SourcePositionTable() {
4061 : Object* maybe_table = source_position_table();
4062 6224917 : if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
4063 : DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
4064 : return SourcePositionTableWithFrameCache::cast(maybe_table)
4065 218742 : ->source_position_table();
4066 : }
4067 :
4068 : int BytecodeArray::BytecodeArraySize() { return SizeFor(this->length()); }
4069 :
4070 2077423 : int BytecodeArray::SizeIncludingMetadata() {
4071 : int size = BytecodeArraySize();
4072 2077423 : size += constant_pool()->Size();
4073 2077426 : size += handler_table()->Size();
4074 4154845 : size += SourcePositionTable()->Size();
4075 2077422 : return size;
4076 : }
4077 :
4078 6977609 : ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset)
4079 :
4080 :
4081 : void* FixedTypedArrayBase::external_pointer() const {
4082 4294373 : intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
4083 : return reinterpret_cast<void*>(ptr);
4084 : }
4085 :
4086 :
4087 : void FixedTypedArrayBase::set_external_pointer(void* value,
4088 : WriteBarrierMode mode) {
4089 16931 : intptr_t ptr = reinterpret_cast<intptr_t>(value);
4090 16931 : WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
4091 : }
4092 :
4093 :
4094 421 : void* FixedTypedArrayBase::DataPtr() {
4095 : return reinterpret_cast<void*>(
4096 8561144 : reinterpret_cast<intptr_t>(base_pointer()) +
4097 4280572 : reinterpret_cast<intptr_t>(external_pointer()));
4098 : }
4099 :
4100 :
4101 2004081 : int FixedTypedArrayBase::ElementSize(InstanceType type) {
4102 : int element_size;
4103 2004081 : switch (type) {
4104 : #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
4105 : case FIXED_##TYPE##_ARRAY_TYPE: \
4106 : element_size = size; \
4107 : break;
4108 :
4109 220476 : TYPED_ARRAYS(TYPED_ARRAY_CASE)
4110 : #undef TYPED_ARRAY_CASE
4111 : default:
4112 0 : UNREACHABLE();
4113 : return 0;
4114 : }
4115 : return element_size;
4116 : }
4117 :
4118 :
4119 : int FixedTypedArrayBase::DataSize(InstanceType type) {
4120 2680106 : if (base_pointer() == Smi::kZero) return 0;
4121 2224910 : return length() * ElementSize(type);
4122 : }
4123 :
4124 :
4125 915562 : int FixedTypedArrayBase::DataSize() {
4126 915562 : return DataSize(map()->instance_type());
4127 : }
4128 :
4129 :
4130 : int FixedTypedArrayBase::size() {
4131 883727 : return OBJECT_POINTER_ALIGN(kDataOffset + DataSize());
4132 : }
4133 :
4134 :
4135 1764544 : int FixedTypedArrayBase::TypedArraySize(InstanceType type) {
4136 1764544 : return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type));
4137 : }
4138 :
4139 :
4140 : int FixedTypedArrayBase::TypedArraySize(InstanceType type, int length) {
4141 146 : return OBJECT_POINTER_ALIGN(kDataOffset + length * ElementSize(type));
4142 : }
4143 :
4144 :
4145 : uint8_t Uint8ArrayTraits::defaultValue() { return 0; }
4146 :
4147 :
4148 : uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; }
4149 :
4150 :
4151 : int8_t Int8ArrayTraits::defaultValue() { return 0; }
4152 :
4153 :
4154 : uint16_t Uint16ArrayTraits::defaultValue() { return 0; }
4155 :
4156 :
4157 : int16_t Int16ArrayTraits::defaultValue() { return 0; }
4158 :
4159 :
4160 : uint32_t Uint32ArrayTraits::defaultValue() { return 0; }
4161 :
4162 :
4163 : int32_t Int32ArrayTraits::defaultValue() { return 0; }
4164 :
4165 :
4166 : float Float32ArrayTraits::defaultValue() {
4167 : return std::numeric_limits<float>::quiet_NaN();
4168 : }
4169 :
4170 :
4171 : double Float64ArrayTraits::defaultValue() {
4172 : return std::numeric_limits<double>::quiet_NaN();
4173 : }
4174 :
4175 :
4176 : template <class Traits>
4177 444734 : typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) {
4178 : DCHECK((index >= 0) && (index < this->length()));
4179 : ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr());
4180 1819662 : return ptr[index];
4181 : }
4182 :
4183 :
4184 : template <class Traits>
4185 209253 : void FixedTypedArray<Traits>::set(int index, ElementType value) {
4186 : DCHECK((index >= 0) && (index < this->length()));
4187 : ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr());
4188 2423824 : ptr[index] = value;
4189 209253 : }
4190 :
4191 : template <class Traits>
4192 : typename Traits::ElementType FixedTypedArray<Traits>::from(int value) {
4193 1077724 : return static_cast<ElementType>(value);
4194 : }
4195 :
4196 : template <>
4197 : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(int value) {
4198 37157 : if (value < 0) return 0;
4199 36940 : if (value > 0xFF) return 0xFF;
4200 36407 : return static_cast<uint8_t>(value);
4201 : }
4202 :
4203 : template <class Traits>
4204 : typename Traits::ElementType FixedTypedArray<Traits>::from(uint32_t value) {
4205 672 : return static_cast<ElementType>(value);
4206 : }
4207 :
4208 : template <>
4209 : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(uint32_t value) {
4210 : // We need this special case for Uint32 -> Uint8Clamped, because the highest
4211 : // Uint32 values will be negative as an int, clamping to 0, rather than 255.
4212 112 : if (value > 0xFF) return 0xFF;
4213 70 : return static_cast<uint8_t>(value);
4214 : }
4215 :
4216 : template <class Traits>
4217 : typename Traits::ElementType FixedTypedArray<Traits>::from(double value) {
4218 484135 : return static_cast<ElementType>(DoubleToInt32(value));
4219 : }
4220 :
4221 : template <>
4222 : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(double value) {
4223 : // Handle NaNs and less than zero values which clamp to zero.
4224 145131 : if (!(value > 0)) return 0;
4225 143603 : if (value > 0xFF) return 0xFF;
4226 142474 : return static_cast<uint8_t>(lrint(value));
4227 : }
4228 :
4229 : template <>
4230 : inline float FixedTypedArray<Float32ArrayTraits>::from(double value) {
4231 176308 : return static_cast<float>(value);
4232 : }
4233 :
4234 : template <>
4235 : inline double FixedTypedArray<Float64ArrayTraits>::from(double value) {
4236 : return value;
4237 : }
4238 :
4239 : template <class Traits>
4240 631785 : Handle<Object> FixedTypedArray<Traits>::get(FixedTypedArray<Traits>* array,
4241 : int index) {
4242 901111 : return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
4243 : }
4244 :
4245 :
4246 : template <class Traits>
4247 1432917 : void FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
4248 : ElementType cast_value = Traits::defaultValue();
4249 1432917 : if (value->IsSmi()) {
4250 : int int_value = Smi::cast(value)->value();
4251 : cast_value = from(int_value);
4252 861872 : } else if (value->IsHeapNumber()) {
4253 : double double_value = HeapNumber::cast(value)->value();
4254 : cast_value = from(double_value);
4255 : } else {
4256 : // Clamp undefined to the default value. All other types have been
4257 : // converted to a number type further up in the call chain.
4258 : DCHECK(value->IsUndefined(GetIsolate()));
4259 : }
4260 1432917 : set(index, cast_value);
4261 1432917 : }
4262 :
4263 :
4264 135118 : Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
4265 135118 : return handle(Smi::FromInt(scalar), isolate);
4266 : }
4267 :
4268 :
4269 3364 : Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate,
4270 : uint8_t scalar) {
4271 3364 : return handle(Smi::FromInt(scalar), isolate);
4272 : }
4273 :
4274 :
4275 7347 : Handle<Object> Int8ArrayTraits::ToHandle(Isolate* isolate, int8_t scalar) {
4276 7347 : return handle(Smi::FromInt(scalar), isolate);
4277 : }
4278 :
4279 :
4280 117732 : Handle<Object> Uint16ArrayTraits::ToHandle(Isolate* isolate, uint16_t scalar) {
4281 117732 : return handle(Smi::FromInt(scalar), isolate);
4282 : }
4283 :
4284 :
4285 5765 : Handle<Object> Int16ArrayTraits::ToHandle(Isolate* isolate, int16_t scalar) {
4286 5765 : return handle(Smi::FromInt(scalar), isolate);
4287 : }
4288 :
4289 :
4290 : Handle<Object> Uint32ArrayTraits::ToHandle(Isolate* isolate, uint32_t scalar) {
4291 116823 : return isolate->factory()->NewNumberFromUint(scalar);
4292 : }
4293 :
4294 :
4295 : Handle<Object> Int32ArrayTraits::ToHandle(Isolate* isolate, int32_t scalar) {
4296 12622 : return isolate->factory()->NewNumberFromInt(scalar);
4297 : }
4298 :
4299 :
4300 : Handle<Object> Float32ArrayTraits::ToHandle(Isolate* isolate, float scalar) {
4301 117173 : return isolate->factory()->NewNumber(scalar);
4302 : }
4303 :
4304 :
4305 : Handle<Object> Float64ArrayTraits::ToHandle(Isolate* isolate, double scalar) {
4306 115841 : return isolate->factory()->NewNumber(scalar);
4307 : }
4308 :
4309 :
4310 : int Map::visitor_id() {
4311 887325107 : return READ_BYTE_FIELD(this, kVisitorIdOffset);
4312 : }
4313 :
4314 :
4315 : void Map::set_visitor_id(int id) {
4316 : DCHECK(0 <= id && id < 256);
4317 61099192 : WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id));
4318 : }
4319 :
4320 :
4321 2604818 : int Map::instance_size() {
4322 3408723465 : return NOBARRIER_READ_BYTE_FIELD(
4323 3409086196 : this, kInstanceSizeOffset) << kPointerSizeLog2;
4324 : }
4325 :
4326 :
4327 : int Map::inobject_properties_or_constructor_function_index() {
4328 559917662 : return READ_BYTE_FIELD(this,
4329 : kInObjectPropertiesOrConstructorFunctionIndexOffset);
4330 : }
4331 :
4332 :
4333 : void Map::set_inobject_properties_or_constructor_function_index(int value) {
4334 : DCHECK(0 <= value && value < 256);
4335 : WRITE_BYTE_FIELD(this, kInObjectPropertiesOrConstructorFunctionIndexOffset,
4336 58618581 : static_cast<byte>(value));
4337 : }
4338 :
4339 :
4340 10321328 : int Map::GetInObjectProperties() {
4341 : DCHECK(IsJSObjectMap());
4342 10321328 : return inobject_properties_or_constructor_function_index();
4343 : }
4344 :
4345 :
4346 : void Map::SetInObjectProperties(int value) {
4347 : DCHECK(IsJSObjectMap());
4348 : set_inobject_properties_or_constructor_function_index(value);
4349 : }
4350 :
4351 :
4352 : int Map::GetConstructorFunctionIndex() {
4353 : DCHECK(IsPrimitiveMap());
4354 : return inobject_properties_or_constructor_function_index();
4355 : }
4356 :
4357 :
4358 : void Map::SetConstructorFunctionIndex(int value) {
4359 : DCHECK(IsPrimitiveMap());
4360 : set_inobject_properties_or_constructor_function_index(value);
4361 : }
4362 :
4363 :
4364 174794440 : int Map::GetInObjectPropertyOffset(int index) {
4365 : // Adjust for the number of properties stored in the object.
4366 174794440 : index -= GetInObjectProperties();
4367 : DCHECK(index <= 0);
4368 174794440 : return instance_size() + (index * kPointerSize);
4369 : }
4370 :
4371 :
4372 : Handle<Map> Map::AddMissingTransitionsForTesting(
4373 : Handle<Map> split_map, Handle<DescriptorArray> descriptors,
4374 : Handle<LayoutDescriptor> full_layout_descriptor) {
4375 : return AddMissingTransitions(split_map, descriptors, full_layout_descriptor);
4376 : }
4377 :
4378 :
4379 2714915897 : int HeapObject::SizeFromMap(Map* map) {
4380 : int instance_size = map->instance_size();
4381 2714915897 : if (instance_size != kVariableSizeSentinel) return instance_size;
4382 : // Only inline the most frequent cases.
4383 : InstanceType instance_type = map->instance_type();
4384 1393847819 : if (instance_type == FIXED_ARRAY_TYPE ||
4385 : instance_type == TRANSITION_ARRAY_TYPE) {
4386 : return FixedArray::SizeFor(
4387 341328652 : reinterpret_cast<FixedArray*>(this)->synchronized_length());
4388 : }
4389 2105038334 : if (instance_type == ONE_BYTE_STRING_TYPE ||
4390 1052519167 : instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
4391 : // Strings may get concurrently truncated, hence we have to access its
4392 : // length synchronized.
4393 : return SeqOneByteString::SizeFor(
4394 366338010 : reinterpret_cast<SeqOneByteString*>(this)->synchronized_length());
4395 : }
4396 686181157 : if (instance_type == BYTE_ARRAY_TYPE) {
4397 289751578 : return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
4398 : }
4399 396429579 : if (instance_type == BYTECODE_ARRAY_TYPE) {
4400 7819177 : return reinterpret_cast<BytecodeArray*>(this)->BytecodeArraySize();
4401 : }
4402 388610402 : if (instance_type == FREE_SPACE_TYPE) {
4403 21218654 : return reinterpret_cast<FreeSpace*>(this)->nobarrier_size();
4404 : }
4405 734783496 : if (instance_type == STRING_TYPE ||
4406 367391748 : instance_type == INTERNALIZED_STRING_TYPE) {
4407 : // Strings may get concurrently truncated, hence we have to access its
4408 : // length synchronized.
4409 : return SeqTwoByteString::SizeFor(
4410 75871721 : reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length());
4411 : }
4412 291520027 : if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
4413 : return FixedDoubleArray::SizeFor(
4414 208065 : reinterpret_cast<FixedDoubleArray*>(this)->length());
4415 : }
4416 291311962 : if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
4417 : instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) {
4418 : return reinterpret_cast<FixedTypedArrayBase*>(
4419 1764544 : this)->TypedArraySize(instance_type);
4420 : }
4421 : DCHECK(instance_type == CODE_TYPE);
4422 289562819 : return reinterpret_cast<Code*>(this)->CodeSize();
4423 : }
4424 :
4425 :
4426 : void Map::set_instance_size(int value) {
4427 : DCHECK_EQ(0, value & (kPointerSize - 1));
4428 32314796 : value >>= kPointerSizeLog2;
4429 : DCHECK(0 <= value && value < 256);
4430 31977384 : NOBARRIER_WRITE_BYTE_FIELD(
4431 : this, kInstanceSizeOffset, static_cast<byte>(value));
4432 : }
4433 :
4434 :
4435 31726576 : void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); }
4436 :
4437 :
4438 10915819079 : InstanceType Map::instance_type() {
4439 40906609442 : return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset));
4440 : }
4441 :
4442 :
4443 : void Map::set_instance_type(InstanceType value) {
4444 32798022 : WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value);
4445 : }
4446 :
4447 :
4448 : int Map::unused_property_fields() {
4449 105697117 : return READ_BYTE_FIELD(this, kUnusedPropertyFieldsOffset);
4450 : }
4451 :
4452 :
4453 : void Map::set_unused_property_fields(int value) {
4454 69830603 : WRITE_BYTE_FIELD(this, kUnusedPropertyFieldsOffset, Min(value, 255));
4455 : }
4456 :
4457 :
4458 257476778 : byte Map::bit_field() const { return READ_BYTE_FIELD(this, kBitFieldOffset); }
4459 :
4460 :
4461 : void Map::set_bit_field(byte value) {
4462 58564475 : WRITE_BYTE_FIELD(this, kBitFieldOffset, value);
4463 : }
4464 :
4465 :
4466 1124035688 : byte Map::bit_field2() const { return READ_BYTE_FIELD(this, kBitField2Offset); }
4467 :
4468 :
4469 : void Map::set_bit_field2(byte value) {
4470 96874979 : WRITE_BYTE_FIELD(this, kBitField2Offset, value);
4471 : }
4472 :
4473 :
4474 : void Map::set_non_instance_prototype(bool value) {
4475 : if (value) {
4476 6612 : set_bit_field(bit_field() | (1 << kHasNonInstancePrototype));
4477 : } else {
4478 689920 : set_bit_field(bit_field() & ~(1 << kHasNonInstancePrototype));
4479 : }
4480 : }
4481 :
4482 :
4483 : bool Map::has_non_instance_prototype() {
4484 5166388 : return ((1 << kHasNonInstancePrototype) & bit_field()) != 0;
4485 : }
4486 :
4487 :
4488 : void Map::set_is_constructor(bool value) {
4489 565 : if (value) {
4490 931 : set_bit_field(bit_field() | (1 << kIsConstructor));
4491 : } else {
4492 474 : set_bit_field(bit_field() & ~(1 << kIsConstructor));
4493 : }
4494 : }
4495 :
4496 :
4497 167294 : bool Map::is_constructor() const {
4498 774794 : return ((1 << kIsConstructor) & bit_field()) != 0;
4499 : }
4500 :
4501 : void Map::set_has_hidden_prototype(bool value) {
4502 : set_bit_field3(HasHiddenPrototype::update(bit_field3(), value));
4503 : }
4504 :
4505 790 : bool Map::has_hidden_prototype() const {
4506 790 : return HasHiddenPrototype::decode(bit_field3());
4507 : }
4508 :
4509 :
4510 : void Map::set_has_indexed_interceptor() {
4511 209 : set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
4512 : }
4513 :
4514 :
4515 240 : bool Map::has_indexed_interceptor() {
4516 16279991 : return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
4517 : }
4518 :
4519 :
4520 : void Map::set_is_undetectable() {
4521 309 : set_bit_field(bit_field() | (1 << kIsUndetectable));
4522 : }
4523 :
4524 :
4525 4720176 : bool Map::is_undetectable() {
4526 10077205 : return ((1 << kIsUndetectable) & bit_field()) != 0;
4527 : }
4528 :
4529 :
4530 : void Map::set_has_named_interceptor() {
4531 1268 : set_bit_field(bit_field() | (1 << kHasNamedInterceptor));
4532 : }
4533 :
4534 :
4535 342 : bool Map::has_named_interceptor() {
4536 46184187 : return ((1 << kHasNamedInterceptor) & bit_field()) != 0;
4537 : }
4538 :
4539 :
4540 : void Map::set_is_access_check_needed(bool access_check_needed) {
4541 : if (access_check_needed) {
4542 214566 : set_bit_field(bit_field() | (1 << kIsAccessCheckNeeded));
4543 : } else {
4544 293 : set_bit_field(bit_field() & ~(1 << kIsAccessCheckNeeded));
4545 : }
4546 : }
4547 :
4548 :
4549 65665689 : bool Map::is_access_check_needed() {
4550 120463265 : return ((1 << kIsAccessCheckNeeded) & bit_field()) != 0;
4551 : }
4552 :
4553 :
4554 : void Map::set_is_extensible(bool value) {
4555 : if (value) {
4556 : set_bit_field2(bit_field2() | (1 << kIsExtensible));
4557 : } else {
4558 52327 : set_bit_field2(bit_field2() & ~(1 << kIsExtensible));
4559 : }
4560 : }
4561 :
4562 : bool Map::is_extensible() {
4563 70035185 : return ((1 << kIsExtensible) & bit_field2()) != 0;
4564 : }
4565 :
4566 :
4567 : void Map::set_is_prototype_map(bool value) {
4568 : set_bit_field2(IsPrototypeMapBits::update(bit_field2(), value));
4569 : }
4570 :
4571 : bool Map::is_prototype_map() const {
4572 : return IsPrototypeMapBits::decode(bit_field2());
4573 : }
4574 :
4575 34217892 : bool Map::should_be_fast_prototype_map() const {
4576 34217894 : if (!prototype_info()->IsPrototypeInfo()) return false;
4577 28559896 : return PrototypeInfo::cast(prototype_info())->should_be_fast_map();
4578 : }
4579 :
4580 : void Map::set_elements_kind(ElementsKind elements_kind) {
4581 : DCHECK(static_cast<int>(elements_kind) < kElementsKindCount);
4582 : DCHECK(kElementsKindCount <= (1 << Map::ElementsKindBits::kSize));
4583 2274308 : set_bit_field2(Map::ElementsKindBits::update(bit_field2(), elements_kind));
4584 : DCHECK(this->elements_kind() == elements_kind);
4585 : }
4586 :
4587 :
4588 7588 : ElementsKind Map::elements_kind() {
4589 7588 : return Map::ElementsKindBits::decode(bit_field2());
4590 : }
4591 :
4592 :
4593 : bool Map::has_fast_smi_elements() {
4594 : return IsFastSmiElementsKind(elements_kind());
4595 : }
4596 :
4597 : bool Map::has_fast_object_elements() {
4598 : return IsFastObjectElementsKind(elements_kind());
4599 : }
4600 :
4601 : bool Map::has_fast_smi_or_object_elements() {
4602 : return IsFastSmiOrObjectElementsKind(elements_kind());
4603 : }
4604 :
4605 : bool Map::has_fast_double_elements() {
4606 : return IsFastDoubleElementsKind(elements_kind());
4607 : }
4608 :
4609 : bool Map::has_fast_elements() { return IsFastElementsKind(elements_kind()); }
4610 :
4611 : bool Map::has_sloppy_arguments_elements() {
4612 : return IsSloppyArgumentsElementsKind(elements_kind());
4613 : }
4614 :
4615 : bool Map::has_fast_sloppy_arguments_elements() {
4616 : return elements_kind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
4617 : }
4618 :
4619 : bool Map::has_fast_string_wrapper_elements() {
4620 : return elements_kind() == FAST_STRING_WRAPPER_ELEMENTS;
4621 : }
4622 :
4623 : bool Map::has_fixed_typed_array_elements() {
4624 : return IsFixedTypedArrayElementsKind(elements_kind());
4625 : }
4626 :
4627 : bool Map::has_dictionary_elements() {
4628 : return IsDictionaryElementsKind(elements_kind());
4629 : }
4630 :
4631 :
4632 : void Map::set_dictionary_map(bool value) {
4633 : uint32_t new_bit_field3 = DictionaryMap::update(bit_field3(), value);
4634 : new_bit_field3 = IsUnstable::update(new_bit_field3, value);
4635 : set_bit_field3(new_bit_field3);
4636 : }
4637 :
4638 :
4639 189312 : bool Map::is_dictionary_map() {
4640 189312 : return DictionaryMap::decode(bit_field3());
4641 : }
4642 :
4643 :
4644 : Code::Flags Code::flags() {
4645 356495647 : return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset));
4646 : }
4647 :
4648 :
4649 : void Map::set_owns_descriptors(bool owns_descriptors) {
4650 : set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors));
4651 : }
4652 :
4653 :
4654 : bool Map::owns_descriptors() {
4655 : return OwnsDescriptors::decode(bit_field3());
4656 : }
4657 :
4658 :
4659 1089 : void Map::set_is_callable() { set_bit_field(bit_field() | (1 << kIsCallable)); }
4660 :
4661 :
4662 26152841 : bool Map::is_callable() const {
4663 31487873 : return ((1 << kIsCallable) & bit_field()) != 0;
4664 : }
4665 :
4666 :
4667 : void Map::deprecate() {
4668 : set_bit_field3(Deprecated::update(bit_field3(), true));
4669 : }
4670 :
4671 :
4672 1500028 : bool Map::is_deprecated() {
4673 1500028 : return Deprecated::decode(bit_field3());
4674 : }
4675 :
4676 :
4677 : void Map::set_migration_target(bool value) {
4678 : set_bit_field3(IsMigrationTarget::update(bit_field3(), value));
4679 : }
4680 :
4681 :
4682 : bool Map::is_migration_target() {
4683 : return IsMigrationTarget::decode(bit_field3());
4684 : }
4685 :
4686 : void Map::set_immutable_proto(bool value) {
4687 : set_bit_field3(ImmutablePrototype::update(bit_field3(), value));
4688 : }
4689 :
4690 : bool Map::is_immutable_proto() {
4691 : return ImmutablePrototype::decode(bit_field3());
4692 : }
4693 :
4694 : void Map::set_new_target_is_base(bool value) {
4695 : set_bit_field3(NewTargetIsBase::update(bit_field3(), value));
4696 : }
4697 :
4698 :
4699 : bool Map::new_target_is_base() { return NewTargetIsBase::decode(bit_field3()); }
4700 :
4701 :
4702 : void Map::set_construction_counter(int value) {
4703 : set_bit_field3(ConstructionCounter::update(bit_field3(), value));
4704 : }
4705 :
4706 :
4707 : int Map::construction_counter() {
4708 : return ConstructionCounter::decode(bit_field3());
4709 : }
4710 :
4711 :
4712 : void Map::mark_unstable() {
4713 : set_bit_field3(IsUnstable::update(bit_field3(), true));
4714 : }
4715 :
4716 :
4717 : bool Map::is_stable() {
4718 23193 : return !IsUnstable::decode(bit_field3());
4719 : }
4720 :
4721 :
4722 : bool Map::has_code_cache() {
4723 : // Code caches are always fixed arrays. The empty fixed array is used as a
4724 : // sentinel for an absent code cache.
4725 : return code_cache()->length() != 0;
4726 : }
4727 :
4728 :
4729 14201 : bool Map::CanBeDeprecated() {
4730 : int descriptor = LastAdded();
4731 17747 : for (int i = 0; i <= descriptor; i++) {
4732 17488 : PropertyDetails details = instance_descriptors()->GetDetails(i);
4733 17488 : if (details.representation().IsNone()) return true;
4734 17488 : if (details.representation().IsSmi()) return true;
4735 13239 : if (details.representation().IsDouble()) return true;
4736 13030 : if (details.representation().IsHeapObject()) return true;
4737 6993 : if (details.kind() == kData && details.location() == kDescriptor) {
4738 : return true;
4739 : }
4740 : }
4741 : return false;
4742 : }
4743 :
4744 :
4745 27694309 : void Map::NotifyLeafMapLayoutChange() {
4746 27694309 : if (is_stable()) {
4747 : mark_unstable();
4748 : dependent_code()->DeoptimizeDependentCodeGroup(
4749 : GetIsolate(),
4750 17356254 : DependentCode::kPrototypeCheckGroup);
4751 : }
4752 27694308 : }
4753 :
4754 :
4755 44622604 : bool Map::CanTransition() {
4756 : // Only JSObject and subtypes have map transitions and back pointers.
4757 : STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
4758 45184498 : return instance_type() >= FIRST_JS_OBJECT_TYPE;
4759 : }
4760 :
4761 :
4762 122057 : bool Map::IsBooleanMap() { return this == GetHeap()->boolean_map(); }
4763 14930862 : bool Map::IsPrimitiveMap() {
4764 : STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
4765 19459117 : return instance_type() <= LAST_PRIMITIVE_TYPE;
4766 : }
4767 : bool Map::IsJSReceiverMap() {
4768 : STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
4769 13522515 : return instance_type() >= FIRST_JS_RECEIVER_TYPE;
4770 : }
4771 413326864 : bool Map::IsJSObjectMap() {
4772 : STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
4773 441724957 : return instance_type() >= FIRST_JS_OBJECT_TYPE;
4774 : }
4775 : bool Map::IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; }
4776 : bool Map::IsJSFunctionMap() { return instance_type() == JS_FUNCTION_TYPE; }
4777 576224 : bool Map::IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; }
4778 217994564 : bool Map::IsJSProxyMap() { return instance_type() == JS_PROXY_TYPE; }
4779 : bool Map::IsJSGlobalProxyMap() {
4780 : return instance_type() == JS_GLOBAL_PROXY_TYPE;
4781 : }
4782 : bool Map::IsJSGlobalObjectMap() {
4783 : return instance_type() == JS_GLOBAL_OBJECT_TYPE;
4784 : }
4785 : bool Map::IsJSTypedArrayMap() { return instance_type() == JS_TYPED_ARRAY_TYPE; }
4786 : bool Map::IsJSDataViewMap() { return instance_type() == JS_DATA_VIEW_TYPE; }
4787 :
4788 15150 : bool Map::IsSpecialReceiverMap() {
4789 : bool result = IsSpecialReceiverInstanceType(instance_type());
4790 : DCHECK_IMPLIES(!result,
4791 : !has_named_interceptor() && !is_access_check_needed());
4792 15150 : return result;
4793 : }
4794 :
4795 : bool Map::CanOmitMapChecks() {
4796 : return is_stable() && FLAG_omit_map_checks_for_leaf_maps;
4797 : }
4798 :
4799 :
4800 : DependentCode* DependentCode::next_link() {
4801 : return DependentCode::cast(get(kNextLinkIndex));
4802 : }
4803 :
4804 :
4805 : void DependentCode::set_next_link(DependentCode* next) {
4806 417557 : set(kNextLinkIndex, next);
4807 : }
4808 :
4809 :
4810 : int DependentCode::flags() { return Smi::cast(get(kFlagsIndex))->value(); }
4811 :
4812 :
4813 : void DependentCode::set_flags(int flags) {
4814 : set(kFlagsIndex, Smi::FromInt(flags));
4815 : }
4816 :
4817 :
4818 3802786 : int DependentCode::count() { return CountField::decode(flags()); }
4819 :
4820 1029686 : void DependentCode::set_count(int value) {
4821 2059372 : set_flags(CountField::update(flags(), value));
4822 1029686 : }
4823 :
4824 :
4825 : DependentCode::DependencyGroup DependentCode::group() {
4826 17404 : return static_cast<DependencyGroup>(GroupField::decode(flags()));
4827 : }
4828 :
4829 :
4830 : void DependentCode::set_group(DependentCode::DependencyGroup group) {
4831 : set_flags(GroupField::update(flags(), static_cast<int>(group)));
4832 : }
4833 :
4834 :
4835 : void DependentCode::set_object_at(int i, Object* object) {
4836 1580940 : set(kCodesStartIndex + i, object);
4837 : }
4838 :
4839 :
4840 : Object* DependentCode::object_at(int i) {
4841 259067510 : return get(kCodesStartIndex + i);
4842 : }
4843 :
4844 :
4845 : void DependentCode::clear_at(int i) {
4846 141616 : set_undefined(kCodesStartIndex + i);
4847 : }
4848 :
4849 :
4850 13521 : void DependentCode::copy(int from, int to) {
4851 27042 : set(kCodesStartIndex + to, get(kCodesStartIndex + from));
4852 13521 : }
4853 :
4854 :
4855 : void Code::set_flags(Code::Flags flags) {
4856 : STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1);
4857 2555744 : WRITE_INT_FIELD(this, kFlagsOffset, flags);
4858 : }
4859 :
4860 :
4861 537880 : Code::Kind Code::kind() {
4862 537880 : return ExtractKindFromFlags(flags());
4863 : }
4864 :
4865 : bool Code::IsCodeStubOrIC() {
4866 : switch (kind()) {
4867 : case STUB:
4868 : case HANDLER:
4869 : #define CASE_KIND(kind) case kind:
4870 : IC_KIND_LIST(CASE_KIND)
4871 : #undef CASE_KIND
4872 : return true;
4873 : default:
4874 : return false;
4875 : }
4876 : }
4877 :
4878 : ExtraICState Code::extra_ic_state() {
4879 : DCHECK(is_binary_op_stub() || is_compare_ic_stub() ||
4880 : is_to_boolean_ic_stub() || is_debug_stub());
4881 : return ExtractExtraICStateFromFlags(flags());
4882 : }
4883 :
4884 :
4885 : // For initialization.
4886 : void Code::set_raw_kind_specific_flags1(int value) {
4887 2555744 : WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value);
4888 : }
4889 :
4890 :
4891 : void Code::set_raw_kind_specific_flags2(int value) {
4892 2555744 : WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value);
4893 : }
4894 :
4895 :
4896 : inline bool Code::is_crankshafted() {
4897 : return IsCrankshaftedField::decode(
4898 26647 : READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
4899 : }
4900 :
4901 :
4902 : inline bool Code::is_hydrogen_stub() {
4903 53294 : return is_crankshafted() && kind() != OPTIMIZED_FUNCTION;
4904 : }
4905 :
4906 42986441 : inline bool Code::is_interpreter_trampoline_builtin() {
4907 42986441 : Builtins* builtins = GetIsolate()->builtins();
4908 94114770 : return this == *builtins->InterpreterEntryTrampoline() ||
4909 93917989 : this == *builtins->InterpreterEnterBytecodeAdvance() ||
4910 93917989 : this == *builtins->InterpreterEnterBytecodeDispatch();
4911 : }
4912 :
4913 : inline bool Code::has_unwinding_info() const {
4914 365728465 : return HasUnwindingInfoField::decode(READ_UINT32_FIELD(this, kFlagsOffset));
4915 : }
4916 :
4917 : inline void Code::set_has_unwinding_info(bool state) {
4918 : uint32_t previous = READ_UINT32_FIELD(this, kFlagsOffset);
4919 : uint32_t updated_value = HasUnwindingInfoField::update(previous, state);
4920 2555744 : WRITE_UINT32_FIELD(this, kFlagsOffset, updated_value);
4921 : }
4922 :
4923 : inline void Code::set_is_crankshafted(bool value) {
4924 279048 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
4925 : int updated = IsCrankshaftedField::update(previous, value);
4926 2834792 : WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
4927 : }
4928 :
4929 : inline bool Code::has_tagged_params() {
4930 1840521 : int flags = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
4931 : return HasTaggedStackField::decode(flags);
4932 : }
4933 :
4934 : inline void Code::set_has_tagged_params(bool value) {
4935 99023 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
4936 : int updated = HasTaggedStackField::update(previous, value);
4937 2654767 : WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
4938 : }
4939 :
4940 266483 : inline bool Code::is_turbofanned() {
4941 : return IsTurbofannedField::decode(
4942 12546931 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
4943 : }
4944 :
4945 :
4946 : inline void Code::set_is_turbofanned(bool value) {
4947 912392 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
4948 : int updated = IsTurbofannedField::update(previous, value);
4949 912392 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
4950 : }
4951 :
4952 :
4953 : inline bool Code::can_have_weak_objects() {
4954 : DCHECK(kind() == OPTIMIZED_FUNCTION);
4955 : return CanHaveWeakObjectsField::decode(
4956 4073613 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
4957 : }
4958 :
4959 :
4960 : inline void Code::set_can_have_weak_objects(bool value) {
4961 : DCHECK(kind() == OPTIMIZED_FUNCTION);
4962 640383 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
4963 : int updated = CanHaveWeakObjectsField::update(previous, value);
4964 640383 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
4965 : }
4966 :
4967 : inline bool Code::is_construct_stub() {
4968 : DCHECK(kind() == BUILTIN);
4969 : return IsConstructStubField::decode(
4970 4099 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
4971 : }
4972 :
4973 : inline void Code::set_is_construct_stub(bool value) {
4974 : DCHECK(kind() == BUILTIN);
4975 14906341 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
4976 : int updated = IsConstructStubField::update(previous, value);
4977 14906341 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
4978 : }
4979 :
4980 : inline bool Code::is_promise_rejection() {
4981 : DCHECK(kind() == BUILTIN);
4982 : return IsPromiseRejectionField::decode(
4983 2288 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
4984 : }
4985 :
4986 : inline void Code::set_is_promise_rejection(bool value) {
4987 : DCHECK(kind() == BUILTIN);
4988 688 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
4989 : int updated = IsPromiseRejectionField::update(previous, value);
4990 688 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
4991 : }
4992 :
4993 : inline bool Code::is_exception_caught() {
4994 : DCHECK(kind() == BUILTIN);
4995 : return IsExceptionCaughtField::decode(
4996 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
4997 : }
4998 :
4999 : inline void Code::set_is_exception_caught(bool value) {
5000 : DCHECK(kind() == BUILTIN);
5001 43 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
5002 : int updated = IsExceptionCaughtField::update(previous, value);
5003 43 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
5004 : }
5005 :
5006 : bool Code::has_deoptimization_support() {
5007 : DCHECK_EQ(FUNCTION, kind());
5008 588595 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5009 : return FullCodeFlagsHasDeoptimizationSupportField::decode(flags);
5010 : }
5011 :
5012 :
5013 : void Code::set_has_deoptimization_support(bool value) {
5014 : DCHECK_EQ(FUNCTION, kind());
5015 1309315 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5016 : flags = FullCodeFlagsHasDeoptimizationSupportField::update(flags, value);
5017 1309315 : WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
5018 : }
5019 :
5020 :
5021 : bool Code::has_debug_break_slots() {
5022 : DCHECK_EQ(FUNCTION, kind());
5023 4666214 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5024 : return FullCodeFlagsHasDebugBreakSlotsField::decode(flags);
5025 : }
5026 :
5027 :
5028 : void Code::set_has_debug_break_slots(bool value) {
5029 : DCHECK_EQ(FUNCTION, kind());
5030 3435 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5031 : flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value);
5032 3435 : WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
5033 : }
5034 :
5035 :
5036 : bool Code::has_reloc_info_for_serialization() {
5037 : DCHECK_EQ(FUNCTION, kind());
5038 228705 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5039 : return FullCodeFlagsHasRelocInfoForSerialization::decode(flags);
5040 : }
5041 :
5042 :
5043 : void Code::set_has_reloc_info_for_serialization(bool value) {
5044 : DCHECK_EQ(FUNCTION, kind());
5045 : unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
5046 : flags = FullCodeFlagsHasRelocInfoForSerialization::update(flags, value);
5047 1080610 : WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
5048 : }
5049 :
5050 :
5051 : int Code::allow_osr_at_loop_nesting_level() {
5052 : DCHECK_EQ(FUNCTION, kind());
5053 13279 : int fields = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
5054 : return AllowOSRAtLoopNestingLevelField::decode(fields);
5055 : }
5056 :
5057 :
5058 : void Code::set_allow_osr_at_loop_nesting_level(int level) {
5059 : DCHECK_EQ(FUNCTION, kind());
5060 : DCHECK(level >= 0 && level <= AbstractCode::kMaxLoopNestingMarker);
5061 1092694 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
5062 : int updated = AllowOSRAtLoopNestingLevelField::update(previous, level);
5063 1092694 : WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
5064 : }
5065 :
5066 :
5067 : int Code::profiler_ticks() {
5068 : DCHECK_EQ(FUNCTION, kind());
5069 : return ProfilerTicksField::decode(
5070 234864 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
5071 : }
5072 :
5073 :
5074 : void Code::set_profiler_ticks(int ticks) {
5075 5582618 : if (kind() == FUNCTION) {
5076 4433431 : unsigned previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
5077 : unsigned updated = ProfilerTicksField::update(previous, ticks);
5078 5582619 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
5079 : }
5080 : }
5081 :
5082 1262264 : int Code::builtin_index() { return READ_INT_FIELD(this, kBuiltinIndexOffset); }
5083 :
5084 : void Code::set_builtin_index(int index) {
5085 2583265 : WRITE_INT_FIELD(this, kBuiltinIndexOffset, index);
5086 : }
5087 :
5088 :
5089 : unsigned Code::stack_slots() {
5090 : DCHECK(is_crankshafted());
5091 : return StackSlotsField::decode(
5092 5570241 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
5093 : }
5094 :
5095 :
5096 1191440 : void Code::set_stack_slots(unsigned slots) {
5097 1191440 : CHECK(slots <= (1 << kStackSlotsBitCount));
5098 : DCHECK(is_crankshafted());
5099 1191440 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
5100 : int updated = StackSlotsField::update(previous, slots);
5101 1191440 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
5102 1191440 : }
5103 :
5104 :
5105 : unsigned Code::safepoint_table_offset() {
5106 : DCHECK(is_crankshafted());
5107 : return SafepointTableOffsetField::decode(
5108 1732479 : READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
5109 : }
5110 :
5111 :
5112 1191440 : void Code::set_safepoint_table_offset(unsigned offset) {
5113 1191440 : CHECK(offset <= (1 << kSafepointTableOffsetBitCount));
5114 : DCHECK(is_crankshafted());
5115 : DCHECK(IsAligned(offset, static_cast<unsigned>(kIntSize)));
5116 1191440 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
5117 : int updated = SafepointTableOffsetField::update(previous, offset);
5118 1191440 : WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
5119 1191440 : }
5120 :
5121 :
5122 : unsigned Code::back_edge_table_offset() {
5123 : DCHECK_EQ(FUNCTION, kind());
5124 : return BackEdgeTableOffsetField::decode(
5125 17366 : READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)) << kPointerSizeLog2;
5126 : }
5127 :
5128 :
5129 : void Code::set_back_edge_table_offset(unsigned offset) {
5130 : DCHECK_EQ(FUNCTION, kind());
5131 : DCHECK(IsAligned(offset, static_cast<unsigned>(kPointerSize)));
5132 1080610 : offset = offset >> kPointerSizeLog2;
5133 1080610 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
5134 : int updated = BackEdgeTableOffsetField::update(previous, offset);
5135 1080610 : WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
5136 : }
5137 :
5138 :
5139 : bool Code::back_edges_patched_for_osr() {
5140 : DCHECK_EQ(FUNCTION, kind());
5141 : return allow_osr_at_loop_nesting_level() > 0;
5142 : }
5143 :
5144 :
5145 209596 : uint16_t Code::to_boolean_state() { return extra_ic_state(); }
5146 :
5147 :
5148 : bool Code::marked_for_deoptimization() {
5149 : DCHECK(kind() == OPTIMIZED_FUNCTION);
5150 : return MarkedForDeoptimizationField::decode(
5151 2076377 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
5152 : }
5153 :
5154 :
5155 : void Code::set_marked_for_deoptimization(bool flag) {
5156 : DCHECK(kind() == OPTIMIZED_FUNCTION);
5157 : DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
5158 1071693 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
5159 : int updated = MarkedForDeoptimizationField::update(previous, flag);
5160 1071693 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
5161 : }
5162 :
5163 : bool Code::deopt_already_counted() {
5164 : DCHECK(kind() == OPTIMIZED_FUNCTION);
5165 : return DeoptAlreadyCountedField::decode(
5166 24374 : READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
5167 : }
5168 :
5169 : void Code::set_deopt_already_counted(bool flag) {
5170 : DCHECK(kind() == OPTIMIZED_FUNCTION);
5171 : DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
5172 360495 : int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
5173 : int updated = DeoptAlreadyCountedField::update(previous, flag);
5174 360495 : WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
5175 : }
5176 :
5177 : bool Code::is_inline_cache_stub() {
5178 : Kind kind = this->kind();
5179 15206559 : switch (kind) {
5180 : #define CASE(name) case name: return true;
5181 : IC_KIND_LIST(CASE)
5182 : #undef CASE
5183 : default: return false;
5184 : }
5185 : }
5186 :
5187 : bool Code::is_debug_stub() {
5188 132634 : if (kind() != BUILTIN) return false;
5189 0 : switch (builtin_index()) {
5190 : #define CASE_DEBUG_BUILTIN(name) case Builtins::k##name:
5191 : BUILTIN_LIST_DBG(CASE_DEBUG_BUILTIN)
5192 : #undef CASE_DEBUG_BUILTIN
5193 : return true;
5194 : default:
5195 : return false;
5196 : }
5197 : return false;
5198 : }
5199 : bool Code::is_handler() { return kind() == HANDLER; }
5200 : bool Code::is_stub() { return kind() == STUB; }
5201 : bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; }
5202 : bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; }
5203 : bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; }
5204 : bool Code::is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; }
5205 : bool Code::is_wasm_code() { return kind() == WASM_FUNCTION; }
5206 :
5207 : Address Code::constant_pool() {
5208 : Address constant_pool = NULL;
5209 : if (FLAG_enable_embedded_constant_pool) {
5210 : int offset = constant_pool_offset();
5211 : if (offset < instruction_size()) {
5212 : constant_pool = FIELD_ADDR(this, kHeaderSize + offset);
5213 : }
5214 : }
5215 : return constant_pool;
5216 : }
5217 :
5218 : Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state) {
5219 : // Compute the bit mask.
5220 : unsigned int bits =
5221 320005 : KindField::encode(kind) | ExtraICStateField::encode(extra_ic_state);
5222 : return static_cast<Flags>(bits);
5223 : }
5224 :
5225 : Code::Flags Code::ComputeHandlerFlags(Kind handler_kind) {
5226 : return ComputeFlags(Code::HANDLER, handler_kind);
5227 : }
5228 :
5229 :
5230 : Code::Kind Code::ExtractKindFromFlags(Flags flags) {
5231 : return KindField::decode(flags);
5232 : }
5233 :
5234 :
5235 : ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
5236 : return ExtraICStateField::decode(flags);
5237 : }
5238 :
5239 :
5240 314361537 : Code* Code::GetCodeFromTargetAddress(Address address) {
5241 : HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize);
5242 : // GetCodeFromTargetAddress might be called when marking objects during mark
5243 : // sweep. reinterpret_cast is therefore used instead of the more appropriate
5244 : // Code::cast. Code::cast does not work when the object's map is
5245 : // marked.
5246 : Code* result = reinterpret_cast<Code*>(code);
5247 314361537 : return result;
5248 : }
5249 :
5250 :
5251 61686674 : Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
5252 : return HeapObject::
5253 265637709 : FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
5254 : }
5255 :
5256 :
5257 : bool Code::CanContainWeakObjects() {
5258 34953019 : return is_optimized_code() && can_have_weak_objects();
5259 : }
5260 :
5261 :
5262 30879406 : bool Code::IsWeakObject(Object* object) {
5263 30879406 : return (CanContainWeakObjects() && IsWeakObjectInOptimizedCode(object));
5264 : }
5265 :
5266 :
5267 10108942 : bool Code::IsWeakObjectInOptimizedCode(Object* object) {
5268 10108941 : if (object->IsMap()) {
5269 338806 : return Map::cast(object)->CanTransition();
5270 : }
5271 9770135 : if (object->IsCell()) {
5272 : object = Cell::cast(object)->value();
5273 9770134 : } else if (object->IsPropertyCell()) {
5274 : object = PropertyCell::cast(object)->value();
5275 : }
5276 17898852 : if (object->IsJSReceiver() || object->IsContext()) {
5277 : return true;
5278 : }
5279 6762778 : return false;
5280 : }
5281 :
5282 :
5283 9133 : int AbstractCode::instruction_size() {
5284 9133 : if (IsCode()) {
5285 8685 : return GetCode()->instruction_size();
5286 : } else {
5287 448 : return GetBytecodeArray()->length();
5288 : }
5289 : }
5290 :
5291 2268639 : ByteArray* AbstractCode::source_position_table() {
5292 2268639 : if (IsCode()) {
5293 603756 : return GetCode()->SourcePositionTable();
5294 : } else {
5295 1664883 : return GetBytecodeArray()->SourcePositionTable();
5296 : }
5297 : }
5298 :
5299 1300 : void AbstractCode::set_source_position_table(ByteArray* source_position_table) {
5300 1300 : if (IsCode()) {
5301 184 : GetCode()->set_source_position_table(source_position_table);
5302 : } else {
5303 1116 : GetBytecodeArray()->set_source_position_table(source_position_table);
5304 : }
5305 1300 : }
5306 :
5307 46982 : Object* AbstractCode::stack_frame_cache() {
5308 : Object* maybe_table;
5309 46982 : if (IsCode()) {
5310 : maybe_table = GetCode()->source_position_table();
5311 : } else {
5312 : maybe_table = GetBytecodeArray()->source_position_table();
5313 : }
5314 46982 : if (maybe_table->IsSourcePositionTableWithFrameCache()) {
5315 : return SourcePositionTableWithFrameCache::cast(maybe_table)
5316 38041 : ->stack_frame_cache();
5317 : }
5318 : return Smi::kZero;
5319 : }
5320 :
5321 0 : int AbstractCode::SizeIncludingMetadata() {
5322 0 : if (IsCode()) {
5323 0 : return GetCode()->SizeIncludingMetadata();
5324 : } else {
5325 0 : return GetBytecodeArray()->SizeIncludingMetadata();
5326 : }
5327 : }
5328 211546 : int AbstractCode::ExecutableSize() {
5329 211546 : if (IsCode()) {
5330 209623 : return GetCode()->ExecutableSize();
5331 : } else {
5332 1923 : return GetBytecodeArray()->BytecodeArraySize();
5333 : }
5334 : }
5335 :
5336 172489 : Address AbstractCode::instruction_start() {
5337 172489 : if (IsCode()) {
5338 169877 : return GetCode()->instruction_start();
5339 : } else {
5340 2612 : return GetBytecodeArray()->GetFirstBytecodeAddress();
5341 : }
5342 : }
5343 :
5344 : Address AbstractCode::instruction_end() {
5345 : if (IsCode()) {
5346 : return GetCode()->instruction_end();
5347 : } else {
5348 : return GetBytecodeArray()->GetFirstBytecodeAddress() +
5349 : GetBytecodeArray()->length();
5350 : }
5351 : }
5352 :
5353 : bool AbstractCode::contains(byte* inner_pointer) {
5354 : return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
5355 : }
5356 :
5357 162407 : AbstractCode::Kind AbstractCode::kind() {
5358 162407 : if (IsCode()) {
5359 : STATIC_ASSERT(AbstractCode::FUNCTION ==
5360 : static_cast<AbstractCode::Kind>(Code::FUNCTION));
5361 157419 : return static_cast<AbstractCode::Kind>(GetCode()->kind());
5362 : } else {
5363 : return INTERPRETED_FUNCTION;
5364 : }
5365 : }
5366 :
5367 : Code* AbstractCode::GetCode() { return Code::cast(this); }
5368 :
5369 : BytecodeArray* AbstractCode::GetBytecodeArray() {
5370 : return BytecodeArray::cast(this);
5371 : }
5372 :
5373 48 : Object* Map::prototype() const {
5374 661943310 : return READ_FIELD(this, kPrototypeOffset);
5375 : }
5376 :
5377 :
5378 63522453 : void Map::set_prototype(Object* value, WriteBarrierMode mode) {
5379 : DCHECK(value->IsNull(GetIsolate()) || value->IsJSReceiver());
5380 63522453 : WRITE_FIELD(this, kPrototypeOffset, value);
5381 116765140 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
5382 63522450 : }
5383 :
5384 :
5385 239461 : LayoutDescriptor* Map::layout_descriptor_gc_safe() {
5386 239461 : Object* layout_desc = READ_FIELD(this, kLayoutDescriptorOffset);
5387 239461 : return LayoutDescriptor::cast_gc_safe(layout_desc);
5388 : }
5389 :
5390 :
5391 : bool Map::HasFastPointerLayout() const {
5392 146532385 : Object* layout_desc = READ_FIELD(this, kLayoutDescriptorOffset);
5393 : return LayoutDescriptor::IsFastPointerLayout(layout_desc);
5394 : }
5395 :
5396 :
5397 44229697 : void Map::UpdateDescriptors(DescriptorArray* descriptors,
5398 : LayoutDescriptor* layout_desc) {
5399 44229697 : set_instance_descriptors(descriptors);
5400 : if (FLAG_unbox_double_fields) {
5401 44229697 : if (layout_descriptor()->IsSlowLayout()) {
5402 3965 : set_layout_descriptor(layout_desc);
5403 : }
5404 : #ifdef VERIFY_HEAP
5405 : // TODO(ishell): remove these checks from VERIFY_HEAP mode.
5406 : if (FLAG_verify_heap) {
5407 : CHECK(layout_descriptor()->IsConsistentWithMap(this));
5408 : CHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
5409 : }
5410 : #else
5411 : SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
5412 : DCHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
5413 : #endif
5414 : }
5415 44229697 : }
5416 :
5417 :
5418 28535470 : void Map::InitializeDescriptors(DescriptorArray* descriptors,
5419 : LayoutDescriptor* layout_desc) {
5420 28535470 : int len = descriptors->number_of_descriptors();
5421 28535470 : set_instance_descriptors(descriptors);
5422 : SetNumberOfOwnDescriptors(len);
5423 :
5424 : if (FLAG_unbox_double_fields) {
5425 28535460 : set_layout_descriptor(layout_desc);
5426 : #ifdef VERIFY_HEAP
5427 : // TODO(ishell): remove these checks from VERIFY_HEAP mode.
5428 : if (FLAG_verify_heap) {
5429 : CHECK(layout_descriptor()->IsConsistentWithMap(this));
5430 : }
5431 : #else
5432 : SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
5433 : #endif
5434 28535459 : set_visitor_id(Heap::GetStaticVisitorIdForMap(this));
5435 : }
5436 28535463 : }
5437 :
5438 :
5439 1494476724 : ACCESSORS(Map, instance_descriptors, DescriptorArray, kDescriptorsOffset)
5440 365311010 : ACCESSORS(Map, layout_descriptor, LayoutDescriptor, kLayoutDescriptorOffset)
5441 :
5442 : void Map::set_bit_field3(uint32_t bits) {
5443 : if (kInt32Size != kPointerSize) {
5444 164791237 : WRITE_UINT32_FIELD(this, kBitField3Offset + kInt32Size, 0);
5445 : }
5446 197657460 : WRITE_UINT32_FIELD(this, kBitField3Offset, bits);
5447 : }
5448 :
5449 :
5450 : uint32_t Map::bit_field3() const {
5451 2231565387 : return READ_UINT32_FIELD(this, kBitField3Offset);
5452 : }
5453 :
5454 :
5455 : LayoutDescriptor* Map::GetLayoutDescriptor() {
5456 : return FLAG_unbox_double_fields ? layout_descriptor()
5457 : : LayoutDescriptor::FastPointerLayout();
5458 : }
5459 :
5460 :
5461 6588 : void Map::AppendDescriptor(Descriptor* desc) {
5462 : DescriptorArray* descriptors = instance_descriptors();
5463 : int number_of_own_descriptors = NumberOfOwnDescriptors();
5464 : DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors);
5465 6588 : descriptors->Append(desc);
5466 6588 : SetNumberOfOwnDescriptors(number_of_own_descriptors + 1);
5467 :
5468 : // This function does not support appending double field descriptors and
5469 : // it should never try to (otherwise, layout descriptor must be updated too).
5470 : #ifdef DEBUG
5471 : PropertyDetails details = desc->GetDetails();
5472 : CHECK(details.location() != kField || !details.representation().IsDouble());
5473 : #endif
5474 6588 : }
5475 :
5476 :
5477 181111832 : Object* Map::GetBackPointer() {
5478 : Object* object = constructor_or_backpointer();
5479 181111826 : if (object->IsMap()) {
5480 : return object;
5481 : }
5482 45723082 : return GetIsolate()->heap()->undefined_value();
5483 : }
5484 :
5485 :
5486 : Map* Map::ElementsTransitionMap() {
5487 : return TransitionArray::SearchSpecial(
5488 3091912 : this, GetHeap()->elements_transition_symbol());
5489 : }
5490 :
5491 :
5492 297398552 : ACCESSORS(Map, raw_transitions, Object, kTransitionsOrPrototypeInfoOffset)
5493 :
5494 :
5495 : Object* Map::prototype_info() const {
5496 : DCHECK(is_prototype_map());
5497 88781822 : return READ_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset);
5498 : }
5499 :
5500 :
5501 11504364 : void Map::set_prototype_info(Object* value, WriteBarrierMode mode) {
5502 : DCHECK(is_prototype_map());
5503 11504364 : WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value);
5504 34513092 : CONDITIONAL_WRITE_BARRIER(
5505 : GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode);
5506 11504363 : }
5507 :
5508 :
5509 : void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
5510 : DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE);
5511 : DCHECK(value->IsMap());
5512 : DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
5513 : DCHECK(!value->IsMap() ||
5514 : Map::cast(value)->GetConstructor() == constructor_or_backpointer());
5515 11753523 : set_constructor_or_backpointer(value, mode);
5516 : }
5517 :
5518 : ACCESSORS(JSArgumentsObject, length, Object, kLengthOffset);
5519 : ACCESSORS(JSSloppyArgumentsObject, callee, Object, kCalleeOffset);
5520 :
5521 32149486 : ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset)
5522 52726300 : ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
5523 161338083 : ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
5524 871821200 : ACCESSORS(Map, constructor_or_backpointer, Object,
5525 : kConstructorOrBackPointerOffset)
5526 :
5527 109784087 : Object* Map::GetConstructor() const {
5528 : Object* maybe_constructor = constructor_or_backpointer();
5529 : // Follow any back pointers.
5530 625864973 : while (maybe_constructor->IsMap()) {
5531 : maybe_constructor =
5532 : Map::cast(maybe_constructor)->constructor_or_backpointer();
5533 : }
5534 109784079 : return maybe_constructor;
5535 : }
5536 :
5537 2519690 : FunctionTemplateInfo* Map::GetFunctionTemplateInfo() const {
5538 2519690 : Object* constructor = GetConstructor();
5539 2519690 : if (constructor->IsJSFunction()) {
5540 : DCHECK(JSFunction::cast(constructor)->shared()->IsApiFunction());
5541 2519690 : return JSFunction::cast(constructor)->shared()->get_api_func_data();
5542 : }
5543 : DCHECK(constructor->IsFunctionTemplateInfo());
5544 : return FunctionTemplateInfo::cast(constructor);
5545 : }
5546 :
5547 : void Map::SetConstructor(Object* constructor, WriteBarrierMode mode) {
5548 : // Never overwrite a back pointer with a constructor.
5549 : DCHECK(!constructor_or_backpointer()->IsMap());
5550 9434094 : set_constructor_or_backpointer(constructor, mode);
5551 : }
5552 :
5553 :
5554 190289 : Handle<Map> Map::CopyInitialMap(Handle<Map> map) {
5555 : return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(),
5556 190289 : map->unused_property_fields());
5557 : }
5558 :
5559 :
5560 5182 : ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
5561 : kBoundTargetFunctionOffset)
5562 3426 : ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
5563 3959 : ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
5564 :
5565 595454109 : ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
5566 202379971 : ACCESSORS(JSFunction, feedback_vector_cell, Cell, kFeedbackVectorOffset)
5567 47589396 : ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset)
5568 :
5569 18519714 : ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset)
5570 388996 : ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset)
5571 :
5572 8995513 : ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
5573 427964 : ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset)
5574 :
5575 932260 : ACCESSORS(AccessorInfo, name, Object, kNameOffset)
5576 5291212 : SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset)
5577 2731072 : ACCESSORS(AccessorInfo, expected_receiver_type, Object,
5578 : kExpectedReceiverTypeOffset)
5579 :
5580 1441710 : ACCESSORS(AccessorInfo, getter, Object, kGetterOffset)
5581 40768653 : ACCESSORS(AccessorInfo, setter, Object, kSetterOffset)
5582 369018 : ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
5583 41475242 : ACCESSORS(AccessorInfo, data, Object, kDataOffset)
5584 :
5585 24522 : ACCESSORS(PromiseResolveThenableJobInfo, thenable, JSReceiver, kThenableOffset)
5586 24522 : ACCESSORS(PromiseResolveThenableJobInfo, then, JSReceiver, kThenOffset)
5587 24522 : ACCESSORS(PromiseResolveThenableJobInfo, resolve, JSFunction, kResolveOffset)
5588 24522 : ACCESSORS(PromiseResolveThenableJobInfo, reject, JSFunction, kRejectOffset)
5589 24522 : ACCESSORS(PromiseResolveThenableJobInfo, context, Context, kContextOffset);
5590 :
5591 230276 : ACCESSORS(PromiseReactionJobInfo, value, Object, kValueOffset);
5592 230276 : ACCESSORS(PromiseReactionJobInfo, tasks, Object, kTasksOffset);
5593 230276 : ACCESSORS(PromiseReactionJobInfo, deferred_promise, Object,
5594 : kDeferredPromiseOffset);
5595 230276 : ACCESSORS(PromiseReactionJobInfo, deferred_on_resolve, Object,
5596 : kDeferredOnResolveOffset);
5597 230276 : ACCESSORS(PromiseReactionJobInfo, deferred_on_reject, Object,
5598 : kDeferredOnRejectOffset);
5599 230276 : ACCESSORS(PromiseReactionJobInfo, context, Context, kContextOffset);
5600 :
5601 : ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
5602 : SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
5603 : ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
5604 : ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
5605 :
5606 : Map* PrototypeInfo::ObjectCreateMap() {
5607 : return Map::cast(WeakCell::cast(object_create_map())->value());
5608 : }
5609 :
5610 : // static
5611 187555 : void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
5612 : Handle<Map> map) {
5613 187555 : Handle<WeakCell> cell = Map::WeakCellForMap(map);
5614 187555 : info->set_object_create_map(*cell);
5615 187555 : }
5616 :
5617 187616 : bool PrototypeInfo::HasObjectCreateMap() {
5618 : Object* cache = object_create_map();
5619 187677 : return cache->IsWeakCell() && !WeakCell::cast(cache)->cleared();
5620 : }
5621 :
5622 5486241 : bool FunctionTemplateInfo::instantiated() {
5623 5486243 : return shared_function_info()->IsSharedFunctionInfo();
5624 : }
5625 :
5626 3962823 : FunctionTemplateInfo* FunctionTemplateInfo::GetParent(Isolate* isolate) {
5627 : Object* parent = parent_template();
5628 : return parent->IsUndefined(isolate) ? nullptr
5629 3962823 : : FunctionTemplateInfo::cast(parent);
5630 : }
5631 :
5632 515464 : ObjectTemplateInfo* ObjectTemplateInfo::GetParent(Isolate* isolate) {
5633 : Object* maybe_ctor = constructor();
5634 515464 : if (maybe_ctor->IsUndefined(isolate)) return nullptr;
5635 : FunctionTemplateInfo* constructor = FunctionTemplateInfo::cast(maybe_ctor);
5636 : while (true) {
5637 200208 : constructor = constructor->GetParent(isolate);
5638 200208 : if (constructor == nullptr) return nullptr;
5639 : Object* maybe_obj = constructor->instance_template();
5640 416 : if (!maybe_obj->IsUndefined(isolate)) {
5641 : return ObjectTemplateInfo::cast(maybe_obj);
5642 : }
5643 : }
5644 : return nullptr;
5645 : }
5646 :
5647 1676075 : ACCESSORS(PrototypeInfo, weak_cell, Object, kWeakCellOffset)
5648 3524350 : ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
5649 750342 : ACCESSORS(PrototypeInfo, object_create_map, Object, kObjectCreateMap)
5650 4625922 : SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
5651 5993670 : ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset)
5652 29723366 : SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
5653 : BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
5654 :
5655 8494074 : ACCESSORS(Tuple2, value1, Object, kValue1Offset)
5656 8539769 : ACCESSORS(Tuple2, value2, Object, kValue2Offset)
5657 7744650 : ACCESSORS(Tuple3, value3, Object, kValue3Offset)
5658 :
5659 3675986 : ACCESSORS(ContextExtension, scope_info, ScopeInfo, kScopeInfoOffset)
5660 11389026 : ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
5661 :
5662 687212 : SMI_ACCESSORS(ConstantElementsPair, elements_kind, kElementsKindOffset)
5663 1299255 : ACCESSORS(ConstantElementsPair, constant_values, FixedArrayBase,
5664 : kConstantValuesOffset)
5665 :
5666 1753 : ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
5667 :
5668 45224 : ACCESSORS(Module, code, Object, kCodeOffset)
5669 19862 : ACCESSORS(Module, exports, ObjectHashTable, kExportsOffset)
5670 8063 : ACCESSORS(Module, regular_exports, FixedArray, kRegularExportsOffset)
5671 6994 : ACCESSORS(Module, regular_imports, FixedArray, kRegularImportsOffset)
5672 7316 : ACCESSORS(Module, module_namespace, HeapObject, kModuleNamespaceOffset)
5673 13189 : ACCESSORS(Module, requested_modules, FixedArray, kRequestedModulesOffset)
5674 6266 : SMI_ACCESSORS(Module, status, kStatusOffset)
5675 6104 : SMI_ACCESSORS(Module, hash, kHashOffset)
5676 :
5677 14810 : bool Module::evaluated() const { return code()->IsModuleInfo(); }
5678 :
5679 1875 : void Module::set_evaluated() {
5680 : DCHECK(instantiated());
5681 : DCHECK(!evaluated());
5682 : return set_code(
5683 1875 : JSFunction::cast(code())->shared()->scope_info()->ModuleDescriptorInfo());
5684 : }
5685 :
5686 16674 : bool Module::instantiated() const { return !code()->IsSharedFunctionInfo(); }
5687 :
5688 5085 : ModuleInfo* Module::info() const {
5689 5369 : if (evaluated()) return ModuleInfo::cast(code());
5690 4801 : ScopeInfo* scope_info = instantiated()
5691 : ? JSFunction::cast(code())->shared()->scope_info()
5692 4801 : : SharedFunctionInfo::cast(code())->scope_info();
5693 4801 : return scope_info->ModuleDescriptorInfo();
5694 : }
5695 :
5696 20892510 : ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
5697 1142753 : ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
5698 :
5699 3672 : ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
5700 1232 : ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
5701 1563 : ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
5702 : kIndexedInterceptorOffset)
5703 3860 : ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
5704 :
5705 876009 : ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
5706 1082351 : ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
5707 282121 : ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
5708 357 : ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
5709 452 : ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
5710 1152 : ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
5711 613 : ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
5712 1443583 : ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
5713 1079231 : SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
5714 : BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
5715 : kCanInterceptSymbolsBit)
5716 : BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
5717 : BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking)
5718 :
5719 62789992 : ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
5720 62782652 : ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
5721 :
5722 12637912 : ACCESSORS(TemplateInfo, tag, Object, kTagOffset)
5723 18353645 : ACCESSORS(TemplateInfo, serial_number, Object, kSerialNumberOffset)
5724 11954212 : SMI_ACCESSORS(TemplateInfo, number_of_properties, kNumberOfProperties)
5725 12857915 : ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)
5726 4532004 : ACCESSORS(TemplateInfo, property_accessors, Object, kPropertyAccessorsOffset)
5727 :
5728 62821178 : ACCESSORS(FunctionTemplateInfo, call_code, Object, kCallCodeOffset)
5729 4486328 : ACCESSORS(FunctionTemplateInfo, prototype_template, Object,
5730 : kPrototypeTemplateOffset)
5731 7314745 : ACCESSORS(FunctionTemplateInfo, prototype_provider_template, Object,
5732 : kPrototypeProviderTemplateOffset)
5733 :
5734 7685293 : ACCESSORS(FunctionTemplateInfo, parent_template, Object, kParentTemplateOffset)
5735 9630540 : ACCESSORS(FunctionTemplateInfo, named_property_handler, Object,
5736 : kNamedPropertyHandlerOffset)
5737 8553562 : ACCESSORS(FunctionTemplateInfo, indexed_property_handler, Object,
5738 : kIndexedPropertyHandlerOffset)
5739 5020838 : ACCESSORS(FunctionTemplateInfo, instance_template, Object,
5740 : kInstanceTemplateOffset)
5741 3950128 : ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)
5742 52396807 : ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)
5743 3851954 : ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object,
5744 : kInstanceCallHandlerOffset)
5745 331368 : ACCESSORS(FunctionTemplateInfo, access_check_info, Object,
5746 : kAccessCheckInfoOffset)
5747 20663948 : ACCESSORS(FunctionTemplateInfo, shared_function_info, Object,
5748 : kSharedFunctionInfoOffset)
5749 11289923 : ACCESSORS(FunctionTemplateInfo, cached_property_name, Object,
5750 : kCachedPropertyNameOffset)
5751 :
5752 116908537 : SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset)
5753 :
5754 2064039 : ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
5755 2820554 : ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset)
5756 :
5757 : int ObjectTemplateInfo::embedder_field_count() const {
5758 : Object* value = data();
5759 : DCHECK(value->IsSmi());
5760 453191 : return EmbedderFieldCount::decode(Smi::cast(value)->value());
5761 : }
5762 :
5763 127497 : void ObjectTemplateInfo::set_embedder_field_count(int count) {
5764 : return set_data(Smi::FromInt(
5765 382491 : EmbedderFieldCount::update(Smi::cast(data())->value(), count)));
5766 : }
5767 :
5768 : bool ObjectTemplateInfo::immutable_proto() const {
5769 : Object* value = data();
5770 : DCHECK(value->IsSmi());
5771 508629 : return IsImmutablePrototype::decode(Smi::cast(value)->value());
5772 : }
5773 :
5774 21 : void ObjectTemplateInfo::set_immutable_proto(bool immutable) {
5775 : return set_data(Smi::FromInt(
5776 63 : IsImmutablePrototype::update(Smi::cast(data())->value(), immutable)));
5777 : }
5778 :
5779 : int TemplateList::length() const {
5780 : return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
5781 : }
5782 :
5783 : Object* TemplateList::get(int index) const {
5784 140145 : return FixedArray::cast(this)->get(kFirstElementIndex + index);
5785 : }
5786 :
5787 : void TemplateList::set(int index, Object* value) {
5788 185 : FixedArray::cast(this)->set(kFirstElementIndex + index, value);
5789 : }
5790 :
5791 21505037 : ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
5792 7317223 : ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
5793 13216419 : SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
5794 16580738 : SMI_ACCESSORS(AllocationSite, pretenure_create_count,
5795 : kPretenureCreateCountOffset)
5796 1866023 : ACCESSORS(AllocationSite, dependent_code, DependentCode,
5797 : kDependentCodeOffset)
5798 10530323 : ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
5799 19052019 : ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset)
5800 :
5801 43802081 : ACCESSORS(Script, source, Object, kSourceOffset)
5802 8805434 : ACCESSORS(Script, name, Object, kNameOffset)
5803 8534695 : SMI_ACCESSORS(Script, id, kIdOffset)
5804 3821279 : SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset)
5805 2582428 : SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset)
5806 25040173 : ACCESSORS(Script, context_data, Object, kContextOffset)
5807 11549017 : ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset)
5808 39678060 : SMI_ACCESSORS(Script, type, kTypeOffset)
5809 11340669 : ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
5810 10212806 : ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset,
5811 : this->type() != TYPE_WASM)
5812 3402698 : SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset,
5813 : this->type() != TYPE_WASM)
5814 20184651 : ACCESSORS(Script, shared_function_infos, FixedArray, kSharedFunctionInfosOffset)
5815 15421653 : SMI_ACCESSORS(Script, flags, kFlagsOffset)
5816 357378 : ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
5817 77185 : ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
5818 37711 : ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
5819 : this->type() == TYPE_WASM)
5820 6284379 : ACCESSORS(Script, preparsed_scope_data, PodArray<uint32_t>,
5821 : kPreParsedScopeDataOffset)
5822 :
5823 : Script::CompilationType Script::compilation_type() {
5824 : return BooleanBit::get(flags(), kCompilationTypeBit) ?
5825 4894607 : COMPILATION_TYPE_EVAL : COMPILATION_TYPE_HOST;
5826 : }
5827 : void Script::set_compilation_type(CompilationType type) {
5828 : set_flags(BooleanBit::set(flags(), kCompilationTypeBit,
5829 : type == COMPILATION_TYPE_EVAL));
5830 : }
5831 0 : Script::CompilationState Script::compilation_state() {
5832 : return BooleanBit::get(flags(), kCompilationStateBit) ?
5833 12100 : COMPILATION_STATE_COMPILED : COMPILATION_STATE_INITIAL;
5834 : }
5835 : void Script::set_compilation_state(CompilationState state) {
5836 : set_flags(BooleanBit::set(flags(), kCompilationStateBit,
5837 : state == COMPILATION_STATE_COMPILED));
5838 : }
5839 : ScriptOriginOptions Script::origin_options() {
5840 144835 : return ScriptOriginOptions((flags() & kOriginOptionsMask) >>
5841 144835 : kOriginOptionsShift);
5842 : }
5843 : void Script::set_origin_options(ScriptOriginOptions origin_options) {
5844 : DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
5845 1501984 : set_flags((flags() & ~kOriginOptionsMask) |
5846 1501984 : (origin_options.Flags() << kOriginOptionsShift));
5847 : }
5848 :
5849 :
5850 125113900 : ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)
5851 328538 : SMI_ACCESSORS(DebugInfo, debugger_hints, kDebuggerHintsIndex)
5852 18713120 : ACCESSORS(DebugInfo, debug_bytecode_array, Object, kDebugBytecodeArrayIndex)
5853 3637058 : ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateIndex)
5854 :
5855 1634039 : bool DebugInfo::HasDebugBytecodeArray() {
5856 1634039 : return debug_bytecode_array()->IsBytecodeArray();
5857 : }
5858 :
5859 : bool DebugInfo::HasDebugCode() {
5860 : Code* code = shared()->code();
5861 : bool has = code->kind() == Code::FUNCTION;
5862 : DCHECK(!has || code->has_debug_break_slots());
5863 : return has;
5864 : }
5865 :
5866 : BytecodeArray* DebugInfo::OriginalBytecodeArray() {
5867 : DCHECK(HasDebugBytecodeArray());
5868 : return shared()->bytecode_array();
5869 : }
5870 :
5871 : BytecodeArray* DebugInfo::DebugBytecodeArray() {
5872 : DCHECK(HasDebugBytecodeArray());
5873 : return BytecodeArray::cast(debug_bytecode_array());
5874 : }
5875 :
5876 : Code* DebugInfo::DebugCode() {
5877 : DCHECK(HasDebugCode());
5878 : return shared()->code();
5879 : }
5880 :
5881 144079 : SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex)
5882 272006 : ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex)
5883 :
5884 71263 : SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex)
5885 71223 : SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex)
5886 70953 : SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex)
5887 76847 : ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameIndex)
5888 121874 : ACCESSORS(StackFrameInfo, script_name_or_source_url, Object,
5889 : kScriptNameOrSourceUrlIndex)
5890 157089 : ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex)
5891 134661 : SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex)
5892 : BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit)
5893 : BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit)
5894 : BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit)
5895 19268 : SMI_ACCESSORS(StackFrameInfo, id, kIdIndex)
5896 :
5897 285227 : ACCESSORS(SourcePositionTableWithFrameCache, source_position_table, ByteArray,
5898 : kSourcePositionTableIndex)
5899 66778 : ACCESSORS(SourcePositionTableWithFrameCache, stack_frame_cache,
5900 : UnseededNumberDictionary, kStackFrameCacheIndex)
5901 :
5902 55606333 : ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset)
5903 79621494 : ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray,
5904 : kOptimizedCodeMapOffset)
5905 45437317 : ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
5906 115001317 : ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata,
5907 : kFeedbackMetadataOffset)
5908 27190060 : SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset)
5909 : #if TRACE_MAPS
5910 : SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset)
5911 : #endif
5912 67683031 : ACCESSORS(SharedFunctionInfo, instance_class_name, Object,
5913 : kInstanceClassNameOffset)
5914 296308121 : ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
5915 127589901 : ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)
5916 60941687 : ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
5917 37309111 : ACCESSORS(SharedFunctionInfo, function_identifier, Object,
5918 : kFunctionIdentifierOffset)
5919 :
5920 7525101 : SMI_ACCESSORS(FunctionTemplateInfo, length, kLengthOffset)
5921 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
5922 : kHiddenPrototypeBit)
5923 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)
5924 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check,
5925 : kNeedsAccessCheckBit)
5926 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype,
5927 : kReadOnlyPrototypeBit)
5928 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, remove_prototype,
5929 : kRemovePrototypeBit)
5930 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache,
5931 : kDoNotCacheBit)
5932 : BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
5933 : kAcceptAnyReceiver)
5934 : BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_named_expression,
5935 : kIsNamedExpressionBit)
5936 867898 : BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
5937 : kIsTopLevelBit)
5938 :
5939 : #if V8_HOST_ARCH_32_BIT
5940 : SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
5941 : SMI_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
5942 : kFormalParameterCountOffset)
5943 : SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
5944 : kExpectedNofPropertiesOffset)
5945 : SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
5946 : kStartPositionAndTypeOffset)
5947 : SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
5948 : SMI_ACCESSORS(SharedFunctionInfo, function_token_position,
5949 : kFunctionTokenPositionOffset)
5950 : SMI_ACCESSORS(SharedFunctionInfo, compiler_hints,
5951 : kCompilerHintsOffset)
5952 : SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason,
5953 : kOptCountAndBailoutReasonOffset)
5954 : SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset)
5955 : SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
5956 : SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset)
5957 :
5958 : #else
5959 :
5960 : #if V8_TARGET_LITTLE_ENDIAN
5961 : #define PSEUDO_SMI_LO_ALIGN 0
5962 : #define PSEUDO_SMI_HI_ALIGN kIntSize
5963 : #else
5964 : #define PSEUDO_SMI_LO_ALIGN kIntSize
5965 : #define PSEUDO_SMI_HI_ALIGN 0
5966 : #endif
5967 :
5968 : #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \
5969 : STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_LO_ALIGN); \
5970 : int holder::name() const { \
5971 : int value = READ_INT_FIELD(this, offset); \
5972 : DCHECK(kHeapObjectTag == 1); \
5973 : DCHECK((value & kHeapObjectTag) == 0); \
5974 : return value >> 1; \
5975 : } \
5976 : void holder::set_##name(int value) { \
5977 : DCHECK(kHeapObjectTag == 1); \
5978 : DCHECK((value & 0xC0000000) == 0xC0000000 || (value & 0xC0000000) == 0x0); \
5979 : WRITE_INT_FIELD(this, offset, (value << 1) & ~kHeapObjectTag); \
5980 : }
5981 :
5982 : #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \
5983 : STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_HI_ALIGN); \
5984 : INT_ACCESSORS(holder, name, offset)
5985 :
5986 :
5987 26130922 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset)
5988 36092862 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, internal_formal_parameter_count,
5989 : kFormalParameterCountOffset)
5990 :
5991 19997150 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
5992 : expected_nof_properties,
5993 : kExpectedNofPropertiesOffset)
5994 :
5995 21464246 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, end_position, kEndPositionOffset)
5996 60801539 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
5997 : start_position_and_type,
5998 : kStartPositionAndTypeOffset)
5999 :
6000 16940919 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
6001 : function_token_position,
6002 : kFunctionTokenPositionOffset)
6003 181564658 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
6004 : compiler_hints,
6005 : kCompilerHintsOffset)
6006 :
6007 12486588 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
6008 : opt_count_and_bailout_reason,
6009 : kOptCountAndBailoutReasonOffset)
6010 103896717 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, counters, kCountersOffset)
6011 :
6012 14290196 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
6013 : ast_node_count,
6014 : kAstNodeCountOffset)
6015 19405953 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
6016 : profiler_ticks,
6017 : kProfilerTicksOffset)
6018 :
6019 : #endif
6020 :
6021 0 : AbstractCode* SharedFunctionInfo::abstract_code() {
6022 1399512 : if (HasBytecodeArray()) {
6023 0 : return AbstractCode::cast(bytecode_array());
6024 : } else {
6025 0 : return AbstractCode::cast(code());
6026 : }
6027 : }
6028 :
6029 1404578 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
6030 : kAllowLazyCompilation)
6031 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_arguments,
6032 : kUsesArguments)
6033 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, has_duplicate_parameters,
6034 : kHasDuplicateParameters)
6035 8178 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, asm_function, kIsAsmFunction)
6036 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_declaration,
6037 : kIsDeclaration)
6038 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, marked_for_tier_up,
6039 : kMarkedForTierUp)
6040 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
6041 : has_concurrent_optimization_job, kHasConcurrentOptimizationJob)
6042 :
6043 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object,
6044 : kNeedsHomeObject)
6045 105056 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
6046 2868 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline)
6047 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo,
6048 : kMustUseIgnitionTurbo)
6049 273634 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
6050 1028 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_asm_wasm_broken,
6051 : kIsAsmWasmBroken)
6052 :
6053 0 : BOOL_GETTER(SharedFunctionInfo, compiler_hints, optimization_disabled,
6054 : kOptimizationDisabled)
6055 :
6056 2168 : void SharedFunctionInfo::set_optimization_disabled(bool disable) {
6057 : set_compiler_hints(BooleanBit::set(compiler_hints(),
6058 : kOptimizationDisabled,
6059 : disable));
6060 2168 : }
6061 :
6062 : LanguageMode SharedFunctionInfo::language_mode() {
6063 : STATIC_ASSERT(LANGUAGE_END == 2);
6064 : return construct_language_mode(
6065 : BooleanBit::get(compiler_hints(), kStrictModeFunction));
6066 : }
6067 :
6068 : void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
6069 : STATIC_ASSERT(LANGUAGE_END == 2);
6070 : // We only allow language mode transitions that set the same language mode
6071 : // again or go up in the chain:
6072 : DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode));
6073 : int hints = compiler_hints();
6074 : hints = BooleanBit::set(hints, kStrictModeFunction, is_strict(language_mode));
6075 : set_compiler_hints(hints);
6076 : }
6077 :
6078 471496 : FunctionKind SharedFunctionInfo::kind() const {
6079 32961805 : return FunctionKindBits::decode(compiler_hints());
6080 : }
6081 :
6082 : void SharedFunctionInfo::set_kind(FunctionKind kind) {
6083 : DCHECK(IsValidFunctionKind(kind));
6084 : int hints = compiler_hints();
6085 24947548 : hints = FunctionKindBits::update(hints, kind);
6086 : set_compiler_hints(hints);
6087 : }
6088 :
6089 3587062 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints,
6090 : name_should_print_as_anonymous, kNameShouldPrintAsAnonymous)
6091 12470776 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, is_anonymous_expression,
6092 : kIsAnonymousExpression)
6093 546 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, deserialized, kDeserialized)
6094 22148 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, has_no_side_effect,
6095 : kHasNoSideEffect)
6096 22148 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, computed_has_no_side_effect,
6097 : kComputedHasNoSideEffect)
6098 43472 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, debug_is_blackboxed,
6099 : kDebugIsBlackboxed)
6100 2153338 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, computed_debug_is_blackboxed,
6101 : kComputedDebugIsBlackboxed)
6102 115502 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, has_reported_binary_coverage,
6103 : kHasReportedBinaryCoverage)
6104 :
6105 92778 : bool Script::HasValidSource() {
6106 : Object* src = this->source();
6107 92778 : if (!src->IsString()) return true;
6108 : String* src_str = String::cast(src);
6109 92778 : if (!StringShape(src_str).IsExternal()) return true;
6110 56022 : if (src_str->IsOneByteRepresentation()) {
6111 55994 : return ExternalOneByteString::cast(src)->resource() != NULL;
6112 28 : } else if (src_str->IsTwoByteRepresentation()) {
6113 28 : return ExternalTwoByteString::cast(src)->resource() != NULL;
6114 : }
6115 : return true;
6116 : }
6117 :
6118 :
6119 : void SharedFunctionInfo::DontAdaptArguments() {
6120 : DCHECK(code()->kind() == Code::BUILTIN || code()->kind() == Code::STUB);
6121 : set_internal_formal_parameter_count(kDontAdaptArgumentsSentinel);
6122 : }
6123 :
6124 :
6125 196129 : int SharedFunctionInfo::start_position() const {
6126 7938651 : return start_position_and_type() >> kStartPositionShift;
6127 : }
6128 :
6129 :
6130 : void SharedFunctionInfo::set_start_position(int start_position) {
6131 6237413 : set_start_position_and_type((start_position << kStartPositionShift)
6132 6237492 : | (start_position_and_type() & ~kStartPositionMask));
6133 : }
6134 :
6135 :
6136 189282432 : Code* SharedFunctionInfo::code() const {
6137 325033538 : return Code::cast(READ_FIELD(this, kCodeOffset));
6138 : }
6139 :
6140 :
6141 13594484 : void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
6142 : DCHECK(value->kind() != Code::OPTIMIZED_FUNCTION);
6143 : // If the SharedFunctionInfo has bytecode we should never mark it for lazy
6144 : // compile, since the bytecode is never flushed.
6145 : DCHECK(value != GetIsolate()->builtins()->builtin(Builtins::kCompileLazy) ||
6146 : !HasBytecodeArray());
6147 13594484 : WRITE_FIELD(this, kCodeOffset, value);
6148 40783473 : CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode);
6149 13594501 : }
6150 :
6151 :
6152 2935139 : void SharedFunctionInfo::ReplaceCode(Code* value) {
6153 : // If the GC metadata field is already used then the function was
6154 : // enqueued as a code flushing candidate and we remove it now.
6155 2935139 : if (code()->gc_metadata() != NULL) {
6156 0 : CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher();
6157 0 : flusher->EvictCandidate(this);
6158 : }
6159 :
6160 : DCHECK(code()->gc_metadata() == NULL && value->gc_metadata() == NULL);
6161 : #ifdef DEBUG
6162 : Code::VerifyRecompiledCode(code(), value);
6163 : #endif // DEBUG
6164 :
6165 2935139 : set_code(value);
6166 2935144 : }
6167 :
6168 : bool SharedFunctionInfo::IsInterpreted() const {
6169 6029814 : return code()->is_interpreter_trampoline_builtin();
6170 : }
6171 :
6172 : bool SharedFunctionInfo::HasBaselineCode() const {
6173 11715 : return code()->kind() == Code::FUNCTION;
6174 : }
6175 :
6176 230847 : ScopeInfo* SharedFunctionInfo::scope_info() const {
6177 7909969 : return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset));
6178 : }
6179 :
6180 :
6181 19827977 : void SharedFunctionInfo::set_scope_info(ScopeInfo* value,
6182 : WriteBarrierMode mode) {
6183 19827977 : WRITE_FIELD(this, kScopeInfoOffset, reinterpret_cast<Object*>(value));
6184 59483915 : CONDITIONAL_WRITE_BARRIER(GetHeap(),
6185 : this,
6186 : kScopeInfoOffset,
6187 : reinterpret_cast<Object*>(value),
6188 : mode);
6189 19827981 : }
6190 :
6191 73929605 : ACCESSORS(SharedFunctionInfo, outer_scope_info, HeapObject,
6192 : kOuterScopeInfoOffset)
6193 :
6194 1027840 : bool SharedFunctionInfo::is_compiled() const {
6195 : Builtins* builtins = GetIsolate()->builtins();
6196 : DCHECK(code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent));
6197 : DCHECK(code() != builtins->builtin(Builtins::kCompileOptimized));
6198 1027840 : return code() != builtins->builtin(Builtins::kCompileLazy);
6199 : }
6200 :
6201 1659 : int SharedFunctionInfo::GetLength() const {
6202 : DCHECK(is_compiled());
6203 : DCHECK(HasLength());
6204 1659 : return length();
6205 : }
6206 :
6207 : bool SharedFunctionInfo::HasLength() const {
6208 : DCHECK_IMPLIES(length() < 0, length() == kInvalidLength);
6209 : return length() != kInvalidLength;
6210 : }
6211 :
6212 : bool SharedFunctionInfo::has_simple_parameters() {
6213 : return scope_info()->HasSimpleParameters();
6214 : }
6215 :
6216 : bool SharedFunctionInfo::HasDebugInfo() const {
6217 : bool has_debug_info = !debug_info()->IsSmi();
6218 : DCHECK_EQ(debug_info()->IsStruct(), has_debug_info);
6219 : DCHECK(!has_debug_info || HasDebugCode());
6220 : return has_debug_info;
6221 : }
6222 :
6223 : DebugInfo* SharedFunctionInfo::GetDebugInfo() const {
6224 : DCHECK(HasDebugInfo());
6225 : return DebugInfo::cast(debug_info());
6226 : }
6227 :
6228 147937 : bool SharedFunctionInfo::HasDebugCode() const {
6229 290239 : if (HasBaselineCode()) return code()->has_debug_break_slots();
6230 5635 : return HasBytecodeArray();
6231 : }
6232 :
6233 : int SharedFunctionInfo::debugger_hints() const {
6234 11895004 : if (HasDebugInfo()) return GetDebugInfo()->debugger_hints();
6235 : return Smi::cast(debug_info())->value();
6236 : }
6237 :
6238 9207492 : void SharedFunctionInfo::set_debugger_hints(int value) {
6239 9207492 : if (HasDebugInfo()) {
6240 : GetDebugInfo()->set_debugger_hints(value);
6241 : } else {
6242 9206091 : set_debug_info(Smi::FromInt(value));
6243 : }
6244 9207494 : }
6245 :
6246 68713040 : bool SharedFunctionInfo::IsApiFunction() {
6247 68713039 : return function_data()->IsFunctionTemplateInfo();
6248 : }
6249 :
6250 :
6251 : FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() {
6252 : DCHECK(IsApiFunction());
6253 : return FunctionTemplateInfo::cast(function_data());
6254 : }
6255 :
6256 : void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
6257 : DCHECK(function_data()->IsUndefined(GetIsolate()));
6258 3761998 : set_function_data(data);
6259 : }
6260 :
6261 3107982 : bool SharedFunctionInfo::HasBytecodeArray() const {
6262 3107983 : return function_data()->IsBytecodeArray();
6263 : }
6264 :
6265 104681 : BytecodeArray* SharedFunctionInfo::bytecode_array() const {
6266 : DCHECK(HasBytecodeArray());
6267 104681 : return BytecodeArray::cast(function_data());
6268 : }
6269 :
6270 1581 : void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) {
6271 : DCHECK(function_data()->IsUndefined(GetIsolate()));
6272 2079421 : set_function_data(bytecode);
6273 1581 : }
6274 :
6275 : void SharedFunctionInfo::ClearBytecodeArray() {
6276 : DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray());
6277 7350 : set_function_data(GetHeap()->undefined_value());
6278 : }
6279 :
6280 20595848 : bool SharedFunctionInfo::HasAsmWasmData() const {
6281 20595848 : return function_data()->IsFixedArray();
6282 : }
6283 :
6284 13483 : FixedArray* SharedFunctionInfo::asm_wasm_data() const {
6285 : DCHECK(HasAsmWasmData());
6286 13483 : return FixedArray::cast(function_data());
6287 : }
6288 :
6289 : void SharedFunctionInfo::set_asm_wasm_data(FixedArray* data) {
6290 : DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData());
6291 3616 : set_function_data(data);
6292 : }
6293 :
6294 507 : void SharedFunctionInfo::ClearAsmWasmData() {
6295 : DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData());
6296 507 : set_function_data(GetHeap()->undefined_value());
6297 507 : }
6298 :
6299 : bool SharedFunctionInfo::HasBuiltinFunctionId() {
6300 : return function_identifier()->IsSmi();
6301 : }
6302 :
6303 : BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
6304 : DCHECK(HasBuiltinFunctionId());
6305 : return static_cast<BuiltinFunctionId>(
6306 275460 : Smi::cast(function_identifier())->value());
6307 : }
6308 :
6309 : void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
6310 24539 : set_function_identifier(Smi::FromInt(id));
6311 : }
6312 :
6313 3676372 : bool SharedFunctionInfo::HasInferredName() {
6314 3676373 : return function_identifier()->IsString();
6315 : }
6316 :
6317 3676373 : String* SharedFunctionInfo::inferred_name() {
6318 3676373 : if (HasInferredName()) {
6319 2818871 : return String::cast(function_identifier());
6320 : }
6321 : Isolate* isolate = GetIsolate();
6322 : DCHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId());
6323 857502 : return isolate->heap()->empty_string();
6324 : }
6325 :
6326 : void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
6327 : DCHECK(function_identifier()->IsUndefined(GetIsolate()) || HasInferredName());
6328 6235390 : set_function_identifier(inferred_name);
6329 : }
6330 :
6331 56411325 : int SharedFunctionInfo::ic_age() {
6332 138919872 : return ICAgeBits::decode(counters());
6333 : }
6334 :
6335 :
6336 : void SharedFunctionInfo::set_ic_age(int ic_age) {
6337 9009354 : set_counters(ICAgeBits::update(counters(), ic_age));
6338 : }
6339 :
6340 :
6341 91 : int SharedFunctionInfo::deopt_count() {
6342 91 : return DeoptCountBits::decode(counters());
6343 : }
6344 :
6345 :
6346 : void SharedFunctionInfo::set_deopt_count(int deopt_count) {
6347 74714 : set_counters(DeoptCountBits::update(counters(), deopt_count));
6348 : }
6349 :
6350 :
6351 : void SharedFunctionInfo::increment_deopt_count() {
6352 : int value = counters();
6353 : int deopt_count = DeoptCountBits::decode(value);
6354 : // Saturate the deopt count when incrementing, rather than overflowing.
6355 258660 : if (deopt_count < DeoptCountBits::kMax) {
6356 515102 : set_counters(DeoptCountBits::update(value, deopt_count + 1));
6357 : }
6358 : }
6359 :
6360 :
6361 : int SharedFunctionInfo::opt_reenable_tries() {
6362 44 : return OptReenableTriesBits::decode(counters());
6363 : }
6364 :
6365 :
6366 : void SharedFunctionInfo::set_opt_reenable_tries(int tries) {
6367 44 : set_counters(OptReenableTriesBits::update(counters(), tries));
6368 : }
6369 :
6370 :
6371 167208 : int SharedFunctionInfo::opt_count() {
6372 167208 : return OptCountBits::decode(opt_count_and_bailout_reason());
6373 : }
6374 :
6375 :
6376 : void SharedFunctionInfo::set_opt_count(int opt_count) {
6377 : set_opt_count_and_bailout_reason(
6378 1359224 : OptCountBits::update(opt_count_and_bailout_reason(), opt_count));
6379 : }
6380 :
6381 :
6382 : BailoutReason SharedFunctionInfo::disable_optimization_reason() {
6383 : return static_cast<BailoutReason>(
6384 183948 : DisabledOptimizationReasonBits::decode(opt_count_and_bailout_reason()));
6385 : }
6386 :
6387 :
6388 : bool SharedFunctionInfo::has_deoptimization_support() {
6389 : Code* code = this->code();
6390 1181085 : return code->kind() == Code::FUNCTION && code->has_deoptimization_support();
6391 : }
6392 :
6393 :
6394 44 : void SharedFunctionInfo::TryReenableOptimization() {
6395 : int tries = opt_reenable_tries();
6396 44 : set_opt_reenable_tries((tries + 1) & OptReenableTriesBits::kMax);
6397 : // We reenable optimization whenever the number of tries is a large
6398 : // enough power of 2.
6399 44 : if (tries >= 16 && (((tries - 1) & tries) == 0)) {
6400 : set_optimization_disabled(false);
6401 : set_deopt_count(0);
6402 : }
6403 44 : }
6404 :
6405 :
6406 2168 : void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) {
6407 : set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update(
6408 118486 : opt_count_and_bailout_reason(), reason));
6409 2168 : }
6410 :
6411 29774352 : bool SharedFunctionInfo::IsUserJavaScript() {
6412 : Object* script_obj = script();
6413 29774352 : if (script_obj->IsUndefined(GetIsolate())) return false;
6414 : Script* script = Script::cast(script_obj);
6415 27904310 : return script->IsUserJavaScript();
6416 : }
6417 :
6418 20872220 : bool SharedFunctionInfo::IsSubjectToDebugging() {
6419 20872220 : return IsUserJavaScript() && !HasAsmWasmData();
6420 : }
6421 :
6422 : bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const {
6423 45338421 : return optimized_code_map() == GetHeap()->empty_fixed_array();
6424 : }
6425 :
6426 7710166 : FeedbackVector* JSFunction::feedback_vector() const {
6427 : DCHECK(feedback_vector_cell()->value()->IsFeedbackVector());
6428 7710166 : return FeedbackVector::cast(feedback_vector_cell()->value());
6429 : }
6430 :
6431 1922411 : bool JSFunction::IsOptimized() {
6432 4640017 : return code()->kind() == Code::OPTIMIZED_FUNCTION;
6433 : }
6434 :
6435 4578 : bool JSFunction::IsInterpreted() {
6436 7182730 : return code()->is_interpreter_trampoline_builtin();
6437 : }
6438 :
6439 : bool JSFunction::IsMarkedForOptimization() {
6440 356137 : return code() == GetIsolate()->builtins()->builtin(
6441 : Builtins::kCompileOptimized);
6442 : }
6443 :
6444 :
6445 5903 : bool JSFunction::IsMarkedForConcurrentOptimization() {
6446 5903 : return code() == GetIsolate()->builtins()->builtin(
6447 5903 : Builtins::kCompileOptimizedConcurrent);
6448 : }
6449 :
6450 :
6451 4270 : bool JSFunction::IsInOptimizationQueue() {
6452 614149 : return code() == GetIsolate()->builtins()->builtin(
6453 4270 : Builtins::kInOptimizationQueue);
6454 : }
6455 :
6456 :
6457 199284 : void JSFunction::CompleteInobjectSlackTrackingIfActive() {
6458 256174 : if (has_initial_map() && initial_map()->IsInobjectSlackTrackingInProgress()) {
6459 40945 : initial_map()->CompleteInobjectSlackTracking();
6460 : }
6461 199284 : }
6462 :
6463 :
6464 : bool Map::IsInobjectSlackTrackingInProgress() {
6465 45730476 : return construction_counter() != Map::kNoSlackTracking;
6466 : }
6467 :
6468 :
6469 408109 : void Map::InobjectSlackTrackingStep() {
6470 816218 : if (!IsInobjectSlackTrackingInProgress()) return;
6471 : int counter = construction_counter();
6472 408109 : set_construction_counter(counter - 1);
6473 408109 : if (counter == kSlackTrackingCounterEnd) {
6474 2177 : CompleteInobjectSlackTracking();
6475 : }
6476 : }
6477 :
6478 : AbstractCode* JSFunction::abstract_code() {
6479 840 : if (IsInterpreted()) {
6480 : return AbstractCode::cast(shared()->bytecode_array());
6481 : } else {
6482 840 : return AbstractCode::cast(code());
6483 : }
6484 : }
6485 :
6486 139146334 : Code* JSFunction::code() {
6487 : return Code::cast(
6488 139146334 : Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset)));
6489 : }
6490 :
6491 :
6492 29732407 : void JSFunction::set_code(Code* value) {
6493 : DCHECK(!GetHeap()->InNewSpace(value));
6494 29732407 : Address entry = value->entry();
6495 29732407 : WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
6496 : GetHeap()->incremental_marking()->RecordWriteOfCodeEntry(
6497 : this,
6498 : HeapObject::RawField(this, kCodeEntryOffset),
6499 59464814 : value);
6500 29732408 : }
6501 :
6502 :
6503 : void JSFunction::set_code_no_write_barrier(Code* value) {
6504 : DCHECK(!GetHeap()->InNewSpace(value));
6505 1358068 : Address entry = value->entry();
6506 1358068 : WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
6507 : }
6508 :
6509 :
6510 2717606 : void JSFunction::ReplaceCode(Code* code) {
6511 : bool was_optimized = IsOptimized();
6512 2717606 : bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION;
6513 :
6514 2717606 : if (was_optimized && is_optimized) {
6515 : shared()->EvictFromOptimizedCodeMap(this->code(),
6516 82 : "Replacing with another optimized code");
6517 : }
6518 :
6519 2717606 : set_code(code);
6520 :
6521 : // Add/remove the function from the list of optimized functions for this
6522 : // context based on the state change.
6523 2717607 : if (!was_optimized && is_optimized) {
6524 1474345 : context()->native_context()->AddOptimizedFunction(this);
6525 : }
6526 2717606 : if (was_optimized && !is_optimized) {
6527 : // TODO(titzer): linear in the number of optimized functions; fix!
6528 6 : context()->native_context()->RemoveOptimizedFunction(this);
6529 : }
6530 2717606 : }
6531 :
6532 10237310 : bool JSFunction::has_feedback_vector() const {
6533 10237309 : return !feedback_vector_cell()->value()->IsUndefined(GetIsolate());
6534 : }
6535 :
6536 18762130 : JSFunction::FeedbackVectorState JSFunction::GetFeedbackVectorState(
6537 : Isolate* isolate) const {
6538 : Cell* cell = feedback_vector_cell();
6539 18762130 : if (cell == isolate->heap()->undefined_cell()) {
6540 : return TOP_LEVEL_SCRIPT_NEEDS_VECTOR;
6541 22875396 : } else if (cell->value() == isolate->heap()->undefined_value() ||
6542 10237190 : !has_feedback_vector()) {
6543 : return NEEDS_VECTOR;
6544 : }
6545 10237189 : return HAS_VECTOR;
6546 : }
6547 :
6548 38602 : Context* JSFunction::context() {
6549 55475549 : return Context::cast(READ_FIELD(this, kContextOffset));
6550 : }
6551 :
6552 489 : bool JSFunction::has_context() const {
6553 978 : return READ_FIELD(this, kContextOffset)->IsContext();
6554 : }
6555 :
6556 86 : JSObject* JSFunction::global_proxy() {
6557 1809399 : return context()->global_proxy();
6558 : }
6559 :
6560 :
6561 597788 : Context* JSFunction::native_context() { return context()->native_context(); }
6562 :
6563 :
6564 26520730 : void JSFunction::set_context(Object* value) {
6565 : DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
6566 26520730 : WRITE_FIELD(this, kContextOffset, value);
6567 79562190 : WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
6568 26520736 : }
6569 :
6570 155103582 : ACCESSORS(JSFunction, prototype_or_initial_map, Object,
6571 : kPrototypeOrInitialMapOffset)
6572 :
6573 :
6574 5997 : Map* JSFunction::initial_map() {
6575 5997 : return Map::cast(prototype_or_initial_map());
6576 : }
6577 :
6578 :
6579 27804507 : bool JSFunction::has_initial_map() {
6580 27804507 : return prototype_or_initial_map()->IsMap();
6581 : }
6582 :
6583 :
6584 682420 : bool JSFunction::has_instance_prototype() {
6585 1335741 : return has_initial_map() ||
6586 682420 : !prototype_or_initial_map()->IsTheHole(GetIsolate());
6587 : }
6588 :
6589 :
6590 210768 : bool JSFunction::has_prototype() {
6591 210768 : return map()->has_non_instance_prototype() || has_instance_prototype();
6592 : }
6593 :
6594 :
6595 : Object* JSFunction::instance_prototype() {
6596 : DCHECK(has_instance_prototype());
6597 5251744 : if (has_initial_map()) return initial_map()->prototype();
6598 : // When there is no initial map and the prototype is a JSObject, the
6599 : // initial map field is used for the prototype field.
6600 : return prototype_or_initial_map();
6601 : }
6602 :
6603 :
6604 4871787 : Object* JSFunction::prototype() {
6605 : DCHECK(has_prototype());
6606 : // If the function's prototype property has been set to a non-JSObject
6607 : // value, that value is stored in the constructor field of the map.
6608 4871787 : if (map()->has_non_instance_prototype()) {
6609 21542 : Object* prototype = map()->GetConstructor();
6610 : // The map must have a prototype in that field, not a back pointer.
6611 : DCHECK(!prototype->IsMap());
6612 : DCHECK(!prototype->IsFunctionTemplateInfo());
6613 21542 : return prototype;
6614 : }
6615 4850245 : return instance_prototype();
6616 : }
6617 :
6618 :
6619 : bool JSFunction::is_compiled() {
6620 : Builtins* builtins = GetIsolate()->builtins();
6621 1954492 : return code() != builtins->builtin(Builtins::kCompileLazy) &&
6622 1900599 : code() != builtins->builtin(Builtins::kCompileOptimized) &&
6623 : code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent);
6624 : }
6625 :
6626 7632798 : ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset)
6627 15141702 : ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
6628 50674 : ACCESSORS(JSProxy, hash, Object, kHashOffset)
6629 :
6630 7509846 : bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); }
6631 :
6632 2519292 : ACCESSORS(JSCollection, table, Object, kTableOffset)
6633 :
6634 :
6635 : #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \
6636 : template<class Derived, class TableType> \
6637 : type* OrderedHashTableIterator<Derived, TableType>::name() const { \
6638 : return type::cast(READ_FIELD(this, offset)); \
6639 : } \
6640 : template<class Derived, class TableType> \
6641 : void OrderedHashTableIterator<Derived, TableType>::set_##name( \
6642 : type* value, WriteBarrierMode mode) { \
6643 : WRITE_FIELD(this, offset, value); \
6644 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
6645 : }
6646 :
6647 95525 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(table, Object, kTableOffset)
6648 143412 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(index, Object, kIndexOffset)
6649 49493 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(kind, Object, kKindOffset)
6650 :
6651 : #undef ORDERED_HASH_TABLE_ITERATOR_ACCESSORS
6652 :
6653 :
6654 420534 : ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
6655 22247 : ACCESSORS(JSWeakCollection, next, Object, kNextOffset)
6656 :
6657 :
6658 153295 : Address Foreign::foreign_address() {
6659 112742127 : return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset));
6660 : }
6661 :
6662 :
6663 : void Foreign::set_foreign_address(Address value) {
6664 4379807 : WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value));
6665 : }
6666 :
6667 :
6668 118205 : ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
6669 184080 : ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
6670 112695 : ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
6671 74073 : ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
6672 138334 : SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
6673 107914 : SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
6674 112641 : ACCESSORS(JSGeneratorObject, register_file, FixedArray, kRegisterFileOffset)
6675 :
6676 0 : bool JSGeneratorObject::is_suspended() const {
6677 : DCHECK_LT(kGeneratorExecuting, 0);
6678 : DCHECK_LT(kGeneratorClosed, 0);
6679 54 : return continuation() >= 0;
6680 : }
6681 :
6682 : bool JSGeneratorObject::is_closed() const {
6683 : return continuation() == kGeneratorClosed;
6684 : }
6685 :
6686 : bool JSGeneratorObject::is_executing() const {
6687 : return continuation() == kGeneratorExecuting;
6688 : }
6689 :
6690 : ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
6691 0 : ACCESSORS(JSAsyncGeneratorObject, await_input_or_debug_pos, Object,
6692 : kAwaitInputOrDebugPosOffset)
6693 0 : ACCESSORS(JSAsyncGeneratorObject, awaited_promise, HeapObject,
6694 : kAwaitedPromiseOffset)
6695 :
6696 5318963 : ACCESSORS(JSValue, value, Object, kValueOffset)
6697 :
6698 :
6699 : HeapNumber* HeapNumber::cast(Object* object) {
6700 : SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
6701 : return reinterpret_cast<HeapNumber*>(object);
6702 : }
6703 :
6704 :
6705 : const HeapNumber* HeapNumber::cast(const Object* object) {
6706 : SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
6707 : return reinterpret_cast<const HeapNumber*>(object);
6708 : }
6709 :
6710 :
6711 856058 : ACCESSORS(JSDate, value, Object, kValueOffset)
6712 256713 : ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
6713 19349 : ACCESSORS(JSDate, year, Object, kYearOffset)
6714 18339 : ACCESSORS(JSDate, month, Object, kMonthOffset)
6715 18072 : ACCESSORS(JSDate, day, Object, kDayOffset)
6716 17959 : ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
6717 22846 : ACCESSORS(JSDate, hour, Object, kHourOffset)
6718 19281 : ACCESSORS(JSDate, min, Object, kMinOffset)
6719 18310 : ACCESSORS(JSDate, sec, Object, kSecOffset)
6720 :
6721 :
6722 1411156 : SMI_ACCESSORS(JSMessageObject, type, kTypeOffset)
6723 4247805 : ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset)
6724 4304459 : ACCESSORS(JSMessageObject, script, Object, kScriptOffset)
6725 4216548 : ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset)
6726 1519521 : SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset)
6727 1430242 : SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
6728 1458110 : SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset)
6729 :
6730 375295465 : INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)
6731 180369035 : INT_ACCESSORS(Code, prologue_offset, kPrologueOffset)
6732 2555745 : INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset)
6733 : #define CODE_ACCESSORS(name, type, offset) \
6734 : ACCESSORS_CHECKED2(Code, name, type, offset, true, \
6735 : !GetHeap()->InNewSpace(value))
6736 11269431 : CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset)
6737 6259969 : CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset)
6738 15181515 : CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset)
6739 21282057 : CODE_ACCESSORS(source_position_table, Object, kSourcePositionTableOffset)
6740 7685659 : CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex)
6741 18659115 : CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset)
6742 7987360 : CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset)
6743 : #undef CODE_ACCESSORS
6744 :
6745 : void Code::WipeOutHeader() {
6746 1366 : WRITE_FIELD(this, kRelocationInfoOffset, NULL);
6747 1366 : WRITE_FIELD(this, kHandlerTableOffset, NULL);
6748 1366 : WRITE_FIELD(this, kDeoptimizationDataOffset, NULL);
6749 1366 : WRITE_FIELD(this, kSourcePositionTableOffset, NULL);
6750 : // Do not wipe out major/minor keys on a code stub or IC
6751 2732 : if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) {
6752 0 : WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL);
6753 : }
6754 1366 : WRITE_FIELD(this, kNextCodeLinkOffset, NULL);
6755 1366 : WRITE_FIELD(this, kGCMetadataOffset, NULL);
6756 : }
6757 :
6758 :
6759 : Object* Code::type_feedback_info() {
6760 : DCHECK(kind() == FUNCTION);
6761 : return raw_type_feedback_info();
6762 : }
6763 :
6764 :
6765 1080611 : void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) {
6766 : DCHECK(kind() == FUNCTION);
6767 1080611 : set_raw_type_feedback_info(value, mode);
6768 3241822 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset,
6769 : value, mode);
6770 1080609 : }
6771 :
6772 1959488 : ByteArray* Code::SourcePositionTable() {
6773 : Object* maybe_table = source_position_table();
6774 1959491 : if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
6775 : DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
6776 : return SourcePositionTableWithFrameCache::cast(maybe_table)
6777 39662 : ->source_position_table();
6778 : }
6779 :
6780 : uint32_t Code::stub_key() {
6781 : DCHECK(IsCodeStubOrIC());
6782 : Smi* smi_key = Smi::cast(raw_type_feedback_info());
6783 879221 : return static_cast<uint32_t>(smi_key->value());
6784 : }
6785 :
6786 :
6787 : void Code::set_stub_key(uint32_t key) {
6788 : DCHECK(IsCodeStubOrIC());
6789 518314 : set_raw_type_feedback_info(Smi::FromInt(key));
6790 : }
6791 :
6792 :
6793 18820862 : ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset)
6794 5111448 : INT_ACCESSORS(Code, ic_age, kICAgeOffset)
6795 :
6796 :
6797 14 : byte* Code::instruction_start() {
6798 14 : return FIELD_ADDR(this, kHeaderSize);
6799 : }
6800 :
6801 :
6802 : byte* Code::instruction_end() {
6803 894470 : return instruction_start() + instruction_size();
6804 : }
6805 :
6806 : int Code::GetUnwindingInfoSizeOffset() const {
6807 : DCHECK(has_unwinding_info());
6808 31 : return RoundUp(kHeaderSize + instruction_size(), kInt64Size);
6809 : }
6810 :
6811 : int Code::unwinding_info_size() const {
6812 : DCHECK(has_unwinding_info());
6813 : return static_cast<int>(
6814 6 : READ_UINT64_FIELD(this, GetUnwindingInfoSizeOffset()));
6815 : }
6816 :
6817 : void Code::set_unwinding_info_size(int value) {
6818 : DCHECK(has_unwinding_info());
6819 25 : WRITE_UINT64_FIELD(this, GetUnwindingInfoSizeOffset(), value);
6820 : }
6821 :
6822 : byte* Code::unwinding_info_start() {
6823 : DCHECK(has_unwinding_info());
6824 31 : return FIELD_ADDR(this, GetUnwindingInfoSizeOffset()) + kInt64Size;
6825 : }
6826 :
6827 : byte* Code::unwinding_info_end() {
6828 : DCHECK(has_unwinding_info());
6829 6 : return unwinding_info_start() + unwinding_info_size();
6830 : }
6831 :
6832 365728465 : int Code::body_size() {
6833 : int unpadded_body_size =
6834 : has_unwinding_info()
6835 6 : ? static_cast<int>(unwinding_info_end() - instruction_start())
6836 365728471 : : instruction_size();
6837 365728465 : return RoundUp(unpadded_body_size, kObjectAlignment);
6838 : }
6839 :
6840 848834 : int Code::SizeIncludingMetadata() {
6841 : int size = CodeSize();
6842 848836 : size += relocation_info()->Size();
6843 848836 : size += deoptimization_data()->Size();
6844 848836 : size += handler_table()->Size();
6845 848834 : if (kind() == FUNCTION) {
6846 1697673 : size += SourcePositionTable()->Size();
6847 : }
6848 848837 : return size;
6849 : }
6850 :
6851 : ByteArray* Code::unchecked_relocation_info() {
6852 180420327 : return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset));
6853 : }
6854 :
6855 :
6856 : byte* Code::relocation_start() {
6857 : return unchecked_relocation_info()->GetDataStartAddress();
6858 : }
6859 :
6860 :
6861 : int Code::relocation_size() {
6862 : return unchecked_relocation_info()->length();
6863 : }
6864 :
6865 :
6866 : byte* Code::entry() {
6867 : return instruction_start();
6868 : }
6869 :
6870 :
6871 : bool Code::contains(byte* inner_pointer) {
6872 1975316 : return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
6873 : }
6874 :
6875 :
6876 : int Code::ExecutableSize() {
6877 : // Check that the assumptions about the layout of the code object holds.
6878 : DCHECK_EQ(static_cast<int>(instruction_start() - address()),
6879 : Code::kHeaderSize);
6880 209623 : return instruction_size() + Code::kHeaderSize;
6881 : }
6882 :
6883 :
6884 365446999 : int Code::CodeSize() { return SizeFor(body_size()); }
6885 :
6886 :
6887 259862490 : ACCESSORS(JSArray, length, Object, kLengthOffset)
6888 :
6889 :
6890 16661 : void* JSArrayBuffer::backing_store() const {
6891 56549154 : intptr_t ptr = READ_INTPTR_FIELD(this, kBackingStoreOffset);
6892 56549154 : return reinterpret_cast<void*>(ptr);
6893 : }
6894 :
6895 :
6896 : void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) {
6897 149047 : intptr_t ptr = reinterpret_cast<intptr_t>(value);
6898 152315 : WRITE_INTPTR_FIELD(this, kBackingStoreOffset, ptr);
6899 : }
6900 :
6901 :
6902 742003 : ACCESSORS(JSArrayBuffer, byte_length, Object, kByteLengthOffset)
6903 :
6904 :
6905 : void JSArrayBuffer::set_bit_field(uint32_t bits) {
6906 : if (kInt32Size != kPointerSize) {
6907 : #if V8_TARGET_LITTLE_ENDIAN
6908 183528 : WRITE_UINT32_FIELD(this, kBitFieldSlot + kInt32Size, 0);
6909 : #else
6910 : WRITE_UINT32_FIELD(this, kBitFieldSlot, 0);
6911 : #endif
6912 : }
6913 595829 : WRITE_UINT32_FIELD(this, kBitFieldOffset, bits);
6914 : }
6915 :
6916 :
6917 : uint32_t JSArrayBuffer::bit_field() const {
6918 97092689 : return READ_UINT32_FIELD(this, kBitFieldOffset);
6919 : }
6920 :
6921 :
6922 210 : bool JSArrayBuffer::is_external() { return IsExternal::decode(bit_field()); }
6923 :
6924 :
6925 3020 : void JSArrayBuffer::set_is_external(bool value) {
6926 : DCHECK(!value || !has_guard_region());
6927 : set_bit_field(IsExternal::update(bit_field(), value));
6928 3020 : }
6929 :
6930 :
6931 : bool JSArrayBuffer::is_neuterable() {
6932 : return IsNeuterable::decode(bit_field());
6933 : }
6934 :
6935 :
6936 : void JSArrayBuffer::set_is_neuterable(bool value) {
6937 : set_bit_field(IsNeuterable::update(bit_field(), value));
6938 : }
6939 :
6940 :
6941 : bool JSArrayBuffer::was_neutered() { return WasNeutered::decode(bit_field()); }
6942 :
6943 :
6944 : void JSArrayBuffer::set_was_neutered(bool value) {
6945 : set_bit_field(WasNeutered::update(bit_field(), value));
6946 : }
6947 :
6948 :
6949 37389600 : bool JSArrayBuffer::is_shared() { return IsShared::decode(bit_field()); }
6950 :
6951 :
6952 : void JSArrayBuffer::set_is_shared(bool value) {
6953 : set_bit_field(IsShared::update(bit_field(), value));
6954 : }
6955 :
6956 : bool JSArrayBuffer::has_guard_region() {
6957 : return HasGuardRegion::decode(bit_field());
6958 : }
6959 :
6960 : void JSArrayBuffer::set_has_guard_region(bool value) {
6961 : set_bit_field(HasGuardRegion::update(bit_field(), value));
6962 : }
6963 :
6964 18720017 : Object* JSArrayBufferView::byte_offset() const {
6965 18735121 : if (WasNeutered()) return Smi::kZero;
6966 18734944 : return Object::cast(READ_FIELD(this, kByteOffsetOffset));
6967 : }
6968 :
6969 :
6970 5943 : void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) {
6971 5943 : WRITE_FIELD(this, kByteOffsetOffset, value);
6972 17829 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode);
6973 5943 : }
6974 :
6975 :
6976 16292 : Object* JSArrayBufferView::byte_length() const {
6977 50021 : if (WasNeutered()) return Smi::kZero;
6978 49844 : return Object::cast(READ_FIELD(this, kByteLengthOffset));
6979 : }
6980 :
6981 :
6982 5943 : void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) {
6983 5943 : WRITE_FIELD(this, kByteLengthOffset, value);
6984 17829 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode);
6985 5943 : }
6986 :
6987 :
6988 78243441 : ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset)
6989 : #ifdef VERIFY_HEAP
6990 : ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset)
6991 : ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset)
6992 : #endif
6993 :
6994 :
6995 41689 : bool JSArrayBufferView::WasNeutered() const {
6996 41689 : return JSArrayBuffer::cast(buffer())->was_neutered();
6997 : }
6998 :
6999 :
7000 18743642 : Object* JSTypedArray::length() const {
7001 18743875 : if (WasNeutered()) return Smi::kZero;
7002 18743830 : return Object::cast(READ_FIELD(this, kLengthOffset));
7003 : }
7004 :
7005 :
7006 59720 : uint32_t JSTypedArray::length_value() const {
7007 59720 : if (WasNeutered()) return 0;
7008 59594 : uint32_t index = 0;
7009 119188 : CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayLength(&index));
7010 59594 : return index;
7011 : }
7012 :
7013 :
7014 372 : void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) {
7015 372 : WRITE_FIELD(this, kLengthOffset, value);
7016 1116 : CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode);
7017 372 : }
7018 :
7019 : // static
7020 43779 : MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
7021 : Handle<Object> receiver,
7022 : const char* method_name) {
7023 43779 : if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
7024 : const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
7025 3388 : THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
7026 : }
7027 :
7028 : Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
7029 42085 : if (V8_UNLIKELY(array->WasNeutered())) {
7030 : const MessageTemplate::Template message =
7031 : MessageTemplate::kDetachedOperation;
7032 : Handle<String> operation =
7033 756 : isolate->factory()->NewStringFromAsciiChecked(method_name);
7034 1512 : THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
7035 : }
7036 :
7037 : // spec describes to return `buffer`, but it may disrupt current
7038 : // implementations, and it's much useful to return array for now.
7039 : return array;
7040 : }
7041 :
7042 : #ifdef VERIFY_HEAP
7043 : ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
7044 : #endif
7045 :
7046 : ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset)
7047 : ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset)
7048 : ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset)
7049 :
7050 508 : SMI_ACCESSORS(JSPromise, status, kStatusOffset)
7051 42 : ACCESSORS(JSPromise, result, Object, kResultOffset)
7052 5642 : ACCESSORS(JSPromise, deferred_promise, Object, kDeferredPromiseOffset)
7053 : ACCESSORS(JSPromise, deferred_on_resolve, Object, kDeferredOnResolveOffset)
7054 : ACCESSORS(JSPromise, deferred_on_reject, Object, kDeferredOnRejectOffset)
7055 : ACCESSORS(JSPromise, fulfill_reactions, Object, kFulfillReactionsOffset)
7056 5642 : ACCESSORS(JSPromise, reject_reactions, Object, kRejectReactionsOffset)
7057 18672 : SMI_ACCESSORS(JSPromise, flags, kFlagsOffset)
7058 15424 : BOOL_ACCESSORS(JSPromise, flags, has_handler, kHasHandlerBit)
7059 : BOOL_ACCESSORS(JSPromise, flags, handled_hint, kHandledHintBit)
7060 :
7061 13818381 : ACCESSORS(JSRegExp, data, Object, kDataOffset)
7062 2149278 : ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
7063 2149338 : ACCESSORS(JSRegExp, source, Object, kSourceOffset)
7064 :
7065 :
7066 3959556 : JSRegExp::Type JSRegExp::TypeTag() {
7067 : Object* data = this->data();
7068 3959556 : if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
7069 : Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
7070 3959556 : return static_cast<JSRegExp::Type>(smi->value());
7071 : }
7072 :
7073 :
7074 368276 : int JSRegExp::CaptureCount() {
7075 368276 : switch (TypeTag()) {
7076 : case ATOM:
7077 : return 0;
7078 : case IRREGEXP:
7079 15492 : return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
7080 : default:
7081 0 : UNREACHABLE();
7082 : return -1;
7083 : }
7084 : }
7085 :
7086 :
7087 156112 : JSRegExp::Flags JSRegExp::GetFlags() {
7088 : DCHECK(this->data()->IsFixedArray());
7089 : Object* data = this->data();
7090 : Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex));
7091 156112 : return Flags(smi->value());
7092 : }
7093 :
7094 :
7095 : String* JSRegExp::Pattern() {
7096 : DCHECK(this->data()->IsFixedArray());
7097 : Object* data = this->data();
7098 : String* pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
7099 : return pattern;
7100 : }
7101 :
7102 173 : Object* JSRegExp::CaptureNameMap() {
7103 : DCHECK(this->data()->IsFixedArray());
7104 : DCHECK_EQ(TypeTag(), IRREGEXP);
7105 : Object* value = DataAt(kIrregexpCaptureNameMapIndex);
7106 : DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
7107 173 : return value;
7108 : }
7109 :
7110 : Object* JSRegExp::DataAt(int index) {
7111 : DCHECK(TypeTag() != NOT_COMPILED);
7112 : return FixedArray::cast(data())->get(index);
7113 : }
7114 :
7115 :
7116 : void JSRegExp::SetDataAt(int index, Object* value) {
7117 : DCHECK(TypeTag() != NOT_COMPILED);
7118 : DCHECK(index >= kDataIndex); // Only implementation data can be set this way.
7119 3557 : FixedArray::cast(data())->set(index, value);
7120 : }
7121 :
7122 0 : void JSRegExp::SetLastIndex(int index) {
7123 : static const int offset =
7124 : kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
7125 : Smi* value = Smi::FromInt(index);
7126 4048 : WRITE_FIELD(this, offset, value);
7127 0 : }
7128 :
7129 0 : Object* JSRegExp::LastIndex() {
7130 : static const int offset =
7131 : kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
7132 8997 : return READ_FIELD(this, offset);
7133 : }
7134 :
7135 679480 : ElementsKind JSObject::GetElementsKind() {
7136 : ElementsKind kind = map()->elements_kind();
7137 : #if VERIFY_HEAP && DEBUG
7138 : FixedArrayBase* fixed_array =
7139 : reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset));
7140 :
7141 : // If a GC was caused while constructing this object, the elements
7142 : // pointer may point to a one pointer filler map.
7143 : if (ElementsAreSafeToExamine()) {
7144 : Map* map = fixed_array->map();
7145 : if (IsFastSmiOrObjectElementsKind(kind)) {
7146 : DCHECK(map == GetHeap()->fixed_array_map() ||
7147 : map == GetHeap()->fixed_cow_array_map());
7148 : } else if (IsFastDoubleElementsKind(kind)) {
7149 : DCHECK(fixed_array->IsFixedDoubleArray() ||
7150 : fixed_array == GetHeap()->empty_fixed_array());
7151 : } else if (kind == DICTIONARY_ELEMENTS) {
7152 : DCHECK(fixed_array->IsFixedArray());
7153 : DCHECK(fixed_array->IsDictionary());
7154 : } else {
7155 : DCHECK(kind > DICTIONARY_ELEMENTS);
7156 : }
7157 : DCHECK(!IsSloppyArgumentsElementsKind(kind) ||
7158 : (elements()->IsFixedArray() && elements()->length() >= 2));
7159 : }
7160 : #endif
7161 679480 : return kind;
7162 : }
7163 :
7164 :
7165 3186002 : bool JSObject::HasFastObjectElements() {
7166 3186002 : return IsFastObjectElementsKind(GetElementsKind());
7167 : }
7168 :
7169 :
7170 1913597 : bool JSObject::HasFastSmiElements() {
7171 1913597 : return IsFastSmiElementsKind(GetElementsKind());
7172 : }
7173 :
7174 :
7175 2254997 : bool JSObject::HasFastSmiOrObjectElements() {
7176 2254997 : return IsFastSmiOrObjectElementsKind(GetElementsKind());
7177 : }
7178 :
7179 :
7180 3910721 : bool JSObject::HasFastDoubleElements() {
7181 3910721 : return IsFastDoubleElementsKind(GetElementsKind());
7182 : }
7183 :
7184 :
7185 8250813 : bool JSObject::HasFastHoleyElements() {
7186 8250813 : return IsFastHoleyElementsKind(GetElementsKind());
7187 : }
7188 :
7189 :
7190 5330974 : bool JSObject::HasFastElements() {
7191 5330974 : return IsFastElementsKind(GetElementsKind());
7192 : }
7193 :
7194 :
7195 960100 : bool JSObject::HasDictionaryElements() {
7196 960100 : return GetElementsKind() == DICTIONARY_ELEMENTS;
7197 : }
7198 :
7199 :
7200 : bool JSObject::HasFastArgumentsElements() {
7201 : return GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
7202 : }
7203 :
7204 :
7205 631210 : bool JSObject::HasSlowArgumentsElements() {
7206 631210 : return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
7207 : }
7208 :
7209 :
7210 1228826 : bool JSObject::HasSloppyArgumentsElements() {
7211 1228826 : return IsSloppyArgumentsElementsKind(GetElementsKind());
7212 : }
7213 :
7214 129458 : bool JSObject::HasStringWrapperElements() {
7215 129458 : return IsStringWrapperElementsKind(GetElementsKind());
7216 : }
7217 :
7218 2200931 : bool JSObject::HasFastStringWrapperElements() {
7219 2200931 : return GetElementsKind() == FAST_STRING_WRAPPER_ELEMENTS;
7220 : }
7221 :
7222 211591 : bool JSObject::HasSlowStringWrapperElements() {
7223 211591 : return GetElementsKind() == SLOW_STRING_WRAPPER_ELEMENTS;
7224 : }
7225 :
7226 1970254 : bool JSObject::HasFixedTypedArrayElements() {
7227 : DCHECK_NOT_NULL(elements());
7228 1970254 : return map()->has_fixed_typed_array_elements();
7229 : }
7230 :
7231 : #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \
7232 : bool JSObject::HasFixed##Type##Elements() { \
7233 : HeapObject* array = elements(); \
7234 : DCHECK(array != NULL); \
7235 : if (!array->IsHeapObject()) return false; \
7236 : return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \
7237 : }
7238 :
7239 1890 : TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK)
7240 :
7241 : #undef FIXED_TYPED_ELEMENTS_CHECK
7242 :
7243 :
7244 0 : bool JSObject::HasNamedInterceptor() {
7245 0 : return map()->has_named_interceptor();
7246 : }
7247 :
7248 :
7249 24606 : bool JSObject::HasIndexedInterceptor() {
7250 24606 : return map()->has_indexed_interceptor();
7251 : }
7252 :
7253 :
7254 : GlobalDictionary* JSObject::global_dictionary() {
7255 : DCHECK(!HasFastProperties());
7256 : DCHECK(IsJSGlobalObject());
7257 : return GlobalDictionary::cast(properties());
7258 : }
7259 :
7260 :
7261 4562 : SeededNumberDictionary* JSObject::element_dictionary() {
7262 : DCHECK(HasDictionaryElements() || HasSlowStringWrapperElements());
7263 4562 : return SeededNumberDictionary::cast(elements());
7264 : }
7265 :
7266 :
7267 : bool Name::IsHashFieldComputed(uint32_t field) {
7268 838348481 : return (field & kHashNotComputedMask) == 0;
7269 : }
7270 :
7271 :
7272 : bool Name::HasHashCode() {
7273 : return IsHashFieldComputed(hash_field());
7274 : }
7275 :
7276 :
7277 19589942 : uint32_t Name::Hash() {
7278 : // Fast case: has hash code already been computed?
7279 : uint32_t field = hash_field();
7280 620958112 : if (IsHashFieldComputed(field)) return field >> kHashShift;
7281 : // Slow case: compute hash code and set it. Has to be a string.
7282 29114635 : return String::cast(this)->ComputeAndSetHash();
7283 : }
7284 :
7285 :
7286 357132199 : bool Name::IsPrivate() {
7287 398664763 : return this->IsSymbol() && Symbol::cast(this)->is_private();
7288 : }
7289 :
7290 :
7291 : StringHasher::StringHasher(int length, uint32_t seed)
7292 : : length_(length),
7293 : raw_running_hash_(seed),
7294 : array_index_(0),
7295 188524907 : is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize),
7296 401530187 : is_first_char_(true) {
7297 : DCHECK(FLAG_randomize_hashes || raw_running_hash_ == 0);
7298 : }
7299 :
7300 :
7301 : bool StringHasher::has_trivial_hash() {
7302 : return length_ > String::kMaxHashCalcLength;
7303 : }
7304 :
7305 :
7306 : uint32_t StringHasher::AddCharacterCore(uint32_t running_hash, uint16_t c) {
7307 2646596745 : running_hash += c;
7308 2646596745 : running_hash += (running_hash << 10);
7309 2646596745 : running_hash ^= (running_hash >> 6);
7310 : return running_hash;
7311 : }
7312 :
7313 :
7314 : uint32_t StringHasher::GetHashCore(uint32_t running_hash) {
7315 217421890 : running_hash += (running_hash << 3);
7316 217421890 : running_hash ^= (running_hash >> 11);
7317 217421890 : running_hash += (running_hash << 15);
7318 217421890 : if ((running_hash & String::kHashBitMask) == 0) {
7319 : return kZeroHash;
7320 : }
7321 : return running_hash;
7322 : }
7323 :
7324 :
7325 : uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash,
7326 : const uc16* chars, int length) {
7327 : DCHECK_NOT_NULL(chars);
7328 : DCHECK(length >= 0);
7329 175 : for (int i = 0; i < length; ++i) {
7330 175 : running_hash = AddCharacterCore(running_hash, *chars++);
7331 : }
7332 : return running_hash;
7333 : }
7334 :
7335 :
7336 : uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash,
7337 : const char* chars,
7338 : int length) {
7339 : DCHECK_NOT_NULL(chars);
7340 : DCHECK(length >= 0);
7341 85696 : for (int i = 0; i < length; ++i) {
7342 85696 : uint16_t c = static_cast<uint16_t>(*chars++);
7343 : running_hash = AddCharacterCore(running_hash, c);
7344 : }
7345 : return running_hash;
7346 : }
7347 :
7348 :
7349 : void StringHasher::AddCharacter(uint16_t c) {
7350 : // Use the Jenkins one-at-a-time hash function to update the hash
7351 : // for the given character.
7352 5113013644 : raw_running_hash_ = AddCharacterCore(raw_running_hash_, c);
7353 : }
7354 :
7355 :
7356 182392333 : bool StringHasher::UpdateIndex(uint16_t c) {
7357 : DCHECK(is_array_index_);
7358 182392333 : if (c < '0' || c > '9') {
7359 145564525 : is_array_index_ = false;
7360 145564525 : return false;
7361 : }
7362 36827808 : int d = c - '0';
7363 36827808 : if (is_first_char_) {
7364 10680698 : is_first_char_ = false;
7365 10680698 : if (c == '0' && length_ > 1) {
7366 18092 : is_array_index_ = false;
7367 18092 : return false;
7368 : }
7369 : }
7370 36809716 : if (array_index_ > 429496729U - ((d + 3) >> 3)) {
7371 4579 : is_array_index_ = false;
7372 4579 : return false;
7373 : }
7374 36805137 : array_index_ = array_index_ * 10 + d;
7375 36805137 : return true;
7376 : }
7377 :
7378 :
7379 : template<typename Char>
7380 199102097 : inline void StringHasher::AddCharacters(const Char* chars, int length) {
7381 : DCHECK(sizeof(Char) == 1 || sizeof(Char) == 2);
7382 : int i = 0;
7383 199102097 : if (is_array_index_) {
7384 36798899 : for (; i < length; i++) {
7385 157908044 : AddCharacter(chars[i]);
7386 157908044 : if (!UpdateIndex(chars[i])) {
7387 121109137 : i++;
7388 121109137 : break;
7389 : }
7390 : }
7391 : }
7392 1871002795 : for (; i < length; i++) {
7393 : DCHECK(!is_array_index_);
7394 1871002795 : AddCharacter(chars[i]);
7395 : }
7396 199102089 : }
7397 :
7398 :
7399 : template <typename schar>
7400 159409091 : uint32_t StringHasher::HashSequentialString(const schar* chars,
7401 : int length,
7402 : uint32_t seed) {
7403 : StringHasher hasher(length, seed);
7404 159409091 : if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length);
7405 159409203 : return hasher.GetHashField();
7406 : }
7407 :
7408 :
7409 : IteratingStringHasher::IteratingStringHasher(int len, uint32_t seed)
7410 : : StringHasher(len, seed) {}
7411 :
7412 :
7413 29115816 : uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) {
7414 : IteratingStringHasher hasher(string->length(), seed);
7415 : // Nothing to do.
7416 29115816 : if (hasher.has_trivial_hash()) return hasher.GetHashField();
7417 29054970 : ConsString* cons_string = String::VisitFlat(&hasher, string);
7418 29054975 : if (cons_string == nullptr) return hasher.GetHashField();
7419 2502618 : hasher.VisitConsString(cons_string);
7420 2502618 : return hasher.GetHashField();
7421 : }
7422 :
7423 :
7424 : void IteratingStringHasher::VisitOneByteString(const uint8_t* chars,
7425 : int length) {
7426 35073669 : AddCharacters(chars, length);
7427 : }
7428 :
7429 :
7430 : void IteratingStringHasher::VisitTwoByteString(const uint16_t* chars,
7431 : int length) {
7432 4304452 : AddCharacters(chars, length);
7433 : }
7434 :
7435 :
7436 175732130 : bool Name::AsArrayIndex(uint32_t* index) {
7437 175732131 : return IsString() && String::cast(this)->AsArrayIndex(index);
7438 : }
7439 :
7440 :
7441 184860899 : bool String::AsArrayIndex(uint32_t* index) {
7442 : uint32_t field = hash_field();
7443 184860899 : if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) {
7444 : return false;
7445 : }
7446 23899336 : return SlowAsArrayIndex(index);
7447 : }
7448 :
7449 :
7450 : void String::SetForwardedInternalizedString(String* canonical) {
7451 : DCHECK(IsInternalizedString());
7452 : DCHECK(HasHashCode());
7453 2756 : if (canonical == this) return; // No need to forward.
7454 : DCHECK(SlowEquals(canonical));
7455 : DCHECK(canonical->IsInternalizedString());
7456 : DCHECK(canonical->HasHashCode());
7457 2756 : WRITE_FIELD(this, kHashFieldSlot, canonical);
7458 : // Setting the hash field to a tagged value sets the LSB, causing the hash
7459 : // code to be interpreted as uninitialized. We use this fact to recognize
7460 : // that we have a forwarded string.
7461 : DCHECK(!HasHashCode());
7462 : }
7463 :
7464 :
7465 : String* String::GetForwardedInternalizedString() {
7466 : DCHECK(IsInternalizedString());
7467 8177 : if (HasHashCode()) return this;
7468 2426 : String* canonical = String::cast(READ_FIELD(this, kHashFieldSlot));
7469 : DCHECK(canonical->IsInternalizedString());
7470 : DCHECK(SlowEquals(canonical));
7471 : DCHECK(canonical->HasHashCode());
7472 : return canonical;
7473 : }
7474 :
7475 :
7476 : // static
7477 0 : Maybe<bool> Object::GreaterThan(Handle<Object> x, Handle<Object> y) {
7478 0 : Maybe<ComparisonResult> result = Compare(x, y);
7479 0 : if (result.IsJust()) {
7480 0 : switch (result.FromJust()) {
7481 : case ComparisonResult::kGreaterThan:
7482 : return Just(true);
7483 : case ComparisonResult::kLessThan:
7484 : case ComparisonResult::kEqual:
7485 : case ComparisonResult::kUndefined:
7486 : return Just(false);
7487 : }
7488 : }
7489 : return Nothing<bool>();
7490 : }
7491 :
7492 :
7493 : // static
7494 0 : Maybe<bool> Object::GreaterThanOrEqual(Handle<Object> x, Handle<Object> y) {
7495 0 : Maybe<ComparisonResult> result = Compare(x, y);
7496 0 : if (result.IsJust()) {
7497 0 : switch (result.FromJust()) {
7498 : case ComparisonResult::kEqual:
7499 : case ComparisonResult::kGreaterThan:
7500 : return Just(true);
7501 : case ComparisonResult::kLessThan:
7502 : case ComparisonResult::kUndefined:
7503 : return Just(false);
7504 : }
7505 : }
7506 : return Nothing<bool>();
7507 : }
7508 :
7509 :
7510 : // static
7511 0 : Maybe<bool> Object::LessThan(Handle<Object> x, Handle<Object> y) {
7512 0 : Maybe<ComparisonResult> result = Compare(x, y);
7513 0 : if (result.IsJust()) {
7514 0 : switch (result.FromJust()) {
7515 : case ComparisonResult::kLessThan:
7516 : return Just(true);
7517 : case ComparisonResult::kEqual:
7518 : case ComparisonResult::kGreaterThan:
7519 : case ComparisonResult::kUndefined:
7520 : return Just(false);
7521 : }
7522 : }
7523 : return Nothing<bool>();
7524 : }
7525 :
7526 :
7527 : // static
7528 0 : Maybe<bool> Object::LessThanOrEqual(Handle<Object> x, Handle<Object> y) {
7529 0 : Maybe<ComparisonResult> result = Compare(x, y);
7530 0 : if (result.IsJust()) {
7531 0 : switch (result.FromJust()) {
7532 : case ComparisonResult::kEqual:
7533 : case ComparisonResult::kLessThan:
7534 : return Just(true);
7535 : case ComparisonResult::kGreaterThan:
7536 : case ComparisonResult::kUndefined:
7537 : return Just(false);
7538 : }
7539 : }
7540 : return Nothing<bool>();
7541 : }
7542 :
7543 206902 : MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
7544 : Handle<Name> name) {
7545 : LookupIterator it =
7546 206902 : LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
7547 206902 : return GetProperty(&it);
7548 : }
7549 :
7550 : MaybeHandle<Object> Object::SetPropertyOrElement(Handle<Object> object,
7551 : Handle<Name> name,
7552 : Handle<Object> value,
7553 : LanguageMode language_mode,
7554 : StoreFromKeyed store_mode) {
7555 : LookupIterator it =
7556 : LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
7557 : MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
7558 : return value;
7559 : }
7560 :
7561 15375 : MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver,
7562 : Handle<Name> name,
7563 : Handle<JSReceiver> holder) {
7564 : LookupIterator it = LookupIterator::PropertyOrElement(
7565 15375 : name->GetIsolate(), receiver, name, holder);
7566 15375 : return GetProperty(&it);
7567 : }
7568 :
7569 :
7570 26564419 : void JSReceiver::initialize_properties() {
7571 : DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
7572 : DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_properties_dictionary()));
7573 26564419 : if (map()->is_dictionary_map()) {
7574 45340 : WRITE_FIELD(this, kPropertiesOffset,
7575 45340 : GetHeap()->empty_properties_dictionary());
7576 : } else {
7577 26519079 : WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array());
7578 : }
7579 26564419 : }
7580 :
7581 :
7582 296297702 : bool JSReceiver::HasFastProperties() {
7583 : DCHECK_EQ(properties()->IsDictionary(), map()->is_dictionary_map());
7584 296297702 : return !properties()->IsDictionary();
7585 : }
7586 :
7587 :
7588 2880880 : NameDictionary* JSReceiver::property_dictionary() {
7589 : DCHECK(!HasFastProperties());
7590 : DCHECK(!IsJSGlobalObject());
7591 2880880 : return NameDictionary::cast(properties());
7592 : }
7593 :
7594 452408 : Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
7595 : Handle<Name> name) {
7596 : LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
7597 452408 : object, name, object);
7598 452408 : return HasProperty(&it);
7599 : }
7600 :
7601 :
7602 10390548 : Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
7603 : Handle<Name> name) {
7604 10390548 : if (object->IsJSObject()) { // Shortcut
7605 : LookupIterator it = LookupIterator::PropertyOrElement(
7606 10388657 : object->GetIsolate(), object, name, object, LookupIterator::OWN);
7607 10388657 : return HasProperty(&it);
7608 : }
7609 :
7610 : Maybe<PropertyAttributes> attributes =
7611 1891 : JSReceiver::GetOwnPropertyAttributes(object, name);
7612 1891 : MAYBE_RETURN(attributes, Nothing<bool>());
7613 1751 : return Just(attributes.FromJust() != ABSENT);
7614 : }
7615 :
7616 30 : Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
7617 : uint32_t index) {
7618 30 : if (object->IsJSObject()) { // Shortcut
7619 : LookupIterator it(object->GetIsolate(), object, index, object,
7620 : LookupIterator::OWN);
7621 30 : return HasProperty(&it);
7622 : }
7623 :
7624 : Maybe<PropertyAttributes> attributes =
7625 0 : JSReceiver::GetOwnPropertyAttributes(object, index);
7626 0 : MAYBE_RETURN(attributes, Nothing<bool>());
7627 0 : return Just(attributes.FromJust() != ABSENT);
7628 : }
7629 :
7630 1839368 : Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
7631 : Handle<JSReceiver> object, Handle<Name> name) {
7632 : LookupIterator it = LookupIterator::PropertyOrElement(name->GetIsolate(),
7633 1839368 : object, name, object);
7634 1839368 : return GetPropertyAttributes(&it);
7635 : }
7636 :
7637 :
7638 1228577 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
7639 : Handle<JSReceiver> object, Handle<Name> name) {
7640 : LookupIterator it = LookupIterator::PropertyOrElement(
7641 1228577 : name->GetIsolate(), object, name, object, LookupIterator::OWN);
7642 1228577 : return GetPropertyAttributes(&it);
7643 : }
7644 :
7645 0 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
7646 : Handle<JSReceiver> object, uint32_t index) {
7647 : LookupIterator it(object->GetIsolate(), object, index, object,
7648 : LookupIterator::OWN);
7649 0 : return GetPropertyAttributes(&it);
7650 : }
7651 :
7652 1812033 : Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
7653 : LookupIterator it(object->GetIsolate(), object, index, object);
7654 1812033 : return HasProperty(&it);
7655 : }
7656 :
7657 :
7658 : Maybe<PropertyAttributes> JSReceiver::GetElementAttributes(
7659 : Handle<JSReceiver> object, uint32_t index) {
7660 : Isolate* isolate = object->GetIsolate();
7661 : LookupIterator it(isolate, object, index, object);
7662 : return GetPropertyAttributes(&it);
7663 : }
7664 :
7665 :
7666 : Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttributes(
7667 : Handle<JSReceiver> object, uint32_t index) {
7668 : Isolate* isolate = object->GetIsolate();
7669 : LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
7670 : return GetPropertyAttributes(&it);
7671 : }
7672 :
7673 :
7674 : bool JSGlobalObject::IsDetached() {
7675 : return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this);
7676 : }
7677 :
7678 :
7679 980097 : bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const {
7680 : const PrototypeIterator iter(this->GetIsolate(),
7681 : const_cast<JSGlobalProxy*>(this));
7682 980097 : return iter.GetCurrent() != global;
7683 : }
7684 :
7685 : inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
7686 : DCHECK_GE(embedder_field_count, 0);
7687 106839 : return kSize + embedder_field_count * kPointerSize;
7688 : }
7689 :
7690 5646 : Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate,
7691 : Handle<JSReceiver> object) {
7692 : return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash(
7693 : isolate, Handle<JSProxy>::cast(object))
7694 : : JSObject::GetOrCreateIdentityHash(
7695 8074 : isolate, Handle<JSObject>::cast(object));
7696 : }
7697 :
7698 16991 : Object* JSReceiver::GetIdentityHash(Isolate* isolate,
7699 : Handle<JSReceiver> receiver) {
7700 : return receiver->IsJSProxy()
7701 : ? JSProxy::GetIdentityHash(Handle<JSProxy>::cast(receiver))
7702 : : JSObject::GetIdentityHash(isolate,
7703 33716 : Handle<JSObject>::cast(receiver));
7704 : }
7705 :
7706 :
7707 : bool AccessorInfo::all_can_read() {
7708 : return BooleanBit::get(flag(), kAllCanReadBit);
7709 : }
7710 :
7711 :
7712 : void AccessorInfo::set_all_can_read(bool value) {
7713 : set_flag(BooleanBit::set(flag(), kAllCanReadBit, value));
7714 : }
7715 :
7716 :
7717 : bool AccessorInfo::all_can_write() {
7718 : return BooleanBit::get(flag(), kAllCanWriteBit);
7719 : }
7720 :
7721 :
7722 : void AccessorInfo::set_all_can_write(bool value) {
7723 : set_flag(BooleanBit::set(flag(), kAllCanWriteBit, value));
7724 : }
7725 :
7726 :
7727 : bool AccessorInfo::is_special_data_property() {
7728 : return BooleanBit::get(flag(), kSpecialDataProperty);
7729 : }
7730 :
7731 :
7732 : void AccessorInfo::set_is_special_data_property(bool value) {
7733 : set_flag(BooleanBit::set(flag(), kSpecialDataProperty, value));
7734 : }
7735 :
7736 : bool AccessorInfo::replace_on_access() {
7737 : return BooleanBit::get(flag(), kReplaceOnAccess);
7738 : }
7739 :
7740 : void AccessorInfo::set_replace_on_access(bool value) {
7741 : set_flag(BooleanBit::set(flag(), kReplaceOnAccess, value));
7742 : }
7743 :
7744 : bool AccessorInfo::is_sloppy() { return BooleanBit::get(flag(), kIsSloppy); }
7745 :
7746 : void AccessorInfo::set_is_sloppy(bool value) {
7747 : set_flag(BooleanBit::set(flag(), kIsSloppy, value));
7748 : }
7749 :
7750 : PropertyAttributes AccessorInfo::property_attributes() {
7751 118411 : return AttributesField::decode(static_cast<uint32_t>(flag()));
7752 : }
7753 :
7754 :
7755 : void AccessorInfo::set_property_attributes(PropertyAttributes attributes) {
7756 248810 : set_flag(AttributesField::update(flag(), attributes));
7757 : }
7758 :
7759 17500 : bool FunctionTemplateInfo::IsTemplateFor(JSObject* object) {
7760 17500 : return IsTemplateFor(object->map());
7761 : }
7762 :
7763 2670258 : bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
7764 2670258 : if (!HasExpectedReceiverType()) return true;
7765 406 : if (!receiver->IsJSObject()) return false;
7766 : return FunctionTemplateInfo::cast(expected_receiver_type())
7767 406 : ->IsTemplateFor(JSObject::cast(receiver)->map());
7768 : }
7769 :
7770 :
7771 2710068 : bool AccessorInfo::HasExpectedReceiverType() {
7772 2710067 : return expected_receiver_type()->IsFunctionTemplateInfo();
7773 : }
7774 :
7775 :
7776 : Object* AccessorPair::get(AccessorComponent component) {
7777 71561 : return component == ACCESSOR_GETTER ? getter() : setter();
7778 : }
7779 :
7780 :
7781 : void AccessorPair::set(AccessorComponent component, Object* value) {
7782 : if (component == ACCESSOR_GETTER) {
7783 : set_getter(value);
7784 : } else {
7785 : set_setter(value);
7786 : }
7787 : }
7788 :
7789 :
7790 507260 : void AccessorPair::SetComponents(Object* getter, Object* setter) {
7791 : Isolate* isolate = GetIsolate();
7792 507261 : if (!getter->IsNull(isolate)) set_getter(getter);
7793 507260 : if (!setter->IsNull(isolate)) set_setter(setter);
7794 507260 : }
7795 :
7796 :
7797 : bool AccessorPair::Equals(AccessorPair* pair) {
7798 : return (this == pair) || pair->Equals(getter(), setter());
7799 : }
7800 :
7801 :
7802 : bool AccessorPair::Equals(Object* getter_value, Object* setter_value) {
7803 51468 : return (getter() == getter_value) && (setter() == setter_value);
7804 : }
7805 :
7806 :
7807 : bool AccessorPair::ContainsAccessor() {
7808 : return IsJSAccessor(getter()) || IsJSAccessor(setter());
7809 : }
7810 :
7811 :
7812 : bool AccessorPair::IsJSAccessor(Object* obj) {
7813 : return obj->IsCallable() || obj->IsUndefined(GetIsolate());
7814 : }
7815 :
7816 :
7817 : template<typename Derived, typename Shape, typename Key>
7818 6169770 : void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7819 : Handle<Object> key,
7820 : Handle<Object> value) {
7821 : this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero));
7822 6169770 : }
7823 :
7824 :
7825 : template<typename Derived, typename Shape, typename Key>
7826 0 : void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7827 : Handle<Object> key,
7828 : Handle<Object> value,
7829 : PropertyDetails details) {
7830 45016951 : Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details);
7831 0 : }
7832 :
7833 :
7834 : template <typename Key>
7835 : template <typename Dictionary>
7836 36185291 : void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry,
7837 : Handle<Object> key,
7838 : Handle<Object> value,
7839 : PropertyDetails details) {
7840 : STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3);
7841 : DCHECK(!key->IsName() || details.dictionary_index() > 0);
7842 : int index = dict->EntryToIndex(entry);
7843 : DisallowHeapAllocation no_gc;
7844 36185291 : WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
7845 36185291 : dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
7846 36185291 : dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
7847 : if (Dictionary::kEntrySize == 3) {
7848 : dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi());
7849 : }
7850 36185291 : }
7851 :
7852 :
7853 : template <typename Dictionary>
7854 8831660 : void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry,
7855 : Handle<Object> key, Handle<Object> value,
7856 : PropertyDetails details) {
7857 : STATIC_ASSERT(Dictionary::kEntrySize == 2);
7858 : DCHECK(!key->IsName() || details.dictionary_index() > 0);
7859 : DCHECK(value->IsPropertyCell());
7860 : int index = dict->EntryToIndex(entry);
7861 : DisallowHeapAllocation no_gc;
7862 8831660 : WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
7863 8831661 : dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
7864 8831661 : dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
7865 : PropertyCell::cast(*value)->set_property_details(details);
7866 8831663 : }
7867 :
7868 :
7869 : bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
7870 : DCHECK(other->IsNumber());
7871 107706833 : return key == static_cast<uint32_t>(other->Number());
7872 : }
7873 :
7874 :
7875 : uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) {
7876 : return ComputeIntegerHash(key, 0);
7877 : }
7878 :
7879 :
7880 181703 : uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key,
7881 : Object* other) {
7882 : DCHECK(other->IsNumber());
7883 363406 : return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0);
7884 : }
7885 :
7886 : Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) {
7887 381990 : return isolate->heap()->unseeded_number_dictionary_map();
7888 : }
7889 :
7890 : uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) {
7891 : return ComputeIntegerHash(key, seed);
7892 : }
7893 :
7894 :
7895 3607223 : uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key,
7896 : uint32_t seed,
7897 : Object* other) {
7898 : DCHECK(other->IsNumber());
7899 7214446 : return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed);
7900 : }
7901 :
7902 :
7903 : Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) {
7904 7691383 : return isolate->factory()->NewNumberFromUint(key);
7905 : }
7906 :
7907 :
7908 : bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
7909 : DCHECK(Name::cast(other)->IsUniqueName());
7910 : DCHECK(key->IsUniqueName());
7911 : return *key == other;
7912 : }
7913 :
7914 :
7915 30903220 : uint32_t NameDictionaryShape::Hash(Handle<Name> key) {
7916 30903220 : return key->Hash();
7917 : }
7918 :
7919 :
7920 : uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) {
7921 : return Name::cast(other)->Hash();
7922 : }
7923 :
7924 :
7925 : Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
7926 : Handle<Name> key) {
7927 : DCHECK(key->IsUniqueName());
7928 : return key;
7929 : }
7930 :
7931 :
7932 : template <typename Dictionary>
7933 : PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
7934 : DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
7935 167670363 : Object* raw_value = dict->ValueAt(entry);
7936 : DCHECK(raw_value->IsPropertyCell());
7937 : PropertyCell* cell = PropertyCell::cast(raw_value);
7938 : return cell->property_details();
7939 : }
7940 :
7941 :
7942 : template <typename Dictionary>
7943 0 : void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
7944 : PropertyDetails value) {
7945 : DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
7946 0 : Object* raw_value = dict->ValueAt(entry);
7947 : DCHECK(raw_value->IsPropertyCell());
7948 : PropertyCell* cell = PropertyCell::cast(raw_value);
7949 : cell->set_property_details(value);
7950 0 : }
7951 :
7952 :
7953 : template <typename Dictionary>
7954 13622742 : bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
7955 : DCHECK(dict->ValueAt(entry)->IsPropertyCell());
7956 : Isolate* isolate = dict->GetIsolate();
7957 27245484 : return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(isolate);
7958 : }
7959 :
7960 :
7961 : bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
7962 1455324 : return key->SameValue(other);
7963 : }
7964 :
7965 :
7966 : uint32_t ObjectHashTableShape::Hash(Handle<Object> key) {
7967 0 : return Smi::cast(key->GetHash())->value();
7968 : }
7969 :
7970 :
7971 : uint32_t ObjectHashTableShape::HashForObject(Handle<Object> key,
7972 : Object* other) {
7973 629056 : return Smi::cast(other->GetHash())->value();
7974 : }
7975 :
7976 :
7977 : Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate,
7978 : Handle<Object> key) {
7979 : return key;
7980 : }
7981 :
7982 :
7983 : Handle<ObjectHashTable> ObjectHashTable::Shrink(
7984 : Handle<ObjectHashTable> table, Handle<Object> key) {
7985 125 : return DerivedHashTable::Shrink(table, key);
7986 : }
7987 :
7988 :
7989 9807 : Object* OrderedHashMap::ValueAt(int entry) {
7990 19614 : return get(EntryToIndex(entry) + kValueOffset);
7991 : }
7992 :
7993 :
7994 : template <int entrysize>
7995 5515638 : bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) {
7996 5515638 : if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
7997 : return key->IsWeakCell() ? WeakCell::cast(*key)->value() == other
7998 11031276 : : *key == other;
7999 : }
8000 :
8001 :
8002 : template <int entrysize>
8003 2247910 : uint32_t WeakHashTableShape<entrysize>::Hash(Handle<Object> key) {
8004 : intptr_t hash =
8005 : key->IsWeakCell()
8006 : ? reinterpret_cast<intptr_t>(WeakCell::cast(*key)->value())
8007 4495826 : : reinterpret_cast<intptr_t>(*key);
8008 2247913 : return (uint32_t)(hash & 0xFFFFFFFF);
8009 : }
8010 :
8011 :
8012 : template <int entrysize>
8013 1275479 : uint32_t WeakHashTableShape<entrysize>::HashForObject(Handle<Object> key,
8014 : Object* other) {
8015 1275479 : if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
8016 1275479 : intptr_t hash = reinterpret_cast<intptr_t>(other);
8017 1275479 : return (uint32_t)(hash & 0xFFFFFFFF);
8018 : }
8019 :
8020 :
8021 : template <int entrysize>
8022 : Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate,
8023 : Handle<Object> key) {
8024 : return key;
8025 : }
8026 :
8027 :
8028 6746 : ACCESSORS(ModuleInfoEntry, export_name, Object, kExportNameOffset)
8029 5584 : ACCESSORS(ModuleInfoEntry, local_name, Object, kLocalNameOffset)
8030 6661 : ACCESSORS(ModuleInfoEntry, import_name, Object, kImportNameOffset)
8031 5102 : SMI_ACCESSORS(ModuleInfoEntry, module_request, kModuleRequestOffset)
8032 4655 : SMI_ACCESSORS(ModuleInfoEntry, cell_index, kCellIndexOffset)
8033 2313 : SMI_ACCESSORS(ModuleInfoEntry, beg_pos, kBegPosOffset)
8034 2313 : SMI_ACCESSORS(ModuleInfoEntry, end_pos, kEndPosOffset)
8035 :
8036 69539039 : void Map::ClearCodeCache(Heap* heap) {
8037 : // No write barrier is needed since empty_fixed_array is not in new space.
8038 : // Please note this function is used during marking:
8039 : // - MarkCompactCollector::MarkUnmarkedObject
8040 : // - IncrementalMarking::Step
8041 69539039 : WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array());
8042 44592621 : }
8043 :
8044 :
8045 6130353 : int Map::SlackForArraySize(int old_size, int size_limit) {
8046 6130353 : const int max_slack = size_limit - old_size;
8047 6130353 : CHECK_LE(0, max_slack);
8048 6130353 : if (old_size < 4) {
8049 : DCHECK_LE(1, max_slack);
8050 : return 1;
8051 : }
8052 6411900 : return Min(max_slack, old_size / 4);
8053 : }
8054 :
8055 :
8056 2438 : void JSArray::set_length(Smi* length) {
8057 : // Don't need a write barrier for a Smi.
8058 28365536 : set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER);
8059 2438 : }
8060 :
8061 :
8062 1719033 : bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) {
8063 : // This constant is somewhat arbitrary. Any large enough value would work.
8064 : const uint32_t kMaxFastArrayLength = 32 * 1024 * 1024;
8065 : // If the new array won't fit in a some non-trivial fraction of the max old
8066 : // space size, then force it to go dictionary mode.
8067 : uint32_t heap_based_upper_bound =
8068 1719033 : static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
8069 : return new_length >= Min(kMaxFastArrayLength, heap_based_upper_bound);
8070 : }
8071 :
8072 :
8073 : bool JSArray::AllowsSetLength() {
8074 : bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
8075 : DCHECK(result == !HasFixedTypedArrayElements());
8076 : return result;
8077 : }
8078 :
8079 :
8080 141370 : void JSArray::SetContent(Handle<JSArray> array,
8081 : Handle<FixedArrayBase> storage) {
8082 : EnsureCanContainElements(array, storage, storage->length(),
8083 282740 : ALLOW_COPIED_DOUBLE_ELEMENTS);
8084 :
8085 : DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() &&
8086 : IsFastDoubleElementsKind(array->GetElementsKind())) ||
8087 : ((storage->map() != array->GetHeap()->fixed_double_array_map()) &&
8088 : (IsFastObjectElementsKind(array->GetElementsKind()) ||
8089 : (IsFastSmiElementsKind(array->GetElementsKind()) &&
8090 : Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
8091 141370 : array->set_elements(*storage);
8092 : array->set_length(Smi::FromInt(storage->length()));
8093 141370 : }
8094 :
8095 :
8096 876449 : bool JSArray::HasArrayPrototype(Isolate* isolate) {
8097 1752898 : return map()->prototype() == *isolate->initial_array_prototype();
8098 : }
8099 :
8100 :
8101 : int TypeFeedbackInfo::ic_total_count() {
8102 161719 : int current = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
8103 : return ICTotalCountField::decode(current);
8104 : }
8105 :
8106 :
8107 : void TypeFeedbackInfo::set_ic_total_count(int count) {
8108 1080614 : int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
8109 : value = ICTotalCountField::update(value,
8110 2161228 : ICTotalCountField::decode(count));
8111 1080614 : WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
8112 : }
8113 :
8114 :
8115 : int TypeFeedbackInfo::ic_with_type_info_count() {
8116 161719 : int current = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
8117 : return ICsWithTypeInfoCountField::decode(current);
8118 : }
8119 :
8120 :
8121 : void TypeFeedbackInfo::change_ic_with_type_info_count(int delta) {
8122 764022 : if (delta == 0) return;
8123 725739 : int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
8124 725739 : int new_count = ICsWithTypeInfoCountField::decode(value) + delta;
8125 : // We can get negative count here when the type-feedback info is
8126 : // shared between two code objects. The can only happen when
8127 : // the debugger made a shallow copy of code object (see Heap::CopyCode).
8128 : // Since we do not optimize when the debugger is active, we can skip
8129 : // this counter update.
8130 725739 : if (new_count >= 0) {
8131 725739 : new_count &= ICsWithTypeInfoCountField::kMask;
8132 1451478 : value = ICsWithTypeInfoCountField::update(value, new_count);
8133 725739 : WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
8134 : }
8135 : }
8136 :
8137 :
8138 : int TypeFeedbackInfo::ic_generic_count() {
8139 186279 : return Smi::cast(READ_FIELD(this, kStorage3Offset))->value();
8140 : }
8141 :
8142 :
8143 : void TypeFeedbackInfo::change_ic_generic_count(int delta) {
8144 764022 : if (delta == 0) return;
8145 24560 : int new_count = ic_generic_count() + delta;
8146 24560 : if (new_count >= 0) {
8147 24560 : new_count &= ~Smi::kMinValue;
8148 24560 : WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(new_count));
8149 : }
8150 : }
8151 :
8152 :
8153 : void TypeFeedbackInfo::initialize_storage() {
8154 1080614 : WRITE_FIELD(this, kStorage1Offset, Smi::kZero);
8155 1080614 : WRITE_FIELD(this, kStorage2Offset, Smi::kZero);
8156 1080614 : WRITE_FIELD(this, kStorage3Offset, Smi::kZero);
8157 : }
8158 :
8159 :
8160 : void TypeFeedbackInfo::change_own_type_change_checksum() {
8161 3977353 : int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
8162 3977353 : int checksum = OwnTypeChangeChecksum::decode(value);
8163 3977353 : checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits);
8164 3977353 : value = OwnTypeChangeChecksum::update(value, checksum);
8165 : // Ensure packed bit field is in Smi range.
8166 : if (value > Smi::kMaxValue) value |= Smi::kMinValue;
8167 : if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
8168 3977353 : WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
8169 : }
8170 :
8171 :
8172 : void TypeFeedbackInfo::set_inlined_type_change_checksum(int checksum) {
8173 : int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
8174 : int mask = (1 << kTypeChangeChecksumBits) - 1;
8175 260261 : value = InlinedTypeChangeChecksum::update(value, checksum & mask);
8176 : // Ensure packed bit field is in Smi range.
8177 : if (value > Smi::kMaxValue) value |= Smi::kMinValue;
8178 : if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
8179 260261 : WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
8180 : }
8181 :
8182 :
8183 : int TypeFeedbackInfo::own_type_change_checksum() {
8184 367622 : int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
8185 367622 : return OwnTypeChangeChecksum::decode(value);
8186 : }
8187 :
8188 :
8189 : bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) {
8190 260261 : int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
8191 : int mask = (1 << kTypeChangeChecksumBits) - 1;
8192 520522 : return InlinedTypeChangeChecksum::decode(value) == (checksum & mask);
8193 : }
8194 :
8195 :
8196 235 : SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot, kAliasedContextSlot)
8197 :
8198 :
8199 192057104 : Relocatable::Relocatable(Isolate* isolate) {
8200 96028552 : isolate_ = isolate;
8201 96028552 : prev_ = isolate->relocatable_top();
8202 : isolate->set_relocatable_top(this);
8203 : }
8204 :
8205 :
8206 96024968 : Relocatable::~Relocatable() {
8207 : DCHECK_EQ(isolate_->relocatable_top(), this);
8208 96024968 : isolate_->set_relocatable_top(prev_);
8209 0 : }
8210 :
8211 :
8212 : template<class Derived, class TableType>
8213 0 : Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
8214 : TableType* table(TableType::cast(this->table()));
8215 : int index = Smi::cast(this->index())->value();
8216 10193 : Object* key = table->KeyAt(index);
8217 : DCHECK(!key->IsTheHole(table->GetIsolate()));
8218 0 : return key;
8219 : }
8220 :
8221 :
8222 6608 : void JSSetIterator::PopulateValueArray(FixedArray* array) {
8223 6608 : array->set(0, CurrentKey());
8224 6608 : }
8225 :
8226 :
8227 3585 : void JSMapIterator::PopulateValueArray(FixedArray* array) {
8228 3585 : array->set(0, CurrentKey());
8229 3585 : array->set(1, CurrentValue());
8230 3585 : }
8231 :
8232 :
8233 : Object* JSMapIterator::CurrentValue() {
8234 : OrderedHashMap* table(OrderedHashMap::cast(this->table()));
8235 : int index = Smi::cast(this->index())->value();
8236 3585 : Object* value = table->ValueAt(index);
8237 : DCHECK(!value->IsTheHole(table->GetIsolate()));
8238 : return value;
8239 : }
8240 :
8241 :
8242 : String::SubStringRange::SubStringRange(String* string, int first, int length)
8243 : : string_(string),
8244 : first_(first),
8245 0 : length_(length == -1 ? string->length() : length) {}
8246 :
8247 :
8248 : class String::SubStringRange::iterator final {
8249 : public:
8250 : typedef std::forward_iterator_tag iterator_category;
8251 : typedef int difference_type;
8252 : typedef uc16 value_type;
8253 : typedef uc16* pointer;
8254 : typedef uc16& reference;
8255 :
8256 : iterator(const iterator& other)
8257 : : content_(other.content_), offset_(other.offset_) {}
8258 :
8259 0 : uc16 operator*() { return content_.Get(offset_); }
8260 : bool operator==(const iterator& other) const {
8261 : return content_.UsesSameString(other.content_) && offset_ == other.offset_;
8262 : }
8263 : bool operator!=(const iterator& other) const {
8264 0 : return !content_.UsesSameString(other.content_) || offset_ != other.offset_;
8265 : }
8266 : iterator& operator++() {
8267 0 : ++offset_;
8268 : return *this;
8269 : }
8270 : iterator operator++(int);
8271 :
8272 : private:
8273 : friend class String;
8274 : iterator(String* from, int offset)
8275 0 : : content_(from->GetFlatContent()), offset_(offset) {}
8276 : String::FlatContent content_;
8277 : int offset_;
8278 : };
8279 :
8280 :
8281 : String::SubStringRange::iterator String::SubStringRange::begin() {
8282 : return String::SubStringRange::iterator(string_, first_);
8283 : }
8284 :
8285 :
8286 : String::SubStringRange::iterator String::SubStringRange::end() {
8287 0 : return String::SubStringRange::iterator(string_, first_ + length_);
8288 : }
8289 :
8290 :
8291 : // Predictably converts HeapObject* or Address to uint32 by calculating
8292 : // offset of the address in respective MemoryChunk.
8293 : static inline uint32_t ObjectAddressForHashing(void* object) {
8294 120793121 : uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
8295 120793121 : return value & MemoryChunk::kAlignmentMask;
8296 : }
8297 :
8298 392 : static inline Handle<Object> MakeEntryPair(Isolate* isolate, uint32_t index,
8299 : Handle<Object> value) {
8300 392 : Handle<Object> key = isolate->factory()->Uint32ToString(index);
8301 : Handle<FixedArray> entry_storage =
8302 392 : isolate->factory()->NewUninitializedFixedArray(2);
8303 : {
8304 392 : entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
8305 392 : entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
8306 : }
8307 : return isolate->factory()->NewJSArrayWithElements(entry_storage,
8308 392 : FAST_ELEMENTS, 2);
8309 : }
8310 :
8311 560 : static inline Handle<Object> MakeEntryPair(Isolate* isolate, Handle<Name> key,
8312 : Handle<Object> value) {
8313 : Handle<FixedArray> entry_storage =
8314 560 : isolate->factory()->NewUninitializedFixedArray(2);
8315 : {
8316 560 : entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
8317 560 : entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
8318 : }
8319 : return isolate->factory()->NewJSArrayWithElements(entry_storage,
8320 560 : FAST_ELEMENTS, 2);
8321 : }
8322 :
8323 1847 : ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
8324 0 : ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
8325 :
8326 45 : ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset)
8327 90 : ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset)
8328 45 : ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset)
8329 :
8330 996 : ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
8331 : kSyncIteratorOffset)
8332 :
8333 24 : ACCESSORS(JSStringIterator, string, String, kStringOffset)
8334 16 : SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
8335 :
8336 : #undef INT_ACCESSORS
8337 : #undef ACCESSORS
8338 : #undef ACCESSORS_CHECKED
8339 : #undef ACCESSORS_CHECKED2
8340 : #undef SMI_ACCESSORS
8341 : #undef SYNCHRONIZED_SMI_ACCESSORS
8342 : #undef NOBARRIER_SMI_ACCESSORS
8343 : #undef BOOL_GETTER
8344 : #undef BOOL_ACCESSORS
8345 : #undef NOBARRIER_READ_FIELD
8346 : #undef NOBARRIER_WRITE_FIELD
8347 : #undef WRITE_BARRIER
8348 : #undef CONDITIONAL_WRITE_BARRIER
8349 : #undef READ_DOUBLE_FIELD
8350 : #undef WRITE_DOUBLE_FIELD
8351 : #undef READ_INT_FIELD
8352 : #undef WRITE_INT_FIELD
8353 : #undef READ_INTPTR_FIELD
8354 : #undef WRITE_INTPTR_FIELD
8355 : #undef READ_UINT8_FIELD
8356 : #undef WRITE_UINT8_FIELD
8357 : #undef READ_INT8_FIELD
8358 : #undef WRITE_INT8_FIELD
8359 : #undef READ_UINT16_FIELD
8360 : #undef WRITE_UINT16_FIELD
8361 : #undef READ_INT16_FIELD
8362 : #undef WRITE_INT16_FIELD
8363 : #undef READ_UINT32_FIELD
8364 : #undef WRITE_UINT32_FIELD
8365 : #undef READ_INT32_FIELD
8366 : #undef WRITE_INT32_FIELD
8367 : #undef READ_FLOAT_FIELD
8368 : #undef WRITE_FLOAT_FIELD
8369 : #undef READ_UINT64_FIELD
8370 : #undef WRITE_UINT64_FIELD
8371 : #undef READ_INT64_FIELD
8372 : #undef WRITE_INT64_FIELD
8373 : #undef READ_BYTE_FIELD
8374 : #undef WRITE_BYTE_FIELD
8375 : #undef NOBARRIER_READ_BYTE_FIELD
8376 : #undef NOBARRIER_WRITE_BYTE_FIELD
8377 :
8378 : } // namespace internal
8379 : } // namespace v8
8380 :
8381 : #include "src/objects/object-macros-undef.h"
8382 :
8383 : #endif // V8_OBJECTS_INL_H_
|