Added nanojit.h from TT.
authorAndreas Gal <gal@uci.edu>
Wed, 18 Jun 2008 20:49:37 -0700
changeset 17270 77195f4d8de82dd03e9271ca4b8664f255461e80
parent 17269 66f37a19393accc0921ab6aa2d0a38748e4acdef
child 17271 98b15b1d79bdc5b2be5404e3faa8bc0ff49073ee
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherdermozilla-central@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Added nanojit.h from TT.
js/src/nanojit/avmplus.h
js/src/nanojit/nanojit.h
--- a/js/src/nanojit/avmplus.h
+++ b/js/src/nanojit/avmplus.h
@@ -49,18 +49,16 @@
 
 typedef JSUint8 uint8_t;
 typedef JSUint16 uint16_t;
 typedef JSUint32 uint32_t;
 typedef JSUint64 uint64_t;
 
 #define NJ_PAGE_SIZE 4096
 
-#define AVMPLUS_IA32
-
 class GC 
 {
 };
 
 namespace avmplus
 {
     class AvmCore 
     {
new file mode 100644
--- /dev/null
+++ b/js/src/nanojit/nanojit.h
@@ -0,0 +1,166 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is [Open Source Virtual Machine].
+ *
+ * The Initial Developer of the Original Code is
+ * Adobe System Incorporated.
+ * Portions created by the Initial Developer are Copyright (C) 2004-2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Adobe AS3 Team
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef __nanojit_h_
+#define __nanojit_h__
+
+#include <stddef.h>
+#include "avmplus.h"
+
+#ifdef AVMPLUS_IA32
+#define NANOJIT_IA32
+#elif AVMPLUS_ARM
+#define NANOJIT_ARM
+#elif AVMPLUS_PPC
+#define NANOJIT_PPC
+#else
+#error "unknown nanojit architecture"
+#endif
+
+namespace nanojit
+{
+	/**
+	 * -------------------------------------------
+	 * START AVM bridging definitions
+	 * -------------------------------------------
+	 */
+	class Fragment;
+	class LIns;
+	struct SideExit;
+	class RegAlloc;
+	typedef avmplus::AvmCore AvmCore;
+	typedef avmplus::OSDep OSDep;
+	typedef const uint16_t* FragID;
+	typedef avmplus::SortedMap<FragID,Fragment*,avmplus::LIST_GCObjects> FragmentMap;
+	typedef avmplus::SortedMap<SideExit*,RegAlloc*,avmplus::LIST_GCObjects> RegAllocMap;
+	typedef avmplus::List<LIns*,avmplus::LIST_NonGCObjects>	InsList;
+	typedef avmplus::List<intptr_t, avmplus::LIST_GCObjects> NInsList;
+	typedef avmplus::List<char*, avmplus::LIST_GCObjects> StringList;
+
+	#if defined(_DEBUG)
+		
+		#ifndef WIN32
+			inline void DebugBreak() { AvmAssert(0); }
+		#endif
+
+		#define _NanoAssertMsg(a,m)		do { if ((a)==0) { AvmDebugLog(("%s", m)); DebugBreak(); } } while (0)
+		#define NanoAssertMsg(x,y)				do { _NanoAssertMsg((x), (y)); } while (0) /* no semi */
+		#define _NanoAssertMsgf(a,m)		do { if ((a)==0) { AvmDebugLog(m); DebugBreak(); } } while (0)
+		#define NanoAssertMsgf(x,y)				do { _NanoAssertMsgf((x), y); } while (0) /* no semi */
+		#define NanoAssert(x)					_NanoAssert((x), __LINE__,__FILE__)
+		#define _NanoAssert(x, line_, file_)	__NanoAssert((x), line_, file_)
+		#define __NanoAssert(x, line_, file_)	do { NanoAssertMsg((x), "Assertion failed: \"" #x "\" (" #file_ ":" #line_ ")"); } while (0) /* no semi */
+	#else
+		#define NanoAssertMsgf(x,y)	do { } while (0) /* no semi */
+		#define NanoAssertMsg(x,y)	do { } while (0) /* no semi */
+		#define NanoAssert(x)		do { } while (0) /* no semi */
+	#endif
+
+	/**
+	 * -------------------------------------------
+	 * END AVM bridging definitions
+	 * -------------------------------------------
+	 */
+}
+
+#ifdef AVMPLUS_VERBOSE
+#define NJ_VERBOSE 1
+#define NJ_PROFILE 1
+#endif
+
+#ifdef NJ_VERBOSE
+	#include <stdio.h>
+	#define verbose_output						if (verbose_enabled()) Assembler::output
+	#define verbose_outputf						if (verbose_enabled()) Assembler::outputf
+	#define verbose_enabled()					(_verbose)
+	#define verbose_only(x)						x
+#else
+	#define verbose_output
+	#define verbose_outputf
+	#define verbose_enabled()
+	#define verbose_only(x)
+#endif /*NJ_VERBOSE*/
+
+#ifdef _DEBUG
+	#define debug_only(x)			x
+#else
+	#define debug_only(x)
+#endif /* DEBUG */
+
+#ifdef NJ_PROFILE
+	#define counter_struct_begin()  struct {
+	#define counter_struct_end()	} _stats;
+	#define counter_define(x) 		int32_t x
+	#define counter_value(x)		_stats.x
+	#define counter_set(x,v)		(counter_value(x)=(v))
+	#define counter_adjust(x,i)		(counter_value(x)+=(int32_t)(i))
+	#define counter_reset(x)		counter_set(x,0)
+	#define counter_increment(x)	counter_adjust(x,1)
+	#define counter_decrement(x)	counter_adjust(x,-1)
+	#define profile_only(x)			x
+#else
+	#define counter_struct_begin()
+	#define counter_struct_end()
+	#define counter_define(x) 		
+	#define counter_value(x)
+	#define counter_set(x,v)
+	#define counter_adjust(x,i)
+	#define counter_reset(x)
+	#define counter_increment(x)	
+	#define counter_decrement(x)	
+	#define profile_only(x)	
+#endif /* NJ_PROFILE */
+
+#define isS8(i)  ( int32_t(i) == int8_t(i) )
+#define isU8(i)  ( int32_t(i) == uint8_t(i) )
+#define isS16(i) ( int32_t(i) == int16_t(i) )
+#define isU16(i) ( int32_t(i) == uint16_t(i) )
+
+#define alignTo(x,s)		((((uint32_t)(x)))&~((s)-1))
+#define alignUp(x,s)		((((uint32_t)(x))+((s)-1))&~((s)-1))
+
+#define pageTop(x)			( (int*)alignTo(x,NJ_PAGE_SIZE) )
+#define pageBottom(x)		( (int*)(alignTo(x,NJ_PAGE_SIZE)+NJ_PAGE_SIZE)-1 )
+#define samepage(x,y)		(pageTop(x) == pageTop(y))
+
+/*#include "Native.h"
+#include "LIR.h"
+#include "RegAlloc.h"
+#include "Fragmento.h"
+#include "Assembler.h"*/
+
+#endif // __nanojit_h_