Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 "field.h" |
| 18 | |
| 19 | #include "field-inl.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 20 | #include "gc/accounting/card_table-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 21 | #include "object-inl.h" |
| 22 | #include "object_utils.h" |
| 23 | #include "runtime.h" |
| 24 | #include "utils.h" |
| 25 | |
| 26 | namespace art { |
| 27 | namespace mirror { |
| 28 | |
| 29 | // TODO: get global references for these |
| 30 | Class* Field::java_lang_reflect_Field_ = NULL; |
| 31 | |
| 32 | void Field::SetClass(Class* java_lang_reflect_Field) { |
| 33 | CHECK(java_lang_reflect_Field_ == NULL); |
| 34 | CHECK(java_lang_reflect_Field != NULL); |
| 35 | java_lang_reflect_Field_ = java_lang_reflect_Field; |
| 36 | } |
| 37 | |
| 38 | void Field::ResetClass() { |
| 39 | CHECK(java_lang_reflect_Field_ != NULL); |
| 40 | java_lang_reflect_Field_ = NULL; |
| 41 | } |
| 42 | |
| 43 | void Field::SetOffset(MemberOffset num_bytes) { |
| 44 | DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame^] | 45 | #if 0 // TODO enable later in boot and under !NDEBUG |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 46 | FieldHelper fh(this); |
| 47 | Primitive::Type type = fh.GetTypeAsPrimitiveType(); |
| 48 | if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) { |
| 49 | DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); |
| 50 | } |
| 51 | #endif |
| 52 | SetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), num_bytes.Uint32Value(), false); |
| 53 | } |
| 54 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 55 | } // namespace mirror |
| 56 | } // namespace art |