blob: 27f791931bda79bffdea9c56dc9ee4d9341f4de9 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070016
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070017#include "class_linker.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070018#include "dex_cache.h"
19#include "heap.h"
20#include "globals.h"
21#include "logging.h"
22#include "object.h"
23
24namespace art {
25
jeffhaoe343b762011-12-05 16:36:44 -080026void CodeAndDirectMethods::SetResolvedDirectMethodTraceEntry(uint32_t method_idx, const void* pcode) {
27 CHECK(pcode != NULL);
28 int32_t code = reinterpret_cast<int32_t>(pcode);
29 Set(CodeIndex(method_idx), code);
30}
31
Ian Rogers0571d352011-11-03 19:51:38 -070032void CodeAndDirectMethods::SetResolvedDirectMethod(uint32_t method_idx, Method* method) {
33 CHECK(method != NULL);
34 CHECK(method->IsDirect()) << PrettyMethod(method);
35 CHECK(method->GetCode() != NULL) << PrettyMethod(method);
36 Set(CodeIndex(method_idx), reinterpret_cast<int32_t>(method->GetCode()));
37 Set(MethodIndex(method_idx), reinterpret_cast<int32_t>(method));
38}
39
Brian Carlstroma663ea52011-08-19 23:33:41 -070040void DexCache::Init(String* location,
41 ObjectArray<String>* strings,
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070042 ObjectArray<Class>* resolved_types,
43 ObjectArray<Method>* resolved_methods,
44 ObjectArray<Field>* resolved_fields,
45 CodeAndDirectMethods* code_and_direct_methods,
46 ObjectArray<StaticStorageBase>* initialized_static_storage) {
Brian Carlstrom83db7722011-08-26 17:32:56 -070047 CHECK(location != NULL);
48 CHECK(strings != NULL);
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070049 CHECK(resolved_types != NULL);
50 CHECK(resolved_methods != NULL);
51 CHECK(resolved_fields != NULL);
Brian Carlstrom9cc262e2011-08-28 12:45:30 -070052 CHECK(code_and_direct_methods != NULL);
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070053 CHECK(initialized_static_storage != NULL);
54 Set(kLocation, location);
55 Set(kStrings, strings);
56 Set(kResolvedTypes, resolved_types);
57 Set(kResolvedMethods, resolved_methods);
58 Set(kResolvedFields, resolved_fields);
59 Set(kCodeAndDirectMethods, code_and_direct_methods);
60 Set(kInitializedStaticStorage, initialized_static_storage);
Brian Carlstromaded5f72011-10-07 17:15:04 -070061
62 Runtime* runtime = Runtime::Current();
63 if (runtime->IsStarted()) {
64 Runtime::TrampolineType unknown_method_resolution_type = Runtime::GetTrampolineType(NULL);
65 ByteArray* res_trampoline = runtime->GetResolutionStubArray(unknown_method_resolution_type);
66 for (size_t i = 0; i < NumResolvedMethods(); i++) {
67 code_and_direct_methods->SetResolvedDirectMethodTrampoline(i, res_trampoline);
68 }
69 }
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070070}
71
72} // namespace art