Add HeapTest and make GC work enough to pass it
Change-Id: If06eaef2921b64b3226bfd347acaec60ec993e67
diff --git a/src/object.cc b/src/object.cc
index 66ea03f..e0544df 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -6,21 +6,16 @@
#include <algorithm>
#include "class_linker.h"
+#include "class_loader.h"
#include "globals.h"
#include "heap.h"
#include "logging.h"
#include "dex_cache.h"
#include "dex_file.h"
+#include "runtime.h"
namespace art {
-const std::vector<const DexFile*>& ClassLoader::GetClassPath(const ClassLoader* class_loader) {
- if (class_loader == NULL) {
- return Runtime::Current()->GetClassLinker()->GetBootClassPath();
- }
- return class_loader->class_path_;
-}
-
Array* Array::Alloc(Class* array_class, int32_t component_count, size_t component_size) {
DCHECK_GE(component_count, 0);
DCHECK(array_class->IsArrayClass());
@@ -50,7 +45,7 @@
return Array::Alloc(klass, component_count);
}
-Object* Class::NewInstanceFromCode(uint32_t type_idx, Method* method) {
+Object* Class::AllocObjectFromCode(uint32_t type_idx, Method* method) {
Class* klass = method->dex_cache_resolved_types_->Get(type_idx);
if (klass == NULL) {
klass = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, method);
@@ -59,7 +54,12 @@
return NULL;
}
}
- return klass->NewInstance();
+ return klass->AllocObject();
+}
+
+Object* Class::AllocObject() {
+ DCHECK(!IsAbstract());
+ return Heap::AllocObject(this, this->object_size_);
}
bool Class::Implements(const Class* klass) const {
@@ -675,26 +675,6 @@
java_lang_String_ = NULL;
}
-// TODO: get global references for these
-Class* PathClassLoader::dalvik_system_PathClassLoader_ = NULL;
-
-const PathClassLoader* PathClassLoader::Alloc(std::vector<const DexFile*> dex_files) {
- PathClassLoader* p = down_cast<PathClassLoader*>(dalvik_system_PathClassLoader_->NewInstance());
- p->SetClassPath(dex_files);
- return p;
-}
-
-void PathClassLoader::SetClass(Class* dalvik_system_PathClassLoader) {
- CHECK(dalvik_system_PathClassLoader_ == NULL);
- CHECK(dalvik_system_PathClassLoader != NULL);
- dalvik_system_PathClassLoader_ = dalvik_system_PathClassLoader;
-}
-
-void PathClassLoader::ResetClass() {
- CHECK(dalvik_system_PathClassLoader_ != NULL);
- dalvik_system_PathClassLoader_ = NULL;
-}
-
Class* StackTraceElement::java_lang_StackTraceElement_ = NULL;
void StackTraceElement::SetClass(Class* java_lang_StackTraceElement) {