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) {} 27 ~BuiltinsObjectStubBuilder() override = default; 28 NO_MOVE_SEMANTIC(BuiltinsObjectStubBuilder); 29 NO_COPY_SEMANTIC(BuiltinsObjectStubBuilder); GenerateCircuit()30 void GenerateCircuit() override {} 31 GateRef CreateListFromArrayLike(GateRef glue, GateRef arrayObj); 32 GateRef CreateArrayFromList(GateRef glue, GateRef elements); 33 void ToString(Variable *result, Label *exit, Label *slowPath); 34 void Create(Variable *result, Label *exit, Label *slowPath); 35 void Assign(Variable *result, Label *exit, Label *slowPath); 36 void HasOwnProperty(Variable *result, Label *exit, Label *slowPath); 37 void Keys(Variable *result, Label *exit, Label *slowPath); 38 39 private: 40 GateRef OrdinaryNewJSObjectCreate(GateRef proto); 41 GateRef TransProtoWithoutLayout(GateRef hClass, GateRef proto); 42 GateRef GetNumKeysFromLayoutInfo(GateRef object, GateRef end, GateRef layoutInfo); 43 GateRef IsUninitializedProperty(GateRef object, GateRef index, 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 void LayoutInfoGetAllEnumKeys(GateRef end, GateRef offset, GateRef array, GateRef object, GateRef layoutInfo); 49 void AssignEnumElementProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source); 50 void LayoutInfoAssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source); 51 void NameDictionaryAssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source, 52 GateRef properties); 53 void SlowAssign(Variable *res, Label *funcExit, GateRef toAssign, GateRef source); 54 void FastAssign(Variable *res, Label *funcExit, GateRef toAssign, GateRef source); 55 void AssignAllEnumProperty(Variable *res, Label *funcExit, GateRef toAssign, GateRef source); 56 void Assign(Variable *res, Label *nextIt, Label *funcExit, GateRef toAssign, GateRef source); 57 58 GateRef glue_ {Circuit::NullGate()}; 59 GateRef thisValue_ {Circuit::NullGate()}; 60 GateRef numArgs_ {Circuit::NullGate()}; 61 }; 62 } // namespace panda::ecmascript::kungfu 63 #endif // ECMASCRIPT_COMPILER_BUILTINS_OBJECT_STUB_BUILDER_H 64