• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "runtime/include/language_context.h"
17 
18 #include "runtime/handle_scope-inl.h"
19 #include "runtime/include/method.h"
20 #include "runtime/include/runtime.h"
21 #include "runtime/include/stack_walker.h"
22 #include "runtime/include/thread.h"
23 #include "runtime/mem/vm_handle.h"
24 
25 namespace panda {
GetCatchMethodAndOffset(Method * method,ManagedThread * thread) const26 std::pair<Method *, uint32_t> LanguageContextBase::GetCatchMethodAndOffset(Method *method, ManagedThread *thread) const
27 {
28     uint32_t catchOffset = 0;
29     Method *catchMethod = method;
30     StackWalker stack(thread);
31     while (stack.HasFrame()) {
32         catchMethod = stack.GetMethod();
33         if (catchMethod->GetPandaFile() == nullptr) {
34             stack.NextFrame();
35             continue;
36         }
37         if (stack.IsCFrame()) {
38             stack.NextFrame();
39             continue;
40         }
41         catchOffset = catchMethod->FindCatchBlock(thread->GetException()->ClassAddr<Class>(), stack.GetBytecodePc());
42 
43         if (catchOffset != panda_file::INVALID_OFFSET) {
44             break;
45         }
46         stack.NextFrame();
47     }
48 
49     return std::make_pair(catchMethod, catchOffset);
50 }
51 
CreateClassLinkerExtension() const52 std::unique_ptr<ClassLinkerExtension> LanguageContextBase::CreateClassLinkerExtension() const
53 {
54     return nullptr;
55 }
56 
ThrowException(ManagedThread * thread,const uint8_t * mutf8_name,const uint8_t * mutf8_msg) const57 void LanguageContextBase::ThrowException([[maybe_unused]] ManagedThread *thread,
58                                          [[maybe_unused]] const uint8_t *mutf8_name,
59                                          [[maybe_unused]] const uint8_t *mutf8_msg) const
60 {
61 }
62 
GetErrorClassDescriptor() const63 const uint8_t *LanguageContextBase::GetErrorClassDescriptor() const
64 {
65     return nullptr;
66 }
67 
CreateITableBuilder() const68 PandaUniquePtr<ITableBuilder> LanguageContextBase::CreateITableBuilder() const
69 {
70     return nullptr;
71 }
72 
CreateVTableBuilder() const73 PandaUniquePtr<VTableBuilder> LanguageContextBase::CreateVTableBuilder() const
74 {
75     return nullptr;
76 }
77 
CreatePtLangExt() const78 PandaUniquePtr<tooling::PtLangExt> LanguageContextBase::CreatePtLangExt() const
79 {
80     return nullptr;
81 }
82 
SetExceptionToVReg(Frame::VRegister & vreg,ObjectHeader * obj) const83 void LanguageContextBase::SetExceptionToVReg(
84     [[maybe_unused]] Frame::VRegister &vreg,  // NOLINTNEXTLINE(google-runtime-references)
85     [[maybe_unused]] ObjectHeader *obj) const
86 {
87 }
88 
89 }  // namespace panda
90