• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_COMPILER_NEW_OBJECT_STUB_BUILDER_H
17 #define ECMASCRIPT_COMPILER_NEW_OBJECT_STUB_BUILDER_H
18 #include "ecmascript/compiler/stub_builder.h"
19 
20 namespace panda::ecmascript::kungfu {
21 class NewObjectStubBuilder : public StubBuilder {
22 public:
NewObjectStubBuilder(StubBuilder * parent)23     explicit NewObjectStubBuilder(StubBuilder *parent)
24         : StubBuilder(parent) {}
NewObjectStubBuilder(Environment * env)25     explicit NewObjectStubBuilder(Environment *env)
26         : StubBuilder(env) {}
27     ~NewObjectStubBuilder() = default;
28     NO_MOVE_SEMANTIC(NewObjectStubBuilder);
29     NO_COPY_SEMANTIC(NewObjectStubBuilder);
GenerateCircuit()30     void GenerateCircuit() override {}
31 
SetParameters(GateRef glue,GateRef size)32     void SetParameters(GateRef glue, GateRef size)
33     {
34         glue_ = glue;
35         size_ = size;
36     }
37 
SetGule(GateRef glue)38     void SetGule(GateRef glue)
39     {
40         glue_ = glue;
41     }
42 
43     void NewLexicalEnv(Variable *result, Label *exit, GateRef numSlots, GateRef parent);
44     void NewJSObject(Variable *result, Label *exit, GateRef hclass);
45     void NewArgumentsList(Variable *result, Label *exit, GateRef sp, GateRef startIdx, GateRef numArgs);
46     void NewArgumentsObj(Variable *result, Label *exit, GateRef argumentsList, GateRef numArgs);
47     void AllocStringObject(Variable *result, Label *exit, GateRef length, bool compressed);
48     void HeapAlloc(Variable *result, Label *exit, RegionSpaceFlag spaceType);
49     void NewJSArrayLiteral(Variable *result, Label *exit, RegionSpaceFlag spaceType, GateRef obj, GateRef hclass,
50                            bool isEmptyArray);
51     void InitializeWithSpeicalValue(Label *exit, GateRef object, GateRef value, GateRef start, GateRef end);
52     GateRef FastNewThisObject(GateRef glue, GateRef ctor);
53     GateRef NewThisObjectChecked(GateRef glue, GateRef ctor);
54 private:
55     void AllocateInYoung(Variable *result, Label *exit);
56     void InitializeTaggedArrayWithSpeicalValue(Label *exit,
57         GateRef array, GateRef value, GateRef start, GateRef length);
58     GateRef glue_ {Circuit::NullGate()};
59     GateRef size_ {0};
60 };
61 }  // namespace panda::ecmascript::kungfu
62 #endif  // ECMASCRIPT_COMPILER_NEW_OBJECT_STUB_BUILDER_H
63