blob: a707c4de59fcdc4eefb21846f03f01ff0de892a2 [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 Hughesc33a32b2011-10-11 18:18:07 -070037 monitor_list_(NULL),
Elliott Hughesdcc24742011-09-07 14:02:44 -070038 thread_list_(NULL),
39 intern_table_(NULL),
40 class_linker_(NULL),
41 signal_catcher_(NULL),
42 java_vm_(NULL),
Brian Carlstrom16192862011-09-12 17:50:06 -070043 jni_stub_array_(NULL),
Brian Carlstrome24fa612011-09-29 00:53:55 -070044 abstract_method_error_stub_array_(NULL),
Elliott Hughesdcc24742011-09-07 14:02:44 -070045 started_(false),
46 vfprintf_(NULL),
47 exit_(NULL),
Elliott Hughes9d5ccec2011-09-19 13:19:50 -070048 abort_(NULL),
49 stats_enabled_(false) {
Ian Rogers4f0d07c2011-10-06 23:38:47 -070050 for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) {
51 resolution_stub_array_[i] = NULL;
52 }
53 for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
54 callee_save_method_[i] = NULL;
55 }
Elliott Hughesdcc24742011-09-07 14:02:44 -070056}
57
Carl Shapiro61e019d2011-07-14 16:53:09 -070058Runtime::~Runtime() {
Elliott Hughes5fe594f2011-09-08 12:33:17 -070059 // Make sure our internal threads are dead before we start tearing down things they're using.
60 delete signal_catcher_;
Elliott Hughes038a8062011-09-18 14:12:41 -070061 // TODO: GC thread.
Elliott Hughes5fe594f2011-09-08 12:33:17 -070062
Elliott Hughes038a8062011-09-18 14:12:41 -070063 // Make sure all other non-daemon threads have terminated, and all daemon threads are suspended.
Elliott Hughes93e74e82011-09-13 11:07:03 -070064 delete thread_list_;
Elliott Hughesc33a32b2011-10-11 18:18:07 -070065 delete monitor_list_;
Elliott Hughes93e74e82011-09-13 11:07:03 -070066
Carl Shapiro61e019d2011-07-14 16:53:09 -070067 delete class_linker_;
Carl Shapiro69759ea2011-07-21 18:13:35 -070068 Heap::Destroy();
Elliott Hughescf4c6c42011-09-01 15:16:42 -070069 delete intern_table_;
Elliott Hughesc5f7c912011-08-18 14:00:42 -070070 delete java_vm_;
Elliott Hughesc1674ed2011-08-25 18:09:09 -070071 Thread::Shutdown();
Carl Shapiro4acf4642011-07-26 18:54:13 -070072 // TODO: acquire a static mutex on Runtime to avoid racing.
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070073 CHECK(instance_ == NULL || instance_ == this);
Carl Shapiro4acf4642011-07-26 18:54:13 -070074 instance_ = NULL;
Carl Shapiro61e019d2011-07-14 16:53:09 -070075}
76
Elliott Hughesffe67362011-07-17 12:09:27 -070077void Runtime::Abort(const char* file, int line) {
78 // Get any pending output out of the way.
79 fflush(NULL);
80
81 // Many people have difficulty distinguish aborts from crashes,
82 // so be explicit.
83 LogMessage(file, line, ERROR, -1).stream() << "Runtime aborting...";
84
Elliott Hughesffe67362011-07-17 12:09:27 -070085 // Perform any platform-specific pre-abort actions.
86 PlatformAbort(file, line);
87
Brian Carlstrom6ea095a2011-08-16 15:26:54 -070088 // use abort hook if we have one
89 if (Runtime::Current() != NULL && Runtime::Current()->abort_ != NULL) {
90 Runtime::Current()->abort_();
91 // notreached
92 }
93
Elliott Hughesffe67362011-07-17 12:09:27 -070094 // If we call abort(3) on a device, all threads in the process
Carl Shapiro69759ea2011-07-21 18:13:35 -070095 // receive SIGABRT. debuggerd dumps the stack trace of the main
96 // thread, whether or not that was the thread that failed. By
97 // stuffing a value into a bogus address, we cause a segmentation
Elliott Hughesffe67362011-07-17 12:09:27 -070098 // fault in the current thread, and get a useful log from debuggerd.
99 // We can also trivially tell the difference between a VM crash and
100 // a deliberate abort by looking at the fault address.
101 *reinterpret_cast<char*>(0xdeadd00d) = 38;
102 abort();
Elliott Hughesffe67362011-07-17 12:09:27 -0700103 // notreached
104}
105
Elliott Hughesbf86d042011-08-31 17:53:14 -0700106void Runtime::CallExitHook(jint status) {
107 if (exit_ != NULL) {
108 ScopedThreadStateChange tsc(Thread::Current(), Thread::kNative);
109 exit_(status);
110 LOG(WARNING) << "Exit hook returned instead of exiting!";
111 }
112}
113
Brian Carlstrom8a436592011-08-15 21:27:23 -0700114// Parse a string of the form /[0-9]+[kKmMgG]?/, which is used to specify
115// memory sizes. [kK] indicates kilobytes, [mM] megabytes, and
116// [gG] gigabytes.
117//
118// "s" should point just past the "-Xm?" part of the string.
Brian Carlstrom8a436592011-08-15 21:27:23 -0700119// "div" specifies a divisor, e.g. 1024 if the value must be a multiple
120// of 1024.
121//
122// The spec says the -Xmx and -Xms options must be multiples of 1024. It
123// doesn't say anything about -Xss.
124//
125// Returns 0 (a useless size) if "s" is malformed or specifies a low or
126// non-evenly-divisible value.
127//
128size_t ParseMemoryOption(const char *s, size_t div) {
129 // strtoul accepts a leading [+-], which we don't want,
130 // so make sure our string starts with a decimal digit.
131 if (isdigit(*s)) {
132 const char *s2;
133 size_t val = strtoul(s, (char **)&s2, 10);
134 if (s2 != s) {
135 // s2 should be pointing just after the number.
136 // If this is the end of the string, the user
137 // has specified a number of bytes. Otherwise,
138 // there should be exactly one more character
139 // that specifies a multiplier.
140 if (*s2 != '\0') {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700141 // The remainder of the string is either a single multiplier
142 // character, or nothing to indicate that the value is in
143 // bytes.
144 char c = *s2++;
145 if (*s2 == '\0') {
146 size_t mul;
147 if (c == '\0') {
148 mul = 1;
149 } else if (c == 'k' || c == 'K') {
150 mul = KB;
151 } else if (c == 'm' || c == 'M') {
152 mul = MB;
153 } else if (c == 'g' || c == 'G') {
154 mul = GB;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700155 } else {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700156 // Unknown multiplier character.
Brian Carlstrom8a436592011-08-15 21:27:23 -0700157 return 0;
158 }
Brian Carlstromf734cf52011-08-17 16:28:14 -0700159
160 if (val <= std::numeric_limits<size_t>::max() / mul) {
161 val *= mul;
162 } else {
163 // Clamp to a multiple of 1024.
164 val = std::numeric_limits<size_t>::max() & ~(1024-1);
165 }
166 } else {
167 // There's more than one character after the numeric part.
168 return 0;
169 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700170 }
171 // The man page says that a -Xm value must be a multiple of 1024.
172 if (val % div == 0) {
173 return val;
174 }
Carl Shapirofc322c72011-07-27 00:20:01 -0700175 }
176 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700177 return 0;
Carl Shapirofc322c72011-07-27 00:20:01 -0700178}
179
Elliott Hughes0af55432011-08-17 18:37:28 -0700180void LoadJniLibrary(JavaVMExt* vm, const char* name) {
181 // TODO: OS_SHARED_LIB_FORMAT_STR
182 std::string mapped_name(StringPrintf("lib%s.so", name));
Elliott Hughes75770752011-08-24 17:52:38 -0700183 std::string reason;
184 if (!vm->LoadNativeLibrary(mapped_name, NULL, reason)) {
Elliott Hughes0af55432011-08-17 18:37:28 -0700185 LOG(FATAL) << "LoadNativeLibrary failed for \"" << mapped_name << "\": "
186 << reason;
187 }
188}
189
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700190Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, bool ignore_unrecognized) {
Elliott Hughes90a33692011-08-30 13:27:07 -0700191 UniquePtr<ParsedOptions> parsed(new ParsedOptions());
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700192 const char* boot_class_path = getenv("BOOTCLASSPATH");
193 if (boot_class_path != NULL) {
194 parsed->boot_class_path_ = getenv("BOOTCLASSPATH");
195 }
196 const char* class_path = getenv("CLASSPATH");
197 if (class_path != NULL) {
198 parsed->class_path_ = getenv("CLASSPATH");
199 }
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700200#ifdef NDEBUG
Elliott Hughes5174fe62011-08-23 15:12:35 -0700201 // -Xcheck:jni is off by default for regular builds...
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700202 parsed->check_jni_ = false;
203#else
204 // ...but on by default in debug builds.
205 parsed->check_jni_ = true;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700206#endif
Elliott Hughes85d15452011-09-16 17:33:01 -0700207
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700208 parsed->heap_initial_size_ = Heap::kInitialSize;
209 parsed->heap_maximum_size_ = Heap::kMaximumSize;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700210 parsed->stack_size_ = Thread::kDefaultStackSize;
211
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700212 parsed->is_zygote_ = false;
213
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700214 parsed->hook_vfprintf_ = vfprintf;
215 parsed->hook_exit_ = exit;
216 parsed->hook_abort_ = abort;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700217
218 for (size_t i = 0; i < options.size(); ++i) {
219 const StringPiece& option = options[i].first;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700220 if (false) {
221 LOG(INFO) << "option[" << i << "]=" << option;
222 }
Brian Carlstrom8a436592011-08-15 21:27:23 -0700223 if (option.starts_with("-Xbootclasspath:")) {
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700224 parsed->boot_class_path_ = option.substr(strlen("-Xbootclasspath:")).data();
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700225 } else if (option == "-classpath" || option == "-cp") {
226 // TODO: support -Djava.class.path
227 i++;
228 if (i == options.size()) {
229 // TODO: usage
230 LOG(FATAL) << "Missing required class path value for " << option;
231 return NULL;
232 }
233 const StringPiece& value = options[i].first;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700234 parsed->class_path_ = value.data();
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700235 } else if (option.starts_with("-Ximage:")) {
236 parsed->images_.push_back(option.substr(strlen("-Ximage:")).data());
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700237 } else if (option.starts_with("-Xcheck:jni")) {
238 parsed->check_jni_ = true;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700239 } else if (option.starts_with("-Xms")) {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700240 size_t size = ParseMemoryOption(option.substr(strlen("-Xms")).data(), 1024);
241 if (size == 0) {
242 if (ignore_unrecognized) {
243 continue;
244 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700245 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700246 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700247 return NULL;
248 }
249 parsed->heap_initial_size_ = size;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700250 } else if (option.starts_with("-Xmx")) {
Brian Carlstromf734cf52011-08-17 16:28:14 -0700251 size_t size = ParseMemoryOption(option.substr(strlen("-Xmx")).data(), 1024);
252 if (size == 0) {
253 if (ignore_unrecognized) {
254 continue;
255 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700256 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700257 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700258 return NULL;
259 }
260 parsed->heap_maximum_size_ = size;
261 } else if (option.starts_with("-Xss")) {
262 size_t size = ParseMemoryOption(option.substr(strlen("-Xss")).data(), 1);
263 if (size == 0) {
264 if (ignore_unrecognized) {
265 continue;
266 }
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700267 // TODO: usage
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700268 LOG(FATAL) << "Failed to parse " << option;
Brian Carlstromf734cf52011-08-17 16:28:14 -0700269 return NULL;
270 }
271 parsed->stack_size_ = size;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700272 } else if (option.starts_with("-D")) {
273 parsed->properties_.push_back(option.substr(strlen("-D")).data());
Elliott Hughesa0957642011-09-02 14:27:33 -0700274 } else if (option.starts_with("-Xjnitrace:")) {
275 parsed->jni_trace_ = option.substr(strlen("-Xjnitrace:")).data();
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700276 } else if (option == "-Xzygote") {
277 parsed->is_zygote_ = true;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700278 } else if (option.starts_with("-verbose:")) {
Elliott Hughes0af55432011-08-17 18:37:28 -0700279 std::vector<std::string> verbose_options;
Elliott Hughes34023802011-08-30 12:06:17 -0700280 Split(option.substr(strlen("-verbose:")).data(), ',', verbose_options);
Elliott Hughes0af55432011-08-17 18:37:28 -0700281 for (size_t i = 0; i < verbose_options.size(); ++i) {
282 parsed->verbose_.insert(verbose_options[i]);
283 }
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700284 } else if (option == "vfprintf") {
285 parsed->hook_vfprintf_ = reinterpret_cast<int (*)(FILE *, const char*, va_list)>(options[i].second);
286 } else if (option == "exit") {
287 parsed->hook_exit_ = reinterpret_cast<void(*)(jint)>(options[i].second);
288 } else if (option == "abort") {
289 parsed->hook_abort_ = reinterpret_cast<void(*)()>(options[i].second);
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700290 } else if (option == "host-prefix") {
291 parsed->host_prefix_ = reinterpret_cast<const char*>(options[i].second);
Brian Carlstrom8a436592011-08-15 21:27:23 -0700292 } else {
293 if (!ignore_unrecognized) {
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700294 // TODO: print usage via vfprintf
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700295 LOG(ERROR) << "Unrecognized option " << option;
296 // TODO: this should exit, but for now tolerate unknown options
297 //return NULL;
Brian Carlstrom8a436592011-08-15 21:27:23 -0700298 }
299 }
300 }
301
Elliott Hughes85d15452011-09-16 17:33:01 -0700302 LOG(INFO) << "CheckJNI is " << (parsed->check_jni_ ? "on" : "off");
303
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700304 return parsed.release();
Brian Carlstrom8a436592011-08-15 21:27:23 -0700305}
306
307Runtime* Runtime::Create(const Options& options, bool ignore_unrecognized) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -0700308 // TODO: acquire a static mutex on Runtime to avoid racing.
309 if (Runtime::instance_ != NULL) {
310 return NULL;
311 }
Elliott Hughesdcc24742011-09-07 14:02:44 -0700312 instance_ = new Runtime;
313 if (!instance_->Init(options, ignore_unrecognized)) {
314 delete instance_;
315 instance_ = NULL;
Carl Shapiro61e019d2011-07-14 16:53:09 -0700316 }
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700317 return instance_;
318}
Elliott Hughes0af55432011-08-17 18:37:28 -0700319
Brian Carlstromaded5f72011-10-07 17:15:04 -0700320void CreateSystemClassLoader() {
321 if (ClassLoader::UseCompileTimeClassPath()) {
322 return;
323 }
324
325 Thread* self = Thread::Current();
326
327 // Must be in the kNative state for calling native methods.
328 CHECK_EQ(self->GetState(), Thread::kNative);
329
330 JNIEnv* env = self->GetJniEnv();
Brian Carlstromdf143242011-10-10 18:05:34 -0700331 ScopedLocalRef<jclass> ClassLoader_class(env, env->FindClass("java/lang/ClassLoader"));
332 CHECK(ClassLoader_class.get() != NULL);
333 jmethodID getSystemClassLoader = env->GetStaticMethodID(ClassLoader_class.get(),
334 "getSystemClassLoader",
335 "()Ljava/lang/ClassLoader;");
336 CHECK(getSystemClassLoader != NULL);
337 ScopedLocalRef<jobject> class_loader(env, env->CallStaticObjectMethod(ClassLoader_class.get(),
338 getSystemClassLoader));
339 CHECK(class_loader.get() != NULL);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700340
Brian Carlstromdf143242011-10-10 18:05:34 -0700341 Thread::Current()->SetClassLoaderOverride(Decode<ClassLoader*>(env, class_loader.get()));
Brian Carlstromaded5f72011-10-07 17:15:04 -0700342}
343
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700344void Runtime::Start() {
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700345 if (IsVerboseStartup()) {
346 LOG(INFO) << "Runtime::Start entering";
347 }
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700348
349 CHECK(host_prefix_.empty()) << host_prefix_;
350
Elliott Hughes038a8062011-09-18 14:12:41 -0700351 InitNativeMethods();
Elliott Hughes85d15452011-09-16 17:33:01 -0700352
Elliott Hughes038a8062011-09-18 14:12:41 -0700353 Thread::FinishStartup();
Elliott Hughes85d15452011-09-16 17:33:01 -0700354
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700355 class_linker_->RunRootClinits();
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700356
Brian Carlstrom5d40f182011-09-26 22:29:18 -0700357 // Class::AllocObject asserts that all objects allocated better be
358 // initialized after Runtime::IsStarted is true, so this needs to
359 // come after ClassLinker::RunRootClinits.
360 started_ = true;
361
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700362 if (!is_zygote_) {
363 signal_catcher_ = new SignalCatcher;
364 }
365
Elliott Hughes85d15452011-09-16 17:33:01 -0700366 StartDaemonThreads();
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700367
Brian Carlstromaded5f72011-10-07 17:15:04 -0700368 CreateSystemClassLoader();
369
Elliott Hughes726079d2011-10-07 18:43:44 -0700370 Thread::Current()->GetJniEnv()->locals.AssertEmpty();
371
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700372 if (IsVerboseStartup()) {
373 LOG(INFO) << "Runtime::Start exiting";
374 }
Elliott Hughes85d15452011-09-16 17:33:01 -0700375}
376
377void Runtime::StartDaemonThreads() {
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700378 if (IsVerboseStartup()) {
379 LOG(INFO) << "Runtime::StartDaemonThreads entering";
380 }
Elliott Hughes85d15452011-09-16 17:33:01 -0700381
Elliott Hughes719b3232011-09-25 17:42:19 -0700382 Thread* self = Thread::Current();
Brian Carlstromaded5f72011-10-07 17:15:04 -0700383
384 // Must be in the kNative state for calling native methods.
385 CHECK_EQ(self->GetState(), Thread::kNative);
386
Elliott Hughes719b3232011-09-25 17:42:19 -0700387 JNIEnv* env = self->GetJniEnv();
Elliott Hughes726079d2011-10-07 18:43:44 -0700388 ScopedLocalRef<jclass> c(env, env->FindClass("java/lang/Daemons"));
389 CHECK(c.get() != NULL);
390 jmethodID mid = env->GetStaticMethodID(c.get(), "start", "()V");
Elliott Hughes719b3232011-09-25 17:42:19 -0700391 CHECK(mid != NULL);
Elliott Hughes726079d2011-10-07 18:43:44 -0700392 env->CallStaticVoidMethod(c.get(), mid);
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700393
394 if (IsVerboseStartup()) {
395 LOG(INFO) << "Runtime::StartDaemonThreads exiting";
396 }
Carl Shapiro61e019d2011-07-14 16:53:09 -0700397}
398
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700399bool Runtime::IsStarted() const {
Elliott Hughesdcc24742011-09-07 14:02:44 -0700400 return started_;
401}
402
Elliott Hughes0af55432011-08-17 18:37:28 -0700403bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700404 CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700405
Elliott Hughes90a33692011-08-30 13:27:07 -0700406 UniquePtr<ParsedOptions> options(ParsedOptions::Create(raw_options, ignore_unrecognized));
407 if (options.get() == NULL) {
Brian Carlstrome24fa612011-09-29 00:53:55 -0700408 LOG(ERROR) << "Failed to parse options";
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700409 return false;
410 }
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700411 verbose_startup_ = options->IsVerbose("startup");
412 if (IsVerboseStartup()) {
413 LOG(INFO) << "Runtime::Init -verbose:startup enabled";
414 }
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700415
Elliott Hughes32d6e1e2011-10-11 14:47:44 -0700416 Monitor::SetVerbose(options->IsVerbose("monitor"));
417
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700418 host_prefix_ = options->host_prefix_;
419 boot_class_path_ = options->boot_class_path_;
420 class_path_ = options->class_path_;
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700421 properties_ = options->properties_;
422
Elliott Hughes9ca7a1f2011-10-11 14:29:52 -0700423 is_zygote_ = options->is_zygote_;
424
Elliott Hughes0af55432011-08-17 18:37:28 -0700425 vfprintf_ = options->hook_vfprintf_;
426 exit_ = options->hook_exit_;
427 abort_ = options->hook_abort_;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700428
Elliott Hughesbe759c62011-09-08 19:38:21 -0700429 default_stack_size_ = options->stack_size_;
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700430
Elliott Hughesc33a32b2011-10-11 18:18:07 -0700431 monitor_list_ = new MonitorList;
Elliott Hughes14357e82011-09-26 10:42:15 -0700432 thread_list_ = new ThreadList(options->IsVerbose("thread"));
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700433 intern_table_ = new InternTable;
434
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700435 Heap::Init(options->heap_initial_size_, options->heap_maximum_size_, options->images_);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700436
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700437 BlockSignals();
438
Elliott Hughesa0957642011-09-02 14:27:33 -0700439 java_vm_ = new JavaVMExt(this, options.get());
Elliott Hughes515a5bc2011-08-17 11:08:34 -0700440
Elliott Hughesbe759c62011-09-08 19:38:21 -0700441 Thread::Startup();
Elliott Hughesd92bec42011-09-02 17:04:36 -0700442
Elliott Hughes5fe594f2011-09-08 12:33:17 -0700443 // ClassLinker needs an attached thread, but we can't fully attach a thread
444 // without creating objects.
445 Thread::Attach(this, "main", false);
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700446
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700447 CHECK_GE(Heap::GetSpaces().size(), 1U);
448 class_linker_ = ((Heap::GetSpaces()[0]->IsImageSpace())
449 ? ClassLinker::Create(intern_table_)
450 : ClassLinker::Create(options->boot_class_path_, intern_table_));
Brian Carlstrom6ea095a2011-08-16 15:26:54 -0700451
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700452 if (IsVerboseStartup()) {
453 LOG(INFO) << "Runtime::Init exiting";
454 }
Carl Shapiro1fb86202011-06-27 17:43:13 -0700455 return true;
456}
457
Elliott Hughes038a8062011-09-18 14:12:41 -0700458void Runtime::InitNativeMethods() {
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700459 if (IsVerboseStartup()) {
460 LOG(INFO) << "Runtime::InitNativeMethods entering";
461 }
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700462 Thread* self = Thread::Current();
463 JNIEnv* env = self->GetJniEnv();
464
Elliott Hughes418d20f2011-09-22 14:00:39 -0700465 // Must be in the kNative state for calling native methods (JNI_OnLoad code).
Brian Carlstromaded5f72011-10-07 17:15:04 -0700466 CHECK_EQ(self->GetState(), Thread::kNative);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700467
Elliott Hughes418d20f2011-09-22 14:00:39 -0700468 // First set up JniConstants, which is used by both the runtime's built-in native
469 // methods and libcore.
Elliott Hughesfea966e2011-09-22 10:26:20 -0700470 JniConstants::init(env);
471
Elliott Hughes418d20f2011-09-22 14:00:39 -0700472 // Then set up the native methods provided by the runtime itself.
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700473 RegisterRuntimeNativeMethods(env);
474
Elliott Hughes418d20f2011-09-22 14:00:39 -0700475 // Then set up libcore, which is just a regular JNI library with a regular JNI_OnLoad.
476 // Most JNI libraries can just use System.loadLibrary, but libcore can't because it's
477 // the library that implements System.loadLibrary!
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700478 LoadJniLibrary(instance_->GetJavaVM(), "javacore");
Brian Carlstrom0a5b14d2011-09-27 13:29:15 -0700479 if (IsVerboseStartup()) {
480 LOG(INFO) << "Runtime::InitNativeMethods exiting";
481 }
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700482}
483
484void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) {
485#define REGISTER(FN) extern void FN(JNIEnv*); FN(env)
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700486 REGISTER(register_dalvik_system_DexFile);
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700487 REGISTER(register_dalvik_system_VMDebug);
Elliott Hughes7ede61e2011-09-14 18:18:06 -0700488 REGISTER(register_dalvik_system_VMRuntime);
Elliott Hughes8daa0922011-09-11 13:46:25 -0700489 REGISTER(register_dalvik_system_VMStack);
Elliott Hughes01158d72011-09-19 19:47:10 -0700490 REGISTER(register_dalvik_system_Zygote);
Elliott Hughesd369bb72011-09-12 14:41:14 -0700491 REGISTER(register_java_lang_Class);
Elliott Hughesbf86d042011-08-31 17:53:14 -0700492 REGISTER(register_java_lang_Object);
493 REGISTER(register_java_lang_Runtime);
494 REGISTER(register_java_lang_String);
495 REGISTER(register_java_lang_System);
Elliott Hughes8daa0922011-09-11 13:46:25 -0700496 REGISTER(register_java_lang_Thread);
Elliott Hughes1240dad2011-09-09 16:24:50 -0700497 REGISTER(register_java_lang_Throwable);
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700498 REGISTER(register_java_lang_VMClassLoader);
Brian Carlstrom5b8e4c82011-09-18 01:38:59 -0700499 REGISTER(register_java_lang_reflect_Array);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700500 REGISTER(register_java_lang_reflect_Constructor);
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700501 REGISTER(register_java_lang_reflect_Field);
502 REGISTER(register_java_lang_reflect_Method);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700503 //REGISTER(register_java_lang_reflect_Proxy);
Elliott Hughesbf86d042011-08-31 17:53:14 -0700504 REGISTER(register_java_util_concurrent_atomic_AtomicLong);
Brian Carlstrom395520e2011-09-25 19:35:00 -0700505 REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmServer);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700506 //REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmVmInternal);
Elliott Hughes5ee7a8b2011-09-13 16:40:07 -0700507 REGISTER(register_sun_misc_Unsafe);
Elliott Hughesad7c2a32011-08-31 11:58:10 -0700508#undef REGISTER
509}
510
Elliott Hughes8daa0922011-09-11 13:46:25 -0700511void Runtime::Dump(std::ostream& os) {
Elliott Hughese27955c2011-08-26 15:21:24 -0700512 // TODO: dump other runtime statistics?
513 os << "Loaded classes: " << class_linker_->NumLoadedClasses() << "\n";
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700514 os << "Intern table size: " << GetInternTable()->Size() << "\n";
Elliott Hughese27955c2011-08-26 15:21:24 -0700515 // LOGV("VM stats: meth=%d ifld=%d sfld=%d linear=%d",
516 // gDvm.numDeclaredMethods,
517 // gDvm.numDeclaredInstFields,
518 // gDvm.numDeclaredStaticFields,
519 // gDvm.pBootLoaderAlloc->curOffset);
520 // LOGI("GC precise methods: %d", dvmPointerSetGetCount(gDvm.preciseMethods));
Elliott Hughes42ee1422011-09-06 12:33:32 -0700521 os << "\n";
Elliott Hughes8daa0922011-09-11 13:46:25 -0700522
523 thread_list_->Dump(os);
Elliott Hughese27955c2011-08-26 15:21:24 -0700524}
525
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700526void Runtime::SetStatsEnabled(bool new_state) {
527 if (new_state == true) {
528 GetStats()->Clear(~0);
529 // TODO: wouldn't it make more sense to clear _all_ threads' stats?
530 Thread::Current()->GetStats()->Clear(~0);
531 }
532 stats_enabled_ = new_state;
533}
534
535void Runtime::ResetStats(int kinds) {
536 GetStats()->Clear(kinds & 0xffff);
537 // TODO: wouldn't it make more sense to clear _all_ threads' stats?
538 Thread::Current()->GetStats()->Clear(kinds >> 16);
539}
540
541RuntimeStats* Runtime::GetStats() {
542 return &stats_;
543}
544
545int32_t Runtime::GetStat(int kind) {
546 RuntimeStats* stats;
547 if (kind < (1<<16)) {
548 stats = GetStats();
549 } else {
550 stats = Thread::Current()->GetStats();
551 kind >>= 16;
552 }
553 switch (kind) {
554 case KIND_ALLOCATED_OBJECTS:
555 return stats->allocated_objects;
556 case KIND_ALLOCATED_BYTES:
557 return stats->allocated_bytes;
558 case KIND_FREED_OBJECTS:
559 return stats->freed_objects;
560 case KIND_FREED_BYTES:
561 return stats->freed_bytes;
562 case KIND_GC_INVOCATIONS:
563 return stats->gc_for_alloc_count;
564 case KIND_CLASS_INIT_COUNT:
565 return stats->class_init_count;
566 case KIND_CLASS_INIT_TIME:
567 // Convert ns to us, reduce to 32 bits.
568 return (int) (stats->class_init_time_ns / 1000);
569 case KIND_EXT_ALLOCATED_OBJECTS:
570 case KIND_EXT_ALLOCATED_BYTES:
571 case KIND_EXT_FREED_OBJECTS:
572 case KIND_EXT_FREED_BYTES:
573 return 0; // backward compatibility
574 default:
575 CHECK(false);
576 return -1; // unreachable
577 }
578}
579
Elliott Hughesc1674ed2011-08-25 18:09:09 -0700580void Runtime::BlockSignals() {
581 sigset_t sigset;
582 if (sigemptyset(&sigset) == -1) {
583 PLOG(FATAL) << "sigemptyset failed";
584 }
585 if (sigaddset(&sigset, SIGPIPE) == -1) {
586 PLOG(ERROR) << "sigaddset SIGPIPE failed";
587 }
588 // SIGQUIT is used to dump the runtime's state (including stack traces).
589 if (sigaddset(&sigset, SIGQUIT) == -1) {
590 PLOG(ERROR) << "sigaddset SIGQUIT failed";
591 }
592 // SIGUSR1 is used to initiate a heap dump.
593 if (sigaddset(&sigset, SIGUSR1) == -1) {
594 PLOG(ERROR) << "sigaddset SIGUSR1 failed";
595 }
596 CHECK_EQ(sigprocmask(SIG_BLOCK, &sigset, NULL), 0);
597}
598
Elliott Hughes5fe594f2011-09-08 12:33:17 -0700599void Runtime::AttachCurrentThread(const char* name, bool as_daemon) {
600 Thread::Attach(instance_, name, as_daemon);
Carl Shapiro61e019d2011-07-14 16:53:09 -0700601}
602
Elliott Hughesd92bec42011-09-02 17:04:36 -0700603void Runtime::DetachCurrentThread() {
Elliott Hughes038a8062011-09-18 14:12:41 -0700604 // TODO: check we're not calling DetachCurrentThread from a call stack that
605 // includes managed frames. (It's only valid if the stack is all-native.)
Elliott Hughes02b48d12011-09-07 17:15:51 -0700606 thread_list_->Unregister();
Carl Shapiro1fb86202011-06-27 17:43:13 -0700607}
608
Brian Carlstrome24fa612011-09-29 00:53:55 -0700609void Runtime::VisitRoots(Heap::RootVisitor* visitor, void* arg) const {
610 class_linker_->VisitRoots(visitor, arg);
611 intern_table_->VisitRoots(visitor, arg);
612 java_vm_->VisitRoots(visitor, arg);
613 thread_list_->VisitRoots(visitor, arg);
614 visitor(jni_stub_array_, arg);
615 visitor(abstract_method_error_stub_array_, arg);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700616 for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) {
617 visitor(resolution_stub_array_[i], arg);
618 }
619 for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
620 visitor(callee_save_method_[i], arg);
621 }
Brian Carlstrome24fa612011-09-29 00:53:55 -0700622}
623
624bool Runtime::HasJniStubArray() const {
625 return jni_stub_array_ != NULL;
626}
627
628ByteArray* Runtime::GetJniStubArray() const {
629 CHECK(jni_stub_array_ != NULL);
630 return jni_stub_array_;
631}
632
633void Runtime::SetJniStubArray(ByteArray* jni_stub_array) {
Brian Carlstromaded5f72011-10-07 17:15:04 -0700634 CHECK(jni_stub_array != NULL) << " jni_stub_array=" << jni_stub_array;
635 CHECK(jni_stub_array_ == NULL || jni_stub_array_ == jni_stub_array)
636 << "jni_stub_array_=" << jni_stub_array_ << " jni_stub_array=" << jni_stub_array;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700637 jni_stub_array_ = jni_stub_array;
638}
639
640bool Runtime::HasAbstractMethodErrorStubArray() const {
641 return abstract_method_error_stub_array_ != NULL;
642}
643
644ByteArray* Runtime::GetAbstractMethodErrorStubArray() const {
645 CHECK(abstract_method_error_stub_array_ != NULL);
646 return abstract_method_error_stub_array_;
647}
648
649void Runtime::SetAbstractMethodErrorStubArray(ByteArray* abstract_method_error_stub_array) {
650 CHECK(abstract_method_error_stub_array != NULL);
651 CHECK(abstract_method_error_stub_array_ == NULL || abstract_method_error_stub_array_ == abstract_method_error_stub_array);
652 abstract_method_error_stub_array_ = abstract_method_error_stub_array;
653}
654
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700655
656Runtime::TrampolineType Runtime::GetTrampolineType(Method* method) {
657 if (method == NULL) {
658 return Runtime::kUnknownMethod;
659 } else if (method->IsStatic()) {
660 return Runtime::kStaticMethod;
661 } else {
662 return Runtime::kInstanceMethod;
663 }
Ian Rogersad25ac52011-10-04 19:13:33 -0700664}
665
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700666bool Runtime::HasResolutionStubArray(TrampolineType type) const {
667 return resolution_stub_array_[type] != NULL;
Ian Rogersad25ac52011-10-04 19:13:33 -0700668}
669
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700670ByteArray* Runtime::GetResolutionStubArray(TrampolineType type) const {
671 CHECK(HasResolutionStubArray(type));
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700672 DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastTrampolineMethodType));
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700673 return resolution_stub_array_[type];
674}
675
676void Runtime::SetResolutionStubArray(ByteArray* resolution_stub_array, TrampolineType type) {
Ian Rogersad25ac52011-10-04 19:13:33 -0700677 CHECK(resolution_stub_array != NULL);
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700678 CHECK(!HasResolutionStubArray(type) || resolution_stub_array_[type] == resolution_stub_array);
679 resolution_stub_array_[type] = resolution_stub_array;
Ian Rogersad25ac52011-10-04 19:13:33 -0700680}
681
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700682Method* Runtime::CreateCalleeSaveMethod(InstructionSet insns, CalleeSaveType type) {
Ian Rogersff1ed472011-09-20 13:46:24 -0700683 Class* method_class = Method::GetMethodClass();
684 Method* method = down_cast<Method*>(method_class->AllocObject());
685 method->SetDeclaringClass(method_class);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700686 const char* name;
687 if (type == kSaveAll) {
688 name = "$$$callee_save_method$$$";
689 } else if (type == kRefsOnly) {
690 name = "$$$refs_only_callee_save_method$$$";
691 } else {
692 DCHECK(type == kRefsAndArgs);
693 name = "$$$refs_and_args_callee_save_method$$$";
694 }
695 method->SetName(intern_table_->InternStrong(name));
Ian Rogersff1ed472011-09-20 13:46:24 -0700696 method->SetSignature(intern_table_->InternStrong("()V"));
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700697 method->SetCode(NULL);
Ian Rogersff1ed472011-09-20 13:46:24 -0700698 if ((insns == kThumb2) || (insns == kArm)) {
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700699 uint32_t ref_spills = (1 << art::arm::R5) | (1 << art::arm::R6) | (1 << art::arm::R7) |
700 (1 << art::arm::R8) | (1 << art::arm::R10) | (1 << art::arm::R11);
701 uint32_t arg_spills = (1 << art::arm::R1) | (1 << art::arm::R2) | (1 << art::arm::R3);
702 uint32_t all_spills = (1 << art::arm::R4) | (1 << art::arm::R9);
703 uint32_t core_spills = ref_spills | (type == kRefsAndArgs ? arg_spills :0) |
704 (type == kSaveAll ? all_spills :0) | (1 << art::arm::LR);
705 uint32_t fp_all_spills = (1 << art::arm::S0) | (1 << art::arm::S1) | (1 << art::arm::S2) |
706 (1 << art::arm::S3) | (1 << art::arm::S4) | (1 << art::arm::S5) |
707 (1 << art::arm::S6) | (1 << art::arm::S7) | (1 << art::arm::S8) |
708 (1 << art::arm::S9) | (1 << art::arm::S10) | (1 << art::arm::S11) |
709 (1 << art::arm::S12) | (1 << art::arm::S13) | (1 << art::arm::S14) |
710 (1 << art::arm::S15) | (1 << art::arm::S16) | (1 << art::arm::S17) |
711 (1 << art::arm::S18) | (1 << art::arm::S19) | (1 << art::arm::S20) |
712 (1 << art::arm::S21) | (1 << art::arm::S22) | (1 << art::arm::S23) |
713 (1 << art::arm::S24) | (1 << art::arm::S25) | (1 << art::arm::S26) |
714 (1 << art::arm::S27) | (1 << art::arm::S28) | (1 << art::arm::S29) |
715 (1 << art::arm::S30) | (1 << art::arm::S31);
716 uint32_t fp_spills = type == kSaveAll ? fp_all_spills : 0;
717 size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
718 __builtin_popcount(fp_spills) /* fprs */ +
719 1 /* Method* */) * kPointerSize, kStackAlignment);
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700720 method->SetFrameSizeInBytes(frame_size);
721 method->SetReturnPcOffsetInBytes(frame_size - kPointerSize);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700722 method->SetCoreSpillMask(core_spills);
723 method->SetFpSpillMask(fp_spills);
Ian Rogersff1ed472011-09-20 13:46:24 -0700724 } else if (insns == kX86) {
725 method->SetFrameSizeInBytes(32);
726 method->SetReturnPcOffsetInBytes(28);
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700727 method->SetCoreSpillMask((1 << art::x86::EBX) | (1 << art::x86::EBP) | (1 << art::x86::ESI) |
Ian Rogersff1ed472011-09-20 13:46:24 -0700728 (1 << art::x86::EDI));
729 method->SetFpSpillMask(0);
730 } else {
731 UNIMPLEMENTED(FATAL);
732 }
733 return method;
734}
735
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700736bool Runtime::HasCalleeSaveMethod(CalleeSaveType type) const {
737 return callee_save_method_[type] != NULL;
Brian Carlstrom1f870082011-08-23 16:02:11 -0700738}
739
Brian Carlstrome24fa612011-09-29 00:53:55 -0700740// Returns a special method that describes all callee saves being spilled to the stack.
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700741Method* Runtime::GetCalleeSaveMethod(CalleeSaveType type) const {
742 CHECK(HasCalleeSaveMethod(type));
743 return callee_save_method_[type];
Brian Carlstrome24fa612011-09-29 00:53:55 -0700744}
745
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700746void Runtime::SetCalleeSaveMethod(Method* method, CalleeSaveType type) {
747 DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastCalleeSaveType));
748 callee_save_method_[type] = method;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700749}
750
Carl Shapiro1fb86202011-06-27 17:43:13 -0700751} // namespace art