WebAssembly effort (#721)

This commit is contained in:
Nikolay Igotti
2017-07-14 16:44:46 +03:00
committed by GitHub
parent 64e106157f
commit 06e31939dd
23 changed files with 340 additions and 35 deletions
+11 -1
View File
@@ -94,7 +94,7 @@ struct MemoryState {
namespace {
// TODO: can we pass this variable as an explicit argument?
__thread MemoryState* memoryState = nullptr;
THREAD_LOCAL_VARIABLE MemoryState* memoryState = nullptr;
inline bool isFreeable(const ContainerHeader* header) {
return (header->refCount_ & CONTAINER_TAG_MASK) < CONTAINER_TAG_PERMANENT;
@@ -649,6 +649,13 @@ OBJ_GETTER(InitInstance,
ObjHeader* object = AllocInstance(type_info, OBJ_RESULT);
UpdateRef(location, object);
#if KONAN_NO_EXCEPTIONS
ctor(object);
#if TRACE_MEMORY
memoryState->globalObjects->push_back(location);
#endif
return object;
#else
try {
ctor(object);
#if TRACE_MEMORY
@@ -660,6 +667,7 @@ OBJ_GETTER(InitInstance,
UpdateRef(location, nullptr);
throw;
}
#endif
}
void SetRef(ObjHeader** location, const ObjHeader* object) {
@@ -882,7 +890,9 @@ OBJ_GETTER(DerefStablePointer, KNativePtr pointer) {
}
OBJ_GETTER(AdoptStablePointer, KNativePtr pointer) {
#ifndef KONAN_NO_THREADS
__sync_synchronize();
#endif
KRef ref = reinterpret_cast<KRef>(pointer);
// Somewhat hacky.
*OBJ_RESULT = ref;