forked from nodejs/llnode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllv8-constants.cc
More file actions
650 lines (520 loc) · 22.4 KB
/
llv8-constants.cc
File metadata and controls
650 lines (520 loc) · 22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#include <stdlib.h>
#include <string.h>
#include <cinttypes>
#include <string>
#include <lldb/API/SBExpressionOptions.h>
#include "src/llv8-constants.h"
#include "src/llv8.h"
namespace llnode {
namespace v8 {
namespace constants {
using lldb::addr_t;
using lldb::SBAddress;
using lldb::SBError;
using lldb::SBProcess;
using lldb::SBSymbol;
using lldb::SBSymbolContext;
using lldb::SBSymbolContextList;
using lldb::SBTarget;
void Module::Assign(SBTarget target, Common* common) {
loaded_ = false;
target_ = target;
common_ = common;
}
void Common::Load() {
kPointerSize = 1 << LoadConstant("PointerSizeLog2", "SystemPointerSizeLog2");
kVersionMajor = LoadRawConstant("v8::internal::Version::major_");
kVersionMinor = LoadRawConstant("v8::internal::Version::minor_");
kVersionPatch = LoadRawConstant("v8::internal::Version::patch_");
}
bool Common::CheckHighestVersion(int64_t major, int64_t minor, int64_t patch) {
Load();
if (kVersionMajor < major) return true;
if (kVersionMajor > major) return false;
if (kVersionMinor < minor) return true;
if (kVersionMinor > minor) return false;
if (kVersionPatch > patch) return false;
return true;
}
bool Common::CheckLowestVersion(int64_t major, int64_t minor, int64_t patch) {
Load();
if (kVersionMajor > major) return true;
if (kVersionMajor < major) return false;
if (kVersionMinor > minor) return true;
if (kVersionMinor < minor) return false;
if (kVersionPatch < patch) return false;
return true;
}
void Smi::Load() {
kTag = LoadConstant("SmiTag");
kTagMask = LoadConstant("SmiTagMask");
kShiftSize = LoadConstant("SmiShiftSize");
}
void HeapObject::Load() {
kTag = LoadConstant("HeapObjectTag");
kTagMask = LoadConstant("HeapObjectTagMask");
kMapOffset = LoadConstant("class_HeapObject__map__Map");
}
void Map::Load() {
Error err;
kInstanceAttrsOffset = LoadConstant({"class_Map__instance_attributes__int",
"class_Map__instance_type__uint16_t"});
if (kInstanceAttrsOffset.name() ==
"v8dbg_class_Map__instance_type__uint16_t") {
kMapTypeMask = 0xffff;
} else {
kMapTypeMask = 0xff;
}
kMaybeConstructorOffset =
LoadConstant("class_Map__constructor_or_backpointer__Object",
"class_Map__constructor__Object");
kInstanceDescriptorsOffset = LoadConstant({
"class_Map__instance_descriptors__DescriptorArray",
"class_Map__instance_descriptors_offset",
});
kBitField3Offset =
LoadConstant("class_Map__bit_field3__int", "class_Map__bit_field3__SMI");
kInObjectPropertiesOffset = LoadConstant(
"class_Map__inobject_properties_or_constructor_function_index__int",
"class_Map__inobject_properties__int");
if (kInObjectPropertiesOffset == -1) {
kInObjectPropertiesStartOffset = LoadConstant(
"class_Map__inobject_properties_start_or_constructor_function_index__"
"char");
}
kInstanceTypeOffset = LoadConstant("class_Map__instance_type__uint16_t");
kInstanceSizeOffset = LoadConstant("class_Map__instance_size__int",
"class_Map__instance_size_in_words__char");
kDictionaryMapShift = LoadConstant("bit_field3_dictionary_map_shift",
"bit_field3_is_dictionary_map_shift");
kNumberOfOwnDescriptorsShift =
LoadConstant("bit_field3_number_of_own_descriptors_shift");
kNumberOfOwnDescriptorsMask =
LoadConstant("bit_field3_number_of_own_descriptors_mask");
if (kNumberOfOwnDescriptorsShift == -1) {
// TODO(indutny): check v8 version?
static const int64_t kDescriptorIndexBitCount = 10;
kNumberOfOwnDescriptorsShift = kDictionaryMapShift;
kNumberOfOwnDescriptorsShift -= kDescriptorIndexBitCount;
kNumberOfOwnDescriptorsMask = (1 << kDescriptorIndexBitCount) - 1;
kNumberOfOwnDescriptorsMask <<= kNumberOfOwnDescriptorsShift;
}
kLayoutDescriptor =
LoadConstant({"class_Map__layout_descriptor__LayoutDescriptor"});
}
bool Map::HasUnboxedDoubleFields() {
// LayoutDescriptor is used by V8 to define which fields are not tagged
// (unboxed). In preparation for pointer compressions, V8 disabled unboxed
// doubles everywhere, which means Map doesn't have a layout_descriptor
// field, but because of how gen-postmortem-metadata works and how Torque
// generates the offsets file, we get a constant for it anyway. In the future
// unboxing will be enabled again, in which case this field will be used.
// Until then, we use the presence of this field as version (if the field is
// present, it's safe to assume we're on V8 8.1+, at least on supported
// release lines).
return !kLayoutDescriptor.Loaded();
}
void JSObject::Load() {
kPropertiesOffset =
LoadConstant("class_JSReceiver__raw_properties_or_hash__Object",
"class_JSReceiver__properties__FixedArray");
if (kPropertiesOffset == -1)
kPropertiesOffset = LoadConstant("class_JSObject__properties__FixedArray");
kElementsOffset = LoadConstant("class_JSObject__elements__Object");
kInternalFieldsOffset =
LoadConstant("class_JSObject__internal_fields__uintptr_t");
if (kInternalFieldsOffset == -1) {
common_->Load();
// TODO(indutny): check V8 version?
kInternalFieldsOffset = kElementsOffset + common_->kPointerSize;
}
}
void HeapNumber::Load() {
kValueOffset = LoadConstant("class_HeapNumber__value__double");
}
void JSArray::Load() {
kLengthOffset = LoadConstant("class_JSArray__length__Object");
}
void JSFunction::Load() {
kSharedInfoOffset =
LoadConstant("class_JSFunction__shared__SharedFunctionInfo");
kContextOffset = LoadConstant("class_JSFunction__context__Context");
if (kContextOffset == -1) {
common_->Load();
// TODO(indutny): check V8 version?
kContextOffset = kSharedInfoOffset + common_->kPointerSize;
}
}
void JSRegExp::Load() {
kSourceOffset = LoadConstant("class_JSRegExp__source__Object");
}
void JSDate::Load() {
kValueOffset = LoadConstant("class_JSDate__value__Object");
};
void SharedInfo::Load() {
kFunctionDataOffset =
LoadConstant("class_SharedFunctionInfo__function_data__Object");
kNameOrScopeInfoOffset =
LoadConstant("class_SharedFunctionInfo__name_or_scope_info__Object");
kNameOffset = LoadConstant("class_SharedFunctionInfo__raw_name__Object",
"class_SharedFunctionInfo__name__Object");
kInferredNameOffset =
LoadConstant("class_SharedFunctionInfo__inferred_name__String",
"class_SharedFunctionInfo__function_identifier__Object");
kScriptOffset = LoadConstant("class_SharedFunctionInfo__script__Object");
kScriptOrDebugInfoOffset = LoadConstant(
{"class_SharedFunctionInfo__script_or_debug_info__Object",
"class_SharedFunctionInfo__script_or_debug_info__HeapObject"});
kStartPositionOffset =
LoadConstant("class_SharedFunctionInfo__start_position_and_type__int",
"class_SharedFunctionInfo__start_position_and_type__SMI");
kEndPositionOffset =
LoadConstant("class_SharedFunctionInfo__end_position__int",
"class_SharedFunctionInfo__end_position__SMI");
kParameterCountOffset = LoadConstant(
"class_SharedFunctionInfo__internal_formal_parameter_count__int",
"class_SharedFunctionInfo__internal_formal_parameter_count__uint16_t");
if (kParameterCountOffset == -1) {
kParameterCountOffset = LoadConstant(
"class_SharedFunctionInfo__internal_formal_parameter_count__SMI",
"class_SharedFunctionInfo__formal_parameter_count__SMI");
}
// NOTE: Could potentially be -1 on v4 and v5 node, should check in llv8
kScopeInfoOffset =
LoadConstant("class_SharedFunctionInfo__scope_info__ScopeInfo");
kStartPositionMask = LoadConstant("sharedfunctioninfo_start_position_mask");
kStartPositionShift = LoadConstant("sharedfunctioninfo_start_position_shift");
if (kStartPositionShift == -1) {
// TODO(indutny): check version?
kStartPositionShift = 2;
kStartPositionMask = ~((1 << kStartPositionShift) - 1);
}
if (LoadConstant("class_SharedFunctionInfo__compiler_hints__int") == -1 &&
kNameOrScopeInfoOffset == -1)
kEndPositionShift = 1;
else
kEndPositionShift = 0;
}
void UncompiledData::Load() {
kInferredNameOffset =
LoadConstant("class_UncompiledData__inferred_name__String");
kStartPositionOffset =
LoadConstant("class_UncompiledData__start_position__int32_t");
kEndPositionOffset =
LoadConstant("class_UncompiledData__end_position__int32_t");
}
void Code::Load() {
kStartOffset = LoadConstant("class_Code__instruction_start__uintptr_t");
kSizeOffset = LoadConstant("class_Code__instruction_size__int");
}
void ScopeInfo::Load() {
kParameterCountOffset = LoadConstant("scopeinfo_idx_nparams");
kStackLocalCountOffset = LoadConstant("scopeinfo_idx_nstacklocals");
kEmbeddedParamAndStackLocals = kStackLocalCountOffset != -1;
kContextLocalCountOffset = LoadConstant("scopeinfo_idx_ncontextlocals");
kVariablePartIndex = LoadConstant("scopeinfo_idx_first_vars");
}
void Context::Load() {
kClosureIndex = LoadConstant("class_Context__closure_index__int",
"context_idx_closure", -1);
kScopeInfoIndex = LoadConstant("context_idx_scope_info", -1);
kPreviousIndex =
LoadConstant("class_Context__previous_index__int", "context_idx_prev");
// TODO (mmarchini) change LoadConstant to accept variable arguments, a list
// of constants or a fallback list).
kNativeIndex =
LoadConstant("class_Context__native_index__int", "context_idx_native");
if (kNativeIndex == -1) {
kNativeIndex = LoadConstant("class_Context__native_context_index__int");
}
kEmbedderDataIndex = LoadConstant("context_idx_embedder_data", (int)5);
kMinContextSlots = LoadConstant("class_Context__min_context_slots__int",
"context_min_slots");
}
void Script::Load() {
kNameOffset = LoadConstant("class_Script__name__Object");
kLineOffsetOffset = LoadConstant("class_Script__line_offset__SMI");
kSourceOffset = LoadConstant("class_Script__source__Object");
kLineEndsOffset = LoadConstant("class_Script__line_ends__Object");
}
void String::Load() {
kEncodingMask = LoadConstant("StringEncodingMask");
kRepresentationMask = LoadConstant("StringRepresentationMask");
kOneByteStringTag = LoadConstant("OneByteStringTag", "AsciiStringTag");
kTwoByteStringTag = LoadConstant("TwoByteStringTag");
kSeqStringTag = LoadConstant("SeqStringTag");
kConsStringTag = LoadConstant("ConsStringTag");
kSlicedStringTag = LoadConstant("SlicedStringTag");
kExternalStringTag = LoadConstant("ExternalStringTag");
kThinStringTag = LoadConstant("ThinStringTag");
kLengthIsSmi = true;
kLengthOffset = LoadConstant("class_String__length__SMI");
if (kLengthOffset == -1) {
kLengthIsSmi = false;
kLengthOffset = LoadConstant("class_String__length__int32_t");
}
}
void OneByteString::Load() {
kCharsOffset = LoadConstant("class_SeqOneByteString__chars__char",
"class_SeqAsciiString__chars__char");
}
void TwoByteString::Load() {
kCharsOffset = LoadConstant("class_SeqTwoByteString__chars__char",
"class_SeqAsciiString__chars__char");
}
void ConsString::Load() {
kFirstOffset = LoadConstant({"class_ConsString__first__String",
"class_ConsString__first_offset__int"});
kSecondOffset = LoadConstant({"class_ConsString__second__String",
"class_ConsString__second_offset__int"});
}
void SlicedString::Load() {
kParentOffset = LoadConstant("class_SlicedString__parent__String");
kOffsetOffset = LoadConstant({"class_SlicedString__offset__SMI",
"class_SlicedString__offset_offset__int"});
}
void ThinString::Load() {
kActualOffset = LoadConstant({"class_ThinString__actual__String",
"class_ThinString__actual_offset__int"});
}
void FixedArrayBase::Load() {
kLengthOffset = LoadConstant("class_FixedArrayBase__length__SMI");
}
void FixedArray::Load() {
kDataOffset = LoadConstant("class_FixedArray__data__uintptr_t");
}
void FixedTypedArrayBase::Load() {
kBasePointerOffset = LoadOptionalConstant(
{"class_FixedTypedArrayBase__base_pointer__Object"}, 0);
kExternalPointerOffset = LoadOptionalConstant(
{"class_FixedTypedArrayBase__external_pointer__Object",
"class_FixedTypedArrayBase__external_pointer__uintptr_t"},
0);
}
void JSTypedArray::Load() {
kBasePointerOffset =
LoadOptionalConstant({"class_JSTypedArray__base_pointer__Object"}, 0);
kExternalPointerOffset = LoadOptionalConstant(
{"class_JSTypedArray__external_pointer__uintptr_t"}, 0);
}
// TODO(mmarchini): proper validation so that we log an error if neither classes
// were able to load their constants.
bool JSTypedArray::IsDataPointerInJSTypedArray() {
return kBasePointerOffset.Loaded() && kExternalPointerOffset.Loaded();
}
void Oddball::Load() {
kKindOffset = LoadConstant("class_Oddball__kind_offset__int");
kException = LoadConstant("OddballException");
kFalse = LoadConstant("OddballFalse");
kTrue = LoadConstant("OddballTrue");
kUndefined = LoadConstant("OddballUndefined");
kTheHole = LoadConstant("OddballTheHole");
kNull = LoadConstant("OddballNull");
kUninitialized = LoadConstant("OddballUninitialized");
}
void JSArrayBuffer::Load() {
kBackingStoreOffset =
LoadConstant({"class_JSArrayBuffer__backing_store__Object",
"class_JSArrayBuffer__backing_store__uintptr_t"});
kByteLengthOffset =
LoadConstant({"class_JSArrayBuffer__byte_length__Object",
"class_JSArrayBuffer__byte_length__size_t"});
if (kBackingStoreOffset.Check()) {
}
kWasNeuteredMask = LoadConstant("jsarray_buffer_was_neutered_mask");
kWasNeuteredShift = LoadConstant("jsarray_buffer_was_neutered_shift");
if (kWasNeuteredMask == -1) {
// TODO(indutny): check V8 version?
kWasNeuteredMask = 1 << 3;
kWasNeuteredShift = 3;
}
}
bool JSArrayBuffer::IsByteLengthScalar() {
return kByteLengthOffset.name() ==
"v8dbg_class_JSArrayBuffer__byte_length__size_t";
}
Constant<int64_t> JSArrayBuffer::BitFieldOffset() {
if (!kBackingStoreOffset.Check()) return Constant<int64_t>();
common_->Load();
int64_t kBitFieldOffset = *kBackingStoreOffset + common_->kPointerSize;
if (common_->kPointerSize == 8) kBitFieldOffset += 4;
return Constant<int64_t>(kBitFieldOffset);
}
void JSArrayBufferView::Load() {
kBufferOffset = LoadConstant("class_JSArrayBufferView__buffer__Object");
kByteOffsetOffset =
LoadConstant({"class_JSArrayBufferView__raw_byte_offset__Object",
"class_JSArrayBufferView__byte_offset__size_t"});
kByteLengthOffset =
LoadConstant({"class_JSArrayBufferView__raw_byte_length__Object",
"class_JSArrayBufferView__byte_length__size_t"});
}
bool JSArrayBufferView::IsByteLengthScalar() {
return kByteLengthOffset.name() ==
"v8dbg_class_JSArrayBufferView__byte_length__size_t";
}
bool JSArrayBufferView::IsByteOffsetScalar() {
return kByteOffsetOffset.name() ==
"v8dbg_class_JSArrayBufferView__byte_offset__size_t";
}
void DescriptorArray::Load() {
kDetailsOffset = LoadConstant({"prop_desc_details"});
kKeyOffset = LoadConstant({"prop_desc_key"});
kValueOffset = LoadConstant({"prop_desc_value"});
kPropertyIndexMask = LoadConstant("prop_index_mask");
kPropertyIndexShift = LoadConstant("prop_index_shift");
kPropertyTypeMask = LoadConstant("prop_type_mask");
if (kPropertyTypeMask == -1) { // node.js >= 8
kPropertyAttributesMask = LoadConstant("prop_attributes_mask");
kPropertyAttributesShift = LoadConstant("prop_attributes_shift");
kPropertyAttributesEnum_NONE = LoadConstant("prop_attributes_NONE");
kPropertyAttributesEnum_READ_ONLY =
LoadConstant("prop_attributes_READ_ONLY");
kPropertyAttributesEnum_DONT_ENUM =
LoadConstant("prop_attributes_DONT_ENUM");
kPropertyAttributesEnum_DONT_DELETE =
LoadConstant("prop_attributes_DONT_ENUM");
kPropertyKindMask = LoadConstant("prop_kind_mask");
kPropertyKindEnum_kAccessor = LoadConstant("prop_kind_Accessor");
kPropertyKindEnum_kData = LoadConstant("prop_kind_Data");
kPropertyLocationMask = LoadConstant("prop_location_mask");
kPropertyLocationShift = LoadConstant("prop_location_shift");
kPropertyLocationEnum_kDescriptor =
LoadConstant("prop_location_Descriptor");
kPropertyLocationEnum_kField = LoadConstant("prop_location_Field");
} else { // node.js <= 7
kFieldType = LoadConstant("prop_type_field");
kConstFieldType = LoadConstant("prop_type_const_field");
if (kConstFieldType == -1) {
// TODO(indutny): check V8 version?
kConstFieldType = kFieldType | 0x2;
}
}
kRepresentationShift = LoadConstant("prop_representation_shift");
kRepresentationMask = LoadConstant("prop_representation_mask");
if (kRepresentationShift == -1) {
// TODO(indutny): check V8 version?
kRepresentationShift = 5;
kRepresentationMask = ((1 << 4) - 1) << kRepresentationShift;
}
kRepresentationDouble = LoadConstant("prop_representation_double");
if (kRepresentationDouble == -1) {
// TODO(indutny): check V8 version?
kRepresentationDouble = 7;
}
// NOTE(mmarchini): removed from V8 7.2.
// https://github.com/v8/v8/commit/1ad0cd5
kFirstIndex = LoadOptionalConstant({"prop_idx_first"}, 0);
kSize = LoadConstant({"prop_desc_size"});
kHeaderSize = LoadOptionalConstant(
{"class_DescriptorArray__header_size__uintptr_t"}, 24);
}
void NameDictionary::Load() {
// TODO(indutny): move this to postmortem
kKeyOffset = 0;
kValueOffset = 1;
kEntrySize = LoadConstant("class_NameDictionaryShape__entry_size__int",
"namedictionaryshape_entry_size");
kPrefixStartIndex =
LoadConstant("class_NameDictionary__prefix_start_index__int",
"namedictionary_prefix_start_index");
if (kPrefixStartIndex == -1) {
// TODO(indutny): check V8 version?
kPrefixStartIndex = kEntrySize;
}
kPrefixSize = LoadConstant("class_NameDictionaryShape__prefix_size__int",
"namedictionaryshape_prefix_size") +
kPrefixStartIndex;
}
void Frame::Load() {
kContextOffset = LoadConstant("off_fp_context");
kFunctionOffset = LoadConstant("off_fp_function");
kArgsOffset = LoadConstant("off_fp_args");
// NOTE: Starting from 5.1.71 these two reside in the same field
kMarkerOffset = LoadConstant("off_fp_marker", "off_fp_context");
kAdaptorFrame = LoadConstant("frametype_ArgumentsAdaptorFrame");
kEntryFrame = LoadConstant("frametype_EntryFrame");
kEntryConstructFrame = LoadConstant("frametype_ConstructEntryFrame",
"frametype_EntryConstructFrame");
kExitFrame = LoadConstant("frametype_ExitFrame");
kInternalFrame = LoadConstant("frametype_InternalFrame");
kConstructFrame = LoadConstant("frametype_ConstructFrame");
// NOTE: The JavaScript frame type was removed in V8 6.3.158.
kJSFrame = LoadConstant("frametype_JavaScriptFrame");
kOptimizedFrame = LoadConstant("frametype_OptimizedFrame");
kStubFrame = LoadConstant("frametype_StubFrame");
}
void Symbol::Load() {
// map is the last field of HeapObject
Constant<int64_t> maybe_name_offset =
LoadConstant({"class_HeapObject__map__Map"});
common_->Load();
if (maybe_name_offset.Check()) {
int name_offset = *maybe_name_offset;
name_offset += common_->kPointerSize;
// class Name extends HeapObject and has only one uint32 field
name_offset += sizeof(uint32_t);
// class Symbol extends Name and has one int32 field before name
name_offset += sizeof(int32_t);
kNameOffset =
LoadOptionalConstant({"class_Symbol__name__Object"}, name_offset);
} else {
kNameOffset = LoadConstant({"class_Symbol__name__Object"});
}
}
void Types::Load() {
kFirstNonstringType = LoadConstant("FirstNonstringType");
kFirstJSObjectType =
LoadConstant("type_JSGlobalObject__JS_GLOBAL_OBJECT_TYPE");
kFirstContextType = LoadConstant("FirstContextType");
kLastContextType = LoadConstant("LastContextType");
kJSErrorType = LoadConstant("type_JSError__JS_ERROR_TYPE");
kJSPromiseType = LoadConstant("type_JSPromise__JS_PROMISE_TYPE");
if (kJSPromiseType == -1) {
// NOTE(mmarchini): On Node.js v10.x, JS_PROMISE always comes after
// JS_MESSAGE_OBJECT_TYPE in the InstanceType enum.
kJSPromiseType =
LoadConstant("type_JSMessageObject__JS_MESSAGE_OBJECT_TYPE") + 1;
}
kHeapNumberType = LoadConstant("type_HeapNumber__HEAP_NUMBER_TYPE");
kMapType = LoadConstant("type_Map__MAP_TYPE");
kGlobalObjectType =
LoadConstant("type_JSGlobalObject__JS_GLOBAL_OBJECT_TYPE");
kGlobalProxyType = LoadConstant("type_JSGlobalProxy__JS_GLOBAL_PROXY_TYPE");
kOddballType = LoadConstant("type_Oddball__ODDBALL_TYPE");
kJSObjectType = LoadConstant("type_JSObject__JS_OBJECT_TYPE");
kJSAPIObjectType = LoadConstant("APIObjectType");
kJSSpecialAPIObjectType =
LoadConstant("SpecialAPIObjectType", "APISpecialObjectType");
kJSArrayType = LoadConstant("type_JSArray__JS_ARRAY_TYPE");
kCodeType = LoadConstant("type_Code__CODE_TYPE");
kJSFunctionType = LoadConstant("type_JSFunction__JS_FUNCTION_TYPE");
kFixedArrayType = LoadConstant("type_FixedArray__FIXED_ARRAY_TYPE");
kJSArrayBufferType = LoadConstant("type_JSArrayBuffer__JS_ARRAY_BUFFER_TYPE");
kJSTypedArrayType = LoadConstant("type_JSTypedArray__JS_TYPED_ARRAY_TYPE");
kJSRegExpType = LoadConstant("type_JSRegExp__JS_REGEXP_TYPE");
kJSDateType = LoadConstant("type_JSDate__JS_DATE_TYPE");
kSharedFunctionInfoType =
LoadConstant("type_SharedFunctionInfo__SHARED_FUNCTION_INFO_TYPE");
kUncompiledDataWithoutPreParsedScopeType = LoadConstant(
{"type_UncompiledDataWithoutPreParsedScope__UNCOMPILED_DATA_WITHOUT_PRE_"
"PARSED_SCOPE_TYPE",
"type_UncompiledDataWithoutPreparseData__UNCOMPILED_DATA_WITHOUT_"
"PREPARSE_DATA_TYPE"});
kUncompiledDataWithPreParsedScopeType = LoadConstant(
{"type_UncompiledDataWithPreParsedScope__UNCOMPILED_DATA_WITH_PRE_PARSED_"
"SCOPE_TYPE",
"type_UncompiledDataWithPreparseData__UNCOMPILED_DATA_WITH_"
"PREPARSE_DATA_TYPE"});
kScriptType = LoadConstant("type_Script__SCRIPT_TYPE");
kScopeInfoType = LoadConstant("type_ScopeInfo__SCOPE_INFO_TYPE");
kSymbolType = LoadConstant("type_Symbol__SYMBOL_TYPE");
if (kJSAPIObjectType == -1) {
common_->Load();
if (common_->CheckLowestVersion(5, 2, 12))
kJSAPIObjectType = kJSObjectType - 1;
}
}
} // namespace constants
} // namespace v8
} // namespace llnode