83a70ddf8b
* Use type_layout to declaratively express heap object headers in both
custom allocator and ObjectFactory.
* Invoke constructor (w/o invoking Kotin constructors) for created
objects and arrays from both custom allocator and ObjectFactory.
Previously:
- custom allocator only checked body for nullability (now this is
performed in body constructor)
- ObjectFactory only constructed ObjectData
* In each GC have a AllocatorImpl.hpp and ObjectData.hpp headers
the first encapsulating allocator-specific types, the second
containing specific ObjectData implementation.
* In each GC have a separate ObjectFactoryTraits that does not
actually depend on the specific GC anymore.
* Each GC now expose ObjectData (as undefined type) and its descriptor,
the latter being used by the custom allocator and ObjectFactory.
* Descriptors for ObjectBody and ArrayBody now live in Memory.h and the
code calculating size is now shared. Their constructors check that the
memory is zeroed (Kotlin constructors will expect this).
53 lines
1001 B
C++
53 lines
1001 B
C++
/*
|
|
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
* that can be found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef RUNTIME_GC_NOOP_NOOP_GC_H
|
|
#define RUNTIME_GC_NOOP_NOOP_GC_H
|
|
|
|
#include <cstddef>
|
|
|
|
#include "AllocatorImpl.hpp"
|
|
#include "GC.hpp"
|
|
#include "Logging.hpp"
|
|
#include "Utils.hpp"
|
|
|
|
namespace kotlin {
|
|
|
|
namespace mm {
|
|
class ThreadData;
|
|
}
|
|
|
|
namespace gc {
|
|
|
|
// No-op GC is a GC that does not free memory.
|
|
// TODO: It can be made more efficient.
|
|
class NoOpGC : private Pinned {
|
|
public:
|
|
class ThreadData : private Pinned {
|
|
public:
|
|
ThreadData() noexcept {}
|
|
~ThreadData() = default;
|
|
|
|
private:
|
|
};
|
|
|
|
NoOpGC() noexcept { RuntimeLogInfo({kTagGC}, "No-op GC initialized"); }
|
|
~NoOpGC() = default;
|
|
|
|
#ifdef CUSTOM_ALLOCATOR
|
|
alloc::Heap& heap() noexcept { return heap_; }
|
|
#endif
|
|
|
|
private:
|
|
#ifdef CUSTOM_ALLOCATOR
|
|
alloc::Heap heap_;
|
|
#endif
|
|
};
|
|
|
|
} // namespace gc
|
|
} // namespace kotlin
|
|
|
|
#endif // RUNTIME_GC_NOOP_NOOP_GC_H
|