Move allocation of fields and methods to heap
Also make Object and subclasses constructors private to prevent
accidental non-heap allocation.
Change-Id: If9513967ba012748eb0d54c04e92df0f0944d385
diff --git a/src/heap.h b/src/heap.h
index 7c679eb..b9f7937 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -26,6 +26,24 @@
return klass;
}
+ static StaticField* AllocStaticField() {
+ size_t size = sizeof(StaticField);
+ byte* raw = new byte[size]();
+ return reinterpret_cast<StaticField*>(raw);
+ }
+
+ static InstanceField* AllocInstanceField() {
+ size_t size = sizeof(InstanceField);
+ byte* raw = new byte[size]();
+ return reinterpret_cast<InstanceField*>(raw);
+ }
+
+ static Method* AllocMethod() {
+ size_t size = sizeof(Method);
+ byte* raw = new byte[size]();
+ return reinterpret_cast<Method*>(raw);
+ }
+
static CharArray* AllocCharArray(size_t length) {
size_t size = sizeof(Array) + length * sizeof(uint16_t);
byte* raw = new byte[size]();