diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/arch/arm/quick_method_frame_info_arm.h | 2 | ||||
| -rw-r--r-- | runtime/arch/arm64/quick_method_frame_info_arm64.h | 2 | ||||
| -rw-r--r-- | runtime/arch/mips64/quick_method_frame_info_mips64.h | 2 | ||||
| -rw-r--r-- | runtime/class_linker_test.cc | 2 | ||||
| -rw-r--r-- | runtime/gc/heap.cc | 2 | ||||
| -rw-r--r-- | runtime/gc/reference_processor.h | 2 | ||||
| -rw-r--r-- | runtime/gc/scoped_gc_critical_section.h | 4 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/arm64/op_iput_wide_quick.S | 2 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/out/mterp_arm64.S | 2 | ||||
| -rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 2 | ||||
| -rw-r--r-- | runtime/monitor.cc | 6 | ||||
| -rw-r--r-- | runtime/monitor.h | 1 | ||||
| -rw-r--r-- | runtime/trace.cc | 36 | ||||
| -rw-r--r-- | runtime/trace.h | 6 |
14 files changed, 45 insertions, 26 deletions
diff --git a/runtime/arch/arm/quick_method_frame_info_arm.h b/runtime/arch/arm/quick_method_frame_info_arm.h index 4b23c77bc5..35f1948138 100644 --- a/runtime/arch/arm/quick_method_frame_info_arm.h +++ b/runtime/arch/arm/quick_method_frame_info_arm.h @@ -62,7 +62,7 @@ constexpr uint32_t ArmCalleeSaveCoreSpills(Runtime::CalleeSaveType type) { constexpr uint32_t ArmCalleeSaveFpSpills(Runtime::CalleeSaveType type) { return kArmCalleeSaveFpAlwaysSpills | kArmCalleeSaveFpRefSpills | - (type == Runtime::kSaveRefsAndArgs ? kArmCalleeSaveFpArgSpills: 0) | + (type == Runtime::kSaveRefsAndArgs ? kArmCalleeSaveFpArgSpills : 0) | (type == Runtime::kSaveAllCalleeSaves ? kArmCalleeSaveFpAllSpills : 0) | (type == Runtime::kSaveEverything ? kArmCalleeSaveFpEverythingSpills : 0); } diff --git a/runtime/arch/arm64/quick_method_frame_info_arm64.h b/runtime/arch/arm64/quick_method_frame_info_arm64.h index 36f283bc91..32d9d08739 100644 --- a/runtime/arch/arm64/quick_method_frame_info_arm64.h +++ b/runtime/arch/arm64/quick_method_frame_info_arm64.h @@ -85,7 +85,7 @@ constexpr uint32_t Arm64CalleeSaveCoreSpills(Runtime::CalleeSaveType type) { constexpr uint32_t Arm64CalleeSaveFpSpills(Runtime::CalleeSaveType type) { return kArm64CalleeSaveFpAlwaysSpills | kArm64CalleeSaveFpRefSpills | - (type == Runtime::kSaveRefsAndArgs ? kArm64CalleeSaveFpArgSpills: 0) | + (type == Runtime::kSaveRefsAndArgs ? kArm64CalleeSaveFpArgSpills : 0) | (type == Runtime::kSaveAllCalleeSaves ? kArm64CalleeSaveFpAllSpills : 0) | (type == Runtime::kSaveEverything ? kArm64CalleeSaveFpEverythingSpills : 0); } diff --git a/runtime/arch/mips64/quick_method_frame_info_mips64.h b/runtime/arch/mips64/quick_method_frame_info_mips64.h index 397776e999..d774473289 100644 --- a/runtime/arch/mips64/quick_method_frame_info_mips64.h +++ b/runtime/arch/mips64/quick_method_frame_info_mips64.h @@ -78,7 +78,7 @@ constexpr uint32_t Mips64CalleeSaveCoreSpills(Runtime::CalleeSaveType type) { constexpr uint32_t Mips64CalleeSaveFpSpills(Runtime::CalleeSaveType type) { return kMips64CalleeSaveFpRefSpills | - (type == Runtime::kSaveRefsAndArgs ? kMips64CalleeSaveFpArgSpills: 0) | + (type == Runtime::kSaveRefsAndArgs ? kMips64CalleeSaveFpArgSpills : 0) | (type == Runtime::kSaveAllCalleeSaves ? kMips64CalleeSaveFpAllSpills : 0) | (type == Runtime::kSaveEverything ? kMips64CalleeSaveFpEverythingSpills : 0); } diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 7d4b1589b6..7b6c0dc510 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -487,7 +487,7 @@ struct CheckOffsets { // says AccessibleObject is 9 bytes but sizeof(AccessibleObject) is 12 bytes due to padding. // The RoundUp is to get around this case. static constexpr size_t kPackAlignment = 4; - size_t expected_size = RoundUp(is_static ? klass->GetClassSize(): klass->GetObjectSize(), + size_t expected_size = RoundUp(is_static ? klass->GetClassSize() : klass->GetObjectSize(), kPackAlignment); if (sizeof(T) != expected_size) { LOG(ERROR) << "Class size mismatch:" diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 34d82845dc..268cca0cfd 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -360,7 +360,7 @@ Heap::Heap(size_t initial_size, // If we are the zygote, the non moving space becomes the zygote space when we run // PreZygoteFork the first time. In this case, call the map "zygote space" since we can't // rename the mem map later. - const char* space_name = is_zygote ? kZygoteSpaceName: kNonMovingSpaceName; + const char* space_name = is_zygote ? kZygoteSpaceName : kNonMovingSpaceName; // Reserve the non moving mem map before the other two since it needs to be at a specific // address. non_moving_space_mem_map.reset( diff --git a/runtime/gc/reference_processor.h b/runtime/gc/reference_processor.h index b15544d549..38b68cbbe8 100644 --- a/runtime/gc/reference_processor.h +++ b/runtime/gc/reference_processor.h @@ -42,7 +42,7 @@ class GarbageCollector; class Heap; -// Used to process java.lang.References concurrently or paused. +// Used to process java.lang.ref.Reference instances concurrently or paused. class ReferenceProcessor { public: explicit ReferenceProcessor(); diff --git a/runtime/gc/scoped_gc_critical_section.h b/runtime/gc/scoped_gc_critical_section.h index ec93bca802..1271ff7af3 100644 --- a/runtime/gc/scoped_gc_critical_section.h +++ b/runtime/gc/scoped_gc_critical_section.h @@ -27,8 +27,8 @@ class Thread; namespace gc { -// Wait until the GC is finished and then prevent GC from starting until the destructor. Used -// to prevent deadlocks in places where we call ClassLinker::VisitClass with all th threads +// Wait until the GC is finished and then prevent the GC from starting until the destructor. Used +// to prevent deadlocks in places where we call ClassLinker::VisitClass with all the threads // suspended. class ScopedGCCriticalSection { public: diff --git a/runtime/interpreter/mterp/arm64/op_iput_wide_quick.S b/runtime/interpreter/mterp/arm64/op_iput_wide_quick.S index 6cec3633a6..28e831a5f8 100644 --- a/runtime/interpreter/mterp/arm64/op_iput_wide_quick.S +++ b/runtime/interpreter/mterp/arm64/op_iput_wide_quick.S @@ -4,7 +4,7 @@ GET_VREG w2, w2 // w2<- fp[B], the object pointer ubfx w0, wINST, #8, #4 // w0<- A cbz w2, common_errNullObject // object was null - GET_VREG_WIDE x0, w0 // x0-< fp[A] + GET_VREG_WIDE x0, w0 // x0<- fp[A] FETCH_ADVANCE_INST 2 // advance rPC, load wINST str x0, [x2, x3] // obj.field<- x0 GET_INST_OPCODE ip // extract opcode from wINST diff --git a/runtime/interpreter/mterp/out/mterp_arm64.S b/runtime/interpreter/mterp/out/mterp_arm64.S index 681790daa8..7d442c0b4b 100644 --- a/runtime/interpreter/mterp/out/mterp_arm64.S +++ b/runtime/interpreter/mterp/out/mterp_arm64.S @@ -6593,7 +6593,7 @@ artMterpAsmInstructionStart = .L_op_nop GET_VREG w2, w2 // w2<- fp[B], the object pointer ubfx w0, wINST, #8, #4 // w0<- A cbz w2, common_errNullObject // object was null - GET_VREG_WIDE x0, w0 // x0-< fp[A] + GET_VREG_WIDE x0, w0 // x0<- fp[A] FETCH_ADVANCE_INST 2 // advance rPC, load wINST str x0, [x2, x3] // obj.field<- x0 GET_INST_OPCODE ip // extract opcode from wINST diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 7dd3d3db4d..feb6e0857a 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -1443,7 +1443,7 @@ void UnstartedRuntime::UnstartedMethodInvoke( ObjPtr<mirror::Object> java_method_obj = shadow_frame->GetVRegReference(arg_offset); ScopedLocalRef<jobject> java_method(env, - java_method_obj == nullptr ? nullptr :env->AddLocalReference<jobject>(java_method_obj)); + java_method_obj == nullptr ? nullptr : env->AddLocalReference<jobject>(java_method_obj)); ObjPtr<mirror::Object> java_receiver_obj = shadow_frame->GetVRegReference(arg_offset + 1); ScopedLocalRef<jobject> java_receiver(env, diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 9c0927584e..071b0e2c75 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -1394,6 +1394,12 @@ void MonitorList::SweepMonitorList(IsMarkedVisitor* visitor) { } } +size_t MonitorList::Size() { + Thread* self = Thread::Current(); + MutexLock mu(self, monitor_list_lock_); + return list_.size(); +} + class MonitorDeflateVisitor : public IsMarkedVisitor { public: MonitorDeflateVisitor() : self_(Thread::Current()), deflate_count_(0) {} diff --git a/runtime/monitor.h b/runtime/monitor.h index c3da5636ad..1fa46826eb 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -331,6 +331,7 @@ class MonitorList { void BroadcastForNewMonitors() REQUIRES(!monitor_list_lock_); // Returns how many monitors were deflated. size_t DeflateMonitors() REQUIRES(!monitor_list_lock_) REQUIRES(Locks::mutator_lock_); + size_t Size() REQUIRES(!monitor_list_lock_); typedef std::list<Monitor*, TrackingAllocator<Monitor*, kAllocatorTagMonitorList>> Monitors; diff --git a/runtime/trace.cc b/runtime/trace.cc index 9d9360e9cb..2add955f8e 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -54,6 +54,7 @@ static constexpr size_t TraceActionBits = MinimumBitsToStore( static_cast<size_t>(kTraceMethodActionMask)); static constexpr uint8_t kOpNewMethod = 1U; static constexpr uint8_t kOpNewThread = 2U; +static constexpr uint8_t kOpTraceSummary = 3U; class BuildStackTraceVisitor : public StackVisitor { public: @@ -700,20 +701,19 @@ void Trace::FinishTracing() { std::string header(os.str()); if (trace_output_mode_ == TraceOutputMode::kStreaming) { - File file(streaming_file_name_ + ".sec", O_CREAT | O_WRONLY, true); - if (!file.IsOpened()) { - LOG(WARNING) << "Could not open secondary trace file!"; - return; - } - if (!file.WriteFully(header.c_str(), header.length())) { - file.Erase(); - std::string detail(StringPrintf("Trace data write failed: %s", strerror(errno))); - PLOG(ERROR) << detail; - ThrowRuntimeException("%s", detail.c_str()); - } - if (file.FlushCloseOrErase() != 0) { - PLOG(ERROR) << "Could not write secondary file"; - } + MutexLock mu(Thread::Current(), *streaming_lock_); // To serialize writing. + // Write a special token to mark the end of trace records and the start of + // trace summary. + uint8_t buf[7]; + Append2LE(buf, 0); + buf[2] = kOpTraceSummary; + Append4LE(buf + 3, static_cast<uint32_t>(header.length())); + WriteToBuf(buf, sizeof(buf)); + // Write the trace summary. The summary is identical to the file header when + // the output mode is not streaming (except for methods). + WriteToBuf(reinterpret_cast<const uint8_t*>(header.c_str()), header.length()); + // Flush the buffer, which may include some trace records before the summary. + FlushBuf(); } else { if (trace_file_.get() == nullptr) { iovec iov[2]; @@ -894,6 +894,14 @@ void Trace::WriteToBuf(const uint8_t* src, size_t src_size) { memcpy(buf_.get() + old_offset, src, src_size); } +void Trace::FlushBuf() { + int32_t offset = cur_offset_.LoadRelaxed(); + if (!trace_file_->WriteFully(buf_.get(), offset)) { + PLOG(WARNING) << "Failed flush the remaining data in streaming."; + } + cur_offset_.StoreRelease(0); +} + void Trace::LogMethodTraceEvent(Thread* thread, ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event, uint32_t thread_clock_diff, uint32_t wall_clock_diff) { diff --git a/runtime/trace.h b/runtime/trace.h index 824b15003a..485e9a133a 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -202,7 +202,8 @@ class Trace FINAL : public instrumentation::InstrumentationListener { // This causes the negative annotations to incorrectly have a false positive. TODO: Figure out // how to annotate this. NO_THREAD_SAFETY_ANALYSIS; - void FinishTracing() REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!*unique_methods_lock_); + void FinishTracing() + REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!*unique_methods_lock_, !*streaming_lock_); void ReadClocks(Thread* thread, uint32_t* thread_clock_diff, uint32_t* wall_clock_diff); @@ -229,6 +230,9 @@ class Trace FINAL : public instrumentation::InstrumentationListener { // annotation. void WriteToBuf(const uint8_t* src, size_t src_size) REQUIRES(streaming_lock_); + // Flush the main buffer to file. Used for streaming. Exposed here for lock annotation. + void FlushBuf() + REQUIRES(streaming_lock_); uint32_t EncodeTraceMethod(ArtMethod* method) REQUIRES(!*unique_methods_lock_); uint32_t EncodeTraceMethodAndAction(ArtMethod* method, TraceAction action) |