Bug 518747 - NJ merge: get rid of NJ_LOG2_PAGE_SIZE et al. r=graydon.
[mozilla-central.git] / js / src / nanojit / Native.h
blob47531aa67b231f2b89767988aea71de05f2b9316
1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is [Open Source Virtual Machine].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2007
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Adobe AS3 Team
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
41 #ifndef __nanojit_Native__
42 #define __nanojit_Native__
44 // define PEDANTIC=1 to ignore specialized forms, force general forms
45 // for everything, far branches, extra page-linking, etc. This will
46 // flush out many corner cases.
48 #define PEDANTIC 0
49 #if PEDANTIC
50 # define UNLESS_PEDANTIC(...)
51 # define IF_PEDANTIC(...) __VA_ARGS__
52 #else
53 # define UNLESS_PEDANTIC(...) __VA_ARGS__
54 # define IF_PEDANTIC(...)
55 #endif
57 #ifdef NANOJIT_IA32
58 #include "Nativei386.h"
59 #elif defined(NANOJIT_ARM)
60 #include "NativeARM.h"
61 #elif defined(NANOJIT_PPC)
62 #include "NativePPC.h"
63 #elif defined(NANOJIT_SPARC)
64 #include "NativeSparc.h"
65 #elif defined(NANOJIT_X64)
66 #include "NativeX64.h"
67 #else
68 #error "unknown nanojit architecture"
69 #endif
71 namespace nanojit {
72 class Fragment;
73 struct SideExit;
74 struct SwitchInfo;
76 struct GuardRecord
78 void* jmp;
79 GuardRecord* next;
80 SideExit* exit;
81 // profiling stuff
82 verbose_only( uint32_t profCount; )
83 verbose_only( uint32_t profGuardID; )
84 verbose_only( GuardRecord* nextInFrag; )
87 struct SideExit
89 GuardRecord* guards;
90 Fragment* from;
91 Fragment* target;
92 SwitchInfo* switchInfo;
94 void addGuard(GuardRecord* gr)
96 NanoAssert(gr->next == NULL);
97 NanoAssert(guards != gr);
98 gr->next = guards;
99 guards = gr;
104 #ifdef NJ_STACK_GROWTH_UP
105 #define stack_direction(n) n
106 #else
107 #define stack_direction(n) -n
108 #endif
110 #define isSPorFP(r) ( (r)==SP || (r)==FP )
112 #ifdef MOZ_NO_VARADIC_MACROS
113 static void asm_output(const char *f, ...) {}
114 #define gpn(r) regNames[(r)]
115 #define fpn(r) regNames[(r)]
116 #elif defined(NJ_VERBOSE)
117 #define asm_output(...) do { \
118 counter_increment(native); \
119 if (_logc->lcbits & LC_Assembly) { \
120 outline[0]='\0'; \
121 if (outputAddr) \
122 VMPI_sprintf(outline, "%010lx ", (unsigned long)_nIns); \
123 else \
124 VMPI_memset(outline, (int)' ', 10+3); \
125 sprintf(&outline[13], ##__VA_ARGS__); \
126 Assembler::outputAlign(outline, 35); \
127 _allocator.formatRegisters(outline, _thisfrag); \
128 Assembler::output_asm(outline); \
129 outputAddr=(_logc->lcbits & LC_NoCodeAddrs) ? false : true; \
131 } while (0) /* no semi */
132 #define gpn(r) regNames[(r)]
133 #define fpn(r) regNames[(r)]
134 #else
135 #define asm_output(...)
136 #define gpn(r)
137 #define fpn(r)
138 #endif /* NJ_VERBOSE */
140 #endif // __nanojit_Native__