/[jscoverage]/trunk/js/nanojit/RegAlloc.h
ViewVC logotype

Contents of /trunk/js/nanojit/RegAlloc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 399 - (show annotations)
Tue Dec 9 03:37:47 2008 UTC (11 years ago) by siliconforks
File MIME type: text/plain
File size: 3396 byte(s)
Use SpiderMonkey from Firefox 3.1b2.

1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is [Open Source Virtual Machine].
16 *
17 * The Initial Developer of the Original Code is
18 * Adobe System Incorporated.
19 * Portions created by the Initial Developer are Copyright (C) 2004-2007
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Adobe AS3 Team
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39
40 #ifndef __nanojit_RegAlloc__
41 #define __nanojit_RegAlloc__
42
43
44 namespace nanojit
45 {
46 inline RegisterMask rmask(Register r)
47 {
48 return 1 << r;
49 }
50
51 class RegAlloc MMGC_SUBCLASS_DECL
52 {
53 public:
54 RegAlloc() : free(0), used(0), priority(0) {}
55 void clear();
56 bool isFree(Register r);
57 void addFree(Register r);
58 void removeFree(Register r);
59 void addActive(Register r, LIns* ins);
60 void useActive(Register r);
61 void removeActive(Register r);
62 void retire(Register r);
63 bool isValid() {
64 return (free|used) != 0;
65 }
66
67 int32_t getPriority(Register r) {
68 NanoAssert(r != UnknownReg && active[r]);
69 return usepri[r];
70 }
71
72 LIns* getActive(Register r) {
73 NanoAssert(r != UnknownReg);
74 return active[r];
75 }
76
77 debug_only( uint32_t countFree(); )
78 debug_only( uint32_t countActive(); )
79 debug_only( void checkCount(); )
80 debug_only( bool isConsistent(Register r, LIns* v); )
81 debug_only( uint32_t count; )
82 debug_only( RegisterMask managed; ) // bitfield of 0..NJ_MAX_REGISTERS denoting which are under our management
83
84 LIns* active[LastReg + 1]; // active[r] = OP that defines r
85 int32_t usepri[LastReg + 1]; // used priority. lower = more likely to spill.
86 RegisterMask free;
87 RegisterMask used;
88 int32_t priority;
89
90 verbose_only( static void formatRegisters(RegAlloc& regs, char* s, Fragment*); )
91
92 DECLARE_PLATFORM_REGALLOC()
93 };
94 }
95 #endif // __nanojit_RegAlloc__

  ViewVC Help
Powered by ViewVC 1.1.24