1 /* 2 * Copyright (c) 2024 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_JIT_JIT_THREAD_H 17 #define ECMASCRIPT_JIT_JIT_THREAD_H 18 19 #include "ecmascript/js_thread.h" 20 #include "ecmascript/ecma_vm.h" 21 #include "ecmascript/mem/heap.h" 22 23 namespace panda::ecmascript { 24 class JitVM; 25 class JitThread final : public JSThread { 26 public: 27 JitThread(JitVM *jitVM); 28 EcmaVM *GetEcmaVM() const; 29 JSThread * PUBLIC_API GetHostThread() const; 30 void SetHostThread(JSThread *thread); 31 JitVM *GetJitVM() const; 32 33 private: 34 JSThread *hostThread_ {nullptr}; 35 }; 36 37 class JitVM final : public EcmaVM { 38 public: JitVM()39 JitVM() : EcmaVM() {} 40 ~JitVM(); 41 static JitVM *Create(); 42 static void Destroy(EcmaVM *jitvm); 43 GetHostVm()44 EcmaVM *GetHostVm() const 45 { 46 return hostVm_; 47 } 48 49 void SetHostVM(JSThread *hostThread); 50 void ReSetHostVM(); 51 52 private: 53 EcmaVM *hostVm_ {nullptr}; 54 JitThread *jitThread_ {nullptr}; 55 }; 56 } // namespace panda::ecmascript 57 #endif // ECMASCRIPT_JIT_TASK_H 58