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