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_INTERPRETER_FAST_RUNTIME_STUB_H 17 #define ECMASCRIPT_INTERPRETER_FAST_RUNTIME_STUB_H 18 19 #include <memory> 20 21 #include "ecmascript/frames.h" 22 #include "ecmascript/js_tagged_value.h" 23 #include "ecmascript/object_fast_operator.h" 24 25 namespace panda::ecmascript { 26 class GlobalEnv; 27 class PropertyAttributes; 28 29 class FastRuntimeStub { 30 public: 31 static inline JSTaggedValue FastMul(JSTaggedValue left, JSTaggedValue right); 32 static inline JSTaggedValue FastDiv(JSTaggedValue left, JSTaggedValue right); 33 static inline JSTaggedValue FastMod(JSTaggedValue left, JSTaggedValue right); 34 static inline JSTaggedValue FastEqual(JSTaggedValue left, JSTaggedValue right); 35 static inline JSTaggedValue FastTypeOf(JSThread *thread, JSTaggedValue obj); 36 static inline JSTaggedValue FastStrictEqual(JSTaggedValue left, JSTaggedValue right); 37 static inline JSTaggedValue NewLexicalEnv(JSThread *thread, ObjectFactory *factory, uint16_t numVars); 38 static inline JSTaggedValue GetGlobalOwnProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); 39 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 40 static inline JSTaggedValue GetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); 41 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 42 static inline JSTaggedValue GetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); 43 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 44 static inline JSTaggedValue GetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index); 45 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 46 static inline JSTaggedValue SetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, 47 JSTaggedValue value); 48 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 49 static inline JSTaggedValue SetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, 50 JSTaggedValue value); 51 template<ObjectFastOperator::Status status = ObjectFastOperator::Status::None> 52 static inline JSTaggedValue SetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index, 53 JSTaggedValue value); 54 55 static inline JSTaggedValue NewThisObject(JSThread *thread, JSTaggedValue ctor, JSTaggedValue newTarget, 56 InterpretedFrame* state); 57 static inline JSTaggedValue CallGetter(JSThread *thread, JSTaggedValue receiver, JSTaggedValue holder, 58 JSTaggedValue value); 59 60 private: 61 friend class ICRuntimeStub; 62 63 static inline JSTaggedValue CallSetter(JSThread *thread, JSTaggedValue receiver, JSTaggedValue value, 64 JSTaggedValue accessorValue); 65 }; 66 } // namespace panda::ecmascript 67 68 #endif // ECMASCRIPT_INTERPRETER_OBJECT_OPERATOR_INL_H 69