Revision: 12032
Author: [email protected]
Date: Tue Jul 10 05:52:36 2012
Log: Add OS::GetCurrentProcessId and prepend output from trace-gc with
the current pid
BUG=none
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/9817002
Patch from Jochen Eisinger <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12032
Modified:
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/incremental-marking-inl.h
/branches/bleeding_edge/src/incremental-marking.cc
/branches/bleeding_edge/src/incremental-marking.h
/branches/bleeding_edge/src/platform-posix.cc
/branches/bleeding_edge/src/platform-win32.cc
/branches/bleeding_edge/src/platform.h
/branches/bleeding_edge/src/v8utils.cc
/branches/bleeding_edge/src/v8utils.h
/branches/bleeding_edge/test/cctest/test-platform-linux.cc
/branches/bleeding_edge/test/cctest/test-platform-win32.cc
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Jul 10 00:53:00 2012
+++ /branches/bleeding_edge/src/heap.cc Tue Jul 10 05:52:36 2012
@@ -320,52 +320,52 @@
void Heap::PrintShortHeapStatistics() {
if (!FLAG_trace_gc_verbose) return;
- PrintF("Memory allocator, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB\n",
- isolate_->memory_allocator()->Size() / KB,
- isolate_->memory_allocator()->Available() / KB);
- PrintF("New space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- new_space_.Size() / KB,
- new_space_.Available() / KB,
- new_space_.CommittedMemory() / KB);
- PrintF("Old pointers, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- old_pointer_space_->SizeOfObjects() / KB,
- old_pointer_space_->Available() / KB,
- old_pointer_space_->CommittedMemory() / KB);
- PrintF("Old data space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- old_data_space_->SizeOfObjects() / KB,
- old_data_space_->Available() / KB,
- old_data_space_->CommittedMemory() / KB);
- PrintF("Code space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- code_space_->SizeOfObjects() / KB,
- code_space_->Available() / KB,
- code_space_->CommittedMemory() / KB);
- PrintF("Map space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- map_space_->SizeOfObjects() / KB,
- map_space_->Available() / KB,
- map_space_->CommittedMemory() / KB);
- PrintF("Cell space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- cell_space_->SizeOfObjects() / KB,
- cell_space_->Available() / KB,
- cell_space_->CommittedMemory() / KB);
- PrintF("Large object space, used: %6" V8_PTR_PREFIX "d KB"
- ", available: %6" V8_PTR_PREFIX "d KB"
- ", committed: %6" V8_PTR_PREFIX "d KB\n",
- lo_space_->SizeOfObjects() / KB,
- lo_space_->Available() / KB,
- lo_space_->CommittedMemory() / KB);
+ PrintPID("Memory allocator, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB\n",
+ isolate_->memory_allocator()->Size() / KB,
+ isolate_->memory_allocator()->Available() / KB);
+ PrintPID("New space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ new_space_.Size() / KB,
+ new_space_.Available() / KB,
+ new_space_.CommittedMemory() / KB);
+ PrintPID("Old pointers, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ old_pointer_space_->SizeOfObjects() / KB,
+ old_pointer_space_->Available() / KB,
+ old_pointer_space_->CommittedMemory() / KB);
+ PrintPID("Old data space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ old_data_space_->SizeOfObjects() / KB,
+ old_data_space_->Available() / KB,
+ old_data_space_->CommittedMemory() / KB);
+ PrintPID("Code space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ code_space_->SizeOfObjects() / KB,
+ code_space_->Available() / KB,
+ code_space_->CommittedMemory() / KB);
+ PrintPID("Map space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ map_space_->SizeOfObjects() / KB,
+ map_space_->Available() / KB,
+ map_space_->CommittedMemory() / KB);
+ PrintPID("Cell space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ cell_space_->SizeOfObjects() / KB,
+ cell_space_->Available() / KB,
+ cell_space_->CommittedMemory() / KB);
+ PrintPID("Large object space, used: %6" V8_PTR_PREFIX "d KB"
+ ", available: %6" V8_PTR_PREFIX "d KB"
+ ", committed: %6" V8_PTR_PREFIX "d KB\n",
+ lo_space_->SizeOfObjects() / KB,
+ lo_space_->Available() / KB,
+ lo_space_->CommittedMemory() / KB);
}
@@ -906,8 +906,8 @@
// have to limit maximal capacity of the young generation.
new_space_high_promotion_mode_active_ = true;
if (FLAG_trace_gc) {
- PrintF("Limited new space size due to high promotion rate: %d MB\n",
- new_space_.InitialCapacity() / MB);
+ PrintPID("Limited new space size due to high promotion rate: %d
MB\n",
+ new_space_.InitialCapacity() / MB);
}
} else if (new_space_high_promotion_mode_active_ &&
IsStableOrDecreasingSurvivalTrend() &&
@@ -917,8 +917,8 @@
// to grow again.
new_space_high_promotion_mode_active_ = false;
if (FLAG_trace_gc) {
- PrintF("Unlimited new space size due to low promotion rate: %d MB\n",
- new_space_.MaximumCapacity() / MB);
+ PrintPID("Unlimited new space size due to low promotion rate: %d
MB\n",
+ new_space_.MaximumCapacity() / MB);
}
}
@@ -5809,8 +5809,8 @@
if (max_semispace_size < Page::kPageSize) {
max_semispace_size = Page::kPageSize;
if (FLAG_trace_gc) {
- PrintF("Max semispace size cannot be less than %dkbytes\n",
- Page::kPageSize >> 10);
+ PrintPID("Max semispace size cannot be less than %dkbytes\n",
+ Page::kPageSize >> 10);
}
}
max_semispace_size_ = max_semispace_size;
@@ -5825,8 +5825,8 @@
if (max_semispace_size_ > reserved_semispace_size_) {
max_semispace_size_ = reserved_semispace_size_;
if (FLAG_trace_gc) {
- PrintF("Max semispace size cannot be more than %dkbytes\n",
- reserved_semispace_size_ >> 10);
+ PrintPID("Max semispace size cannot be more than %dkbytes\n",
+ reserved_semispace_size_ >> 10);
}
}
} else {
@@ -6920,7 +6920,7 @@
}
}
- PrintF("%8.0f ms: ", heap_->isolate()->time_millis_since_init());
+ PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init());
if (!FLAG_trace_gc_nvp) {
int external_time = static_cast<int>(scopes_[Scope::EXTERNAL]);
=======================================
--- /branches/bleeding_edge/src/incremental-marking-inl.h Wed May 16
03:07:50 2012
+++ /branches/bleeding_edge/src/incremental-marking-inl.h Tue Jul 10
05:52:36 2012
@@ -107,7 +107,7 @@
// trace it. In this case we switch to non-incremental marking in
// order to finish off this marking phase.
if (FLAG_trace_gc) {
- PrintF("Hurrying incremental marking because of lack of
progress\n");
+ PrintPID("Hurrying incremental marking because of lack of
progress\n");
}
allocation_marking_factor_ = kMaxAllocationMarkingFactor;
}
=======================================
--- /branches/bleeding_edge/src/incremental-marking.cc Wed May 16 03:07:50
2012
+++ /branches/bleeding_edge/src/incremental-marking.cc Tue Jul 10 05:52:36
2012
@@ -892,8 +892,8 @@
if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) {
if (FLAG_trace_gc) {
- PrintF("Speed up marking after %d steps\n",
- static_cast<int>(kAllocationMarkingFactorSpeedupInterval));
+ PrintPID("Speed up marking after %d steps\n",
+ static_cast<int>(kAllocationMarkingFactorSpeedupInterval));
}
speed_up = true;
}
@@ -907,7 +907,7 @@
if (space_left_is_very_small ||
only_1_nth_of_space_that_was_available_still_left) {
- if (FLAG_trace_gc) PrintF("Speed up marking because of low space
left\n");
+ if (FLAG_trace_gc) PrintPID("Speed up marking because of low space
left\n");
speed_up = true;
}
@@ -918,7 +918,7 @@
if (size_of_old_space_multiplied_by_n_during_marking) {
speed_up = true;
if (FLAG_trace_gc) {
- PrintF("Speed up marking because of heap size increase\n");
+ PrintPID("Speed up marking because of heap size increase\n");
}
}
@@ -930,7 +930,7 @@
// We try to scan at at least twice the speed that we are allocating.
if (promoted_during_marking > bytes_scanned_ / 2 + scavenge_slack +
delay) {
if (FLAG_trace_gc) {
- PrintF("Speed up marking because marker was not keeping up\n");
+ PrintPID("Speed up marking because marker was not keeping up\n");
}
speed_up = true;
}
@@ -938,7 +938,7 @@
if (speed_up) {
if (state_ != MARKING) {
if (FLAG_trace_gc) {
- PrintF("Postponing speeding up marking until marking starts\n");
+ PrintPID("Postponing speeding up marking until marking starts\n");
}
} else {
allocation_marking_factor_ += kAllocationMarkingFactorSpeedup;
@@ -946,7 +946,7 @@
Min(kMaxAllocationMarkingFactor,
static_cast<intptr_t>(allocation_marking_factor_ * 1.3)));
if (FLAG_trace_gc) {
- PrintF("Marking speed increased to %d\n",
allocation_marking_factor_);
+ PrintPID("Marking speed increased to %d\n",
allocation_marking_factor_);
}
}
}
=======================================
--- /branches/bleeding_edge/src/incremental-marking.h Wed May 16 03:07:50
2012
+++ /branches/bleeding_edge/src/incremental-marking.h Tue Jul 10 05:52:36
2012
@@ -215,8 +215,9 @@
if (IsMarking()) {
if (allocation_marking_factor_ < kFastMarking) {
if (FLAG_trace_gc) {
- PrintF("Increasing marking speed to %d due to high promotion
rate\n",
- static_cast<int>(kFastMarking));
+ PrintPID("Increasing marking speed to %d "
+ "due to high promotion rate\n",
+ static_cast<int>(kFastMarking));
}
allocation_marking_factor_ = kFastMarking;
}
=======================================
--- /branches/bleeding_edge/src/platform-posix.cc Mon May 21 05:58:48 2012
+++ /branches/bleeding_edge/src/platform-posix.cc Tue Jul 10 05:52:36 2012
@@ -151,6 +151,11 @@
// NAN from math.h is defined in C99 and not in POSIX.
return NAN;
}
+
+
+int OS::GetCurrentProcessId() {
+ return static_cast<int>(getpid());
+}
//
----------------------------------------------------------------------------
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc Mon May 21 05:58:48 2012
+++ /branches/bleeding_edge/src/platform-win32.cc Tue Jul 10 05:52:36 2012
@@ -625,6 +625,11 @@
int OS::GetLastError() {
return ::GetLastError();
}
+
+
+int OS::GetCurrentProcessId() {
+ return static_cast<int>(::GetCurrentProcessId());
+}
//
----------------------------------------------------------------------------
=======================================
--- /branches/bleeding_edge/src/platform.h Mon May 21 03:02:49 2012
+++ /branches/bleeding_edge/src/platform.h Tue Jul 10 05:52:36 2012
@@ -317,6 +317,8 @@
static const int kMinComplexMemCopy = 256;
#endif // V8_TARGET_ARCH_IA32
+ static int GetCurrentProcessId();
+
private:
static const int msPerSecond = 1000;
=======================================
--- /branches/bleeding_edge/src/v8utils.cc Mon Jan 16 04:38:59 2012
+++ /branches/bleeding_edge/src/v8utils.cc Tue Jul 10 05:52:36 2012
@@ -51,6 +51,15 @@
OS::VFPrint(out, format, arguments);
va_end(arguments);
}
+
+
+void PrintPID(const char* format, ...) {
+ OS::Print("[%d] ", OS::GetCurrentProcessId());
+ va_list arguments;
+ va_start(arguments, format);
+ OS::VPrint(format, arguments);
+ va_end(arguments);
+}
void Flush(FILE* out) {
=======================================
--- /branches/bleeding_edge/src/v8utils.h Tue May 8 05:38:24 2012
+++ /branches/bleeding_edge/src/v8utils.h Tue Jul 10 05:52:36 2012
@@ -57,6 +57,9 @@
void PRINTF_CHECKING PrintF(const char* format, ...);
void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...);
+// Prepends the current process ID to the output.
+void PRINTF_CHECKING PrintPID(const char* format, ...);
+
// Our version of fflush.
void Flush(FILE* out);
=======================================
--- /branches/bleeding_edge/test/cctest/test-platform-linux.cc Fri Jan 13
05:09:52 2012
+++ /branches/bleeding_edge/test/cctest/test-platform-linux.cc Tue Jul 10
05:52:36 2012
@@ -79,3 +79,9 @@
CHECK(vm->Uncommit(block_addr, block_size));
delete vm;
}
+
+
+TEST(GetCurrentProcessId) {
+ OS::SetUp();
+ CHECK_EQ(static_cast<int>(getpid()), OS::GetCurrentProcessId());
+}
=======================================
--- /branches/bleeding_edge/test/cctest/test-platform-win32.cc Fri Jan 13
05:09:52 2012
+++ /branches/bleeding_edge/test/cctest/test-platform-win32.cc Tue Jul 10
05:52:36 2012
@@ -25,3 +25,10 @@
CHECK(vm->Uncommit(block_addr, block_size));
delete vm;
}
+
+
+TEST(GetCurrentProcessId) {
+ OS::SetUp();
+ CHECK_EQ(static_cast<int>(::GetCurrentProcessId()),
+ OS::GetCurrentProcessId());
+}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev