More MIPS fixes. The vm-tests and oat tests all work on the emulator.
- Changed the base address of the art image for MIPS to allow enough
space for CTS to run on the target.
- Fixed exception delivery to jump without linking, and to preserve the
value of $gp.
- Added dumping of /proc/self/maps whenever mmap fails, and cleaned up
other debugging output (not MIPS related).
Change-Id: I4e92e992ee6a6167e901db8ad90a6062bbc5168a
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 0d31237..193afbf 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -78,11 +78,20 @@
-DDYNAMIC_ANNOTATIONS_ENABLED=1 \
-UNDEBUG
-ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1
+# start of image reserved address space
+IMG_HOST_BASE_ADDRESS := 0x60000000
+
+ifeq ($(TARGET_ARCH),mips)
+IMG_TARGET_BASE_ADDRESS := 0x30000000
+else
+IMG_TARGET_BASE_ADDRESS := 0x60000000
+endif
+
+ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(IMG_HOST_BASE_ADDRESS)
# The host GCC isn't necessarily new enough to support -Wthread-safety (GCC 4.4).
ART_HOST_CFLAGS := $(filter-out -Wthread-safety,$(ART_HOST_CFLAGS))
-ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET
+ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(IMG_TARGET_BASE_ADDRESS)
ifeq ($(TARGET_CPU_SMP),true)
ART_TARGET_CFLAGS += -DANDROID_SMP=1
else
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index cdb7349..7868204 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -27,10 +27,6 @@
# TODO: for now, override with debug version for better error reporting
OATDUMP := $(OATDUMPD)
-# start of image reserved address space
-IMG_HOST_BASE_ADDRESS := 0x60000000
-IMG_TARGET_BASE_ADDRESS := 0x60000000
-
PRELOADED_CLASSES := frameworks/base/preloaded-classes
########################################################################
diff --git a/src/gc/atomic_stack.h b/src/gc/atomic_stack.h
index 3494861..d67d2f2 100644
--- a/src/gc/atomic_stack.h
+++ b/src/gc/atomic_stack.h
@@ -136,11 +136,7 @@
// Size in number of elements.
void Init() {
mem_map_.reset(MemMap::MapAnonymous(name_.c_str(), NULL, capacity_ * sizeof(T), PROT_READ | PROT_WRITE));
- if (mem_map_.get() == NULL) {
- std::string maps;
- ReadFileToString("/proc/self/maps", &maps);
- LOG(FATAL) << "couldn't allocate mark stack\n" << maps;
- }
+ CHECK(mem_map_.get() != NULL) << "couldn't allocate mark stack";
byte* addr = mem_map_->Begin();
CHECK(addr != NULL);
begin_ = reinterpret_cast<T*>(addr);
diff --git a/src/gc/card_table.cc b/src/gc/card_table.cc
index 5a1e9b5..a5531d8 100644
--- a/src/gc/card_table.cc
+++ b/src/gc/card_table.cc
@@ -54,11 +54,7 @@
/* Allocate an extra 256 bytes to allow fixed low-byte of base */
UniquePtr<MemMap> mem_map(MemMap::MapAnonymous("dalvik-card-table", NULL,
capacity + 256, PROT_READ | PROT_WRITE));
- if (mem_map.get() == NULL) {
- std::string maps;
- ReadFileToString("/proc/self/maps", &maps);
- LOG(FATAL) << "couldn't allocate card table\n" << maps;
- }
+ CHECK(mem_map.get() != NULL) << "couldn't allocate card table";
// All zeros is the correct initial value; all clean. Anonymous mmaps are initialized to zero, we
// don't clear the card table to avoid unnecessary pages being allocated
COMPILE_ASSERT(kCardClean == 0, card_clean_must_be_0);
diff --git a/src/heap.cc b/src/heap.cc
index 33f8366..2ed467f 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -87,7 +87,8 @@
const char* oat_file_option = oat_file_option_string.c_str();
arg_vector.push_back(strdup(oat_file_option));
- arg_vector.push_back(strdup("--base=0x60000000"));
+ std::string base_option_string(StringPrintf("--base=0x%x", ART_BASE_ADDRESS));
+ arg_vector.push_back(strdup(base_option_string.c_str()));
std::string command_line(Join(arg_vector, ' '));
LOG(INFO) << command_line;
@@ -233,8 +234,8 @@
growth_limit, capacity,
requested_begin));
alloc_space_ = alloc_space.release();
- alloc_space_->SetFootprintLimit(alloc_space_->Capacity());
CHECK(alloc_space_ != NULL) << "Failed to create alloc space";
+ alloc_space_->SetFootprintLimit(alloc_space_->Capacity());
AddSpace(alloc_space_);
// Spaces are sorted in order of Begin().
diff --git a/src/image_test.cc b/src/image_test.cc
index b72226b..feb490c 100644
--- a/src/image_test.cc
+++ b/src/image_test.cc
@@ -48,13 +48,15 @@
}
}
- ImageWriter writer(NULL);
ScratchFile tmp_image;
- const uintptr_t requested_image_base = 0x60000000;
- bool success_image = writer.Write(tmp_image.GetFilename(), requested_image_base,
- tmp_oat.GetFilename(), tmp_oat.GetFilename(),
- *compiler_.get());
- ASSERT_TRUE(success_image);
+ const uintptr_t requested_image_base = ART_BASE_ADDRESS;
+ {
+ ImageWriter writer(NULL);
+ bool success_image = writer.Write(tmp_image.GetFilename(), requested_image_base,
+ tmp_oat.GetFilename(), tmp_oat.GetFilename(),
+ *compiler_.get());
+ ASSERT_TRUE(success_image);
+ }
{
UniquePtr<File> file(OS::OpenFile(tmp_image.GetFilename().c_str(), false));
diff --git a/src/mem_map.cc b/src/mem_map.cc
index 653eb3f..f322773 100644
--- a/src/mem_map.cc
+++ b/src/mem_map.cc
@@ -87,8 +87,11 @@
byte* actual = reinterpret_cast<byte*>(mmap(addr, page_aligned_byte_count, prot, flags, fd.get(), 0));
if (actual == MAP_FAILED) {
+ std::string maps;
+ ReadFileToString("/proc/self/maps", &maps);
PLOG(ERROR) << "mmap(" << reinterpret_cast<void*>(addr) << ", " << page_aligned_byte_count
- << ", " << prot << ", " << flags << ", " << fd.get() << ", 0) failed for " << name;
+ << ", " << prot << ", " << flags << ", " << fd.get() << ", 0) failed for " << name
+ << "\n" << maps;
return NULL;
}
return new MemMap(name, actual, byte_count, actual, page_aligned_byte_count, prot);
@@ -110,7 +113,11 @@
fd,
page_aligned_offset));
if (actual == MAP_FAILED) {
- PLOG(ERROR) << "mmap failed";
+ std::string maps;
+ ReadFileToString("/proc/self/maps", &maps);
+ PLOG(ERROR) << "mmap(" << reinterpret_cast<void*>(addr) << ", " << page_aligned_byte_count
+ << ", " << prot << ", " << flags << ", " << fd << ", " << page_aligned_offset
+ << ") failed\n" << maps;
return NULL;
}
return new MemMap("file", actual + page_offset, byte_count, actual, page_aligned_byte_count,
diff --git a/src/oat/runtime/mips/runtime_support_mips.S b/src/oat/runtime/mips/runtime_support_mips.S
index 349e802..bc0aecf 100644
--- a/src/oat/runtime/mips/runtime_support_mips.S
+++ b/src/oat/runtime/mips/runtime_support_mips.S
@@ -22,7 +22,7 @@
/* Deliver the given exception */
.extern artDeliverExceptionFromCode
/* Deliver an exception pending on a thread */
- .extern artDeliverPendingException
+ .extern artDeliverPendingExceptionFromCode
/* Cache alignment for function entry */
.macro ALIGN_FUNCTION_ENTRY
@@ -115,16 +115,17 @@
* exception is Thread::Current()->exception_
*/
.macro DELIVER_PENDING_EXCEPTION
- SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
- move $a0, rSELF # pass Thread::Current
- jal artDeliverPendingExceptionFromCode # artDeliverPendingExceptionFromCode(Thread*, $sp)
- move $a1, $sp # pass $sp
+ SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
+ move $a0, rSELF # pass Thread::Current
+ la $t9, artDeliverPendingExceptionFromCode
+ jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
+ move $a1, $sp # pass $sp
.endm
.macro RETURN_IF_NO_EXCEPTION
lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
- bnez $t0, 1f # success if no exception is pending
+ bnez $t0, 1f # success if no exception is pending
nop
jr $ra
nop
@@ -254,9 +255,10 @@
art_deliver_exception_from_code:
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
- move $a1, rSELF # pass Thread::Current
- jal artDeliverExceptionFromCode # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
- move $a2, $sp # pass $sp
+ move $a1, rSELF # pass Thread::Current
+ la $t9, artDeliverExceptionFromCode
+ jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
+ move $a2, $sp # pass $sp
.global art_throw_null_pointer_exception_from_code
.extern artThrowNullPointerExceptionFromCode
@@ -267,9 +269,10 @@
art_throw_null_pointer_exception_from_code:
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
- move $a0, rSELF # pass Thread::Current
- jal artThrowNullPointerExceptionFromCode # artThrowNullPointerExceptionFromCode(Thread*, $sp)
- move $a1, $sp # pass $sp
+ move $a0, rSELF # pass Thread::Current
+ la $t9, artThrowNullPointerExceptionFromCode
+ jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
+ move $a1, $sp # pass $sp
.global art_throw_div_zero_from_code
.extern artThrowDivZeroFromCode
@@ -281,7 +284,8 @@
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
move $a0, rSELF # pass Thread::Current
- jal artThrowDivZeroFromCode # artThrowDivZeroFromCode(Thread*, $sp)
+ la $t9, artThrowDivZeroFromCode
+ jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
move $a1, $sp # pass $sp
.global art_throw_array_bounds_from_code
@@ -293,9 +297,10 @@
art_throw_array_bounds_from_code:
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
- move $a2, rSELF # pass Thread::Current
- jal artThrowArrayBoundsFromCode # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
- move $a3, $sp # pass $sp
+ move $a2, rSELF # pass Thread::Current
+ la $t9, artThrowArrayBoundsFromCode
+ jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
+ move $a3, $sp # pass $sp
.global art_throw_stack_overflow_from_code
.extern artThrowStackOverflowFromCode
@@ -306,9 +311,10 @@
art_throw_stack_overflow_from_code:
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
- move $a0, rSELF # pass Thread::Current
- jal artThrowStackOverflowFromCode # artThrowStackOverflowFromCode(Thread*, $sp)
- move $a1, $sp # pass $sp
+ move $a0, rSELF # pass Thread::Current
+ la $t9, artThrowStackOverflowFromCode
+ jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
+ move $a1, $sp # pass $sp
.global art_throw_no_such_method_from_code
.extern artThrowNoSuchMethodFromCode
@@ -319,9 +325,10 @@
art_throw_no_such_method_from_code:
.cpload $25
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
- move $a1, rSELF # pass Thread::Current
- jal artThrowNoSuchMethodFromCode # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
- move $a2, $sp # pass $sp
+ move $a1, rSELF # pass Thread::Current
+ la $t9, artThrowNoSuchMethodFromCode
+ jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
+ move $a2, $sp # pass $sp
/*
* All generated callsites for interface invokes and invocation slow paths will load arguments
@@ -349,8 +356,10 @@
move $t0, $sp # save $sp
addiu $sp, $sp, -16 # make space for extra args
move $a3, rSELF # pass Thread::Current
+ sw $gp, 12($sp) # save $gp
jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
sw $t0, 16($sp) # pass $sp
+ lw $gp, 12($sp) # restore $gp
addiu $sp, $sp, 16 # release out args
move $a0, $v0 # save target Method*
move $t9, $v1 # save $v0->code_
@@ -866,12 +875,12 @@
move $a2, $ra # pass $ra
jal artTraceMethodEntryFromCode # (Method*, Thread*, LR)
move $a1, rSELF # pass Thread::Current
- move $t0, $v0 # $t0 holds reference to code
+ move $t9, $v0 # $t9 holds reference to code
lw $a0, 0($sp)
lw $a1, 4($sp)
lw $a2, 8($sp)
lw $a3, 12($sp)
- jalr $t0 # call method
+ jalr $t9 # call method
addiu $sp, $sp, 16
/* intentional fallthrough */