Skip to content

Commit

Permalink
Revert D6937119: Introduce HeaderKind::Cpp for gc-aware C++ objects, …
Browse files Browse the repository at this point in the history
…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 fb9f5a2
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 62 deletions.
4 changes: 1 addition & 3 deletions hphp/runtime/base/header-kind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/base/heap-collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/base/heap-report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "]";
Expand Down
44 changes: 20 additions & 24 deletions hphp/runtime/base/heap-scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions hphp/runtime/base/memory-manager-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 0 additions & 22 deletions hphp/runtime/base/memory-manager-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions hphp/runtime/base/memory-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/base/perf-mem-event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions hphp/runtime/base/req-malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>())
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/ext/objprof/ext_heapgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fb9f5a2

Please sign in to comment.