allocation.cc 811 B

123456789101112131415161718192021222324252627
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/services/heap_profiling/allocation.h"
  5. #include "base/hash/hash.h"
  6. namespace heap_profiling {
  7. namespace {
  8. uint32_t ComputeHash(const std::vector<Address>& addrs) {
  9. return base::Hash(addrs.data(), addrs.size() * sizeof(Address));
  10. }
  11. } // namespace
  12. AllocationSite::AllocationSite(AllocatorType allocator,
  13. std::vector<Address>&& stack,
  14. int context_id)
  15. : allocator(allocator),
  16. stack(std::move(stack)),
  17. context_id(context_id),
  18. hash_(ComputeHash(this->stack)) {}
  19. AllocationSite::~AllocationSite() = default;
  20. } // namespace heap_profiling