Permalink
Browse files

Revert D6937119: Introduce HeaderKind::Cpp for gc-aware C++ objects, …

…use in make_raw

Summary:
This reverts commit d6e4ab48fea9e40e580c829ce9e2a598c63eb9f2

bypass-lint

An infra SEV is better than not reverting this diff.
If you copy this password, see you in SEV Review!
cause_a_sev_many_files

Differential Revision:
D6937119

Original commit changeset: d6e4ab48fea9

fbshipit-source-id: 76912c2ea395d8c693a1a26ddd4531b03609cc40
  • Loading branch information...
fredemmott authored and hhvm-bot committed Feb 11, 2018
1 parent e72f97e commit fb9f5a2cba0bb59a5026e864e2f3e655a560f2d7
@@ -61,7 +61,6 @@ enum class HeaderKind : uint8_t {
AsyncFuncFrame, // NativeNode followed by Frame, Resumable, AFWH
NativeData, // a NativeData header preceding an HNI ObjectData
ClosureHdr, // a ClosureHdr preceding a Closure ObjectData
Cpp, // a managed object with associated C++ type
SmallMalloc, // small req::malloc'd block
BigMalloc, // big req::malloc'd block
BigObj, // big size-tracked object (valid header follows MallocNode)
@@ -154,8 +153,7 @@ enum class GCBits : uint8_t {};
* [ ar_off | kind | marks | ] AsyncFuncFrame (NativeNode)
* [ ar_off | kind | marks | tyindex:16 ] NativeData (NativeNode)
* [ size | kind | marks | ] ClosureHeader (ClosureHdr)
* [ | kind | marks | tyindex:16 ] Cpp, SmallMalloc (MallocNode)
* [ index | kind | marks | tyindex:16 ] BigMalloc (MallocNode)
* [ index | kind | marks | tyindex:16 ] Small/BigMalloc (MallocNode)
* [ index | kind | marks | kIndexUnkown ] BigObj (MallocNode)
* [ size | kind | marks | ] Free, Hole (FreeNode)
* [ | kind | | ] Slab
@@ -168,7 +168,6 @@ DEBUG_ONLY bool checkEnqueuedKind(const HeapObject* h) {
case HeaderKind::VecArray:
case HeaderKind::Keyset:
case HeaderKind::Empty:
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc:
case HeaderKind::BigMalloc:
case HeaderKind::String:
@@ -79,7 +79,6 @@ DEBUG_ONLY std::string describe(const HeapGraph& g, int n) {
out << "[" << getContainerSize(make_tv<KindOfObject>(obj)) << "]";
break;
}
case HeaderKind::Cpp:
case HeaderKind::BigMalloc:
case HeaderKind::SmallMalloc:
out << "[" << static_cast<const MallocNode*>(h)->nbytes << "]";
@@ -16,39 +16,36 @@
#ifndef HPHP_HEAP_SCAN_H
#define HPHP_HEAP_SCAN_H
#include "hphp/runtime/base/apc-local-array.h"
#include "hphp/runtime/base/apc-local-array-defs.h"
#include "hphp/runtime/base/string-data.h"
#include "hphp/runtime/base/array-data.h"
#include "hphp/runtime/base/heap-graph.h"
#include "hphp/runtime/base/memory-manager.h"
#include "hphp/runtime/base/mixed-array.h"
#include "hphp/runtime/base/mixed-array-defs.h"
#include "hphp/runtime/base/object-data.h"
#include "hphp/runtime/base/resource-data.h"
#include "hphp/runtime/base/ref-data.h"
#include "hphp/runtime/base/packed-array.h"
#include "hphp/runtime/base/packed-array-defs.h"
#include "hphp/runtime/base/mixed-array.h"
#include "hphp/runtime/base/mixed-array-defs.h"
#include "hphp/runtime/base/apc-local-array.h"
#include "hphp/runtime/base/apc-local-array-defs.h"
#include "hphp/runtime/base/thread-info.h"
#include "hphp/runtime/base/rds-header.h"
#include "hphp/runtime/base/ref-data.h"
#include "hphp/runtime/base/memory-manager.h"
#include "hphp/runtime/base/req-root.h"
#include "hphp/runtime/base/resource-data.h"
#include "hphp/runtime/base/string-data.h"
#include "hphp/runtime/base/thread-info.h"
#include "hphp/runtime/ext/asio/asio-external-thread-event-queue.h"
#include "hphp/runtime/ext/asio/ext_async-function-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_async-generator.h"
#include "hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_reschedule-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_resumable-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_sleep-wait-handle.h"
#include "hphp/runtime/ext/extension-registry.h"
#include "hphp/runtime/ext/generator/ext_generator.h"
#include "hphp/runtime/server/server-note.h"
#include "hphp/runtime/base/heap-graph.h"
#include "hphp/runtime/vm/globals-array.h"
#include "hphp/runtime/vm/named-entity.h"
#include "hphp/runtime/vm/named-entity-defs.h"
#include "hphp/runtime/vm/runtime.h"
#include "hphp/runtime/ext/extension-registry.h"
#include "hphp/runtime/server/server-note.h"
#include "hphp/runtime/ext/asio/ext_sleep-wait-handle.h"
#include "hphp/runtime/ext/asio/asio-external-thread-event-queue.h"
#include "hphp/runtime/ext/asio/ext_reschedule-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_resumable-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_async-function-wait-handle.h"
#include "hphp/runtime/ext/asio/ext_async-generator.h"
#include "hphp/runtime/ext/generator/ext_generator.h"
#include "hphp/util/hphp-config.h"
@@ -148,7 +145,6 @@ inline void scanHeapObject(const HeapObject* h, type_scan::Scanner& scanner) {
case HeaderKind::Ref:
scanner.scan(*static_cast<const RefData*>(h)->tv());
return;
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc:
case HeaderKind::BigMalloc: {
auto n = static_cast<const MallocNode*>(h);
@@ -18,11 +18,10 @@
#define incl_HPHP_MEMORY_MANAGER_DEFS_H
#include "hphp/runtime/base/apc-local-array.h"
#include "hphp/runtime/base/apc-local-array-defs.h"
#include "hphp/runtime/base/mixed-array-defs.h"
#include "hphp/runtime/base/packed-array-defs.h"
#include "hphp/runtime/base/set-array.h"
#include "hphp/runtime/base/apc-local-array-defs.h"
#include "hphp/runtime/vm/globals-array.h"
#include "hphp/runtime/vm/native-data.h"
#include "hphp/runtime/vm/resumable.h"
@@ -270,7 +269,6 @@ inline size_t allocSize(const HeapObject* h) {
0, /* AsyncFuncFrame */
0, /* NativeData */
0, /* ClosureHdr */
0, /* Cpp */
0, /* SmallMalloc */
0, /* BigMalloc */
0, /* BigObj */
@@ -311,7 +309,6 @@ inline size_t allocSize(const HeapObject* h) {
CHECKSIZE(AsyncFuncFrame)
CHECKSIZE(NativeData)
CHECKSIZE(ClosureHdr)
CHECKSIZE(Cpp)
CHECKSIZE(SmallMalloc)
CHECKSIZE(BigMalloc)
CHECKSIZE(BigObj)
@@ -382,7 +379,6 @@ inline size_t allocSize(const HeapObject* h) {
// [ResourceHdr][ResourceData subclass]
size = static_cast<const ResourceHdr*>(h)->heapSize();
break;
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc: // [MallocNode][bytes...]
// size = h->nbytes // 64-bit
size = static_cast<const MallocNode*>(h)->nbytes;
@@ -401,28 +401,6 @@ inline StringDataNode& MemoryManager::getStringList() {
///////////////////////////////////////////////////////////////////////////////
namespace req {
template<class T, class... Args> T* make_raw(Args&&... args) {
static_assert(alignof(T) <= std::min(sizeof(MallocNode),kSmallSizeAlign),"");
auto constexpr size = sizeof(MallocNode) + sizeof(T);
auto n = static_cast<MallocNode*>(tl_heap->objMalloc(size));
n->initHeader_32_16(HeaderKind::Cpp, size,
type_scan::getIndexForMalloc<T>());
n->nbytes = size;
try {
return new (n + 1) T(std::forward<Args>(args)...);
} catch (...) {
tl_heap->objFree(n, size);
throw;
}
}
template<class T> void destroy_raw(T* t) {
t->~T();
auto n = reinterpret_cast<MallocNode*>(t) - 1;
tl_heap->objFree(n, n->nbytes);
}
}
}
#endif
@@ -555,7 +555,6 @@ void MemoryManager::checkHeap(const char* phase) {
case HeaderKind::AsyncFuncFrame:
case HeaderKind::NativeData:
case HeaderKind::ClosureHdr:
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc:
case HeaderKind::BigMalloc:
break;
@@ -993,9 +992,6 @@ void free(void* ptr) {
if (LIKELY(n->kind() == HeaderKind::SmallMalloc)) {
return tl_heap->freeSmallSize(n, n->nbytes);
}
if (n->kind() == HeaderKind::Cpp) {
return tl_heap->objFree(n, n->nbytes);
}
assert(n->kind() == HeaderKind::BigMalloc);
tl_heap->freeBigSize(ptr);
}
@@ -327,7 +327,6 @@ bool record_request_heap_mem_event(const void* addr,
case HeaderKind::ClosureHdr:
break;
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc:
case HeaderKind::BigMalloc:
case HeaderKind::BigObj:
@@ -204,6 +204,21 @@ using ConservativeAllocator = Allocator<T, type_scan::Action::Conservative<T>>;
/////////////////////////////////////////////////////////////////////
template<class T, class... Args> T* make_raw(Args&&... args) {
auto const mem = req::malloc(sizeof(T), type_scan::getIndexForMalloc<T>());
try {
return new (mem) T(std::forward<Args>(args)...);
} catch (...) {
req::free(mem);
throw;
}
}
template<class T> void destroy_raw(T* t) {
t->~T();
req::free(t);
}
template<class T> T* make_raw_array(size_t count) {
T* ret = static_cast<T*>(
req::malloc(count * sizeof(T), type_scan::getIndexForMalloc<T>())
@@ -298,7 +298,6 @@ CapturedPtr getEdgeInfo(const HeapGraph& g, int ptr) {
case HeaderKind::String:
case HeaderKind::Resource:
case HeaderKind::BigMalloc:
case HeaderKind::Cpp:
case HeaderKind::SmallMalloc:
case HeaderKind::Free:
case HeaderKind::BigObj:

0 comments on commit fb9f5a2

Please sign in to comment.