Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: base/trace_event/heap_profiler_allocation_context.cc

Issue 1907593002: Revert of [tracing] Turn StackFrame into struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/heap_profiler_allocation_context.cc
diff --git a/base/trace_event/heap_profiler_allocation_context.cc b/base/trace_event/heap_profiler_allocation_context.cc
index aacc7b048d00ad9f8d2b3cf9a2c437c7dfd1c466..038c083f0fa83241f9fef46c0ed239572d282d62 100644
--- a/base/trace_event/heap_profiler_allocation_context.cc
+++ b/base/trace_event/heap_profiler_allocation_context.cc
@@ -12,26 +12,26 @@
namespace base {
namespace trace_event {
-bool operator < (const StackFrame& lhs, const StackFrame& rhs) {
- return lhs.value < rhs.value;
+// Constructor that does not initialize members.
+AllocationContext::AllocationContext() {}
+
+// static
+AllocationContext AllocationContext::Empty() {
+ AllocationContext ctx;
+
+ for (size_t i = 0; i < arraysize(ctx.backtrace.frames); i++)
+ ctx.backtrace.frames[i] = nullptr;
+
+ ctx.type_name = nullptr;
+
+ return ctx;
}
-bool operator == (const StackFrame& lhs, const StackFrame& rhs) {
- return lhs.value == rhs.value;
+bool operator==(const Backtrace& lhs, const Backtrace& rhs) {
+ // Pointer equality of the stack frames is assumed, so instead of doing a deep
+ // string comparison on all of the frames, a |memcmp| suffices.
+ return std::memcmp(lhs.frames, rhs.frames, sizeof(lhs.frames)) == 0;
}
-
-bool operator != (const StackFrame& lhs, const StackFrame& rhs) {
- return !(lhs.value == rhs.value);
-}
-
-Backtrace::Backtrace(): frame_count(0) {}
-
-bool operator==(const Backtrace& lhs, const Backtrace& rhs) {
- if (lhs.frame_count != rhs.frame_count) return false;
- return std::equal(lhs.frames, lhs.frames + lhs.frame_count, rhs.frames);
-}
-
-AllocationContext::AllocationContext(): type_name(nullptr) {}
bool operator==(const AllocationContext& lhs, const AllocationContext& rhs) {
return (lhs.backtrace == rhs.backtrace) && (lhs.type_name == rhs.type_name);
@@ -43,19 +43,10 @@
namespace BASE_HASH_NAMESPACE {
using base::trace_event::AllocationContext;
using base::trace_event::Backtrace;
-using base::trace_event::StackFrame;
-
-size_t hash<StackFrame>::operator()(const StackFrame& frame) const {
- return hash<const void*>()(frame.value);
-}
size_t hash<Backtrace>::operator()(const Backtrace& backtrace) const {
- const void* values[Backtrace::kMaxFrameCount];
- for (size_t i = 0; i != backtrace.frame_count; ++i) {
- values[i] = backtrace.frames[i].value;
- }
- return base::SuperFastHash(reinterpret_cast<const char*>(values),
- backtrace.frame_count * sizeof(*values));
+ return base::SuperFastHash(reinterpret_cast<const char*>(backtrace.frames),
+ sizeof(backtrace.frames));
}
size_t hash<AllocationContext>::operator()(const AllocationContext& ctx) const {
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context.h ('k') | base/trace_event/heap_profiler_allocation_context_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698