• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_IC_PROTOTYPE_CHANGE_DETAILS_H
17 #define ECMASCRIPT_IC_PROTOTYPE_CHANGE_DETAILS_H
18 
19 #include "ecmascript/ecma_macros.h"
20 #include "ecmascript/js_handle.h"
21 #include "ecmascript/js_tagged_value.h"
22 #include "ecmascript/weak_vector.h"
23 
24 namespace panda {
25 namespace ecmascript {
26 class ProtoChangeMarker : public TaggedObject {
27 public:
Cast(TaggedObject * object)28     static ProtoChangeMarker *Cast(TaggedObject *object)
29     {
30         ASSERT(JSTaggedValue(object).IsProtoChangeMarker());
31         return static_cast<ProtoChangeMarker *>(object);
32     }
33 
34     static constexpr size_t BIT_FIELD_OFFSET = TaggedObjectSize();
35     ACCESSORS_BIT_FIELD(BitField, BIT_FIELD_OFFSET, LAST_OFFSET)
36     DEFINE_ALIGN_SIZE(LAST_OFFSET);
37 
38     // define BitField
39     static constexpr size_t HAS_CHANGED_BITS = 1;
40     FIRST_BIT_FIELD(BitField, HasChanged, bool, HAS_CHANGED_BITS);
41 
42     DECL_DUMP()
43 };
44 
45 class ProtoChangeDetails : public TaggedObject {
46 public:
47     static constexpr int UNREGISTERED = -1;
Cast(TaggedObject * object)48     static ProtoChangeDetails *Cast(TaggedObject *object)
49     {
50         ASSERT(JSTaggedValue(object).IsProtoChangeDetails());
51         return static_cast<ProtoChangeDetails *>(object);
52     }
53 
54     static constexpr size_t CHANGE_LISTENER_OFFSET = TaggedObjectSize();
55     ACCESSORS(ChangeListener, CHANGE_LISTENER_OFFSET, REGISTER_INDEX_OFFSET);
56     ACCESSORS_PRIMITIVE_FIELD(RegisterIndex, uint32_t, REGISTER_INDEX_OFFSET, LAST_OFFSET);
57     DEFINE_ALIGN_SIZE(LAST_OFFSET);
58 
59     DECL_VISIT_OBJECT(CHANGE_LISTENER_OFFSET, REGISTER_INDEX_OFFSET)
60     DECL_DUMP()
61 };
62 
63 class ChangeListener : public WeakVector {
64 public:
Cast(TaggedObject * object)65     static ChangeListener *Cast(TaggedObject *object)
66     {
67         return static_cast<ChangeListener *>(object);
68     }
69 
70     static JSHandle<ChangeListener> Add(const JSThread *thread, const JSHandle<ChangeListener> &array,
71                                         const JSHandle<JSHClass> &value, uint32_t *index);
72 
73     static uint32_t CheckHole(const JSHandle<ChangeListener> &array);
74 
75     JSTaggedValue Get(uint32_t index);
76 };
77 }  // namespace ecmascript
78 }  // namespace panda
79 
80 #endif  // ECMASCRIPT_IC_PROTOTYPE_CHANGE_DETAILS_H
81