Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "class_ext.h" |
| 18 | |
| 19 | #include "art_method-inl.h" |
| 20 | #include "base/casts.h" |
| 21 | #include "base/enums.h" |
| 22 | #include "class-inl.h" |
| 23 | #include "dex_file-inl.h" |
| 24 | #include "gc/accounting/card_table-inl.h" |
| 25 | #include "object-inl.h" |
| 26 | #include "object_array.h" |
| 27 | #include "object_array-inl.h" |
| 28 | #include "stack_trace_element.h" |
| 29 | #include "utils.h" |
| 30 | #include "well_known_classes.h" |
| 31 | |
| 32 | namespace art { |
| 33 | namespace mirror { |
| 34 | |
| 35 | GcRoot<Class> ClassExt::dalvik_system_ClassExt_; |
| 36 | |
| 37 | ClassExt* ClassExt::Alloc(Thread* self) { |
| 38 | DCHECK(dalvik_system_ClassExt_.Read() != nullptr); |
| 39 | return down_cast<ClassExt*>(dalvik_system_ClassExt_.Read()->AllocObject(self).Ptr()); |
| 40 | } |
| 41 | |
| 42 | void ClassExt::SetVerifyError(ObjPtr<Object> err) { |
| 43 | if (Runtime::Current()->IsActiveTransaction()) { |
| 44 | SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err); |
| 45 | } else { |
| 46 | SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void ClassExt::SetClass(ObjPtr<Class> dalvik_system_ClassExt) { |
| 51 | CHECK(dalvik_system_ClassExt != nullptr); |
| 52 | dalvik_system_ClassExt_ = GcRoot<Class>(dalvik_system_ClassExt); |
| 53 | } |
| 54 | |
| 55 | void ClassExt::ResetClass() { |
| 56 | CHECK(!dalvik_system_ClassExt_.IsNull()); |
| 57 | dalvik_system_ClassExt_ = GcRoot<Class>(nullptr); |
| 58 | } |
| 59 | |
| 60 | void ClassExt::VisitRoots(RootVisitor* visitor) { |
| 61 | dalvik_system_ClassExt_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass)); |
| 62 | } |
| 63 | |
| 64 | } // namespace mirror |
| 65 | } // namespace art |