Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Rebase with googlesource android-7.1.2_r39 #2

Open
wants to merge 51 commits into
base: anbox/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b787644
Pass the right class loader when inlining.
Jul 28, 2016
3e6bae7
Fix profiling output to properly display class info.
jeffyhao Aug 1, 2016
9417648
Put the deletion of profiling info under a GC critical section.
Aug 10, 2016
e172481
ART: Check for more low-space situations in zygote
agampe Aug 11, 2016
d1c6005
Merge "ART: Check for more low-space situations in zygote" into nyc-m…
agampe Aug 11, 2016
39a2c1f
Fix pending exception failure for encoded statics
Aug 11, 2016
f128e5b
Merge "Fix pending exception failure for encoded statics" into nyc-mr…
Aug 11, 2016
27a4af2
Fix debugger calling new String().
jeffyhao Aug 22, 2016
8890690
Save environment snapshot and use at fork/exec
Aug 22, 2016
9857533
Merge "Save environment snapshot and use at fork/exec" into nyc-mr1-dev
Aug 22, 2016
021c143
Revert "Save environment snapshot and use at fork/exec"
Aug 23, 2016
a0168cb
Merge "Revert "Save environment snapshot and use at fork/exec"" into …
Aug 23, 2016
43f3664
Use try lock to fix class resolution race
Aug 24, 2016
1f678c0
Revert "Use try lock to fix class resolution race"
Aug 24, 2016
4d6ad96
Revert "Revert "Use try lock to fix class resolution race""
Aug 24, 2016
8bc2d5e
Card mark holding class instead of declaring class
Aug 25, 2016
4318328
Add lock when iterating over BacktraceMap.
cferris1000 Aug 26, 2016
92cf579
Pass the right class loader when inlining. am: c770fe0480 am: 5b5ee2a89f
Aug 29, 2016
953baf0
Save environment snapshot and use at fork/exec
Aug 31, 2016
ee5c399
Don't assume resolved classses are filled in for ResolvedFieldAccessTest
Sep 9, 2016
76e1722
Fix vtable corruption issue
allight Sep 9, 2016
549fcea
Merge "Fix vtable corruption issue" into nyc-mr1-dev
allight Sep 9, 2016
88a10c7
Ensure class is initialized when reading its fields from debugger.
jeffyhao Sep 20, 2016
211afe9
Make image test multi image
Sep 22, 2016
fe1bcce
Merge "Make image test multi image" into nyc-mr1-dev
Sep 22, 2016
93f1742
Smarter image layout
Sep 23, 2016
50d2227
Make test for app-image loading.
allight Sep 26, 2016
d6a77d2
ART: Dump referenced type in IRT overflows
agampe Sep 28, 2016
c7e8eca
DO NOT MERGE: Update Oat version to 088
allight Sep 28, 2016
96527e3
ART: Clean up IRT-related abort messaging
agampe Oct 5, 2016
f7fe4ed
ART: Reprint long messages on abort
agampe Oct 5, 2016
2a539ab
Ensure OpenDexFilesFromImage closes file to prevent file descriptor leak
bdcgoogle Oct 17, 2016
b33635d
ART: Prioritize reference table dump
agampe Nov 15, 2016
2b25ca9
Fix event reporting from the debugger thread
Nov 22, 2016
8394cee
Prune uses library classes even without profile DO NOT MERGE
Aug 5, 2016
f22e9f6
Prune uses library classes even without profile DO NOT MERGE
Dec 15, 2016
dfd17f1
Prune uses library classes even without profile
Aug 5, 2016
e737165
Merge "Prune uses library classes even without profile" into nyc-mr2-dev
Dec 16, 2016
fc9bec2
Revert "Prune uses library classes even without profile DO NOT MERGE"
Dec 19, 2016
a03ed24
Revert "Prune uses library classes even without profile DO NOT MERGE"
Dec 19, 2016
9d5d85e
Revert "Revert "Prune uses library classes even without profile DO NO…
Jan 5, 2017
40d4c76
Add visiting for class loaders in StickyMarkSweep
neo-lg Nov 7, 2016
2f3fb4d
Merge "Add visiting for class loaders in StickyMarkSweep" into nyc-mr…
Jan 6, 2017
61049e8
Delete extra arm64/mips64 MterpReturn suspend check
Jan 10, 2017
3f3d4d6
Cache flush/invalidate needs RWX permission
Nov 17, 2016
f5f462b
Add Thread entry to signal if the thread can call into java
Dec 15, 2016
2db6c40
ART: Add ThreadPool mode that creates peers
agampe Jan 24, 2017
f9e3754
Revert "Revert "ART: Give JIT thread pool workers a peer""
agampe Jan 30, 2017
8602eda
Use conservative permissions when creating files in ART
May 23, 2019
e8b9f89
ART: Change main-thread thread paging scheme
agampe Jun 29, 2017
21dd6b2
Merge pull request #2 from Road-Drum/preprebase
Road-Drum Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/image_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ bool ImageWriter::PruneAppImageClassInternal(
result = result || PruneAppImageClassInternal(klass->GetSuperClass(),
&my_early_exit,
visited);
// Remove the class if the dex file is not in the set of dex files. This happens for classes that
// are from uses library if there is no profile. b/30688277
mirror::DexCache* dex_cache = klass->GetDexCache();
if (dex_cache != nullptr) {
result = result ||
dex_file_oat_index_map_.find(dex_cache->GetDexFile()) == dex_file_oat_index_map_.end();
}
// Erase the element we stored earlier since we are exiting the function.
auto it = visited->find(klass);
DCHECK(it != visited->end());
Expand Down
10 changes: 9 additions & 1 deletion runtime/class_linker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ void ClassLinker::VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) {
boot_class_table_.VisitRoots(buffered_visitor);

// If tracing is enabled, then mark all the class loaders to prevent unloading.
if (tracing_enabled) {
if ((flags & kVisitRootFlagClassLoader) != 0 || tracing_enabled) {
for (const ClassLoaderData& data : class_loaders_) {
GcRoot<mirror::Object> root(GcRoot<mirror::Object>(self->DecodeJObject(data.weak_root)));
root.VisitRoot(visitor, RootInfo(kRootVMInternal));
Expand Down Expand Up @@ -2409,6 +2409,14 @@ mirror::Class* ClassLinker::FindClass(Thread* self,

// We'll let the Java-side rediscover all this and throw the exception with the right stack
// trace.
if (!self->CanCallIntoJava()) {
// Oops, we can't call into java so we can't run actual class-loader code.
// This is true for e.g. for the compiler (jit or aot).
mirror::Throwable* pre_allocated =
Runtime::Current()->GetPreAllocatedNoClassDefFoundError();
self->SetException(pre_allocated);
return nullptr;
}
}

if (Runtime::Current()->IsAotCompiler()) {
Expand Down
3 changes: 1 addition & 2 deletions runtime/gc/collector/mark_sweep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ void MarkSweep::MarkNonThreadRoots() {
void MarkSweep::MarkConcurrentRoots(VisitRootFlags flags) {
TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings());
// Visit all runtime roots and clear dirty flags.
Runtime::Current()->VisitConcurrentRoots(
this, static_cast<VisitRootFlags>(flags | kVisitRootFlagNonMoving));
Runtime::Current()->VisitConcurrentRoots(this, flags);
}

class MarkSweep::DelayReferenceReferentVisitor {
Expand Down
2 changes: 1 addition & 1 deletion runtime/gc/collector/mark_sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MarkSweep : public GarbageCollector {
REQUIRES(!mark_stack_lock_)
SHARED_REQUIRES(Locks::mutator_lock_);

void MarkConcurrentRoots(VisitRootFlags flags)
virtual void MarkConcurrentRoots(VisitRootFlags flags)
REQUIRES(Locks::heap_bitmap_lock_)
REQUIRES(!mark_stack_lock_)
SHARED_REQUIRES(Locks::mutator_lock_);
Expand Down
13 changes: 13 additions & 0 deletions runtime/gc/collector/sticky_mark_sweep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ void StickyMarkSweep::MarkReachableObjects() {
RecursiveMarkDirtyObjects(false, accounting::CardTable::kCardDirty - 1);
}

void StickyMarkSweep::MarkConcurrentRoots(VisitRootFlags flags) {
TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings());
// Visit all runtime roots and clear dirty flags including class loader. This is done to prevent
// incorrect class unloading since the GC does not card mark when storing store the class during
// object allocation. Doing this for each allocation would be slow.
// Since the card is not dirty, it means the object may not get scanned. This can cause class
// unloading to occur even though the class and class loader are reachable through the object's
// class.
Runtime::Current()->VisitConcurrentRoots(
this,
static_cast<VisitRootFlags>(flags | kVisitRootFlagClassLoader));
}

void StickyMarkSweep::Sweep(bool swap_bitmaps ATTRIBUTE_UNUSED) {
SweepArray(GetHeap()->GetLiveStack(), false);
}
Expand Down
6 changes: 6 additions & 0 deletions runtime/gc/collector/sticky_mark_sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class StickyMarkSweep FINAL : public PartialMarkSweep {
StickyMarkSweep(Heap* heap, bool is_concurrent, const std::string& name_prefix = "");
~StickyMarkSweep() {}

void MarkConcurrentRoots(VisitRootFlags flags)
OVERRIDE
REQUIRES(!mark_stack_lock_)
REQUIRES(Locks::heap_bitmap_lock_)
SHARED_REQUIRES(Locks::mutator_lock_);

protected:
// Bind the live bits to the mark bits of bitmaps for all spaces, all spaces other than the
// alloc space will be marked as immune.
Expand Down
6 changes: 0 additions & 6 deletions runtime/interpreter/mterp/arm64/footer.S
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ MterpExceptionReturn:
b MterpDone
MterpReturn:
ldr x2, [xFP, #OFF_FP_RESULT_REGISTER]
ldr lr, [xSELF, #THREAD_FLAGS_OFFSET]
str x0, [x2]
mov x0, xSELF
ands lr, lr, #(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST)
b.eq check2
bl MterpSuspendCheck // (self)
check2:
mov x0, #1 // signal return to caller.
MterpDone:
/*
Expand Down
6 changes: 0 additions & 6 deletions runtime/interpreter/mterp/mips64/footer.S
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ MterpExceptionReturn:
*/
MterpReturn:
ld a2, OFF_FP_RESULT_REGISTER(rFP)
lw ra, THREAD_FLAGS_OFFSET(rSELF)
sd a0, 0(a2)
move a0, rSELF
and ra, ra, (THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST)
beqzc ra, check2
jal MterpSuspendCheck # (self)
check2:
li v0, 1 # signal return to caller.
MterpDone:
ld s5, STACK_OFFSET_S5(sp)
Expand Down
6 changes: 0 additions & 6 deletions runtime/interpreter/mterp/out/mterp_arm64.S
Original file line number Diff line number Diff line change
Expand Up @@ -11554,13 +11554,7 @@ MterpExceptionReturn:
b MterpDone
MterpReturn:
ldr x2, [xFP, #OFF_FP_RESULT_REGISTER]
ldr lr, [xSELF, #THREAD_FLAGS_OFFSET]
str x0, [x2]
mov x0, xSELF
ands lr, lr, #(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST)
b.eq check2
bl MterpSuspendCheck // (self)
check2:
mov x0, #1 // signal return to caller.
MterpDone:
/*
Expand Down
6 changes: 0 additions & 6 deletions runtime/interpreter/mterp/out/mterp_mips64.S
Original file line number Diff line number Diff line change
Expand Up @@ -12386,13 +12386,7 @@ MterpExceptionReturn:
*/
MterpReturn:
ld a2, OFF_FP_RESULT_REGISTER(rFP)
lw ra, THREAD_FLAGS_OFFSET(rSELF)
sd a0, 0(a2)
move a0, rSELF
and ra, ra, (THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST)
beqzc ra, check2
jal MterpSuspendCheck # (self)
check2:
li v0, 1 # signal return to caller.
MterpDone:
ld s5, STACK_OFFSET_S5(sp)
Expand Down
47 changes: 25 additions & 22 deletions runtime/jdwp/jdwp_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ void JdwpState::SendRequestAndPossiblySuspend(ExpandBuf* pReq, JdwpSuspendPolicy
Thread* const self = Thread::Current();
self->AssertThreadSuspensionIsAllowable();
CHECK(pReq != nullptr);
CHECK_EQ(threadId, Dbg::GetThreadSelfId()) << "Only the current thread can suspend itself";
/* send request and possibly suspend ourselves */
JDWP::ObjectId thread_self_id = Dbg::GetThreadSelfId();
ScopedThreadSuspension sts(self, kWaitingForDebuggerSend);
if (suspend_policy != SP_NONE) {
AcquireJdwpTokenForEvent(threadId);
Expand All @@ -631,7 +631,7 @@ void JdwpState::SendRequestAndPossiblySuspend(ExpandBuf* pReq, JdwpSuspendPolicy
{
// Before suspending, we change our state to kSuspended so the debugger sees us as RUNNING.
ScopedThreadStateChange stsc(self, kSuspended);
SuspendByPolicy(suspend_policy, thread_self_id);
SuspendByPolicy(suspend_policy, threadId);
}
}

Expand All @@ -658,13 +658,10 @@ void JdwpState::ReleaseJdwpTokenForCommand() {
}

void JdwpState::AcquireJdwpTokenForEvent(ObjectId threadId) {
CHECK_NE(Thread::Current(), GetDebugThread()) << "Expected event thread";
CHECK_NE(debug_thread_id_, threadId) << "Not expected debug thread";
SetWaitForJdwpToken(threadId);
}

void JdwpState::ReleaseJdwpTokenForEvent() {
CHECK_NE(Thread::Current(), GetDebugThread()) << "Expected event thread";
ClearWaitForJdwpToken();
}

Expand All @@ -685,23 +682,28 @@ void JdwpState::SetWaitForJdwpToken(ObjectId threadId) {
/* this is held for very brief periods; contention is unlikely */
MutexLock mu(self, jdwp_token_lock_);

CHECK_NE(jdwp_token_owner_thread_id_, threadId) << "Thread is already holding event thread lock";
if (jdwp_token_owner_thread_id_ == threadId) {
// Only the debugger thread may already hold the event token. For instance, it may trigger
// a CLASS_PREPARE event while processing a command that initializes a class.
CHECK_EQ(threadId, debug_thread_id_) << "Non-debugger thread is already holding event token";
} else {
/*
* If another thread is already doing stuff, wait for it. This can
* go to sleep indefinitely.
*/

/*
* If another thread is already doing stuff, wait for it. This can
* go to sleep indefinitely.
*/
while (jdwp_token_owner_thread_id_ != 0) {
VLOG(jdwp) << StringPrintf("event in progress (%#" PRIx64 "), %#" PRIx64 " sleeping",
jdwp_token_owner_thread_id_, threadId);
waited = true;
jdwp_token_cond_.Wait(self);
}
while (jdwp_token_owner_thread_id_ != 0) {
VLOG(jdwp) << StringPrintf("event in progress (%#" PRIx64 "), %#" PRIx64 " sleeping",
jdwp_token_owner_thread_id_, threadId);
waited = true;
jdwp_token_cond_.Wait(self);
}

if (waited || threadId != debug_thread_id_) {
VLOG(jdwp) << StringPrintf("event token grabbed (%#" PRIx64 ")", threadId);
if (waited || threadId != debug_thread_id_) {
VLOG(jdwp) << StringPrintf("event token grabbed (%#" PRIx64 ")", threadId);
}
jdwp_token_owner_thread_id_ = threadId;
}
jdwp_token_owner_thread_id_ = threadId;
}

/*
Expand Down Expand Up @@ -1224,14 +1226,15 @@ void JdwpState::PostClassPrepare(mirror::Class* klass) {
VLOG(jdwp) << " suspend_policy=" << suspend_policy;
}

if (thread_id == debug_thread_id_) {
ObjectId reported_thread_id = thread_id;
if (reported_thread_id == debug_thread_id_) {
/*
* JDWP says that, for a class prep in the debugger thread, we
* should set thread to null and if any threads were supposed
* to be suspended then we suspend all other threads.
*/
VLOG(jdwp) << " NOTE: class prepare in debugger thread!";
thread_id = 0;
reported_thread_id = 0;
if (suspend_policy == SP_EVENT_THREAD) {
suspend_policy = SP_ALL;
}
Expand All @@ -1244,7 +1247,7 @@ void JdwpState::PostClassPrepare(mirror::Class* klass) {
for (const JdwpEvent* pEvent : match_list) {
expandBufAdd1(pReq, pEvent->eventKind);
expandBufAdd4BE(pReq, pEvent->requestId);
expandBufAddObjectId(pReq, thread_id);
expandBufAddObjectId(pReq, reported_thread_id);
expandBufAdd1(pReq, tag);
expandBufAddRefTypeId(pReq, class_id);
expandBufAddUtf8String(pReq, signature);
Expand Down
13 changes: 11 additions & 2 deletions runtime/jit/jit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ Jit::Jit() : dump_info_on_shutdown_(false),
memory_use_("Memory used for compilation", 16),
lock_("JIT memory use lock"),
use_jit_compilation_(true),
save_profiling_info_(false) {}
save_profiling_info_(false),
hot_method_threshold_(0),
warm_method_threshold_(0),
osr_method_threshold_(0),
priority_thread_weight_(0),
invoke_transition_weight_(0) {}

Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
DCHECK(options->UseJitCompilation() || options->GetSaveProfilingInfo());
Expand Down Expand Up @@ -280,7 +285,11 @@ bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
void Jit::CreateThreadPool() {
// There is a DCHECK in the 'AddSamples' method to ensure the tread pool
// is not null when we instrument.
thread_pool_.reset(new ThreadPool("Jit thread pool", 1));

// We need peers as we may report the JIT thread, e.g., in the debugger.
constexpr bool kJitPoolNeedsPeers = true;
thread_pool_.reset(new ThreadPool("Jit thread pool", 1, kJitPoolNeedsPeers));

thread_pool_->SetPthreadPriority(kJitPoolThreadPthreadPriority);
thread_pool_->StartWorkers(Thread::Current());
}
Expand Down
10 changes: 8 additions & 2 deletions runtime/jit/jit_code_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,16 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self,
core_spill_mask,
fp_spill_mask,
code_size);
// Flush caches before we remove write permission because on some ARMv8 hardware,
// flushing caches require write permissions.
//
// For reference, here are kernel patches discussing about this issue:
// https://android.googlesource.com/kernel/msm/%2B/0e7f7bcc3fc87489cda5aa6aff8ce40eed912279
// https://patchwork.kernel.org/patch/9047921/
FlushInstructionCache(reinterpret_cast<char*>(code_ptr),
reinterpret_cast<char*>(code_ptr + code_size));
}

FlushInstructionCache(reinterpret_cast<char*>(code_ptr),
reinterpret_cast<char*>(code_ptr + code_size));
number_of_compilations_++;
}
// We need to update the entry point in the runnable state for the instrumentation.
Expand Down
2 changes: 1 addition & 1 deletion runtime/os_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ File* OS::CreateEmptyFileWriteOnly(const char* name) {
File* OS::OpenFileWithFlags(const char* name, int flags) {
CHECK(name != nullptr);
std::unique_ptr<File> file(new File);
if (!file->Open(name, flags, 0666)) {
if (!file->Open(name, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) {
return nullptr;
}
return file.release();
Expand Down
Loading