Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 3 | #include <dirent.h> |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 4 | #include <dlfcn.h> |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 5 | #include <sys/mman.h> |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 6 | #include <sys/stat.h> |
| 7 | #include <sys/types.h> |
| 8 | |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 9 | #include "UniquePtr.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 10 | #include "base64.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 11 | #include "class_linker.h" |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 12 | #include "class_loader.h" |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 13 | #include "compiler.h" |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 14 | #include "constants.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 15 | #include "dex_file.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 16 | #include "gtest/gtest.h" |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 17 | #include "heap.h" |
| 18 | #include "runtime.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 19 | #include "stringprintf.h" |
| 20 | #include "thread.h" |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 21 | #include "unicode/uclean.h" |
| 22 | #include "unicode/uvernum.h" |
| 23 | |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 24 | namespace art { |
| 25 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 26 | static inline const DexFile* OpenDexFileBase64(const char* base64, |
| 27 | const std::string& location) { |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 28 | CHECK(base64 != NULL); |
| 29 | size_t length; |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 30 | byte* dex_bytes = DecodeBase64(base64, &length); |
| 31 | CHECK(dex_bytes != NULL); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 32 | const DexFile* dex_file = DexFile::OpenPtr(dex_bytes, length, location); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 33 | CHECK(dex_file != NULL); |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 34 | return dex_file; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 37 | class ScratchFile { |
| 38 | public: |
| 39 | ScratchFile() { |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 40 | filename_ = getenv("ANDROID_DATA"); |
| 41 | filename_ += "/TmpFile-XXXXXX"; |
| 42 | fd_ = mkstemp(&filename_[0]); |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 43 | CHECK_NE(-1, fd_); |
| 44 | } |
| 45 | |
| 46 | ~ScratchFile() { |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 47 | int unlink_result = unlink(filename_.c_str()); |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 48 | CHECK_EQ(0, unlink_result); |
| 49 | int close_result = close(fd_); |
| 50 | CHECK_EQ(0, close_result); |
| 51 | } |
| 52 | |
| 53 | const char* GetFilename() const { |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 54 | return filename_.c_str(); |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | int GetFd() const { |
| 58 | return fd_; |
| 59 | } |
| 60 | |
| 61 | private: |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 62 | std::string filename_; |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 63 | int fd_; |
| 64 | }; |
| 65 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 66 | class CommonTest : public testing::Test { |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 67 | public: |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 68 | static void MakeExecutable(const ByteArray* byte_array) { |
| 69 | uintptr_t data = reinterpret_cast<uintptr_t>(byte_array->GetData()); |
| 70 | uintptr_t base = RoundDown(data, kPageSize); |
| 71 | uintptr_t limit = RoundUp(data + byte_array->GetLength(), kPageSize); |
| 72 | uintptr_t len = limit - base; |
| 73 | int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC); |
| 74 | CHECK_EQ(result, 0); |
| 75 | } |
| 76 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 77 | protected: |
| 78 | virtual void SetUp() { |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 79 | is_host_ = getenv("ANDROID_BUILD_TOP") != NULL; |
| 80 | |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 81 | if (is_host_) { |
| 82 | // $ANDROID_ROOT is set on the device, but not on the host. |
| 83 | // We need to set this so that icu4c can find its locale data. |
| 84 | std::string root; |
| 85 | root += getenv("ANDROID_BUILD_TOP"); |
| 86 | root += "/out/host/linux-x86"; |
| 87 | setenv("ANDROID_ROOT", root.c_str(), 1); |
| 88 | } |
| 89 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 90 | // On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of art-cache |
| 91 | android_data_ = (is_host_ ? "/tmp/art-data-XXXXXX" : "/data/art-cache/art-data-XXXXXX"); |
Elliott Hughes | 0f4c41d | 2011-09-04 14:58:03 -0700 | [diff] [blame] | 92 | if (mkdtemp(&android_data_[0]) == NULL) { |
| 93 | PLOG(FATAL) << "mkdtemp(\"" << &android_data_[0] << "\") failed"; |
| 94 | } |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 95 | setenv("ANDROID_DATA", android_data_.c_str(), 1); |
| 96 | art_cache_.append(android_data_.c_str()); |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 97 | art_cache_.append("/art-cache"); |
| 98 | int mkdir_result = mkdir(art_cache_.c_str(), 0700); |
| 99 | ASSERT_EQ(mkdir_result, 0); |
| 100 | |
Elliott Hughes | a5b897e | 2011-08-16 11:33:06 -0700 | [diff] [blame] | 101 | java_lang_dex_file_.reset(GetLibCoreDex()); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 102 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 103 | boot_class_path_.push_back(java_lang_dex_file_.get()); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 104 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 105 | Runtime::Options options; |
| 106 | options.push_back(std::make_pair("bootclasspath", &boot_class_path_)); |
| 107 | options.push_back(std::make_pair("-Xcheck:jni", reinterpret_cast<void*>(NULL))); |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 108 | options.push_back(std::make_pair("-Xms16m", reinterpret_cast<void*>(NULL))); |
| 109 | options.push_back(std::make_pair("-Xmx16m", reinterpret_cast<void*>(NULL))); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 110 | runtime_.reset(Runtime::Create(options, false)); |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 111 | ASSERT_TRUE(runtime_.get() != NULL); |
Carl Shapiro | 7a90959 | 2011-07-24 19:21:59 -0700 | [diff] [blame] | 112 | class_linker_ = runtime_->GetClassLinker(); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 113 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 114 | #if defined(__i386__) |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 115 | runtime_->SetJniStubArray(JniCompiler::CreateJniStub(kX86)); |
Ian Rogers | 0e073f7 | 2011-09-09 10:45:46 -0700 | [diff] [blame] | 116 | compiler_.reset(new Compiler(kX86)); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 117 | #elif defined(__arm__) |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 118 | runtime_->SetJniStubArray(JniCompiler::CreateJniStub(kThumb2)); |
Ian Rogers | 0e073f7 | 2011-09-09 10:45:46 -0700 | [diff] [blame] | 119 | compiler_.reset(new Compiler(kThumb2)); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 120 | #endif |
| 121 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 122 | Heap::VerifyHeap(); // Check for heap corruption before the test |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 125 | virtual void TearDown() { |
| 126 | const char* android_data = getenv("ANDROID_DATA"); |
| 127 | ASSERT_TRUE(android_data != NULL); |
| 128 | DIR* dir = opendir(art_cache_.c_str()); |
| 129 | ASSERT_TRUE(dir != NULL); |
| 130 | while (true) { |
| 131 | struct dirent entry; |
| 132 | struct dirent* entry_ptr; |
| 133 | int readdir_result = readdir_r(dir, &entry, &entry_ptr); |
| 134 | ASSERT_EQ(0, readdir_result); |
| 135 | if (entry_ptr == NULL) { |
| 136 | break; |
| 137 | } |
| 138 | if ((strcmp(entry_ptr->d_name, ".") == 0) || (strcmp(entry_ptr->d_name, "..") == 0)) { |
| 139 | continue; |
| 140 | } |
| 141 | std::string filename(art_cache_); |
| 142 | filename.push_back('/'); |
| 143 | filename.append(entry_ptr->d_name); |
| 144 | int unlink_result = unlink(filename.c_str()); |
| 145 | ASSERT_EQ(0, unlink_result); |
Jesse Wilson | ac5b9e2 | 2011-07-27 15:11:13 -0400 | [diff] [blame] | 146 | } |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 147 | closedir(dir); |
| 148 | int rmdir_cache_result = rmdir(art_cache_.c_str()); |
| 149 | ASSERT_EQ(0, rmdir_cache_result); |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 150 | int rmdir_data_result = rmdir(android_data_.c_str()); |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 151 | ASSERT_EQ(0, rmdir_data_result); |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 152 | |
| 153 | // icu4c has a fixed 10-element array "gCommonICUDataArray". |
| 154 | // If we run > 10 tests, we fill that array and u_setCommonData fails. |
| 155 | // There's a function to clear the array, but it's not public... |
| 156 | typedef void (*IcuCleanupFn)(); |
| 157 | void* sym = dlsym(RTLD_DEFAULT, "u_cleanup_" U_ICU_VERSION_SHORT); |
| 158 | CHECK(sym != NULL); |
| 159 | IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym); |
| 160 | (*icu_cleanup_fn)(); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 161 | |
Ian Rogers | 0e073f7 | 2011-09-09 10:45:46 -0700 | [diff] [blame] | 162 | compiler_.reset(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 163 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 164 | Heap::VerifyHeap(); // Check for heap corruption after the test |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 165 | } |
Jesse Wilson | ac5b9e2 | 2011-07-27 15:11:13 -0400 | [diff] [blame] | 166 | |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 167 | std::string GetLibCoreDexFileName() { |
| 168 | if (is_host_) { |
| 169 | const char* host_dir = getenv("ANDROID_HOST_OUT"); |
| 170 | CHECK(host_dir != NULL); |
| 171 | return StringPrintf("%s/framework/core-hostdex.jar", host_dir); |
| 172 | } |
| 173 | return std::string("/system/framework/core.jar"); |
| 174 | } |
| 175 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 176 | const DexFile* GetLibCoreDex() { |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 177 | std::string libcore_dex_file_name = GetLibCoreDexFileName(); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 178 | return DexFile::OpenZip(libcore_dex_file_name, ""); |
Jesse Wilson | ac5b9e2 | 2011-07-27 15:11:13 -0400 | [diff] [blame] | 179 | } |
| 180 | |
Brian Carlstrom | 848a4b3 | 2011-09-04 11:29:27 -0700 | [diff] [blame] | 181 | uint32_t FindTypeIdxByDescriptor(const DexFile& dex_file, const StringPiece& descriptor) { |
| 182 | for (size_t i = 0; i < dex_file.NumTypeIds(); i++) { |
| 183 | const DexFile::TypeId& type_id = dex_file.GetTypeId(i); |
| 184 | if (descriptor == dex_file.GetTypeDescriptor(type_id)) { |
| 185 | return i; |
| 186 | } |
| 187 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 188 | CHECK(false) << "Failed to find type index for " << descriptor; |
Brian Carlstrom | 848a4b3 | 2011-09-04 11:29:27 -0700 | [diff] [blame] | 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | uint32_t FindFieldIdxByDescriptorAndName(const DexFile& dex_file, |
| 193 | const StringPiece& class_descriptor, |
| 194 | const StringPiece& field_name) { |
| 195 | for (size_t i = 0; i < dex_file.NumFieldIds(); i++) { |
| 196 | const DexFile::FieldId& field_id = dex_file.GetFieldId(i); |
| 197 | if (class_descriptor == dex_file.GetFieldClassDescriptor(field_id) |
| 198 | && field_name == dex_file.GetFieldName(field_id)) { |
| 199 | return i; |
| 200 | } |
| 201 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 202 | CHECK(false) << "Failed to find field index for " << class_descriptor << " " << field_name; |
Brian Carlstrom | 848a4b3 | 2011-09-04 11:29:27 -0700 | [diff] [blame] | 203 | return 0; |
| 204 | } |
| 205 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 206 | const ClassLoader* AllocPathClassLoader(const DexFile* dex_file) { |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 207 | CHECK(dex_file != NULL); |
| 208 | class_linker_->RegisterDexFile(*dex_file); |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 209 | std::vector<const DexFile*> dex_files; |
| 210 | dex_files.push_back(dex_file); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 211 | return PathClassLoader::Alloc(dex_files); |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 214 | const DexFile* OpenTestDexFile(const char* name) { |
| 215 | CHECK(name != NULL); |
| 216 | std::string filename; |
| 217 | if (is_host_) { |
| 218 | // on the host, just read target dex file |
| 219 | filename += getenv("ANDROID_PRODUCT_OUT"); |
| 220 | } |
| 221 | filename += "/system/framework/art-test-dex-"; |
| 222 | filename += name; |
| 223 | filename += ".jar"; |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 224 | const DexFile* dex_file = DexFile::OpenZip(filename, ""); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 225 | CHECK(dex_file != NULL) << "Failed to open " << filename; |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 226 | return dex_file; |
| 227 | } |
| 228 | |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 229 | const ClassLoader* LoadDex(const char* dex_name) { |
| 230 | const DexFile* dex_file = OpenTestDexFile(dex_name); |
| 231 | CHECK(dex_file != NULL); |
| 232 | loaded_dex_files_.push_back(dex_file); |
| 233 | class_linker_->RegisterDexFile(*dex_file); |
| 234 | std::vector<const DexFile*> class_path; |
| 235 | class_path.push_back(dex_file); |
| 236 | const ClassLoader* class_loader = PathClassLoader::Alloc(class_path); |
| 237 | CHECK(class_loader != NULL); |
| 238 | Thread::Current()->SetClassLoaderOverride(class_loader); |
| 239 | return class_loader; |
| 240 | } |
| 241 | |
| 242 | std::string ConvertClassNameToClassDescriptor(const char* class_name) { |
| 243 | std::string desc; |
| 244 | desc += "L"; |
| 245 | desc += class_name; |
| 246 | desc += ";"; |
| 247 | std::replace(desc.begin(), desc.end(), '.', '/'); |
| 248 | return desc; |
| 249 | } |
| 250 | |
| 251 | void CompileMethod(Method* method) { |
| 252 | CHECK(method != NULL); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 253 | compiler_->CompileOne(method); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 254 | MakeExecutable(runtime_->GetJniStubArray()); |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 255 | MakeExecutable(method->GetCodeArray()); |
| 256 | MakeExecutable(method->GetInvokeStubArray()); |
| 257 | } |
| 258 | |
| 259 | void CompileDirectMethod(const ClassLoader* class_loader, |
| 260 | const char* class_name, |
| 261 | const char* method_name, |
| 262 | const char* signature) { |
| 263 | std::string class_descriptor = ConvertClassNameToClassDescriptor(class_name); |
| 264 | Class* klass = class_linker_->FindClass(class_descriptor, class_loader); |
| 265 | CHECK(klass != NULL) << "Class not found " << class_name; |
| 266 | Method* method = klass->FindDirectMethod(method_name, signature); |
Elliott Hughes | 0f4c41d | 2011-09-04 14:58:03 -0700 | [diff] [blame] | 267 | CHECK(method != NULL) << "Direct method not found: " |
| 268 | << class_name << "." << method_name << signature; |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 269 | CompileMethod(method); |
| 270 | } |
| 271 | |
| 272 | void CompileVirtualMethod(const ClassLoader* class_loader, |
| 273 | const char* class_name, |
| 274 | const char* method_name, |
| 275 | const char* signature) { |
| 276 | std::string class_descriptor = ConvertClassNameToClassDescriptor(class_name); |
| 277 | Class* klass = class_linker_->FindClass(class_descriptor, class_loader); |
| 278 | CHECK(klass != NULL) << "Class not found " << class_name; |
| 279 | Method* method = klass->FindVirtualMethod(method_name, signature); |
Elliott Hughes | 0f4c41d | 2011-09-04 14:58:03 -0700 | [diff] [blame] | 280 | CHECK(method != NULL) << "Virtual method not found: " |
| 281 | << class_name << "." << method_name << signature; |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 282 | CompileMethod(method); |
| 283 | } |
| 284 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 285 | bool is_host_; |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 286 | std::string android_data_; |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 287 | std::string art_cache_; |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 288 | UniquePtr<const DexFile> java_lang_dex_file_; |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 289 | std::vector<const DexFile*> boot_class_path_; |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 290 | UniquePtr<Runtime> runtime_; |
Ian Rogers | 0e073f7 | 2011-09-09 10:45:46 -0700 | [diff] [blame] | 291 | // Owned by the runtime |
Carl Shapiro | 7a90959 | 2011-07-24 19:21:59 -0700 | [diff] [blame] | 292 | ClassLinker* class_linker_; |
Ian Rogers | 0e073f7 | 2011-09-09 10:45:46 -0700 | [diff] [blame] | 293 | UniquePtr<Compiler> compiler_; |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 294 | |
| 295 | private: |
| 296 | std::vector<const DexFile*> loaded_dex_files_; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 297 | }; |
| 298 | |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 299 | } // namespace art |
Elliott Hughes | 3402380 | 2011-08-30 12:06:17 -0700 | [diff] [blame] | 300 | |
| 301 | namespace std { |
| 302 | |
| 303 | // TODO: isn't gtest supposed to be able to print STL types for itself? |
| 304 | template <typename T> |
| 305 | std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) { |
| 306 | os << "["; |
| 307 | for (size_t i = 0; i < rhs.size(); ++i) { |
| 308 | os << rhs[i]; |
| 309 | if (i < rhs.size() - 1) { |
| 310 | os << ", "; |
| 311 | } |
| 312 | } |
| 313 | os << "]"; |
| 314 | return os; |
| 315 | } |
| 316 | |
| 317 | } // namespace std |