v8/include/cppgc/internal/accessors.h
Omer Katz 46a1fa1a2c cppgc: Fix GetHeapFromPayload
GetHeapFromPayload returned the page header address instead of the
value of the first field of the header.

Bug: chromium:1056170
Change-Id: I4de5be975accced32460d6fab91543e6a5b07ba0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2143825
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67079}
2020-04-09 10:10:23 +00:00

26 lines
678 B
C++

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
#define INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
#include "include/cppgc/internal/api-constants.h"
namespace cppgc {
class Heap;
namespace internal {
inline cppgc::Heap* GetHeapFromPayload(const void* payload) {
return *reinterpret_cast<cppgc::Heap**>(
(reinterpret_cast<uintptr_t>(payload) & api_constants::kPageBaseMask) +
api_constants::kHeapOffset);
}
} // namespace internal
} // namespace cppgc
#endif // INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_