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