| Barry Hayes | 7ef0755 | 2010-06-25 13:36:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
| Carl Shapiro | 44dcf29 | 2010-10-11 14:55:08 -0700 | [diff] [blame] | 17 | #ifndef _DALVIK_ALLOC_WRITEBARRIER |
| 18 | #define _DALVIK_ALLOC_WRITEBARRIER |
| 19 | |
| Barry Hayes | 7ef0755 | 2010-06-25 13:36:37 -0700 | [diff] [blame] | 20 | /* |
| 21 | * Note writes to the heap. These functions must be called if a field |
| 22 | * of an Object in the heap changes, and before any GC safe-point. The |
| 23 | * call is not needed if NULL is stored in the field. |
| 24 | */ |
| 25 | |
| 26 | /* |
| 27 | * The address within the Object has been written, and perhaps changed. |
| 28 | */ |
| Barry Hayes | 6e5cf60 | 2010-06-22 12:32:59 -0700 | [diff] [blame] | 29 | INLINE void dvmWriteBarrierField(const Object *obj, void *addr) |
| 30 | { |
| 31 | dvmMarkCard(obj); |
| Barry Hayes | 7ef0755 | 2010-06-25 13:36:37 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | /* |
| 35 | * All of the Object may have changed. |
| 36 | */ |
| Barry Hayes | 6e5cf60 | 2010-06-22 12:32:59 -0700 | [diff] [blame] | 37 | INLINE void dvmWriteBarrierObject(const Object *obj) |
| 38 | { |
| 39 | dvmMarkCard(obj); |
| Barry Hayes | 7ef0755 | 2010-06-25 13:36:37 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /* |
| 43 | * Some or perhaps all of the array indexes in the Array, greater than |
| 44 | * or equal to start and strictly less than end, have been written, |
| 45 | * and perhaps changed. |
| 46 | */ |
| Barry Hayes | 6e5cf60 | 2010-06-22 12:32:59 -0700 | [diff] [blame] | 47 | INLINE void dvmWriteBarrierArray(const ArrayObject *obj, |
| 48 | size_t start, size_t end) |
| 49 | { |
| 50 | dvmMarkCard((Object *)obj); |
| Barry Hayes | 7ef0755 | 2010-06-25 13:36:37 -0700 | [diff] [blame] | 51 | } |
| Carl Shapiro | 44dcf29 | 2010-10-11 14:55:08 -0700 | [diff] [blame] | 52 | |
| 53 | #endif /* _DALVIK_ALLOC_WRITEBARRIER */ |