• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_COMPILER_BUILTINS_OBJECT_STUB_BUILDER_H
17 #define ECMASCRIPT_COMPILER_BUILTINS_OBJECT_STUB_BUILDER_H
18 #include "ecmascript/compiler/builtins/builtins_stubs.h"
19 
20 namespace panda::ecmascript::kungfu {
21 class BuiltinsObjectStubBuilder : public BuiltinsStubBuilder {
22 public:
BuiltinsObjectStubBuilder(StubBuilder * parent)23     explicit BuiltinsObjectStubBuilder(StubBuilder *parent)
24         : BuiltinsStubBuilder(parent) {}
BuiltinsObjectStubBuilder(BuiltinsStubBuilder * parent,GateRef glue,GateRef thisValue,GateRef numArgs)25     BuiltinsObjectStubBuilder(BuiltinsStubBuilder *parent, GateRef glue, GateRef thisValue, GateRef numArgs)
26         : BuiltinsStubBuilder(parent), glue_(glue), thisValue_(thisValue), numArgs_(numArgs) {}
BuiltinsObjectStubBuilder(Environment * env,GateRef glue)27     BuiltinsObjectStubBuilder(Environment *env, GateRef glue)
28         : BuiltinsStubBuilder(env), glue_(glue) {}
29     ~BuiltinsObjectStubBuilder() override = default;
30     NO_MOVE_SEMANTIC(BuiltinsObjectStubBuilder);
31     NO_COPY_SEMANTIC(BuiltinsObjectStubBuilder);
GenerateCircuit()32     void GenerateCircuit() override {}
33 
34 #define DECLARE_BUILTINS_OBJECT_STUB_BUILDER(method, ...)           \
35     void method(Variable *result, Label *exit, Label *slowPath);
36 BUILTINS_WITH_OBJECT_STUB_BUILDER(DECLARE_BUILTINS_OBJECT_STUB_BUILDER)
37 #undef DECLARE_BUILTINS_OBJECT_STUB_BUILDER
38 
39     void HasOwnProperty(Variable *result, Label *exit, Label *slowPath, GateRef thisValue, GateRef prop,
40                         GateRef hir = Circuit::NullGate());
41 
42 private:
43     GateRef GetNumKeysFromLayoutInfo(GateRef end, GateRef layoutInfo);
44     GateRef GetNumKeysFromDictionary(GateRef array);
45     GateRef CopyFromEnumCache(GateRef glue, GateRef elements);
46     GateRef GetAllEnumKeys(GateRef glue, GateRef obj);
47     GateRef GetEnumElementKeys(GateRef glue, GateRef obj);
48     GateRef GetAllElementKeys(GateRef glue, GateRef obj, GateRef offset, GateRef array);
49     GateRef GetAllPropertyKeys(GateRef glue, GateRef obj, GateRef offset, GateRef array);
50     GateRef GetEnumElementEntries(GateRef glue, GateRef obj, Label *slowPath);
51     GateRef GetEnumPropertyEntries(GateRef glue, GateRef obj, Label *slowPath);
52     GateRef TestIntegrityLevel(GateRef glue, GateRef obj, GateRef level, Label *slowPath);
53     GateRef ObjectSetPrototype(GateRef glue, GateRef obj, GateRef proto);
54     GateRef IsNotSlowObjectKey(GateRef obj);
55     void LayoutInfoGetAllEnumKeys(GateRef end, GateRef offset, GateRef array, GateRef layoutInfo);
56     void AssignEnumElementProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source);
57     void LayoutInfoAssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source);
58     void NameDictionaryAssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source,
59         GateRef properties);
60     void SlowAssign(Variable *res, Label *funcExit, GateRef toAssign, GateRef source);
61     void FastAssign(Variable *res, Label *funcExit, GateRef toAssign, GateRef source);
62     void AssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source);
63     void Assign(Variable *res, Label *nextIt, Label *funcExit, GateRef toAssign, GateRef source);
64 
65     GateRef glue_ {Circuit::NullGate()};
66     GateRef thisValue_ {Circuit::NullGate()};
67     GateRef numArgs_ {Circuit::NullGate()};
68 };
69 }  // namespace panda::ecmascript::kungfu
70 #endif  // ECMASCRIPT_COMPILER_BUILTINS_OBJECT_STUB_BUILDER_H
71