Browse Source

重新启用 inline state 选项

3.0.0
tearshark 6 months ago
parent
commit
8e5b74b811

+ 3
- 3
CMakeLists.txt View File

@@ -52,11 +52,11 @@ endif()
if(${LIBRF_COMPILER_SETTING} STREQUAL "msvc")
option(LIBRF_INLINE_STATE "Enable Inline state" OFF)
option(LIBRF_INLINE_STATE "Enable Inline state" ON)
elseif ("${LIBRF_COMPILER_SETTING}" STREQUAL "clang_on_msvc")
option(LIBRF_INLINE_STATE "Enable Inline state" OFF)
option(LIBRF_INLINE_STATE "Enable Inline state" ON)
elseif(${LIBRF_COMPILER_SETTING} STREQUAL "clang")
option(LIBRF_INLINE_STATE "Enable Inline state" OFF)
option(LIBRF_INLINE_STATE "Enable Inline state" ON)
elseif(${LIBRF_COMPILER_SETTING} STREQUAL "gcc")
option(LIBRF_INLINE_STATE "Enable Inline state" OFF)
else()

+ 1
- 1
benchmark/benchmark_async_mem.cpp View File

@@ -37,7 +37,7 @@ void resumable_main_benchmark_mem(bool wait_key)
}
//clang : 平均 256 字节
//msvc : 平均 320 字节(vs2022,17.7.4)
//msvc : 平均 304 字节(vs2022,17.7.4)
#if LIBRF_TUTORIAL_STAND_ALONE
int main()

+ 2
- 2
include/librf/src/config.h View File

@@ -2,9 +2,9 @@

#ifndef RESUMEF_INLINE_STATE
#if defined(__clang__) || defined(_MSC_VER)
/* #undef RESUMEF_INLINE_STATE */
#define RESUMEF_INLINE_STATE 1
#else
/* #undef RESUMEF_INLINE_STATE */
#define RESUMEF_INLINE_STATE 0
#endif //defined(__clang__) || defined(_MSC_VER)
#endif //RESUMEF_INLINE_STATE


+ 2
- 1
include/librf/src/generator.h View File

@@ -186,7 +186,8 @@ namespace librf
char* ptr = reinterpret_cast<char*>(h.address()) - _State_size;
return reinterpret_cast<state_type*>(ptr);
#elif defined(_MSC_VER)
char* ptr = reinterpret_cast<char*>(this) - _State_size;
auto h = coroutine_handle<promise_type>::from_promise(*this);
char* ptr = reinterpret_cast<char*>(h.address()) - _State_size;
return reinterpret_cast<state_type*>(ptr);
#else
#error "Unknown compiler"

+ 4
- 1
include/librf/src/promise.inl View File

@@ -26,8 +26,11 @@ namespace librf
char* ptr = reinterpret_cast<char*>(h.address()) - _State_size;
return reinterpret_cast<state_type*>(ptr);
#elif defined(_MSC_VER)
char* ptr = reinterpret_cast<char*>(this) - _State_size;
auto h = coroutine_handle<promise_type>::from_promise(*reinterpret_cast<promise_type*>(this));
char* ptr = reinterpret_cast<char*>(h.address()) - _State_size;
return reinterpret_cast<state_type*>(ptr);
//char* ptr = reinterpret_cast<char*>(this) - _State_size;
//return reinterpret_cast<state_type*>(ptr);
#else
#error "Unknown compiler"
#endif

+ 3
- 3
tutorial/test_async_memory_layout.cpp View File

@@ -65,9 +65,9 @@ future_t<int64_t> resumeable_get_long(int64_t x, int64_t y)

std::cout << " frame ptr=" << frame_ptr << "," << (void*)&frame_ptr << std::endl;
std::cout << " frame end=" << (void*)((char*)(frame_ptr)+_coro_frame_size()) << std::endl;
std::cout << " promise ptr=" << promise << "," << (void*)&promise << std::endl;
std::cout << " handle ptr=" << handler.address() << "," << (void*)&handler << std::endl;
std::cout << " state ptr=" << state << "," << (void*)&state << std::endl;
std::cout << " promise ptr=" << promise << "," << (void*)&promise << ",offset=" << ((char*)promise - (char*)frame_ptr) << std::endl;
std::cout << " handle ptr=" << handler.address() << "," << (void*)&handler << ",offset=" << ((char*)handler.address() - (char*)frame_ptr) << std::endl;
std::cout << " state ptr=" << state << "," << (void*)&state << ",offset=" << ((char*)state - (char*)frame_ptr) << std::endl;
std::cout << " parent ptr=" << state->get_parent() << std::endl;

std::cout << " x=" << x << ", &x=" << std::addressof(x) << std::endl;

Loading…
Cancel
Save