blob: e3aed70c3d76954f2564d60bb6b048aaf7a52be9 [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07003#include "runtime.h"
Carl Shapiro1fb86202011-06-27 17:43:13 -07004
Elliott Hughesffe67362011-07-17 12:09:27 -07005#include <cstdio>
6#include <cstdlib>
Brian Carlstrom8a436592011-08-15 21:27:23 -07007#include <limits>
Carl Shapiro2ed144c2011-07-26 16:52:08 -07008#include <vector>
Elliott Hughesffe67362011-07-17 12:09:27 -07009
Brian Carlstromaded5f72011-10-07 17:15:04 -070010#include "ScopedLocalRef.h"
Elliott Hughes90a33692011-08-30 13:27:07 -070011#include "UniquePtr.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070012#include "class_linker.h"
Brian Carlstromaded5f72011-10-07 17:15:04 -070013#include "class_loader.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070014#include "heap.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070015#include "image.h"
Elliott Hughescf4c6c42011-09-01 15:16:42 -070016#include "intern_table.h"
Elliott Hughesc5f7c912011-08-18 14:00:42 -070017#include "jni_internal.h"
Elliott Hughes32d6e1e2011-10-11 14:47:44 -070018#include "monitor.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070019#include "oat_file.h"
Elliott Hughes726079d2011-10-07 18:43:44 -070020#include "ScopedLocalRef.h"
Elliott Hughese27955c2011-08-26 15:21:24 -070021#include "signal_catcher.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070022#include "space.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070023#include "thread.h"
Elliott Hughes8daa0922011-09-11 13:46:25 -070024#include "thread_list.h"
Carl Shapiro61e019d2011-07-14 16:53:09 -070025
Elliott Hughes90a33692011-08-30 13:27:07 -070026// TODO: this drags in cutil/log.h, which conflicts with our logging.h.
27#include "JniConstants.h"
28
Carl Shapiro1fb86202011-06-27 17:43:13 -070029namespace art {
30
Carl Shapiro2ed144c2011-07-26 16:52:08 -070031Runtime* Runtime::instance_ = NULL;
32
Elliott Hughesdcc24742011-09-07 14:02:44 -070033Runtime::Runtime()
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -070034 : verbose_startup_(false),
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -070035 is_zygote_(false),
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -070036 default_stack_size_(Thread::kDefaultStackSize),
Elliott Hughesdcc24742011-09-07 14:02:44 -070037 thread_list_(NULL),
38 intern_table_(NULL),
39 class_linker_(NULL),
40 signal_catcher_(NULL),
41 java_vm_(NULL),
Brian Carlstrom16192862011-09-12 17:50:06 -070042 jni_stub_array_(NULL),
Brian Carlstrome24fa612011-09-29 00:53:55 -070043 abstract_method_error_stub_array_(NULL),
Elliott Hughesdcc24742011-09-07 14:02:44 -070044 started_(false),
45 vfprintf_(NULL),
46 exit_(NULL),
Elliott Hughes9d5ccec2011-09-19 13:19:50 -070047 abort_(NULL),
48 stats_enabled_(false) {
Ian Rogers4f0d07c2011-10-06 23:38:47 -070049 for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) {
50 resolution_stub_array_[i] = NULL;
51 }
52 for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
53 callee_save_method_[i] = NULL;
54 }
Elliott Hughesdcc24742011-09-07 14:02:44 -070055}
56
Carl Shapiro61e019d2011-07-14 16:53:09 -070057Runtime::~Runtime() {
Elliott Hughes5fe594f2011-09-08 12:33:17 -070058 // Make sure our internal threads are dead before we start tearing down things they're using.
59 delete signal_catcher_;
Elliott Hughes038a8062011-09-18 14:12:41 -070060 // TODO: GC thread.
Elliott Hughes5fe594f2011-09-08 12:33:17 -070061
Elliott Hughes038a8062011-09-18 14:12:41 -070062 // Make sure all other non-daemon threads have terminated, and all daemon threads are suspended.
Elliott Hughes93e74e82011-09-13 11:07:03 -070063 delete thread_list_;
64
Carl Shapiro61e019d2011-07-14 16:53:09 -070065 delete class_linker_;
Carl Shapiro69759ea2011-07-21 18:13:35 -070066 Heap::Destroy();
Elliott Hughescf4c6c42011-09-01 15:16:42 -070067 delete intern_table_;
Elliott Hughesc5f7c912011-08-18 14:00:42 -070068 delete java_vm_;
Elliott Hughesc1674ed2011-08-25 18:09:09 -070069 Thread::Shutdown();
Carl Shapiro4acf4642011-07-26 18:54:13 -070070 // TODO: acquire a static mutex on Runtime to avoid racing.
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070071 CHECK(instance_ == NULL || instance_ == this);
Carl Shapiro4acf4642011-07-26 18:54:13 -070072 instance_ = NULL;
Carl Shapiro61e019d2011-07-14 16:53:09 -070073}
74
Elliott Hughesffe67362011-07-17 12:09:27 -070075void Runtime::Abort(const char* file, int line) {
76 // Get any pending output out of the way.
77 fflush(NULL);
78
79 // Many people have difficulty distinguish aborts from crashes,
80 // so be explicit.
81 LogMessage(file, line, ERROR, -1).stream() << "Runtime aborting...";
82
Elliott Hughesffe67362011-07-17 12:09:27 -070083 // Perform any platform-specific pre-abort actions.
84 PlatformAbort(file, line);
85
Brian Carlstrom6ea095a2011-08-16 15:26:54 -070086 // use abort hook if we have one
87 if (Runtime::Current() != NULL && Runtime::Current()->abort_ != NULL) {
88 Runtime::Current()->abort_();
89 // notreached
90 }
91
Elliott Hughesffe67362011-07-17 12:09:27 -070092 // If we call abort(3) on a device, all threads in the process
Carl Shapiro69759ea2011-07-21 18:13:35 -070093 // receive SIGABRT. debuggerd dumps the stack trace of the main
94 // thread, whether or not that was the thread that failed. By
95 // stuffing a value into a bogus address, we cause a segmentation
Elliott Hughesffe67362011-07-17 12:09:27 -070096 // fault in the current thread, and get a useful log from debuggerd.
97 // We can also trivially tell the difference between a VM crash and
98 // a deliberate abort by looking at the fault address.
99 *reinterpret_cast<char*>(0xdeadd00d) = 38;
100 abort();
Elliott Hughesffe67362011-07-17 12:09:27 -0700101 // notreached
102}
103
Elliott Hughesbf86d042011-08-31 17:53:14 -0700104void Runtime::CallExitHook(jint status) {
105 if (exit_ != NULL) {
106 ScopedThreadStateChange tsc(Thread::Current(), Thread::kNative);
107 exit_(status);
108 LOG(WARNING) << "Exit hook returned instead of exiting!";
109 }
110}
111
Brian Carlstrom8a436592011-08-15 21:27:23 -0700112// Parse a string of the form /[0-9]+[kKmMgG]?/, which is used to specify
113// memory sizes. [kK] indicates kilobytes, [mM] megabytes, and
114// [gG] gigabytes.
115//
116// "s" should point just past the "-Xm?" part of the string.
Brian Carlstrom8a436592011-08-15 21:27:23 -0700117// "div" specifies a divisor, e.g. 1024 if the value must be a multiple
118// of 1024.
119//
120// The spec says the -Xmx and -Xms options must be multiples of 1024. It
121// doesn't say anything about -Xss.
122//
123// Returns 0 (a useless size) if "s" is malformed or specifies a low or
124// non-evenly-divisible value.
125//
126size_t ParseMemoryOption(const char *s, size_t div) {
127 // strtoul accepts a leading [+-], which we don't want,
128 // so make sure our string starts with a decimal digit.
129 if (isdigit(*s)) {
130 const char *s2;
131 size_t val = strtoul(s, (char **)&s2, 10);
132 if (s2 != s) {
133 // s2 should be pointing just after the number.
134 // If this is the end of the string, the user
135 // has specified a number of bytes. Otherwise,
136 // there should be exactly one more character
137 // that specifies a multiplier.
138 if (*s2 != '\0') {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700139 // The remainder of the string is either a single multiplier
140 // character, or nothing to indicate that the value is in
141 // bytes.
142 char c = *s2++;
143 if (*s2 == '\0') {
144 size_t mul;
145 if (c == '\0') {
146 mul = 1;
147 } else if (c == 'k' || c == 'K') {
148 mul = KB;
149 } else if (c == 'm' || c == 'M') {
150 mul = MB;
151 } else if (c == 'g' || c == 'G') {
152 mul = GB;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700153 } else {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700154 // Unknown multiplier character.
Brian Carlstrom8a436592011-08-15 21:27:23 -0700155 return 0;
156 }
Brian Carlstromf734cf52011-08-17 16:28:14 -0700157
158 if (val <= std::numeric_limits<size_t>::max() / mul) {
159 val *= mul;
160 } else {
161 // Clamp to a multiple of 1024.
162 val = std::numeric_limits<size_t>::max() & ~(1024-1);
163 }
164 } else {
165 // There's more than one character after the numeric part.
166 return 0;
167 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700168 }
169 // The man page says that a -Xm value must be a multiple of 1024.
170 if (val % div == 0) {
171 return val;
172 }
Carl Shapirofc322c72011-07-27 00:20:01 -0700173 }
174 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700175 return 0;
Carl Shapirofc322c72011-07-27 00:20:01 -0700176}
177
Elliott Hughes0af55432011-08-17 18:37:28 -0700178void LoadJniLibrary(JavaVMExt* vm, const char* name) {
179 // TODO: OS_SHARED_LIB_FORMAT_STR
180 std::string mapped_name(StringPrintf("lib%s.so", name));
Elliott Hughes75770752011-08-24 17:52:38 -0700181 std::string reason;
182 if (!vm->LoadNativeLibrary(mapped_name, NULL, reason)) {
Elliott Hughes0af55432011-08-17 18:37:28 -0700183 LOG(FATAL) << "LoadNativeLibrary failed for \"" << mapped_name << "\": "
184 << reason;
185 }
186}
187
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700188Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, bool ignore_unrecognized) {
Elliott Hughes90a33692011-08-30 13:27:07 -0700189 UniquePtr<ParsedOptions> parsed(new ParsedOptions());
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700190 const char* boot_class_path = getenv("BOOTCLASSPATH");
191 if (boot_class_path != NULL) {
192 parsed->boot_class_path_ = getenv("BOOTCLASSPATH");
193 }
194 const char* class_path = getenv("CLASSPATH");
195 if (class_path != NULL) {
196 parsed->class_path_ = getenv("CLASSPATH");
197 }
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700198#ifdef NDEBUG
Elliott Hughes5174fe62011-08-23 15:12:35 -0700199 // -Xcheck:jni is off by default for regular builds...
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700200 parsed->check_jni_ = false;
201#else
202 // ...but on by default in debug builds.
203 parsed->check_jni_ = true;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700204#endif
Elliott Hughes85d15452011-09-16 17:33:01 -0700205
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700206 parsed->heap_initial_size_ = Heap::kInitialSize;
207 parsed->heap_maximum_size_ = Heap::kMaximumSize;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700208 parsed->stack_size_ = Thread::kDefaultStackSize;
209
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700210 parsed->is_zygote_ = false;
211
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700212 parsed->hook_vfprintf_ = vfprintf;
213 parsed->hook_exit_ = exit;
214 parsed->hook_abort_ = abort;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700215
216 for (size_t i = 0; i < options.size(); ++i) {
217 const StringPiece& option = options[i].first;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700218 if (false) {
219 LOG(INFO) << "option[" << i << "]=" << option;
220 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700221 if (option.starts_with("-Xbootclasspath:")) {
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700222 parsed->boot_class_path_ = option.substr(strlen("-Xbootclasspath:")).data();
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700223 } else if (option == "-classpath" || option == "-cp") {
224 // TODO: support -Djava.class.path
225 i++;
226 if (i == options.size()) {
227 // TODO: usage
228 LOG(FATAL) << "Missing required class path value for " << option;
229 return NULL;
230 }
231 const StringPiece& value = options[i].first;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700232 parsed->class_path_ = value.data();
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700233 } else if (option.starts_with("-Ximage:")) {
234 parsed->images_.push_back(option.substr(strlen("-Ximage:")).data());
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700235 } else if (option.starts_with("-Xcheck:jni")) {
236 parsed->check_jni_ = true;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700237 } else if (option.starts_with("-Xms")) {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700238 size_t size = ParseMemoryOption(option.substr(strlen("-Xms")).data(), 1024);
239 if (size == 0) {
240 if (ignore_unrecognized) {
241 continue;
242 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700243 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700244 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700245 return NULL;
246 }
247 parsed->heap_initial_size_ = size;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700248 } else if (option.starts_with("-Xmx")) {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700249 size_t size = ParseMemoryOption(option.substr(strlen("-Xmx")).data(), 1024);
250 if (size == 0) {
251 if (ignore_unrecognized) {
252 continue;
253 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700254 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700255 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700256 return NULL;
257 }
258 parsed->heap_maximum_size_ = size;
259 } else if (option.starts_with("-Xss")) {
260 size_t size = ParseMemoryOption(option.substr(strlen("-Xss")).data(), 1);
261 if (size == 0) {
262 if (ignore_unrecognized) {
263 continue;
264 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700265 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700266 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700267 return NULL;
268 }
269 parsed->stack_size_ = size;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700270 } else if (option.starts_with("-D")) {
271 parsed->properties_.push_back(option.substr(strlen("-D")).data());
Elliott Hughesa0957642011-09-02 14:27:33 -0700272 } else if (option.starts_with("-Xjnitrace:")) {
273 parsed->jni_trace_ = option.substr(strlen("-Xjnitrace:")).data();
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700274 } else if (option == "-Xzygote") {
275 parsed->is_zygote_ = true;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700276 } else if (option.starts_with("-verbose:")) {
Elliott Hughes0af55432011-08-17 18:37:28 -0700277 std::vector<std::string> verbose_options;
Elliott Hughes34023802011-08-30 12:06:17 -0700278 Split(option.substr(strlen("-verbose:")).data(), ',', verbose_options);
Elliott Hughes0af55432011-08-17 18:37:28 -0700279 for (size_t i = 0; i < verbose_options.size(); ++i) {
280 parsed->verbose_.insert(verbose_options[i]);
281 }
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700282 } else if (option == "vfprintf") {
283 parsed->hook_vfprintf_ = reinterpret_cast<int (*)(FILE *, const char*, va_list)>(options[i].second);
284 } else if (option == "exit") {
285 parsed->hook_exit_ = reinterpret_cast<void(*)(jint)>(options[i].second);
286 } else if (option == "abort") {
287 parsed->hook_abort_ = reinterpret_cast<void(*)()>(options[i].second);
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700288 } else if (option == "host-prefix") {
289 parsed->host_prefix_ = reinterpret_cast<const char*>(options[i].second);
Brian Carlstrom8a436592011-08-15 21:27:23 -0700290 } else {
291 if (!ignore_unrecognized) {
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700292 // TODO: print usage via vfprintf
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700293 LOG(ERROR) << "Unrecognized option " << option;
294 // TODO: this should exit, but for now tolerate unknown options
295 //return NULL;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700296 }
297 }
298 }
299
Elliott Hughes85d15452011-09-16 17:33:01 -0700300 LOG(INFO) << "CheckJNI is " << (parsed->check_jni_ ? "on" : "off");
301
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700302 return parsed.release();
Brian Carlstrom8a436592011-08-15 21:27:23 -0700303}
304
305Runtime* Runtime::Create(const Options& options, bool ignore_unrecognized) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -0700306 // TODO: acquire a static mutex on Runtime to avoid racing.
307 if (Runtime::instance_ != NULL) {
308 return NULL;
309 }
Elliott Hughesdcc24742011-09-07 14:02:44 -0700310 instance_ = new Runtime;
311 if (!instance_->Init(options, ignore_unrecognized)) {
312 delete instance_;
313 instance_ = NULL;
Carl Shapiro61e019d2011-07-14 16:53:09 -0700314 }
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700315 return instance_;
316}
Elliott Hughes0af55432011-08-17 18:37:28 -0700317
Brian Carlstromaded5f72011-10-07 17:15:04 -0700318void CreateSystemClassLoader() {
319 if (ClassLoader::UseCompileTimeClassPath()) {
320 return;
321 }
322
323 Thread* self = Thread::Current();
324
325 // Must be in the kNative state for calling native methods.
326 CHECK_EQ(self->GetState(), Thread::kNative);
327
328 JNIEnv* env = self->GetJniEnv();
Brian Carlstromdf143242011-10-10 18:05:34 -0700329 ScopedLocalRef<jclass> ClassLoader_class(env, env->FindClass("java/lang/ClassLoader"));
330 CHECK(ClassLoader_class.get() != NULL);
331 jmethodID getSystemClassLoader = env->GetStaticMethodID(ClassLoader_class.get(),
332 "getSystemClassLoader",
333 "()Ljava/lang/ClassLoader;");
334 CHECK(getSystemClassLoader != NULL);
335 ScopedLocalRef<jobject> class_loader(env, env->CallStaticObjectMethod(ClassLoader_class.get(),
336 getSystemClassLoader));
337 CHECK(class_loader.get() != NULL);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700338
Brian Carlstromdf143242011-10-10 18:05:34 -0700339 Thread::Current()->SetClassLoaderOverride(Decode<ClassLoader*>(env, class_loader.get()));
Brian Carlstromaded5f72011-10-07 17:15:04 -0700340}
341
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700342void Runtime::Start() {
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700343 if (IsVerboseStartup()) {
344 LOG(INFO) << "Runtime::Start entering";
345 }
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700346
347 CHECK(host_prefix_.empty()) << host_prefix_;
348
Elliott Hughes038a8062011-09-18 14:12:41 -0700349 InitNativeMethods();
Elliott Hughes85d15452011-09-16 17:33:01 -0700350
Elliott Hughes038a8062011-09-18 14:12:41 -0700351 Thread::FinishStartup();
Elliott Hughes85d15452011-09-16 17:33:01 -0700352
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700353 class_linker_->RunRootClinits();
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700354
Brian Carlstrom5d40f182011-09-26 22:29:18 -0700355 // Class::AllocObject asserts that all objects allocated better be
356 // initialized after Runtime::IsStarted is true, so this needs to
357 // come after ClassLinker::RunRootClinits.
358 started_ = true;
359
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700360 if (!is_zygote_) {
361 signal_catcher_ = new SignalCatcher;
362 }
363
Elliott Hughes85d15452011-09-16 17:33:01 -0700364 StartDaemonThreads();
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700365
Brian Carlstromaded5f72011-10-07 17:15:04 -0700366 CreateSystemClassLoader();
367
Elliott Hughes726079d2011-10-07 18:43:44 -0700368 Thread::Current()->GetJniEnv()->locals.AssertEmpty();
369
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700370 if (IsVerboseStartup()) {
371 LOG(INFO) << "Runtime::Start exiting";
372 }
Elliott Hughes85d15452011-09-16 17:33:01 -0700373}
374
375void Runtime::StartDaemonThreads() {
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700376 if (IsVerboseStartup()) {
377 LOG(INFO) << "Runtime::StartDaemonThreads entering";
378 }
Elliott Hughes85d15452011-09-16 17:33:01 -0700379
Elliott Hughes719b3232011-09-25 17:42:19 -0700380 Thread* self = Thread::Current();
Brian Carlstromaded5f72011-10-07 17:15:04 -0700381
382 // Must be in the kNative state for calling native methods.
383 CHECK_EQ(self->GetState(), Thread::kNative);
384
Elliott Hughes719b3232011-09-25 17:42:19 -0700385 JNIEnv* env = self->GetJniEnv();
Elliott Hughes726079d2011-10-07 18:43:44 -0700386 ScopedLocalRef<jclass> c(env, env->FindClass("java/lang/Daemons"));
387 CHECK(c.get() != NULL);
388 jmethodID mid = env->GetStaticMethodID(c.get(), "start", "()V");
Elliott Hughes719b3232011-09-25 17:42:19 -0700389 CHECK(mid != NULL);
Elliott Hughes726079d2011-10-07 18:43:44 -0700390 env->CallStaticVoidMethod(c.get(), mid);
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700391
392 if (IsVerboseStartup()) {
393 LOG(INFO) << "Runtime::StartDaemonThreads exiting";
394 }
Carl Shapiro61e019d2011-07-14 16:53:09 -0700395}
396
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700397bool Runtime::IsStarted() const {
Elliott Hughesdcc24742011-09-07 14:02:44 -0700398 return started_;
399}
400
Elliott Hughes0af55432011-08-17 18:37:28 -0700401bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700402 CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700403
Elliott Hughes90a33692011-08-30 13:27:07 -0700404 UniquePtr<ParsedOptions> options(ParsedOptions::Create(raw_options, ignore_unrecognized));
405 if (options.get() == NULL) {
Brian Carlstrome24fa612011-09-29 00:53:55 -0700406 LOG(ERROR) << "Failed to parse options";
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700407 return false;
408 }
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700409 verbose_startup_ = options->IsVerbose("startup");
410 if (IsVerboseStartup()) {
411 LOG(INFO) << "Runtime::Init -verbose:startup enabled";
412 }
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700413
Elliott Hughes32d6e1e2011-10-11 14:47:44 -0700414 Monitor::SetVerbose(options->IsVerbose("monitor"));
415
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700416 host_prefix_ = options->host_prefix_;
417 boot_class_path_ = options->boot_class_path_;
418 class_path_ = options->class_path_;
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700419 properties_ = options->properties_;
420
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700421 is_zygote_ = options->is_zygote_;
422
Elliott Hughes0af55432011-08-17 18:37:28 -0700423 vfprintf_ = options->hook_vfprintf_;
424 exit_ = options->hook_exit_;
425 abort_ = options->hook_abort_;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700426
Elliott Hughesbe759c62011-09-08 19:38:21 -0700427 default_stack_size_ = options->stack_size_;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700428
Elliott Hughes14357e82011-09-26 10:42:15 -0700429 thread_list_ = new ThreadList(options->IsVerbose("thread"));
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700430 intern_table_ = new InternTable;
431
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700432 Heap::Init(options->heap_initial_size_, options->heap_maximum_size_, options->images_);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700433
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700434 BlockSignals();
435
Elliott Hughesa0957642011-09-02 14:27:33 -0700436 java_vm_ = new JavaVMExt(this, options.get());
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700437
Elliott Hughesbe759c62011-09-08 19:38:21 -0700438 Thread::Startup();
Elliott Hughesd92bec42011-09-02 17:04:36 -0700439
Elliott Hughes5fe594f2011-09-08 12:33:17 -0700440 // ClassLinker needs an attached thread, but we can't fully attach a thread
441 // without creating objects.
442 Thread::Attach(this, "main", false);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700443
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700444 CHECK_GE(Heap::GetSpaces().size(), 1U);
445 class_linker_ = ((Heap::GetSpaces()[0]->IsImageSpace())
446 ? ClassLinker::Create(intern_table_)
447 : ClassLinker::Create(options->boot_class_path_, intern_table_));
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700448
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700449 if (IsVerboseStartup()) {
450 LOG(INFO) << "Runtime::Init exiting";
451 }
Carl Shapiro1fb86202011-06-27 17:43:13 -0700452 return true;
453}
454
Elliott Hughes038a8062011-09-18 14:12:41 -0700455void Runtime::InitNativeMethods() {
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700456 if (IsVerboseStartup()) {
457 LOG(INFO) << "Runtime::InitNativeMethods entering";
458 }
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700459 Thread* self = Thread::Current();
460 JNIEnv* env = self->GetJniEnv();
461
Elliott Hughes418d20f2011-09-22 14:00:39 -0700462 // Must be in the kNative state for calling native methods (JNI_OnLoad code).
Brian Carlstromaded5f72011-10-07 17:15:04 -0700463 CHECK_EQ(self->GetState(), Thread::kNative);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700464
Elliott Hughes418d20f2011-09-22 14:00:39 -0700465 // First set up JniConstants, which is used by both the runtime's built-in native
466 // methods and libcore.
Elliott Hughesfea966e2011-09-22 10:26:20 -0700467 JniConstants::init(env);
468
Elliott Hughes418d20f2011-09-22 14:00:39 -0700469 // Then set up the native methods provided by the runtime itself.
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700470 RegisterRuntimeNativeMethods(env);
471
Elliott Hughes418d20f2011-09-22 14:00:39 -0700472 // Then set up libcore, which is just a regular JNI library with a regular JNI_OnLoad.
473 // Most JNI libraries can just use System.loadLibrary, but libcore can't because it's
474 // the library that implements System.loadLibrary!
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700475 LoadJniLibrary(instance_->GetJavaVM(), "javacore");
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700476 if (IsVerboseStartup()) {
477 LOG(INFO) << "Runtime::InitNativeMethods exiting";
478 }
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700479}
480
481void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) {
482#define REGISTER(FN) extern void FN(JNIEnv*); FN(env)
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700483 REGISTER(register_dalvik_system_DexFile);
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700484 REGISTER(register_dalvik_system_VMDebug);
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700485 REGISTER(register_dalvik_system_VMRuntime);
Elliott Hughes8daa0922011-09-11 13:46:25 -0700486 REGISTER(register_dalvik_system_VMStack);
Elliott Hughes01158d72011-09-19 19:47:10 -0700487 REGISTER(register_dalvik_system_Zygote);
Elliott Hughesd369bb72011-09-12 14:41:14 -0700488 REGISTER(register_java_lang_Class);
Elliott Hughesbf86d042011-08-31 17:53:14 -0700489 REGISTER(register_java_lang_Object);
490 REGISTER(register_java_lang_Runtime);
491 REGISTER(register_java_lang_String);
492 REGISTER(register_java_lang_System);
Elliott Hughes8daa0922011-09-11 13:46:25 -0700493 REGISTER(register_java_lang_Thread);
Elliott Hughes1240dad2011-09-09 16:24:50 -0700494 REGISTER(register_java_lang_Throwable);
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700495 REGISTER(register_java_lang_VMClassLoader);
Brian Carlstrom5b8e4c82011-09-18 01:38:59 -0700496 REGISTER(register_java_lang_reflect_Array);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700497 REGISTER(register_java_lang_reflect_Constructor);
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700498 REGISTER(register_java_lang_reflect_Field);
499 REGISTER(register_java_lang_reflect_Method);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700500 //REGISTER(register_java_lang_reflect_Proxy);
Elliott Hughesbf86d042011-08-31 17:53:14 -0700501 REGISTER(register_java_util_concurrent_atomic_AtomicLong);
Brian Carlstrom395520e2011-09-25 19:35:00 -0700502 REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmServer);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700503 //REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmVmInternal);
Elliott Hughes5ee7a8b2011-09-13 16:40:07 -0700504 REGISTER(register_sun_misc_Unsafe);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700505#undef REGISTER
506}
507
Elliott Hughes8daa0922011-09-11 13:46:25 -0700508void Runtime::Dump(std::ostream& os) {
Elliott Hughese27955c2011-08-26 15:21:24 -0700509 // TODO: dump other runtime statistics?
510 os << "Loaded classes: " << class_linker_->NumLoadedClasses() << "\n";
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700511 os << "Intern table size: " << GetInternTable()->Size() << "\n";
Elliott Hughese27955c2011-08-26 15:21:24 -0700512 // LOGV("VM stats: meth=%d ifld=%d sfld=%d linear=%d",
513 // gDvm.numDeclaredMethods,
514 // gDvm.numDeclaredInstFields,
515 // gDvm.numDeclaredStaticFields,
516 // gDvm.pBootLoaderAlloc->curOffset);
517 // LOGI("GC precise methods: %d", dvmPointerSetGetCount(gDvm.preciseMethods));
Elliott Hughes42ee1422011-09-06 12:33:32 -0700518 os << "\n";
Elliott Hughes8daa0922011-09-11 13:46:25 -0700519
520 thread_list_->Dump(os);
Elliott Hughese27955c2011-08-26 15:21:24 -0700521}
522
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700523void Runtime::SetStatsEnabled(bool new_state) {
524 if (new_state == true) {
525 GetStats()->Clear(~0);
526 // TODO: wouldn't it make more sense to clear _all_ threads' stats?
527 Thread::Current()->GetStats()->Clear(~0);
528 }
529 stats_enabled_ = new_state;
530}
531
532void Runtime::ResetStats(int kinds) {
533 GetStats()->Clear(kinds & 0xffff);
534 // TODO: wouldn't it make more sense to clear _all_ threads' stats?
535 Thread::Current()->GetStats()->Clear(kinds >> 16);
536}
537
538RuntimeStats* Runtime::GetStats() {
539 return &stats_;
540}
541
542int32_t Runtime::GetStat(int kind) {
543 RuntimeStats* stats;
544 if (kind < (1<<16)) {
545 stats = GetStats();
546 } else {
547 stats = Thread::Current()->GetStats();
548 kind >>= 16;
549 }
550 switch (kind) {
551 case KIND_ALLOCATED_OBJECTS:
552 return stats->allocated_objects;
553 case KIND_ALLOCATED_BYTES:
554 return stats->allocated_bytes;
555 case KIND_FREED_OBJECTS:
556 return stats->freed_objects;
557 case KIND_FREED_BYTES:
558 return stats->freed_bytes;
559 case KIND_GC_INVOCATIONS:
560 return stats->gc_for_alloc_count;
561 case KIND_CLASS_INIT_COUNT:
562 return stats->class_init_count;
563 case KIND_CLASS_INIT_TIME:
564 // Convert ns to us, reduce to 32 bits.
565 return (int) (stats->class_init_time_ns / 1000);
566 case KIND_EXT_ALLOCATED_OBJECTS:
567 case KIND_EXT_ALLOCATED_BYTES:
568 case KIND_EXT_FREED_OBJECTS:
569 case KIND_EXT_FREED_BYTES:
570 return 0; // backward compatibility
571 default:
572 CHECK(false);
573 return -1; // unreachable
574 }
575}
576
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700577void Runtime::BlockSignals() {
578 sigset_t sigset;
579 if (sigemptyset(&sigset) == -1) {
580 PLOG(FATAL) << "sigemptyset failed";
581 }
582 if (sigaddset(&sigset, SIGPIPE) == -1) {
583 PLOG(ERROR) << "sigaddset SIGPIPE failed";
584 }
585 // SIGQUIT is used to dump the runtime's state (including stack traces).
586 if (sigaddset(&sigset, SIGQUIT) == -1) {
587 PLOG(ERROR) << "sigaddset SIGQUIT failed";
588 }
589 // SIGUSR1 is used to initiate a heap dump.
590 if (sigaddset(&sigset, SIGUSR1) == -1) {
591 PLOG(ERROR) << "sigaddset SIGUSR1 failed";
592 }
593 CHECK_EQ(sigprocmask(SIG_BLOCK, &sigset, NULL), 0);
594}
595
Elliott Hughes5fe594f2011-09-08 12:33:17 -0700596void Runtime::AttachCurrentThread(const char* name, bool as_daemon) {
597 Thread::Attach(instance_, name, as_daemon);
Carl Shapiro61e019d2011-07-14 16:53:09 -0700598}
599
Elliott Hughesd92bec42011-09-02 17:04:36 -0700600void Runtime::DetachCurrentThread() {
Elliott Hughes038a8062011-09-18 14:12:41 -0700601 // TODO: check we're not calling DetachCurrentThread from a call stack that
602 // includes managed frames. (It's only valid if the stack is all-native.)
Elliott Hughes02b48d12011-09-07 17:15:51 -0700603 thread_list_->Unregister();
Carl Shapiro1fb86202011-06-27 17:43:13 -0700604}
605
Brian Carlstrome24fa612011-09-29 00:53:55 -0700606void Runtime::VisitRoots(Heap::RootVisitor* visitor, void* arg) const {
607 class_linker_->VisitRoots(visitor, arg);
608 intern_table_->VisitRoots(visitor, arg);
609 java_vm_->VisitRoots(visitor, arg);
610 thread_list_->VisitRoots(visitor, arg);
611 visitor(jni_stub_array_, arg);
612 visitor(abstract_method_error_stub_array_, arg);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700613 for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) {
614 visitor(resolution_stub_array_[i], arg);
615 }
616 for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
617 visitor(callee_save_method_[i], arg);
618 }
Brian Carlstrome24fa612011-09-29 00:53:55 -0700619
620 //(*visitor)(&gDvm.outOfMemoryObj, 0, ROOT_VM_INTERNAL, arg);
621 //(*visitor)(&gDvm.internalErrorObj, 0, ROOT_VM_INTERNAL, arg);
622 //(*visitor)(&gDvm.noClassDefFoundErrorObj, 0, ROOT_VM_INTERNAL, arg);
623 UNIMPLEMENTED(WARNING) << "some roots not marked";
624}
625
626bool Runtime::HasJniStubArray() const {
627 return jni_stub_array_ != NULL;
628}
629
630ByteArray* Runtime::GetJniStubArray() const {
631 CHECK(jni_stub_array_ != NULL);
632 return jni_stub_array_;
633}
634
635void Runtime::SetJniStubArray(ByteArray* jni_stub_array) {
Brian Carlstromaded5f72011-10-07 17:15:04 -0700636 CHECK(jni_stub_array != NULL) << " jni_stub_array=" << jni_stub_array;
637 CHECK(jni_stub_array_ == NULL || jni_stub_array_ == jni_stub_array)
638 << "jni_stub_array_=" << jni_stub_array_ << " jni_stub_array=" << jni_stub_array;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700639 jni_stub_array_ = jni_stub_array;
640}
641
642bool Runtime::HasAbstractMethodErrorStubArray() const {
643 return abstract_method_error_stub_array_ != NULL;
644}
645
646ByteArray* Runtime::GetAbstractMethodErrorStubArray() const {
647 CHECK(abstract_method_error_stub_array_ != NULL);
648 return abstract_method_error_stub_array_;
649}
650
651void Runtime::SetAbstractMethodErrorStubArray(ByteArray* abstract_method_error_stub_array) {
652 CHECK(abstract_method_error_stub_array != NULL);
653 CHECK(abstract_method_error_stub_array_ == NULL || abstract_method_error_stub_array_ == abstract_method_error_stub_array);
654 abstract_method_error_stub_array_ = abstract_method_error_stub_array;
655}
656
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700657
658Runtime::TrampolineType Runtime::GetTrampolineType(Method* method) {
659 if (method == NULL) {
660 return Runtime::kUnknownMethod;
661 } else if (method->IsStatic()) {
662 return Runtime::kStaticMethod;
663 } else {
664 return Runtime::kInstanceMethod;
665 }
Ian Rogersad25ac52011-10-04 19:13:33 -0700666}
667
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700668bool Runtime::HasResolutionStubArray(TrampolineType type) const {
669 return resolution_stub_array_[type] != NULL;
Ian Rogersad25ac52011-10-04 19:13:33 -0700670}
671
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700672ByteArray* Runtime::GetResolutionStubArray(TrampolineType type) const {
673 CHECK(HasResolutionStubArray(type));
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700674 DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastTrampolineMethodType));
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700675 return resolution_stub_array_[type];
676}
677
678void Runtime::SetResolutionStubArray(ByteArray* resolution_stub_array, TrampolineType type) {
Ian Rogersad25ac52011-10-04 19:13:33 -0700679 CHECK(resolution_stub_array != NULL);
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700680 CHECK(!HasResolutionStubArray(type) || resolution_stub_array_[type] == resolution_stub_array);
681 resolution_stub_array_[type] = resolution_stub_array;
Ian Rogersad25ac52011-10-04 19:13:33 -0700682}
683
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700684Method* Runtime::CreateCalleeSaveMethod(InstructionSet insns, CalleeSaveType type) {
Ian Rogersff1ed472011-09-20 13:46:24 -0700685 Class* method_class = Method::GetMethodClass();
686 Method* method = down_cast<Method*>(method_class->AllocObject());
687 method->SetDeclaringClass(method_class);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700688 const char* name;
689 if (type == kSaveAll) {
690 name = "$$$callee_save_method$$$";
691 } else if (type == kRefsOnly) {
692 name = "$$$refs_only_callee_save_method$$$";
693 } else {
694 DCHECK(type == kRefsAndArgs);
695 name = "$$$refs_and_args_callee_save_method$$$";
696 }
697 method->SetName(intern_table_->InternStrong(name));
Ian Rogersff1ed472011-09-20 13:46:24 -0700698 method->SetSignature(intern_table_->InternStrong("()V"));
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700699 method->SetCode(NULL);
Ian Rogersff1ed472011-09-20 13:46:24 -0700700 if ((insns == kThumb2) || (insns == kArm)) {
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700701 uint32_t ref_spills = (1 << art::arm::R5) | (1 << art::arm::R6) | (1 << art::arm::R7) |
702 (1 << art::arm::R8) | (1 << art::arm::R10) | (1 << art::arm::R11);
703 uint32_t arg_spills = (1 << art::arm::R1) | (1 << art::arm::R2) | (1 << art::arm::R3);
704 uint32_t all_spills = (1 << art::arm::R4) | (1 << art::arm::R9);
705 uint32_t core_spills = ref_spills | (type == kRefsAndArgs ? arg_spills :0) |
706 (type == kSaveAll ? all_spills :0) | (1 << art::arm::LR);
707 uint32_t fp_all_spills = (1 << art::arm::S0) | (1 << art::arm::S1) | (1 << art::arm::S2) |
708 (1 << art::arm::S3) | (1 << art::arm::S4) | (1 << art::arm::S5) |
709 (1 << art::arm::S6) | (1 << art::arm::S7) | (1 << art::arm::S8) |
710 (1 << art::arm::S9) | (1 << art::arm::S10) | (1 << art::arm::S11) |
711 (1 << art::arm::S12) | (1 << art::arm::S13) | (1 << art::arm::S14) |
712 (1 << art::arm::S15) | (1 << art::arm::S16) | (1 << art::arm::S17) |
713 (1 << art::arm::S18) | (1 << art::arm::S19) | (1 << art::arm::S20) |
714 (1 << art::arm::S21) | (1 << art::arm::S22) | (1 << art::arm::S23) |
715 (1 << art::arm::S24) | (1 << art::arm::S25) | (1 << art::arm::S26) |
716 (1 << art::arm::S27) | (1 << art::arm::S28) | (1 << art::arm::S29) |
717 (1 << art::arm::S30) | (1 << art::arm::S31);
718 uint32_t fp_spills = type == kSaveAll ? fp_all_spills : 0;
719 size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
720 __builtin_popcount(fp_spills) /* fprs */ +
721 1 /* Method* */) * kPointerSize, kStackAlignment);
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700722 method->SetFrameSizeInBytes(frame_size);
723 method->SetReturnPcOffsetInBytes(frame_size - kPointerSize);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700724 method->SetCoreSpillMask(core_spills);
725 method->SetFpSpillMask(fp_spills);
Ian Rogersff1ed472011-09-20 13:46:24 -0700726 } else if (insns == kX86) {
727 method->SetFrameSizeInBytes(32);
728 method->SetReturnPcOffsetInBytes(28);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700729 method->SetCoreSpillMask((1 << art::x86::EBX) | (1 << art::x86::EBP) | (1 << art::x86::ESI) |
Ian Rogersff1ed472011-09-20 13:46:24 -0700730 (1 << art::x86::EDI));
731 method->SetFpSpillMask(0);
732 } else {
733 UNIMPLEMENTED(FATAL);
734 }
735 return method;
736}
737
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700738bool Runtime::HasCalleeSaveMethod(CalleeSaveType type) const {
739 return callee_save_method_[type] != NULL;
Brian Carlstrom1f870082011-08-23 16:02:11 -0700740}
741
Brian Carlstrome24fa612011-09-29 00:53:55 -0700742// Returns a special method that describes all callee saves being spilled to the stack.
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700743Method* Runtime::GetCalleeSaveMethod(CalleeSaveType type) const {
744 CHECK(HasCalleeSaveMethod(type));
745 return callee_save_method_[type];
Brian Carlstrome24fa612011-09-29 00:53:55 -0700746}
747
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700748void Runtime::SetCalleeSaveMethod(Method* method, CalleeSaveType type) {
749 DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastCalleeSaveType));
750 callee_save_method_[type] = method;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700751}
752
Carl Shapiro1fb86202011-06-27 17:43:13 -0700753} // namespace art