diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2014-06-18 13:47:35 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2014-06-20 11:23:58 -0700 |
commit | ea2e1bd713ca8295ba4fcd01e77a3ce532ea61e4 (patch) | |
tree | d41be4b08041c5a2b1af626d8cdf6b69280723d5 /runtime/reference_table.cc | |
parent | 241fd1192dfc0f7322660343179f9fc0591ed9ff (diff) | |
download | art-ea2e1bd713ca8295ba4fcd01e77a3ce532ea61e4.tar.gz art-ea2e1bd713ca8295ba4fcd01e77a3ce532ea61e4.tar.bz2 art-ea2e1bd713ca8295ba4fcd01e77a3ce532ea61e4.zip |
Add more read barriers for JNI roots.
To make it possible to concurrently scan the JNI global roots (that
is, the roots visited by JavaVMExt::VisitRoots()), add read barriers
to the indirect reference table and the reference table.
Also, add read barriers to the jmethodID/jfieldID decode routines
(ScopedObjectAccessAlreadyRunnable::DecodeField/DecodeMethod) so that
we can concurrently handle (encoded) fields and methods.
Bug: 12687968
Change-Id: I3df4e4e622a572ff0ea8d44b2dc70a4d6b3ba058
Diffstat (limited to 'runtime/reference_table.cc')
-rw-r--r-- | runtime/reference_table.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc index 11527fa2fe..cd35863543 100644 --- a/runtime/reference_table.cc +++ b/runtime/reference_table.cc @@ -24,6 +24,7 @@ #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/string-inl.h" +#include "read_barrier.h" #include "thread.h" #include "utils.h" @@ -51,7 +52,9 @@ void ReferenceTable::Add(mirror::Object* obj) { void ReferenceTable::Remove(mirror::Object* obj) { // We iterate backwards on the assumption that references are LIFO. for (int i = entries_.size() - 1; i >= 0; --i) { - if (entries_[i] == obj) { + mirror::Object* entry = + ReadBarrier::BarrierForRoot<mirror::Object, kWithReadBarrier>(&entries_[i]); + if (entry == obj) { entries_.erase(entries_.begin() + i); return; } @@ -140,12 +143,12 @@ size_t ReferenceTable::Size() const { return entries_.size(); } -void ReferenceTable::Dump(std::ostream& os) const { +void ReferenceTable::Dump(std::ostream& os) { os << name_ << " reference table dump:\n"; Dump(os, entries_); } -void ReferenceTable::Dump(std::ostream& os, const Table& entries) { +void ReferenceTable::Dump(std::ostream& os, Table& entries) { if (entries.empty()) { os << " (empty)\n"; return; @@ -160,7 +163,8 @@ void ReferenceTable::Dump(std::ostream& os, const Table& entries) { } os << " Last " << (count - first) << " entries (of " << count << "):\n"; for (int idx = count - 1; idx >= first; --idx) { - mirror::Object* ref = entries[idx]; + mirror::Object* ref = + ReadBarrier::BarrierForRoot<mirror::Object, kWithReadBarrier>(&entries[idx]); if (ref == NULL) { continue; } @@ -194,7 +198,12 @@ void ReferenceTable::Dump(std::ostream& os, const Table& entries) { } // Make a copy of the table and sort it. - Table sorted_entries(entries.begin(), entries.end()); + Table sorted_entries; + for (size_t i = 0; i < entries.size(); ++i) { + mirror::Object* entry = + ReadBarrier::BarrierForRoot<mirror::Object, kWithReadBarrier>(&entries[i]); + sorted_entries.push_back(entry); + } std::sort(sorted_entries.begin(), sorted_entries.end(), ObjectComparator()); // Remove any uninteresting stuff from the list. The sort moved them all to the end. |