blob: 885a9bc96b044528411b5ae1c0755b6cbe59cdb9 [file] [log] [blame]
Ian Rogersbdb03912011-09-14 00:55:44 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#include "context_arm.h"
4
5#include "object.h"
Brian Carlstrom6f495f22011-10-10 15:05:03 -07006#include "runtime_support.h"
Ian Rogersbdb03912011-09-14 00:55:44 -07007
8namespace art {
9namespace arm {
10
11ArmContext::ArmContext() {
Ian Rogers67375ac2011-09-14 00:55:44 -070012#ifndef NDEBUG
Ian Rogersad42e132011-09-17 20:23:33 -070013 // Initialize registers with easy to spot debug values
Ian Rogersbdb03912011-09-14 00:55:44 -070014 for (int i=0; i < 16; i++) {
Ian Rogers67375ac2011-09-14 00:55:44 -070015 gprs_[i] = 0xEBAD6070+i;
Ian Rogersbdb03912011-09-14 00:55:44 -070016 }
Ian Rogers15fdb8c2011-09-25 15:45:07 -070017 for (int i=0; i < 32; i++) {
18 fprs_[i] = 0xEBAD8070+i;
19 }
Ian Rogers67375ac2011-09-14 00:55:44 -070020#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070021}
22
23void ArmContext::FillCalleeSaves(const Frame& fr) {
24 Method* method = fr.GetMethod();
25 uint32_t core_spills = method->GetCoreSpillMask();
Ian Rogers15fdb8c2011-09-25 15:45:07 -070026 uint32_t fp_core_spills = method->GetFpSpillMask();
Ian Rogersbdb03912011-09-14 00:55:44 -070027 size_t spill_count = __builtin_popcount(core_spills);
Ian Rogers15fdb8c2011-09-25 15:45:07 -070028 size_t fp_spill_count = __builtin_popcount(fp_core_spills);
Ian Rogersbdb03912011-09-14 00:55:44 -070029 if (spill_count > 0) {
30 // Lowest number spill is furthest away, walk registers and fill into context
31 int j = 1;
32 for(int i = 0; i < 16; i++) {
33 if (((core_spills >> i) & 1) != 0) {
34 gprs_[i] = fr.LoadCalleeSave(spill_count - j);
35 j++;
36 }
37 }
38 }
Ian Rogers15fdb8c2011-09-25 15:45:07 -070039 if (fp_spill_count > 0) {
40 // Lowest number spill is furthest away, walk registers and fill into context
41 int j = 1;
42 for(int i = 0; i < 32; i++) {
43 if (((fp_core_spills >> i) & 1) != 0) {
44 fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j);
45 j++;
46 }
47 }
48 }
Ian Rogersbdb03912011-09-14 00:55:44 -070049}
50
51void ArmContext::DoLongJump() {
Elliott Hughes85d15452011-09-16 17:33:01 -070052#if defined(__arm__)
Brian Carlstrom6f495f22011-10-10 15:05:03 -070053 art_do_long_jump(&gprs_[0], &fprs_[S0]);
Elliott Hughes85d15452011-09-16 17:33:01 -070054#else
55 UNIMPLEMENTED(FATAL);
56#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070057}
58
59} // namespace arm
60} // namespace art