blob: d0bc6c7559f96cc208e936e9a423cce93545ce99 [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 */
Ian Rogersbdb03912011-09-14 00:55:44 -070016
17#include "context_arm.h"
18
19#include "object.h"
Brian Carlstrom6f495f22011-10-10 15:05:03 -070020#include "runtime_support.h"
Ian Rogersbdb03912011-09-14 00:55:44 -070021
22namespace art {
23namespace arm {
24
25ArmContext::ArmContext() {
Ian Rogers67375ac2011-09-14 00:55:44 -070026#ifndef NDEBUG
Ian Rogersad42e132011-09-17 20:23:33 -070027 // Initialize registers with easy to spot debug values
Elliott Hughes362f9bc2011-10-17 18:56:41 -070028 for (int i = 0; i < 16; i++) {
Ian Rogers67375ac2011-09-14 00:55:44 -070029 gprs_[i] = 0xEBAD6070+i;
Ian Rogersbdb03912011-09-14 00:55:44 -070030 }
Elliott Hughes362f9bc2011-10-17 18:56:41 -070031 for (int i = 0; i < 32; i++) {
Ian Rogers15fdb8c2011-09-25 15:45:07 -070032 fprs_[i] = 0xEBAD8070+i;
33 }
Ian Rogers67375ac2011-09-14 00:55:44 -070034#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070035}
36
37void ArmContext::FillCalleeSaves(const Frame& fr) {
38 Method* method = fr.GetMethod();
39 uint32_t core_spills = method->GetCoreSpillMask();
Ian Rogers15fdb8c2011-09-25 15:45:07 -070040 uint32_t fp_core_spills = method->GetFpSpillMask();
Ian Rogersbdb03912011-09-14 00:55:44 -070041 size_t spill_count = __builtin_popcount(core_spills);
Ian Rogers15fdb8c2011-09-25 15:45:07 -070042 size_t fp_spill_count = __builtin_popcount(fp_core_spills);
Ian Rogersbdb03912011-09-14 00:55:44 -070043 if (spill_count > 0) {
44 // Lowest number spill is furthest away, walk registers and fill into context
45 int j = 1;
Elliott Hughes362f9bc2011-10-17 18:56:41 -070046 for (int i = 0; i < 16; i++) {
Ian Rogersbdb03912011-09-14 00:55:44 -070047 if (((core_spills >> i) & 1) != 0) {
48 gprs_[i] = fr.LoadCalleeSave(spill_count - j);
49 j++;
50 }
51 }
52 }
Ian Rogers15fdb8c2011-09-25 15:45:07 -070053 if (fp_spill_count > 0) {
54 // Lowest number spill is furthest away, walk registers and fill into context
55 int j = 1;
Elliott Hughes362f9bc2011-10-17 18:56:41 -070056 for (int i = 0; i < 32; i++) {
Ian Rogers15fdb8c2011-09-25 15:45:07 -070057 if (((fp_core_spills >> i) & 1) != 0) {
58 fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j);
59 j++;
60 }
61 }
62 }
Ian Rogersbdb03912011-09-14 00:55:44 -070063}
64
65void ArmContext::DoLongJump() {
Elliott Hughes85d15452011-09-16 17:33:01 -070066#if defined(__arm__)
Brian Carlstrom6f495f22011-10-10 15:05:03 -070067 art_do_long_jump(&gprs_[0], &fprs_[S0]);
Elliott Hughes85d15452011-09-16 17:33:01 -070068#else
69 UNIMPLEMENTED(FATAL);
70#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070071}
72
73} // namespace arm
74} // namespace art