Commit d9619f27 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

let coro malloc/free use wrappers

Summary: The coroutine library has non-elidable wrappers for alloc/dealloc. They directly call `operator new` and `operator delete` but, of course, they have conditionals. Switch to the wrappers which handle the conditionals.

Reviewed By: luciang

Differential Revision: D33181403

fbshipit-source-id: ab8d56634569b82680b36d6b72fb9ff7f5c05f19
parent bc278815
...@@ -17,14 +17,13 @@ ...@@ -17,14 +17,13 @@
#include <folly/experimental/coro/detail/Malloc.h> #include <folly/experimental/coro/detail/Malloc.h>
#include <folly/BenchmarkUtil.h> #include <folly/BenchmarkUtil.h>
#include <folly/lang/New.h>
#include <new>
extern "C" { extern "C" {
FOLLY_NOINLINE FOLLY_NOINLINE
void* folly_coro_async_malloc(std::size_t size) { void* folly_coro_async_malloc(std::size_t size) {
void* p = ::operator new(size); auto p = folly::operator_new(size);
// Add this after the call to prevent the compiler from // Add this after the call to prevent the compiler from
// turning the call to operator new() into a tailcall. // turning the call to operator new() into a tailcall.
...@@ -35,13 +34,7 @@ void* folly_coro_async_malloc(std::size_t size) { ...@@ -35,13 +34,7 @@ void* folly_coro_async_malloc(std::size_t size) {
FOLLY_NOINLINE FOLLY_NOINLINE
void folly_coro_async_free(void* ptr, std::size_t size) { void folly_coro_async_free(void* ptr, std::size_t size) {
#if __cpp_sized_deallocation >= 201309 folly::operator_delete(ptr, size);
::operator delete(ptr, size);
#else
// sized delete is not available on iOS before 10.0
(void)size;
::operator delete(ptr);
#endif
// Add this after the call to prevent the compiler from // Add this after the call to prevent the compiler from
// turning the call to operator delete() into a tailcall. // turning the call to operator delete() into a tailcall.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment