blob: 1181304ab4bc2cc35a244f242b947a505cca0367 [file] [log] [blame]
Elliott Hughes11e45072011-08-16 17:40:46 -07001/*
2 * Copyright (C) 2008 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_REFERENCE_TABLE_H_
18#define ART_SRC_REFERENCE_TABLE_H_
19
20#include <cstddef>
21#include <iosfwd>
22#include <string>
23#include <vector>
24
25namespace art {
26
27class Object;
28
Carl Shapiro5b1982d2011-08-16 18:35:19 -070029static const Object* const kInvalidIndirectRefObject = reinterpret_cast<Object*>(0xdead4321);
30static const Object* const kClearedJniWeakGlobal = reinterpret_cast<Object*>(0xdead1234);
Elliott Hughes11e45072011-08-16 17:40:46 -070031
Carl Shapiro5b1982d2011-08-16 18:35:19 -070032// Maintain a table of references. Used for internal local references,
33// JNI monitor references, and JNI pinned array references.
34//
35// None of the functions are synchronized.
Elliott Hughes11e45072011-08-16 17:40:46 -070036class ReferenceTable {
37 public:
38 ReferenceTable(const char* name, size_t initial_size, size_t max_size);
39
40 void Add(Object* obj);
41
42 void Remove(Object* obj);
43
44 size_t Size() const;
45
46 void Dump() const;
47
48 private:
49 std::string name_;
50 std::vector<Object*> entries_;
51 size_t max_size_;
52};
53
54} // namespace art
55
56#endif // ART_SRC_REFERENCE_TABLE_H_