Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [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 | #ifndef ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ |
| 18 | #define ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ |
| 19 | |
| 20 | namespace art { |
| 21 | |
| 22 | #include "macros.h" |
| 23 | |
| 24 | class Object; |
| 25 | |
| 26 | // Stack allocated indirect reference table, allocated within the bridge frame |
| 27 | // between managed and native code. |
| 28 | class StackIndirectReferenceTable { |
| 29 | public: |
| 30 | // Number of references contained within this SIRT |
| 31 | size_t NumberOfReferences() { |
| 32 | return number_of_references_; |
| 33 | } |
| 34 | |
| 35 | // Link to previous SIRT or NULL |
| 36 | StackIndirectReferenceTable* Link() { |
| 37 | return link_; |
| 38 | } |
| 39 | |
| 40 | Object** References() { |
| 41 | return references_; |
| 42 | } |
| 43 | |
| 44 | // Offset of length within SIRT, used by generated code |
| 45 | static size_t NumberOfReferencesOffset() { |
| 46 | return OFFSETOF_MEMBER(StackIndirectReferenceTable, number_of_references_); |
| 47 | } |
| 48 | |
| 49 | // Offset of link within SIRT, used by generated code |
| 50 | static size_t LinkOffset() { |
| 51 | return OFFSETOF_MEMBER(StackIndirectReferenceTable, link_); |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | StackIndirectReferenceTable() {} |
| 56 | |
| 57 | size_t number_of_references_; |
| 58 | StackIndirectReferenceTable* link_; |
| 59 | |
| 60 | // Fake array, really allocated and filled in by jni_compiler. |
| 61 | Object* references_[0]; |
| 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(StackIndirectReferenceTable); |
| 64 | }; |
| 65 | |
| 66 | } // namespace art |
| 67 | |
| 68 | #endif // ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ |