| 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 038c083f0fa83241f9fef46c0ed239572d282d62..aacc7b048d00ad9f8d2b3cf9a2c437c7dfd1c466 100644
|
| --- a/base/trace_event/heap_profiler_allocation_context.cc
|
| +++ b/base/trace_event/heap_profiler_allocation_context.cc
|
| @@ -12,27 +12,27 @@
|
| namespace base {
|
| namespace trace_event {
|
|
|
| -// 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;
|
| +bool operator < (const StackFrame& lhs, const StackFrame& rhs) {
|
| + return lhs.value < rhs.value;
|
| +}
|
|
|
| - ctx.type_name = nullptr;
|
| +bool operator == (const StackFrame& lhs, const StackFrame& rhs) {
|
| + return lhs.value == rhs.value;
|
| +}
|
|
|
| - return ctx;
|
| +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) {
|
| - // 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;
|
| + 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,10 +43,19 @@ bool operator==(const AllocationContext& lhs, const AllocationContext& rhs) {
|
| 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 {
|
| - return base::SuperFastHash(reinterpret_cast<const char*>(backtrace.frames),
|
| - sizeof(backtrace.frames));
|
| + 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));
|
| }
|
|
|
| size_t hash<AllocationContext>::operator()(const AllocationContext& ctx) const {
|
|
|