• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_MEM_OBJECT_XRAY_H
17 #define ECMASCRIPT_MEM_OBJECT_XRAY_H
18 
19 #include <cstdint>
20 
21 #include "ecmascript/ecma_vm.h"
22 #include "ecmascript/js_async_from_sync_iterator.h"
23 #include "ecmascript/global_env.h"
24 #include "ecmascript/ic/ic_handler.h"
25 #include "ecmascript/ic/proto_change_details.h"
26 #include "ecmascript/jobs/micro_job_queue.h"
27 #include "ecmascript/jobs/pending_job.h"
28 #include "ecmascript/jspandafile/class_info_extractor.h"
29 #include "ecmascript/jspandafile/class_literal.h"
30 #include "ecmascript/jspandafile/program_object.h"
31 #include "ecmascript/js_api/js_api_arraylist.h"
32 #include "ecmascript/js_api/js_api_arraylist_iterator.h"
33 #include "ecmascript/js_api/js_api_deque.h"
34 #include "ecmascript/js_api/js_api_deque_iterator.h"
35 #include "ecmascript/js_api/js_api_hashmap.h"
36 #include "ecmascript/js_api/js_api_hashmap_iterator.h"
37 #include "ecmascript/js_api/js_api_hashset.h"
38 #include "ecmascript/js_api/js_api_hashset_iterator.h"
39 #include "ecmascript/js_api/js_api_lightweightmap.h"
40 #include "ecmascript/js_api/js_api_lightweightmap_iterator.h"
41 #include "ecmascript/js_api/js_api_lightweightset.h"
42 #include "ecmascript/js_api/js_api_lightweightset_iterator.h"
43 #include "ecmascript/js_api/js_api_linked_list.h"
44 #include "ecmascript/js_api/js_api_linked_list_iterator.h"
45 #include "ecmascript/js_api/js_api_list.h"
46 #include "ecmascript/js_api/js_api_list_iterator.h"
47 #include "ecmascript/js_api/js_api_plain_array.h"
48 #include "ecmascript/js_api/js_api_plain_array_iterator.h"
49 #include "ecmascript/js_api/js_api_queue.h"
50 #include "ecmascript/js_api/js_api_queue_iterator.h"
51 #include "ecmascript/js_api/js_api_stack.h"
52 #include "ecmascript/js_api/js_api_stack_iterator.h"
53 #include "ecmascript/js_api/js_api_tree_map.h"
54 #include "ecmascript/js_api/js_api_tree_map_iterator.h"
55 #include "ecmascript/js_api/js_api_tree_set.h"
56 #include "ecmascript/js_api/js_api_tree_set_iterator.h"
57 #include "ecmascript/js_api/js_api_vector.h"
58 #include "ecmascript/js_api/js_api_vector_iterator.h"
59 #include "ecmascript/js_arguments.h"
60 #include "ecmascript/js_array.h"
61 #include "ecmascript/js_array_iterator.h"
62 #include "ecmascript/js_arraybuffer.h"
63 #include "ecmascript/js_async_function.h"
64 #include "ecmascript/js_async_generator_object.h"
65 #include "ecmascript/js_collator.h"
66 #include "ecmascript/js_dataview.h"
67 #include "ecmascript/js_date.h"
68 #include "ecmascript/js_date_time_format.h"
69 #include "ecmascript/js_for_in_iterator.h"
70 #include "ecmascript/js_finalization_registry.h"
71 #include "ecmascript/js_function.h"
72 #include "ecmascript/js_generator_object.h"
73 #include "ecmascript/js_hclass.h"
74 #include "ecmascript/js_intl.h"
75 #include "ecmascript/js_locale.h"
76 #include "ecmascript/js_map.h"
77 #include "ecmascript/js_map_iterator.h"
78 #include "ecmascript/js_number_format.h"
79 #include "ecmascript/js_object-inl.h"
80 #include "ecmascript/js_plural_rules.h"
81 #include "ecmascript/js_primitive_ref.h"
82 #include "ecmascript/js_promise.h"
83 #include "ecmascript/js_realm.h"
84 #include "ecmascript/js_regexp.h"
85 #include "ecmascript/js_regexp_iterator.h"
86 #include "ecmascript/js_relative_time_format.h"
87 #include "ecmascript/js_set.h"
88 #include "ecmascript/js_displaynames.h"
89 #include "ecmascript/js_list_format.h"
90 #include "ecmascript/js_set_iterator.h"
91 #include "ecmascript/js_string_iterator.h"
92 #include "ecmascript/js_typed_array.h"
93 #include "ecmascript/byte_array.h"
94 #include "ecmascript/js_weak_container.h"
95 #include "ecmascript/jspandafile/class_info_extractor.h"
96 #include "ecmascript/jspandafile/program_object.h"
97 #include "ecmascript/js_weak_ref.h"
98 #include "ecmascript/mem/machine_code.h"
99 #include "ecmascript/mem/mem.h"
100 #include "ecmascript/mem/slots.h"
101 #include "ecmascript/module/js_module_namespace.h"
102 #include "ecmascript/module/js_module_source_text.h"
103 #include "ecmascript/tagged_node.h"
104 #include "ecmascript/ts_types/ts_type.h"
105 #include "ecmascript/ts_types/ts_type_table.h"
106 #include "ecmascript/require/js_cjs_module.h"
107 #include "ecmascript/require/js_cjs_require.h"
108 #include "ecmascript/require/js_cjs_exports.h"
109 
110 namespace panda::ecmascript {
111 class ObjectXRay {
112 public:
ObjectXRay(EcmaVM * ecmaVm)113     explicit ObjectXRay(EcmaVM *ecmaVm) : ecmaVm_(ecmaVm) {}
114     ~ObjectXRay() = default;
115 
VisitVMRoots(const RootVisitor & visitor,const RootRangeVisitor & rangeVisitor,const RootBaseAndDerivedVisitor & derivedVisitor)116     inline void VisitVMRoots(const RootVisitor &visitor, const RootRangeVisitor &rangeVisitor,
117         const RootBaseAndDerivedVisitor &derivedVisitor) const
118     {
119         ecmaVm_->Iterate(visitor, rangeVisitor);
120         ecmaVm_->GetJSThread()->Iterate(visitor, rangeVisitor, derivedVisitor);
121     }
122     template<VisitType visitType>
VisitObjectBody(TaggedObject * object,JSHClass * klass,const EcmaObjectRangeVisitor & visitor)123     inline void VisitObjectBody(TaggedObject *object, JSHClass *klass, const EcmaObjectRangeVisitor &visitor)
124     {
125         // handle body
126         JSType type = klass->GetObjectType();
127         switch (type) {
128             case JSType::JS_OBJECT:
129             case JSType::JS_ERROR:
130             case JSType::JS_EVAL_ERROR:
131             case JSType::JS_RANGE_ERROR:
132             case JSType::JS_REFERENCE_ERROR:
133             case JSType::JS_TYPE_ERROR:
134             case JSType::JS_AGGREGATE_ERROR:
135             case JSType::JS_URI_ERROR:
136             case JSType::JS_SYNTAX_ERROR:
137             case JSType::JS_OOM_ERROR:
138             case JSType::JS_ASYNCITERATOR:
139             case JSType::JS_ITERATOR:
140                 JSObject::Cast(object)->VisitRangeSlot(visitor);
141                 break;
142             case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
143                 JSAsyncFromSyncIterator::Cast(object)->VisitRangeSlot(visitor);
144                 break;
145             case JSType::JS_GLOBAL_OBJECT:
146                 JSGlobalObject::Cast(object)->VisitRangeSlot(visitor);
147                 break;
148             case JSType::JS_FUNCTION_BASE: {
149                 auto jsFunctionBase = JSFunctionBase::Cast(object);
150                 jsFunctionBase->VisitRangeSlot(visitor);
151                 break;
152             }
153             case JSType::JS_FUNCTION: {
154                 auto jsFunction = JSFunction::Cast(object);
155                 jsFunction->VisitRangeSlot(visitor);
156                 break;
157             }
158             case JSType::JS_GENERATOR_FUNCTION: {
159                 auto jsGeneratorFunction = JSGeneratorFunction::Cast(object);
160                 jsGeneratorFunction->VisitRangeSlot(visitor);
161                 break;
162             }
163             case JSType::JS_ASYNC_GENERATOR_FUNCTION: {
164                 auto jsGeneratorFunction = JSAsyncGeneratorFunction::Cast(object);
165                 jsGeneratorFunction->VisitRangeSlot(visitor);
166                 break;
167             }
168             case JSType::JS_PROXY_REVOC_FUNCTION: {
169                 auto jsProxyRevocFunction = JSProxyRevocFunction::Cast(object);
170                 jsProxyRevocFunction->VisitRangeSlot(visitor);
171                 break;
172             }
173             case JSType::JS_PROMISE_REACTIONS_FUNCTION: {
174                 auto jsPromiseReactionsFunction = JSPromiseReactionsFunction::Cast(object);
175                 jsPromiseReactionsFunction->VisitRangeSlot(visitor);
176                 break;
177             }
178             case JSType::JS_PROMISE_EXECUTOR_FUNCTION: {
179                 auto jsPromiseExecutorFunction = JSPromiseExecutorFunction::Cast(object);
180                 jsPromiseExecutorFunction->VisitRangeSlot(visitor);
181                 break;
182             }
183             case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION: {
184                 auto jsAsyncFromSyncIterUnwarpFunction = JSAsyncFromSyncIterUnwarpFunction::Cast(object);
185                 jsAsyncFromSyncIterUnwarpFunction->VisitRangeSlot(visitor);
186                 break;
187             }
188             case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION: {
189                 auto jsPromiseAllResolveElementFunction = JSPromiseAllResolveElementFunction::Cast(object);
190                 jsPromiseAllResolveElementFunction->VisitRangeSlot(visitor);
191                 break;
192             }
193             case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN: {
194                 auto jsAsyGeneratorRseNextRtnProRstFtn = JSAsyncGeneratorResNextRetProRstFtn::Cast(object);
195                 jsAsyGeneratorRseNextRtnProRstFtn->VisitRangeSlot(visitor);
196                 break;
197             }
198             case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION: {
199                 auto jsPromiseAnyRejectElementFunction = JSPromiseAnyRejectElementFunction::Cast(object);
200                 jsPromiseAnyRejectElementFunction->VisitRangeSlot(visitor);
201                 break;
202             }
203             case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION: {
204                 auto jsPromiseAllSettledElementFunction = JSPromiseAllSettledElementFunction::Cast(object);
205                 jsPromiseAllSettledElementFunction->VisitRangeSlot(visitor);
206                 break;
207             }
208             case JSType::JS_PROMISE_FINALLY_FUNCTION: {
209                 auto jsPromiseFinallyFunction = JSPromiseFinallyFunction::Cast(object);
210                 jsPromiseFinallyFunction->VisitRangeSlot(visitor);
211                 break;
212             }
213             case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION: {
214                 auto jsPromiseValueThunkOrThrowerFunction = JSPromiseValueThunkOrThrowerFunction::Cast(object);
215                 jsPromiseValueThunkOrThrowerFunction->VisitRangeSlot(visitor);
216                 break;
217             }
218             case JSType::JS_ASYNC_FUNCTION: {
219                 auto jsAsyncFunction = JSAsyncFunction::Cast(object);
220                 jsAsyncFunction->VisitRangeSlot(visitor);
221                 break;
222             }
223             case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION: {
224                 auto jsAsyncAwaitStatusFunction = JSAsyncAwaitStatusFunction::Cast(object);
225                 jsAsyncAwaitStatusFunction->VisitRangeSlot(visitor);
226                 break;
227             }
228             case JSType::JS_REG_EXP:
229                 JSRegExp::Cast(object)->VisitRangeSlot(visitor);
230                 break;
231             case JSType::JS_SET:
232                 JSSet::Cast(object)->VisitRangeSlot(visitor);
233                 break;
234             case JSType::JS_MAP:
235                 JSMap::Cast(object)->VisitRangeSlot(visitor);
236                 break;
237             case JSType::JS_WEAK_MAP:
238                 JSWeakMap::Cast(object)->VisitRangeSlot(visitor);
239                 break;
240             case JSType::JS_WEAK_SET:
241                 JSWeakSet::Cast(object)->VisitRangeSlot(visitor);
242                 break;
243             case JSType::JS_WEAK_REF:
244                 JSWeakRef::Cast(object)->VisitRangeSlot(visitor);
245                 break;
246             case JSType::JS_FINALIZATION_REGISTRY:
247                 JSFinalizationRegistry::Cast(object)->VisitRangeSlot(visitor);
248                 break;
249             case JSType::CELL_RECORD:
250                 CellRecord::Cast(object)->VisitRangeSlot(visitor);
251                 break;
252             case JSType::JS_DATE:
253                 JSDate::Cast(object)->VisitRangeSlot(visitor);
254                 break;
255             case JSType::JS_FORIN_ITERATOR:
256                 JSForInIterator::Cast(object)->VisitRangeSlot(visitor);
257                 break;
258             case JSType::JS_MAP_ITERATOR:
259                 JSMapIterator::Cast(object)->VisitRangeSlot(visitor);
260                 break;
261             case JSType::JS_SET_ITERATOR:
262                 JSSetIterator::Cast(object)->VisitRangeSlot(visitor);
263                 break;
264             case JSType::JS_REG_EXP_ITERATOR:
265                 JSRegExpIterator::Cast(object)->VisitRangeSlot(visitor);
266                 break;
267             case JSType::JS_ARRAY_ITERATOR:
268                 JSArrayIterator::Cast(object)->VisitRangeSlot(visitor);
269                 break;
270             case JSType::JS_STRING_ITERATOR:
271                 JSStringIterator::Cast(object)->VisitRangeSlot(visitor);
272                 break;
273             case JSType::JS_ARRAY_BUFFER:
274                 JSArrayBuffer::Cast(object)->VisitRangeSlot(visitor);
275                 break;
276             case JSType::JS_SHARED_ARRAY_BUFFER:
277                 JSArrayBuffer::Cast(object)->VisitRangeSlot(visitor);
278                 break;
279             case JSType::JS_PROMISE:
280                 JSPromise::Cast(object)->VisitRangeSlot(visitor);
281                 break;
282             case JSType::JS_DATA_VIEW:
283                 JSDataView::Cast(object)->VisitRangeSlot(visitor);
284                 break;
285             case JSType::JS_BOUND_FUNCTION: {
286                 auto jsBoundFunction = JSBoundFunction::Cast(object);
287                 jsBoundFunction->VisitRangeSlot(visitor);
288                 break;
289             }
290             case JSType::JS_ARGUMENTS:
291                 JSArguments::Cast(object)->VisitRangeSlot(visitor);
292                 break;
293             case JSType::JS_GENERATOR_OBJECT:
294                 JSGeneratorObject::Cast(object)->VisitRangeSlot(visitor);
295                 break;
296             case JSType::JS_ASYNC_GENERATOR_OBJECT:
297                 JSAsyncGeneratorObject::Cast(object)->VisitRangeSlot(visitor);
298                 break;
299             case JSType::JS_ASYNC_FUNC_OBJECT:
300                 JSAsyncFuncObject::Cast(object)->VisitRangeSlot(visitor);
301                 break;
302             case JSType::JS_ARRAY:
303                 JSArray::Cast(object)->VisitRangeSlot(visitor);
304                 break;
305             case JSType::JS_TYPED_ARRAY:
306             case JSType::JS_INT8_ARRAY:
307             case JSType::JS_UINT8_ARRAY:
308             case JSType::JS_UINT8_CLAMPED_ARRAY:
309             case JSType::JS_INT16_ARRAY:
310             case JSType::JS_UINT16_ARRAY:
311             case JSType::JS_INT32_ARRAY:
312             case JSType::JS_UINT32_ARRAY:
313             case JSType::JS_FLOAT32_ARRAY:
314             case JSType::JS_FLOAT64_ARRAY:
315             case JSType::JS_BIGINT64_ARRAY:
316             case JSType::JS_BIGUINT64_ARRAY:
317                 JSTypedArray::Cast(object)->VisitRangeSlot(visitor);
318                 break;
319             case JSType::BYTE_ARRAY:
320                 break;
321             case JSType::JS_PRIMITIVE_REF:
322                 JSPrimitiveRef::Cast(object)->VisitRangeSlot(visitor);
323                 break;
324             case JSType::JS_PROXY: {
325                 auto jsProxy = JSProxy::Cast(object);
326                 jsProxy->VisitRangeSlot(visitor);
327                 break;
328             }
329             case JSType::HCLASS:
330                 // semi gc is not needed to visit hclass
331                 if (visitType != VisitType::SEMI_GC_VISIT) {
332                     JSHClass::Cast(object)->VisitRangeSlot(visitor);
333                 }
334                 break;
335             case JSType::STRING:
336                 break;
337             case JSType::JS_NATIVE_POINTER:
338                 if (visitType == VisitType::SNAPSHOT_VISIT) {
339                     JSNativePointer::Cast(object)->VisitRangeSlotForNative(visitor);
340                 }
341                 break;
342             case JSType::TAGGED_ARRAY:
343             case JSType::TAGGED_DICTIONARY:
344             case JSType::TEMPLATE_MAP:
345             case JSType::LEXICAL_ENV:
346             case JSType::AOT_LITERAL_INFO:
347             case JSType::COW_TAGGED_ARRAY:
348                 TaggedArray::Cast(object)->VisitRangeSlot(visitor);
349                 break;
350             case JSType::CONSTANT_POOL:
351                 ConstantPool::Cast(object)->VisitRangeSlot(visitor);
352                 break;
353             case JSType::GLOBAL_ENV:
354                 GlobalEnv::Cast(object)->VisitRangeSlot(visitor);
355                 break;
356             case JSType::ACCESSOR_DATA:
357             case JSType::INTERNAL_ACCESSOR:
358                 AccessorData::Cast(object)->VisitRangeSlot(visitor);
359                 break;
360             case JSType::SYMBOL:
361                 JSSymbol::Cast(object)->VisitRangeSlot(visitor);
362                 break;
363             case JSType::JS_GENERATOR_CONTEXT:
364                 GeneratorContext::Cast(object)->VisitRangeSlot(visitor);
365                 break;
366             case JSType::PROTOTYPE_HANDLER:
367                 PrototypeHandler::Cast(object)->VisitRangeSlot(visitor);
368                 break;
369             case JSType::TRANSITION_HANDLER:
370                 TransitionHandler::Cast(object)->VisitRangeSlot(visitor);
371                 break;
372             case JSType::TRANS_WITH_PROTO_HANDLER:
373                 TransWithProtoHandler::Cast(object)->VisitRangeSlot(visitor);
374                 break;
375             case JSType::STORE_TS_HANDLER:
376                 StoreTSHandler::Cast(object)->VisitRangeSlot(visitor);
377                 break;
378             case JSType::PROPERTY_BOX:
379                 PropertyBox::Cast(object)->VisitRangeSlot(visitor);
380                 break;
381             case JSType::PROTO_CHANGE_MARKER:
382                 break;
383             case JSType::PROTOTYPE_INFO:
384                 ProtoChangeDetails::Cast(object)->VisitRangeSlot(visitor);
385                 break;
386             case JSType::PROMISE_CAPABILITY:
387                 PromiseCapability::Cast(object)->VisitRangeSlot(visitor);
388                 break;
389             case JSType::ASYNC_GENERATOR_REQUEST:
390                 AsyncGeneratorRequest::Cast(object)->VisitRangeSlot(visitor);
391                 break;
392             case JSType::ASYNC_ITERATOR_RECORD:
393                 AsyncIteratorRecord::Cast(object)->VisitRangeSlot(visitor);
394                 break;
395             case JSType::PROMISE_RECORD:
396                 PromiseRecord::Cast(object)->VisitRangeSlot(visitor);
397                 break;
398             case JSType::RESOLVING_FUNCTIONS_RECORD:
399                 ResolvingFunctionsRecord::Cast(object)->VisitRangeSlot(visitor);
400                 break;
401             case JSType::PROMISE_REACTIONS:
402                 PromiseReaction::Cast(object)->VisitRangeSlot(visitor);
403                 break;
404             case JSType::PROMISE_ITERATOR_RECORD:
405                 PromiseIteratorRecord::Cast(object)->VisitRangeSlot(visitor);
406                 break;
407             case JSType::MICRO_JOB_QUEUE:
408                 job::MicroJobQueue::Cast(object)->VisitRangeSlot(visitor);
409                 break;
410             case JSType::PENDING_JOB:
411                 job::PendingJob::Cast(object)->VisitRangeSlot(visitor);
412                 break;
413             case JSType::COMPLETION_RECORD:
414                 CompletionRecord::Cast(object)->VisitRangeSlot(visitor);
415                 break;
416             case JSType::PROGRAM:
417                 Program::Cast(object)->VisitRangeSlot(visitor);
418                 break;
419             case JSType::JS_INTL:
420                 JSIntl::Cast(object)->VisitRangeSlot(visitor);
421                 break;
422             case JSType::JS_NUMBER_FORMAT:
423                 JSNumberFormat::Cast(object)->VisitRangeSlot(visitor);
424                 break;
425             case JSType::JS_LOCALE:
426                 JSLocale::Cast(object)->VisitRangeSlot(visitor);
427                 break;
428             case JSType::JS_DATE_TIME_FORMAT:
429                 JSDateTimeFormat::Cast(object)->VisitRangeSlot(visitor);
430                 break;
431             case JSType::JS_RELATIVE_TIME_FORMAT:
432                 JSRelativeTimeFormat::Cast(object)->VisitRangeSlot(visitor);
433                 break;
434             case JSType::JS_INTL_BOUND_FUNCTION: {
435                 auto jsIntlBoundFunction = JSIntlBoundFunction::Cast(object);
436                 jsIntlBoundFunction->VisitRangeSlot(visitor);
437                 break;
438             }
439             case JSType::JS_REALM:
440                 JSRealm::Cast(object)->VisitRangeSlot(visitor);
441                 break;
442             case JSType::JS_COLLATOR:
443                 JSCollator::Cast(object)->VisitRangeSlot(visitor);
444                 break;
445             case JSType::JS_PLURAL_RULES:
446                 JSPluralRules::Cast(object)->VisitRangeSlot(visitor);
447                 break;
448             case JSType::JS_DISPLAYNAMES:
449                 JSDisplayNames::Cast(object)->VisitRangeSlot(visitor);
450                 break;
451             case JSType::JS_LIST_FORMAT:
452                 JSListFormat::Cast(object)->VisitRangeSlot(visitor);
453                 break;
454             case JSType::MACHINE_CODE_OBJECT:
455                 MachineCode::Cast(object)->VisitRangeSlot(visitor);
456                 break;
457             case JSType::CLASS_INFO_EXTRACTOR: {
458                 auto classInfoExtractor = ClassInfoExtractor::Cast(object);
459                 classInfoExtractor->VisitRangeSlot(visitor);
460                 break;
461             }
462             case JSType::JS_API_QUEUE:
463                 JSAPIQueue::Cast(object)->VisitRangeSlot(visitor);
464                 break;
465             case JSType::JS_API_QUEUE_ITERATOR:
466                 JSAPIQueueIterator::Cast(object)->VisitRangeSlot(visitor);
467                 break;
468             case JSType::JS_API_ARRAY_LIST:
469                 JSAPIArrayList::Cast(object)->VisitRangeSlot(visitor);
470                 break;
471             case JSType::JS_API_ARRAYLIST_ITERATOR:
472                 JSAPIArrayListIterator::Cast(object)->VisitRangeSlot(visitor);
473                 break;
474             case JSType::JS_API_LIGHT_WEIGHT_MAP:
475                 JSAPILightWeightMap::Cast(object)->VisitRangeSlot(visitor);
476                 break;
477             case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
478                 JSAPILightWeightMapIterator::Cast(object)->VisitRangeSlot(visitor);
479                 break;
480             case JSType::JS_API_LIGHT_WEIGHT_SET:
481                 JSAPILightWeightSet::Cast(object)->VisitRangeSlot(visitor);
482                 break;
483             case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
484                 JSAPILightWeightSetIterator::Cast(object)->VisitRangeSlot(visitor);
485                 break;
486             case JSType::TS_OBJECT_TYPE:
487                 TSObjectType::Cast(object)->VisitRangeSlot(visitor);
488                 break;
489             case JSType::TS_CLASS_TYPE:
490                 TSClassType::Cast(object)->VisitRangeSlot(visitor);
491                 break;
492             case JSType::TS_UNION_TYPE:
493                 TSUnionType::Cast(object)->VisitRangeSlot(visitor);
494                 break;
495             case JSType::TS_INTERFACE_TYPE:
496                 TSInterfaceType::Cast(object)->VisitRangeSlot(visitor);
497                 break;
498             case JSType::TS_CLASS_INSTANCE_TYPE:
499                 break;
500             case JSType::TS_FUNCTION_TYPE:
501                 TSFunctionType::Cast(object)->VisitRangeSlot(visitor);
502                 break;
503             case JSType::TS_ARRAY_TYPE:
504                 break;
505             case JSType::TS_ITERATOR_INSTANCE_TYPE:
506                 break;
507             case JSType::RB_TREENODE:
508                 RBTreeNode::Cast(object)->VisitRangeSlot(visitor);
509                 break;
510             case JSType::LINKED_NODE:
511                 LinkedNode::Cast(object)->VisitRangeSlot(visitor);
512                 break;
513             case JSType::JS_API_HASH_MAP:
514                 JSAPIHashMap::Cast(object)->VisitRangeSlot(visitor);
515                 break;
516             case JSType::JS_API_HASH_SET:
517                 JSAPIHashSet::Cast(object)->VisitRangeSlot(visitor);
518                 break;
519             case JSType::JS_API_HASHMAP_ITERATOR:
520                 JSAPIHashMapIterator::Cast(object)->VisitRangeSlot(visitor);
521                 break;
522             case JSType::JS_API_HASHSET_ITERATOR:
523                 JSAPIHashSetIterator::Cast(object)->VisitRangeSlot(visitor);
524                 break;
525             case JSType::JS_API_TREE_MAP:
526                 JSAPITreeMap::Cast(object)->VisitRangeSlot(visitor);
527                 break;
528             case JSType::JS_API_TREE_SET:
529                 JSAPITreeSet::Cast(object)->VisitRangeSlot(visitor);
530                 break;
531             case JSType::JS_API_TREEMAP_ITERATOR:
532                 JSAPITreeMapIterator::Cast(object)->VisitRangeSlot(visitor);
533                 break;
534             case JSType::JS_API_TREESET_ITERATOR:
535                 JSAPITreeSetIterator::Cast(object)->VisitRangeSlot(visitor);
536                 break;
537             case JSType::JS_API_PLAIN_ARRAY:
538                 JSAPIPlainArray::Cast(object)->VisitRangeSlot(visitor);
539                 break;
540             case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
541                 JSAPIPlainArrayIterator::Cast(object)->VisitRangeSlot(visitor);
542                 break;
543             case JSType::JS_API_DEQUE:
544                 JSAPIDeque::Cast(object)->VisitRangeSlot(visitor);
545                 break;
546             case JSType::JS_API_DEQUE_ITERATOR:
547                 JSAPIDequeIterator::Cast(object)->VisitRangeSlot(visitor);
548                 break;
549             case JSType::JS_API_STACK:
550                 JSAPIStack::Cast(object)->VisitRangeSlot(visitor);
551                 break;
552             case JSType::JS_API_STACK_ITERATOR:
553                 JSAPIStackIterator::Cast(object)->VisitRangeSlot(visitor);
554                 break;
555             case JSType::JS_API_VECTOR:
556                 JSAPIVector::Cast(object)->VisitRangeSlot(visitor);
557                 break;
558             case JSType::JS_API_VECTOR_ITERATOR:
559                 JSAPIVectorIterator::Cast(object)->VisitRangeSlot(visitor);
560                 break;
561             case JSType::JS_API_LIST:
562                 JSAPIList::Cast(object)->VisitRangeSlot(visitor);
563                 break;
564             case JSType::JS_API_LINKED_LIST:
565                 JSAPILinkedList::Cast(object)->VisitRangeSlot(visitor);
566                 break;
567             case JSType::JS_API_LIST_ITERATOR:
568                 JSAPIListIterator::Cast(object)->VisitRangeSlot(visitor);
569                 break;
570             case JSType::JS_API_LINKED_LIST_ITERATOR:
571                 JSAPILinkedListIterator::Cast(object)->VisitRangeSlot(visitor);
572                 break;
573             case JSType::BIGINT:
574                 break;
575             case JSType::SOURCE_TEXT_MODULE_RECORD:
576                 SourceTextModule::Cast(object)->VisitRangeSlot(visitor);
577                 break;
578             case JSType::IMPORTENTRY_RECORD:
579                 ImportEntry::Cast(object)->VisitRangeSlot(visitor);
580                 break;
581             case JSType::LOCAL_EXPORTENTRY_RECORD:
582                 LocalExportEntry::Cast(object)->VisitRangeSlot(visitor);
583                 break;
584             case JSType::INDIRECT_EXPORTENTRY_RECORD:
585                 IndirectExportEntry::Cast(object)->VisitRangeSlot(visitor);
586                 break;
587             case JSType::STAR_EXPORTENTRY_RECORD:
588                 StarExportEntry::Cast(object)->VisitRangeSlot(visitor);
589                 break;
590             case JSType::RESOLVEDBINDING_RECORD:
591                 ResolvedBinding::Cast(object)->VisitRangeSlot(visitor);
592                 break;
593             case JSType::RESOLVEDINDEXBINDING_RECORD:
594                 ResolvedIndexBinding::Cast(object)->VisitRangeSlot(visitor);
595                 break;
596             case JSType::JS_MODULE_NAMESPACE:
597                 ModuleNamespace::Cast(object)->VisitRangeSlot(visitor);
598                 break;
599             case JSType::JS_CJS_EXPORTS:
600                 CjsExports::Cast(object)->VisitRangeSlot(visitor);
601                 break;
602             case JSType::JS_CJS_MODULE:
603                 CjsModule::Cast(object)->VisitRangeSlot(visitor);
604                 break;
605             case JSType::JS_CJS_REQUIRE:
606                 CjsRequire::Cast(object)->VisitRangeSlot(visitor);
607                 break;
608             case JSType::METHOD:
609                 Method::Cast(object)->VisitRangeSlot(visitor);
610                 break;
611             case JSType::CLASS_LITERAL:
612                 ClassLiteral::Cast(object)->VisitRangeSlot(visitor);
613                 break;
614             default:
615                 UNREACHABLE();
616         }
617     }
618 
619 private:
620     EcmaVM *ecmaVm_ {nullptr};
621 };
622 }  // namespace panda::ecmascript
623 
624 #endif  // ECMASCRIPT_MEM_OBJECT_XRAY_H
625