blob: d8449098627e4c7f0a522aebd3e2c0c4547f4c6c [file] [log] [blame]
Brian Carlstrom7e49dca2011-07-22 18:07:34 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -07003#include "class_linker.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -07004#include "dex_cache.h"
5#include "heap.h"
6#include "globals.h"
7#include "logging.h"
8#include "object.h"
9
10namespace art {
11
jeffhaoe343b762011-12-05 16:36:44 -080012void CodeAndDirectMethods::SetResolvedDirectMethodTraceEntry(uint32_t method_idx, const void* pcode) {
13 CHECK(pcode != NULL);
14 int32_t code = reinterpret_cast<int32_t>(pcode);
15 Set(CodeIndex(method_idx), code);
16}
17
Ian Rogers0571d352011-11-03 19:51:38 -070018void CodeAndDirectMethods::SetResolvedDirectMethod(uint32_t method_idx, Method* method) {
19 CHECK(method != NULL);
20 CHECK(method->IsDirect()) << PrettyMethod(method);
21 CHECK(method->GetCode() != NULL) << PrettyMethod(method);
22 Set(CodeIndex(method_idx), reinterpret_cast<int32_t>(method->GetCode()));
23 Set(MethodIndex(method_idx), reinterpret_cast<int32_t>(method));
24}
25
Brian Carlstroma663ea52011-08-19 23:33:41 -070026void DexCache::Init(String* location,
27 ObjectArray<String>* strings,
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070028 ObjectArray<Class>* resolved_types,
29 ObjectArray<Method>* resolved_methods,
30 ObjectArray<Field>* resolved_fields,
31 CodeAndDirectMethods* code_and_direct_methods,
32 ObjectArray<StaticStorageBase>* initialized_static_storage) {
Brian Carlstrom83db7722011-08-26 17:32:56 -070033 CHECK(location != NULL);
34 CHECK(strings != NULL);
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070035 CHECK(resolved_types != NULL);
36 CHECK(resolved_methods != NULL);
37 CHECK(resolved_fields != NULL);
Brian Carlstrom9cc262e2011-08-28 12:45:30 -070038 CHECK(code_and_direct_methods != NULL);
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070039 CHECK(initialized_static_storage != NULL);
40 Set(kLocation, location);
41 Set(kStrings, strings);
42 Set(kResolvedTypes, resolved_types);
43 Set(kResolvedMethods, resolved_methods);
44 Set(kResolvedFields, resolved_fields);
45 Set(kCodeAndDirectMethods, code_and_direct_methods);
46 Set(kInitializedStaticStorage, initialized_static_storage);
Brian Carlstromaded5f72011-10-07 17:15:04 -070047
48 Runtime* runtime = Runtime::Current();
49 if (runtime->IsStarted()) {
50 Runtime::TrampolineType unknown_method_resolution_type = Runtime::GetTrampolineType(NULL);
51 ByteArray* res_trampoline = runtime->GetResolutionStubArray(unknown_method_resolution_type);
52 for (size_t i = 0; i < NumResolvedMethods(); i++) {
53 code_and_direct_methods->SetResolvedDirectMethodTrampoline(i, res_trampoline);
54 }
55 }
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070056}
57
58} // namespace art