GBC Expander. Removed lir.
Change-Id: If8d13e36f1e6d82c2a7f7bfec62b8fb41fd8cdaa
diff --git a/src/greenland/runtime/runtime_utils.h b/src/greenland/runtime/runtime_utils.h
new file mode 100644
index 0000000..cbdfcc6
--- /dev/null
+++ b/src/greenland/runtime/runtime_utils.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_GREENLAND_RUNTIME_UTILS_H_
+#define ART_SRC_GREENLAND_RUNTIME_UTILS_H_
+
+#include "asm_support.h"
+#include "thread.h"
+
+namespace art {
+namespace greenland {
+
+static inline Thread* art_get_current_thread() {
+#if defined(__i386__)
+ Thread* ptr;
+ __asm__ __volatile__("movl %%fs:(%1), %0"
+ : "=r"(ptr) // output
+ : "r"(THREAD_SELF_OFFSET) // input
+ :); // clobber
+ return ptr;
+#else
+ return Thread::Current();
+#endif
+}
+
+} // namespace greenland
+} // namespace art
+
+#endif // ART_SRC_GREENLAND_RUNTIME_UTILS_H_
diff --git a/src/greenland/runtime/support_alloc.cc b/src/greenland/runtime/support_alloc.cc
new file mode 100644
index 0000000..5198903
--- /dev/null
+++ b/src/greenland/runtime/support_alloc.cc
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "runtime_utils.h"
+#include "runtime_support.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+Object* art_alloc_array_from_code(uint32_t type_idx,
+ Method* referrer,
+ uint32_t length,
+ Thread* thread) {
+ return AllocArrayFromCode(type_idx, referrer, length, thread, false);
+}
+
+Object* art_alloc_array_from_code_with_access_check(uint32_t type_idx,
+ Method* referrer,
+ uint32_t length,
+ Thread* thread) {
+ return AllocArrayFromCode(type_idx, referrer, length, thread, true);
+}
+
+Object* art_check_and_alloc_array_from_code(uint32_t type_idx,
+ Method* referrer,
+ uint32_t length,
+ Thread* thread) {
+ return CheckAndAllocArrayFromCode(type_idx, referrer, length, thread, false);
+}
+
+Object* art_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx,
+ Method* referrer,
+ uint32_t length,
+ Thread* thread) {
+ return CheckAndAllocArrayFromCode(type_idx, referrer, length, thread, true);
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitAllocRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->AllocArray = art_alloc_array_from_code;
+ entry_points->AllocArrayWithAccessCheck = art_alloc_array_from_code_with_access_check;
+ entry_points->CheckAndAllocArray = art_check_and_alloc_array_from_code;
+ entry_points->CheckAndAllocArrayWithAccessCheck = art_check_and_alloc_array_from_code_with_access_check;
+ return;
+}
+
+} // namespace greenland
+} // namespace art
diff --git a/src/greenland/runtime/support_cast.cc b/src/greenland/runtime/support_cast.cc
new file mode 100644
index 0000000..d74dbe7
--- /dev/null
+++ b/src/greenland/runtime/support_cast.cc
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "runtime_utils.h"
+#include "runtime_support.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+void art_check_put_array_element_from_code(const Object* element,
+ const Object* array) {
+ if (element == NULL) {
+ return;
+ }
+ DCHECK(array != NULL);
+ Class* array_class = array->GetClass();
+ DCHECK(array_class != NULL);
+ Class* component_type = array_class->GetComponentType();
+ Class* element_class = element->GetClass();
+ if (UNLIKELY(!component_type->IsAssignableFrom(element_class))) {
+ Thread* thread = art_get_current_thread();
+ thread->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
+ "%s cannot be stored in an array of type %s",
+ PrettyDescriptor(element_class).c_str(),
+ PrettyDescriptor(array_class).c_str());
+ }
+ return;
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitCastRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->CheckPutArrayElement = art_check_put_array_element_from_code;
+}
+
+} // namespace greenland
+} // namespace art
diff --git a/src/greenland/runtime/support_dexcache.cc b/src/greenland/runtime/support_dexcache.cc
new file mode 100644
index 0000000..903e5cc
--- /dev/null
+++ b/src/greenland/runtime/support_dexcache.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "runtime_utils.h"
+#include "runtime_support.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+Object* art_resolve_string(Method* referrer, uint32_t string_idx) {
+ return ResolveStringFromCode(referrer, string_idx);
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitDexCacheRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->ResolveString = art_resolve_string;
+}
+
+} // namespace greenland
+} // namespace art
diff --git a/src/greenland/runtime/support_exception.cc b/src/greenland/runtime/support_exception.cc
new file mode 100644
index 0000000..2470051
--- /dev/null
+++ b/src/greenland/runtime/support_exception.cc
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "nth_caller_visitor.h"
+#include "runtime_utils.h"
+#include "runtime_support.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+int32_t art_find_catch_block(Method* current_method, uint32_t ti_offset) {
+ Thread* thread = art_get_current_thread();
+ Class* exception_type = thread->GetException()->GetClass();
+ MethodHelper mh(current_method);
+ const DexFile::CodeItem* code_item = mh.GetCodeItem();
+ DCHECK_LT(ti_offset, code_item->tries_size_);
+ const DexFile::TryItem* try_item = DexFile::GetTryItems(*code_item, ti_offset);
+
+ int iter_index = 0;
+ // Iterate over the catch handlers associated with dex_pc
+ for (CatchHandlerIterator it(*code_item, *try_item); it.HasNext(); it.Next()) {
+ uint16_t iter_type_idx = it.GetHandlerTypeIndex();
+ // Catch all case
+ if (iter_type_idx == DexFile::kDexNoIndex16) {
+ return iter_index;
+ }
+ // Does this catch exception type apply?
+ Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx);
+ if (iter_exception_type == NULL) {
+ // The verifier should take care of resolving all exception classes early
+ LOG(WARNING) << "Unresolved exception class when finding catch block: "
+ << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx);
+ } else if (iter_exception_type->IsAssignableFrom(exception_type)) {
+ return iter_index;
+ }
+ ++iter_index;
+ }
+ // Handler not found
+ return -1;
+}
+
+void art_throw_array_bounds(int32_t length, int32_t index) {
+ Thread* thread = art_get_current_thread();
+ thread->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
+ "length=%d; index=%d", length, index);
+}
+
+void art_throw_null_pointer_exception(uint32_t dex_pc) {
+ Thread* thread = art_get_current_thread();
+ NthCallerVisitor visitor(0);
+ thread->WalkStack(&visitor);
+ Method* throw_method = visitor.caller;
+ ThrowNullPointerExceptionFromDexPC(thread, throw_method, dex_pc);
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitExceptionRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->FindCatchBlock = art_find_catch_block;
+ entry_points->ThrowIndexOutOfBounds = art_throw_array_bounds;
+ entry_points->ThrowNullPointerException = art_throw_null_pointer_exception;
+}
+
+} // namespace greenland
+} // namespace art
diff --git a/src/greenland/runtime/support_field.cc b/src/greenland/runtime/support_field.cc
new file mode 100644
index 0000000..523740f
--- /dev/null
+++ b/src/greenland/runtime/support_field.cc
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "runtime_utils.h"
+#include "runtime_support.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+Object* art_get_obj_static_from_code(uint32_t field_idx, Method* referrer) {
+ Field* field = FindFieldFast(field_idx, referrer, false, false, sizeof(Object*));
+ if (LIKELY(field != NULL)) {
+ return field->GetObj(NULL);
+ }
+ field = FindFieldFromCode(field_idx, referrer, art_get_current_thread(),
+ true, false, false, sizeof(Object*));
+ if (LIKELY(field != NULL)) {
+ return field->GetObj(NULL);
+ }
+ return 0;
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitFieldRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->GetObjectStatic = art_get_obj_static_from_code;
+}
+
+} // namespace greenland
+} // namespace art
diff --git a/src/greenland/runtime/support_thread.cc b/src/greenland/runtime/support_thread.cc
new file mode 100644
index 0000000..25fb698
--- /dev/null
+++ b/src/greenland/runtime/support_thread.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "greenland/runtime_entry_points.h"
+
+#include "runtime_utils.h"
+#include "runtime_support.h"
+#include "thread_list.h"
+
+using namespace art;
+using namespace art::greenland;
+
+namespace {
+
+void art_test_suspend(Thread* thread) {
+ Runtime::Current()->GetThreadList()->FullSuspendCheck(thread);
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace greenland {
+
+void InitThreadRuntimes(RuntimeEntryPoints* entry_points) {
+ entry_points->TestSuspend = art_test_suspend;
+}
+
+} // namespace greenland
+} // namespace art