merge m-c to fx-team
authorTim Taubert <tim.taubert@gmx.de>
Mon, 16 Jan 2012 11:20:19 +0100
changeset 85780 a895ecb782e1da97478a33d06e78b012cc9b87b2
parent 85768 047c8ba7d2e405845a1e7940b23c6a9e6407a395 (diff)
parent 85779 2cba23414a5c8b89add15ed70ffbf4a9c8069ee6 (current diff)
child 85781 93d7303c1684c0f48220269e88465cb98f548818
child 85833 027cfe0bb45e603c506060d994c8a5b98e3ea3ed
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone12.0a1
merge m-c to fx-team
editor/libeditor/base/tests/test_selection_move_commands.xul
--- a/accessible/tests/mochitest/events/test_focus_browserui.xul
+++ b/accessible/tests/mochitest/events/test_focus_browserui.xul
@@ -17,16 +17,18 @@
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
+    Components.utils.import("resource://gre/modules/Services.jsm");
+
     ////////////////////////////////////////////////////////////////////////////
     // Helpers
 
     function tabBrowser()
     {
       return gBrowserWnd.gBrowser;
     }
 
@@ -92,18 +94,18 @@
     // Testing
 
     var gInputDocURI = "data:text/html,<html><input id='input'></html>";
     var gButtonDocURI = "data:text/html,<html><input id='input' type='button' value='button'></html>";
 
     var gBrowserWnd = null;
     function loadBrowser()
     {
-      gBrowserWnd = window.openDialog("chrome://browser/content/", "_blank",
-                                      "chrome,all,dialog=no", gInputDocURI);
+      gBrowserWnd = window.openDialog(Services.prefs.getCharPref("browser.chromeURL"),
+                                      "_blank", "chrome,all,dialog=no", gInputDocURI);
 
       addA11yLoadEvent(startTests, gBrowserWnd);
     }
 
     function startTests()
     {
       // Wait for tab load.
       var browser = gBrowserWnd.gBrowser.selectedBrowser;
--- a/browser/base/content/browser-appmenu.inc
+++ b/browser/base/content/browser-appmenu.inc
@@ -336,16 +336,23 @@
                       command="Browser:ShowAllHistory"
                       key="showAllHistoryKb"/>
             <menuseparator/>
             <menuitem id="appmenu_sanitizeHistory"
                       label="&clearRecentHistory.label;"
                       key="key_sanitize"
                       command="Tools:Sanitize"/>
             <menuseparator class="hide-if-empty-places-result"/>
+#ifdef MOZ_SERVICES_SYNC
+            <menuitem id="appmenu_sync-tabs"
+                      class="syncTabsMenuItem"
+                      label="&syncTabsMenu.label;"
+                      oncommand="BrowserOpenSyncTabs();"
+                      disabled="true"/>
+#endif
             <menuitem id="appmenu_restoreLastSession"
                       class="restoreLastSession"
                       label="&historyRestoreLastSession.label;"
                       oncommand="restoreLastSession();"
                       disabled="true"/>
             <menu id="appmenu_recentlyClosedTabsMenu"
                   class="recentlyClosedTabsMenu"
                   label="&historyUndoMenu.label;"
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -85,26 +85,18 @@ let gSyncUI = {
     if (gBrowser) {
       this._obs.push("weave:notification:added");
     }
 
     this._obs.forEach(function(topic) {
       Services.obs.addObserver(this, topic, true);
     }, this);
 
-    // Find the alltabs-popup, only if there is a gBrowser
-    if (gBrowser) {
-      let popup = document.getElementById("alltabs-popup");
-      if (popup) {
-        popup.addEventListener(
-          "popupshowing", this.alltabsPopupShowing.bind(this), true);
-      }
-
-      if (Weave.Notifications.notifications.length)
-        this.initNotifications();
+    if (gBrowser && Weave.Notifications.notifications.length) {
+      this.initNotifications();
     }
     this.updateUI();
   },
 
   initNotifications: function SUI_initNotifications() {
     const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     let notificationbox = document.createElementNS(XULNS, "notificationbox");
     notificationbox.id = "sync-notifications";
@@ -144,44 +136,16 @@ let gSyncUI = {
       return;
 
     button.removeAttribute("status");
     this._updateLastSyncTime();
     if (needsSetup)
       button.removeAttribute("tooltiptext");
   },
 
-  alltabsPopupShowing: function(event) {
-    // Should we show the menu item?
-    //XXXphilikon We should remove the check for isLoggedIn here and have
-    //            about:sync-tabs auto-login (bug 583344)
-    if (!Weave.Service.isLoggedIn || !Weave.Engines.get("tabs").enabled)
-      return;
-
-    let label = this._stringBundle.GetStringFromName("tabs.fromOtherComputers.label");
-
-    let popup = document.getElementById("alltabs-popup");
-    if (!popup)
-      return;
-
-    let menuitem = document.createElement("menuitem");
-    menuitem.setAttribute("id", "sync-tabs-menuitem");
-    menuitem.setAttribute("label", label);
-    menuitem.setAttribute("class", "alltabs-item");
-    menuitem.setAttribute("oncommand", "BrowserOpenSyncTabs();");
-
-    // Fake the tab object on the menu entries, so that we don't have to worry
-    // about removing them ourselves. They will just get cleaned up by popup
-    // binding.
-    menuitem.tab = { "linkedBrowser": { "currentURI": { "spec": label } } };
-
-    let sep = document.getElementById("alltabs-popup-separator");
-    popup.insertBefore(menuitem, sep);
-  },
-
 
   // Functions called by observers
   onActivityStart: function SUI_onActivityStart() {
     if (!gBrowser)
       return;
 
     let button = document.getElementById("sync-button");
     if (!button)
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2612,17 +2612,17 @@ function UpdateUrlbarSearchSplitterState
       splitter.className = "chromeclass-toolbar-additional";
     }
     urlbar.parentNode.insertBefore(splitter, ibefore);
   } else if (splitter)
     splitter.parentNode.removeChild(splitter);
 }
 
 function setUrlAndSearchBarWidthForConditionalForwardButton() {
-  // Woraround for bug 694084: Showing/hiding the conditional forward button resizes
+  // Workaround for bug 694084: Showing/hiding the conditional forward button resizes
   // the search bar when the url/search bar splitter hasn't been used.
   var urlbarContainer = document.getElementById("urlbar-container");
   var searchbarContainer = document.getElementById("search-container");
   if (!urlbarContainer ||
       !searchbarContainer ||
       urlbarContainer.hasAttribute("width") ||
       searchbarContainer.hasAttribute("width") ||
       urlbarContainer.parentNode != searchbarContainer.parentNode)
@@ -5482,17 +5482,17 @@ function updateAppButtonDisplay() {
     !gInPrintPreviewMode &&
     window.menubar.visible &&
     document.getElementById("toolbar-menubar").getAttribute("autohide") == "true";
 
 #ifdef CAN_DRAW_IN_TITLEBAR
   document.getElementById("titlebar").hidden = !displayAppButton;
 
   if (displayAppButton)
-    document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
+    document.documentElement.setAttribute("chromemargin", "0,2,2,2");
   else
     document.documentElement.removeAttribute("chromemargin");
 
   TabsInTitlebar.allowedBy("drawing-in-titlebar", displayAppButton);
 #else
   document.getElementById("appmenu-toolbar-button").hidden =
     !displayAppButton;
 #endif
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -129,17 +129,16 @@
 @BINPATH@/components/content_htmldoc.xpt
 @BINPATH@/components/content_html.xpt
 @BINPATH@/components/content_xslt.xpt
 @BINPATH@/components/content_xtf.xpt
 @BINPATH@/components/cookie.xpt
 @BINPATH@/components/directory.xpt
 @BINPATH@/components/docshell.xpt
 @BINPATH@/components/dom.xpt
-@BINPATH@/components/dom_apps.xpt
 @BINPATH@/components/dom_base.xpt
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/dom_telephony.xpt
 @BINPATH@/components/dom_wifi.xpt
 @BINPATH@/components/dom_system_b2g.xpt
 #endif
 @BINPATH@/components/dom_battery.xpt
 @BINPATH@/components/dom_canvas.xpt
@@ -384,18 +383,16 @@
 @BINPATH@/components/nsPrompter.manifest
 @BINPATH@/components/nsPrompter.js
 #ifdef MOZ_SERVICES_SYNC
 @BINPATH@/components/SyncComponents.manifest
 @BINPATH@/components/Weave.js
 #endif
 @BINPATH@/components/TelemetryPing.js
 @BINPATH@/components/TelemetryPing.manifest
-@BINPATH@/components/Webapps.js
-@BINPATH@/components/Webapps.manifest
 
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsSafebrowsingApplication.manifest
 @BINPATH@/components/nsSafebrowsingApplication.js
 @BINPATH@/components/nsURLClassifier.manifest
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -151,17 +151,20 @@ class RemoteAutomation(Automation):
     class RProcess(object):
         # device manager process
         dm = None
         def __init__(self, dm, cmd, stdout = None, stderr = None, env = None, cwd = '.'):
             self.dm = dm
             self.stdoutlen = 0
             self.proc = dm.launchProcess(cmd, stdout, cwd, env, True)
             if (self.proc is None):
-              raise Exception("unable to launch process")
+              if cmd[0] == 'am':
+                self.proc = stdout
+              else:
+                raise Exception("unable to launch process")
             exepath = cmd[0]
             name = exepath.split('/')[-1]
             self.procName = name
 
             # Setting timeout at 1 hour since on a remote device this takes much longer
             self.timeout = 3600
             time.sleep(15)
 
--- a/build/unix/gnu-ld-scripts/components-mapfile
+++ b/build/unix/gnu-ld-scripts/components-mapfile
@@ -1,6 +1,7 @@
 {
    global:
 		NSModule;
 		NSGetModule;
+		__RLD_MAP;
    local: *;
 };
--- a/build/unix/gnu-ld-scripts/components-version-script
+++ b/build/unix/gnu-ld-scripts/components-version-script
@@ -1,6 +1,7 @@
 EXPORTED {
    global:
 		NSModule;
 		NSGetModule;
+		__RLD_MAP;
    local: *;
 };
--- a/configure.in
+++ b/configure.in
@@ -2531,17 +2531,17 @@ ia64*-hpux*)
         CXXFLAGS="$CXXFLAGS -mms-bitfields"
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
         RC='$(WINDRES)'
         # Use temp file for windres (bug 213281)
         RCFLAGS='-O coff --use-temp-file'
         # mingw doesn't require kernel32, user32, and advapi32 explicitly
-        LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32"
+        LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv"
         MOZ_FIX_LINK_PATHS=
         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
         DLL_PREFIX=
         IMPORT_LIB_SUFFIX=dll.a
         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
     else
         TARGET_COMPILER_ABI=msvc
--- a/content/base/src/nsPropertyTable.cpp
+++ b/content/base/src/nsPropertyTable.cpp
@@ -156,16 +156,43 @@ nsPropertyTable::Enumerate(nsPropertyOwn
       (PL_DHashTableOperate(&prop->mObjectValueMap, aObject, PL_DHASH_LOOKUP));
     if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
       aCallback(const_cast<void*>(aObject.get()), prop->mName, entry->value,
                  aData);
     }
   }
 }
 
+struct PropertyEnumeratorData
+{
+  nsIAtom* mName;
+  NSPropertyFunc mCallBack;
+  void* mData;
+};
+
+static PLDHashOperator
+PropertyEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr,
+                   PRUint32 aNumber, void* aArg)
+{
+  PropertyListMapEntry* entry = static_cast<PropertyListMapEntry*>(aHdr);
+  PropertyEnumeratorData* data = static_cast<PropertyEnumeratorData*>(aArg);
+  data->mCallBack(const_cast<void*>(entry->key), data->mName, entry->value,
+                  data->mData);
+  return PL_DHASH_NEXT;
+}
+
+void
+nsPropertyTable::EnumerateAll(NSPropertyFunc aCallBack, void* aData)
+{
+  for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
+    PropertyEnumeratorData data = { prop->mName, aCallBack, aData };
+    PL_DHashTableEnumerate(&prop->mObjectValueMap, PropertyEnumerator, &data);
+  }
+}
+
 void*
 nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
                                      nsIAtom    *aPropertyName,
                                      bool        aRemove,
                                      nsresult   *aResult)
 {
   NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
   nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
--- a/content/base/src/nsPropertyTable.h
+++ b/content/base/src/nsPropertyTable.h
@@ -177,16 +177,23 @@ class nsPropertyTable
    * Enumerate the properties for object |aObject|.
    * For every property |aCallback| will be called with as arguments |aObject|,
    * the property name, the property value and |aData|.
    */
   NS_HIDDEN_(void) Enumerate(nsPropertyOwner aObject,
                              NSPropertyFunc aCallback, void *aData);
 
   /**
+   * Enumerate all the properties.
+   * For every property |aCallback| will be called with arguments the owner,
+   * the property name, the property value and |aData|.
+   */
+  NS_HIDDEN_(void) EnumerateAll(NSPropertyFunc aCallback, void *aData);
+
+  /**
    * Deletes all of the properties for all objects in the property
    * table, calling the destructor function for each property.
    */
   NS_HIDDEN_(void) DeleteAllProperties();
 
   nsPropertyTable() : mPropertyList(nsnull) {}  
   ~nsPropertyTable() {
     DeleteAllProperties();
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -287,16 +287,50 @@ nsRangeUtils::CompareNodeToRange(nsICont
 nsRange::~nsRange() 
 {
   NS_ASSERTION(!IsInSelection(), "deleting nsRange that is in use");
 
   // we want the side effects (releases and list removals)
   DoSetRange(nsnull, 0, nsnull, 0, nsnull);
 } 
 
+/* static */
+nsresult
+nsRange::CreateRange(nsIDOMNode* aStartParent, PRInt32 aStartOffset,
+                     nsIDOMNode* aEndParent, PRInt32 aEndOffset,
+                     nsRange** aRange)
+{
+  MOZ_ASSERT(aRange);
+  *aRange = NULL;
+
+  nsRefPtr<nsRange> range = new nsRange();
+
+  nsresult rv = range->SetStart(aStartParent, aStartOffset);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = range->SetEnd(aEndParent, aEndOffset);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  range.forget(aRange);
+  return NS_OK;
+}
+
+/* static */
+nsresult
+nsRange::CreateRange(nsIDOMNode* aStartParent, PRInt32 aStartOffset,
+                     nsIDOMNode* aEndParent, PRInt32 aEndOffset,
+                     nsIDOMRange** aRange)
+{
+  nsRefPtr<nsRange> range;
+  nsresult rv = nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
+                                     aEndOffset, getter_AddRefs(range));
+  range.forget(aRange);
+  return rv;
+}
+
 /******************************************************
  * nsISupports
  ******************************************************/
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsRange)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRange)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsRange)
--- a/content/base/src/nsRange.h
+++ b/content/base/src/nsRange.h
@@ -61,16 +61,23 @@ public:
     , mEndOffset(0)
     , mIsPositioned(false)
     , mIsDetached(false)
     , mMaySpanAnonymousSubtrees(false)
     , mInSelection(false)
   {}
   virtual ~nsRange();
 
+  static nsresult CreateRange(nsIDOMNode* aStartParent, PRInt32 aStartOffset,
+                              nsIDOMNode* aEndParent, PRInt32 aEndOffset,
+                              nsRange** aRange);
+  static nsresult CreateRange(nsIDOMNode* aStartParent, PRInt32 aStartOffset,
+                              nsIDOMNode* aEndParent, PRInt32 aEndOffset,
+                              nsIDOMRange** aRange);
+
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsRange, nsIDOMRange)
 
   // nsIDOMRange interface
   NS_DECL_NSIDOMRANGE
   
   nsINode* GetRoot() const
   {
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -36,17 +36,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * A class that handles loading and evaluation of <script> elements.
  */
 
-#include "jscntxt.h"
+#include "jsapi.h"
+#include "jsfriendapi.h"
 #include "nsScriptLoader.h"
 #include "nsParserUtils.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsGkAtoms.h"
 #include "nsNetUtil.h"
@@ -493,17 +494,17 @@ nsScriptLoader::ProcessScriptElement(nsI
         if (rv != NS_ERROR_INVALID_ARG)
           return false;
       } else {
         if (value.Length() == 1 && value[0] == '1')
           // This means that we need to set JSOPTION_XML in the JS options.
           // We re-use our knowledge of the implementation to reuse
           // JSVERSION_HAS_XML as a safe version flag.
           // If version has JSVERSION_UNKNOWN (-1), then this is still OK.
-          version |= js::VersionFlags::HAS_XML;
+          version = js::VersionSetXML(JSVersion(version), true);
       }
     }
   } else {
     // no 'type=' element
     // "language" is a deprecated attribute of HTML, so we check it only for
     // HTML script elements.
     if (scriptContent->IsHTML()) {
       scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::language, language);
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -111,17 +111,16 @@ include $(topsrcdir)/config/rules.mk
 		test_bug357450_svg.xhtml \
 		test_bug357509.html \
 		test_bug358660.html \
 		test_bug362391.xhtml \
 		test_bug364092.xhtml \
 		test_bug364413.xhtml \
 		test_bug366946.html \
 		test_bug367164.html \
-		test_bug371576-1.html \
 		test_bug371576-2.html \
 		test_bug371576-3.html \
 		test_bug371576-4.html \
 		test_bug371576-5.html \
 		test_bug372086.html \
 		test_bug372964.html \
 		test_bug372964-2.html \
 		test_bug373181.xhtml \
deleted file mode 100644
--- a/content/base/test/test_bug371576-1.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=371576
--->
-<head id="head">
-  <title>Test for Bug 371576</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=371576">Mozilla Bug 371576</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-  var result = "A";
-  var scrElem= document.createElement('script');
-  scrElem.setAttribute('src','data:text/javascript,result+="C";$("content").innerHTML="--";result+="D";');
-  $("head").appendChild(scrElem);
-  result += "B";
-
-</script>
-<script>result += "E"</script>
-<script>result += "F"</script>
-<script>is(result, "ABCDEF", "Wrong order of execution");</script>
-</pre>
-</body>
-</html>
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -144,12 +144,11 @@ INCLUDES	+= \
 		-I$(srcdir)/../../../../layout/tables \
 		-I$(srcdir)/../../../../layout/xul/base/src \
 		-I$(srcdir)/../../../../layout/generic \
 		-I$(srcdir)/../../../../dom/base \
 		-I$(srcdir)/../../../../editor/libeditor/base \
 		-I$(srcdir)/../../../../editor/libeditor/text \
 		-I$(srcdir) \
 		-I$(topsrcdir)/xpcom/ds \
-		-I$(srcdir)/../../../../js/xpconnect/src \
 		$(NULL)
 
 DEFINES += -D_IMPL_NS_LAYOUT
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -498,17 +498,18 @@ nsGenericHTMLElement::GetOffsetRect(nsRe
   nsIFrame* frame = GetStyledFrame();
   if (!frame) {
     return;
   }
 
   nsIFrame* parent = frame->GetParent();
   nsPoint origin(0, 0);
 
-  if (parent && parent->GetType() == nsGkAtoms::tableOuterFrame) {
+  if (parent && parent->GetType() == nsGkAtoms::tableOuterFrame &&
+      frame->GetType() == nsGkAtoms::tableFrame) {
     origin = parent->GetPositionIgnoringScrolling();
     parent = parent->GetParent();
   }
 
   Element* docElement = GetCurrentDoc()->GetRootElement();
   nsIContent* content = frame->GetContent();
 
   if (content && (content->IsHTML(nsGkAtoms::body) || content == docElement)) {
--- a/content/html/content/src/nsHTMLDNSPrefetch.cpp
+++ b/content/html/content/src/nsHTMLDNSPrefetch.cpp
@@ -135,27 +135,16 @@ nsHTMLDNSPrefetch::IsAllowed (nsIDocumen
 {
   // There is no need to do prefetch on non UI scenarios such as XMLHttpRequest.
   return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow();
 }
 
 nsresult
 nsHTMLDNSPrefetch::Prefetch(Link *aElement, PRUint16 flags)
 {
-  if (IsNeckoChild()) {
-    // Instead of transporting the Link object to the other process
-    // we are using the hostname based function here, too. Compared to the 
-    // IPC the performance hit should be negligible.
-    nsAutoString hostname;
-    nsresult rv = aElement->GetHostname(hostname);
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    return Prefetch(hostname, flags);
-  }
-
   if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
     return NS_ERROR_NOT_AVAILABLE;
 
   return sPrefetches->Add(flags, aElement);
 }
 
 nsresult
 nsHTMLDNSPrefetch::PrefetchLow(Link *aElement)
@@ -294,21 +283,26 @@ nsHTMLDNSPrefetch::nsDeferrals::SubmitQu
     nsCOMPtr<nsIContent> content = do_QueryReferent(mEntries[mTail].mElement);
     if (content) {
       nsCOMPtr<Link> link = do_QueryInterface(content);
       nsCOMPtr<nsIURI> hrefURI(link ? link->GetURI() : nsnull);
       if (hrefURI)
         hrefURI->GetAsciiHost(hostName);
 
       if (!hostName.IsEmpty()) {
-        nsCOMPtr<nsICancelable> tmpOutstanding;
+        if (IsNeckoChild()) {
+          gNeckoChild->SendHTMLDNSPrefetch(NS_ConvertUTF8toUTF16(hostName),
+                                           mEntries[mTail].mFlags);
+        } else {
+          nsCOMPtr<nsICancelable> tmpOutstanding;
 
-        sDNSService->AsyncResolve(hostName, 
+          sDNSService->AsyncResolve(hostName, 
                                   mEntries[mTail].mFlags | nsIDNSService::RESOLVE_SPECULATE,
                                   sDNSListener, nsnull, getter_AddRefs(tmpOutstanding));
+        }
       }
     }
     
     mEntries[mTail].mElement = nsnull;
     mTail = (mTail + 1) & sMaxDeferredMask;
   }
   
   if (mTimerArmed) {
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -1155,20 +1155,16 @@ nsTextEditorState::PrepareEditor(const n
   if (IsSingleLineTextControl())
     editorFlags |= nsIPlaintextEditor::eEditorSingleLineMask;
   if (IsPasswordTextControl())
     editorFlags |= nsIPlaintextEditor::eEditorPasswordMask;
 
   // All nsTextControlFrames are widgets
   editorFlags |= nsIPlaintextEditor::eEditorWidgetMask;
 
-  // Use async reflow and painting for text widgets to improve
-  // performance.
-  editorFlags |= nsIPlaintextEditor::eEditorUseAsyncUpdatesMask;
-  
   // Spell check is diabled at creation time. It is enabled once
   // the editor comes into focus.
   editorFlags |= nsIPlaintextEditor::eEditorSkipSpellCheck;
 
   bool shouldInitializeEditor = false;
   nsCOMPtr<nsIEditor> newEditor; // the editor that we might create
   nsresult rv = NS_OK;
   if (!mEditor) {
@@ -1309,22 +1305,17 @@ nsTextEditorState::PrepareEditor(const n
   }
 
   // If we have a default value, insert it under the div we created
   // above, but be sure to use the editor so that '*' characters get
   // displayed for password fields, etc. SetValue() will call the
   // editor for us.
 
   if (!defaultValue.IsEmpty()) {
-    // Avoid causing reentrant painting and reflowing by telling the editor
-    // that we don't want it to force immediate view refreshes or force
-    // immediate reflows during any editor calls.
-
-    rv = newEditor->SetFlags(editorFlags |
-                             nsIPlaintextEditor::eEditorUseAsyncUpdatesMask);
+    rv = newEditor->SetFlags(editorFlags);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Now call SetValue() which will make the necessary editor calls to set
     // the default value.  Make sure to turn off undo before setting the default
     // value, and turn it back on afterwards. This will make sure we can't undo
     // past the default value.
 
     rv = newEditor->EnableUndo(false);
@@ -1832,17 +1823,16 @@ nsTextEditorState::SetValue(const nsAStr
 
         // get the flags, remove readonly and disabled, set the value,
         // restore flags
         PRUint32 flags, savedFlags;
         mEditor->GetFlags(&savedFlags);
         flags = savedFlags;
         flags &= ~(nsIPlaintextEditor::eEditorDisabledMask);
         flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask);
-        flags |= nsIPlaintextEditor::eEditorUseAsyncUpdatesMask;
         flags |= nsIPlaintextEditor::eEditorDontEchoPassword;
         mEditor->SetFlags(flags);
 
         mTextListener->SettingValue(true);
 
         // Also don't enforce max-length here
         PRInt32 savedMaxLength;
         plaintextEditor->GetMaxTextLength(&savedMaxLength);
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -277,16 +277,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug617528.html \
 		test_bug660959-1.html \
 		test_bug660959-2.html \
 		test_bug660959-3.html \
 		test_checked.html \
 		test_bug677658.html \
 		test_bug677463.html \
 		test_bug682886.html \
+		test_bug717819.html \
 		file_fullscreen-api.html \
 		file_fullscreen-api-keys.html \
 		test_fullscreen-api.html \
 		file_fullscreen-plugins.html \
 		file_fullscreen-denied.html \
 		file_fullscreen-denied-inner.html \
 		file_fullscreen-hidden.html \
 		file_fullscreen-navigation.html \
--- a/content/html/content/test/test_bug375003-1.html
+++ b/content/html/content/test/test_bug375003-1.html
@@ -71,18 +71,17 @@ function run_test() {
    t3('tr7'  ,[0,0,39,24],[9,9,39,24],[0,0,39,22],'table7');
    t3('span8' ,[0,0,20,20],[26,37,20,20],[0,0,20,20],'table7');
    t3('table7',[7,7,43,54],[10,319,57,68],[0,0,57,50],'body');
    t3('div7',[10,10,-1,68],[0,309,-1,88],[0,0,-1,70],'body');
 
    t3('span9' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td9');
    t3('td9'   ,[1,1,22,22],[15,15,24,24],[0,0,24,24],'table9');
    t3('tr9'  ,[0,0,24,24],[15,15,24,24],[0,0,24,22],'table9');
-   // t3('span10' ,[0,0,20,20],[3,30,20,20],[0,0,20,20],'table9');
-   t3('span10' ,[0,0,20,20],[27,450,20,20],[0,0,20,20],'body');  // bug: 'body' should be 'table9'
+   t3('span10' ,[0,0,20,20],[17,43,20,20],[0,0,20,20],'table9');
    t3('table9',[13,13,28,34],[10,407,54,60],[0,0,54,50],'body');
    t3('div9',[10,10,-1,0],[0,397,-1,20],[0,0,-1,70],'body');
 
    t3('span11' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td11');
    t3('td11'   ,[0,0,22,22],[2,2,22,22],[0,0,22,22],'table11');
    t3('tr11'  ,[0,0,22,22],[2,2,22,22],[0,0,22,22],'table11');
    t3('span12' ,[0,0,20,20],[28,454,20,20],[0,0,20,20],'body');
    t3('table11',[0,0,26,30],[10,427,26,30],[0,0,26,50],'body');
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/test_bug717819.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717819
+-->
+<head>
+  <title>Test for Bug 717819</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717819">Mozilla Bug 717819</a>
+<p id="display"></p>
+<div id="content">
+  <table style="position: relative; top: 100px;">
+    <tr>
+      <td>
+        <div id="test" style="position: absolute; top: 50px;"></div>
+      </td>
+    </tr>
+  </table>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 717819 **/
+var div = document.getElementById("test");
+is(div.offsetTop, 50, "The offsetTop must be calculated correctly");
+is(div.offsetParent, document.querySelector("table"),
+   "The offset should be calculated off of the correct parent");
+
+</script>
+</pre>
+</body>
+</html>
--- a/content/xbl/src/Makefile.in
+++ b/content/xbl/src/Makefile.in
@@ -85,12 +85,11 @@ LOCAL_INCLUDES	= \
 		-I$(srcdir)/../../html/document/src \
 		-I$(srcdir)/../../xml/document/src \
 		-I$(srcdir)/../../xul/content/src \
 		-I$(srcdir)/../../xul/document/src \
 		-I$(srcdir)/../../events/src \
 		-I$(srcdir)/../../../layout/style \
 		-I$(srcdir)/../../../dom/base \
 		-I$(topsrcdir)/xpcom/ds \
-		-I$(srcdir)/../../../js/xpconnect/src \
 		$(NULL)
 
 DEFINES += -D_IMPL_NS_LAYOUT
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -53,16 +53,17 @@
 #include "nsIPrincipal.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsDOMJSUtils.h"
 #include "mozilla/Services.h"
 #include "xpcpublic.h"
 #include "mozilla/scache/StartupCache.h"
 #include "mozilla/scache/StartupCacheUtils.h"
+#include "nsCCUncollectableMarker.h"
 
 using namespace mozilla::scache;
 
 static const char kXBLCachePrefix[] = "xblcache";
 
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 // An XBLDocumentInfo object has a special context associated with it which we can use to pre-compile 
@@ -299,17 +300,17 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
 {
   if (aLangID != nsIProgrammingLanguage::JAVASCRIPT) {
     NS_WARNING("XBL still JS only");
     return NS_ERROR_INVALID_ARG;
   }
   if (mScriptContext)
     return NS_OK; // already initialized for this lang
   nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
-  NS_ENSURE_TRUE(factory, nsnull);
+  NS_ENSURE_TRUE(factory, NS_OK);
 
   nsresult rv;
 
   nsCOMPtr<nsIScriptRuntime> scriptRuntime;
   rv = NS_GetScriptRuntimeByID(aLangID, getter_AddRefs(scriptRuntime));
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIScriptContext> newCtx = scriptRuntime->CreateContext();
   rv = SetScriptContext(aLangID, newCtx);
@@ -322,17 +323,17 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
   // why - see bug 339647)
   JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
 
   nsIPrincipal *principal = GetPrincipal();
   JSCompartment *compartment;
 
   rv = xpc_CreateGlobalObject(cx, &gSharedGlobalClass, principal, nsnull,
                               false, &mJSObject, &compartment);
-  NS_ENSURE_SUCCESS(rv, nsnull);
+  NS_ENSURE_SUCCESS(rv, NS_OK);
 
   ::JS_SetGlobalObject(cx, mJSObject);
 
   // Add an owning reference from JS back to us. This'll be
   // released when the JSObject is finalized.
   ::JS_SetPrivate(cx, mJSObject, this);
   NS_ADDREF(this);
   return NS_OK;
@@ -461,16 +462,21 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLDocu
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXBLDocumentInfo)
   if (tmp->mBindingTable) {
     tmp->mBindingTable->Enumerate(UnlinkProtoJSObjects, nsnull);
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocument)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobalObject)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo)
+  if (tmp->mDocument &&
+      nsCCUncollectableMarker::InGeneration(cb, tmp->mDocument->GetMarkedCCGeneration())) {
+    NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
+    return NS_SUCCESS_INTERRUPTED_TRAVERSE;
+  }
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument)
   if (tmp->mBindingTable) {
     tmp->mBindingTable->Enumerate(TraverseProtos, &cb);
   }
   cb.NoteXPCOMChild(static_cast<nsIScriptGlobalObject*>(tmp->mGlobalObject));
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXBLDocumentInfo)
--- a/content/xul/document/src/nsXULContentSink.cpp
+++ b/content/xul/document/src/nsXULContentSink.cpp
@@ -42,17 +42,18 @@
 /*
  * An implementation for a Gecko-style content sink that knows how
  * to build a content model (the "prototype" document) from XUL.
  *
  * For more information on XUL,
  * see http://developer.mozilla.org/en/docs/XUL
  */
 
-#include "jscntxt.h"  // for JSVERSION_HAS_XML
+#include "jsapi.h"
+#include "jsfriendapi.h"
 #include "nsXULContentSink.h"
 #include "nsCOMPtr.h"
 #include "nsForwardReference.h"
 #include "nsIContentSink.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMXULDocument.h"
@@ -1055,40 +1056,40 @@ XULContentSinkImpl::OpenScript(const PRU
             }
           }
           // Some js specifics yet to be abstracted.
           if (langID == nsIProgrammingLanguage::JAVASCRIPT) {
               // By default scripts in XUL documents have E4X turned on. We use
               // our implementation knowledge to reuse JSVERSION_HAS_XML as a
               // safe version flag. This is still OK if version is
               // JSVERSION_UNKNOWN (-1),
-              version |= js::VersionFlags::HAS_XML;
+              version = js::VersionSetXML(JSVersion(version), true);
 
               nsAutoString value;
               rv = parser.GetParameter("e4x", value);
               if (NS_FAILED(rv)) {
                   if (rv != NS_ERROR_INVALID_ARG)
                       return rv;
               } else {
                   if (value.Length() == 1 && value[0] == '0')
-                    version &= ~js::VersionFlags::HAS_XML;
+                    version = js::VersionSetXML(JSVersion(version), false);
               }
           }
       }
       else if (key.EqualsLiteral("language")) {
           // Language is deprecated, and the impl in nsScriptLoader ignores the
           // various version strings anyway.  So we make no attempt to support
           // languages other than JS for language=
           nsAutoString lang(aAttributes[1]);
           if (nsParserUtils::IsJavaScriptLanguage(lang, &version)) {
               langID = nsIProgrammingLanguage::JAVASCRIPT;
 
               // Even when JS version < 1.6 is specified, E4X is
               // turned on in XUL.
-              version |= js::VersionFlags::HAS_XML;
+              version = js::VersionSetXML(JSVersion(version), true);
           }
       }
       aAttributes += 2;
   }
   // Not all script languages have a "sandbox" concept.  At time of
   // writing, Python is the only other language, and it does not.
   // For such languages, neither any inline script nor remote script are
   // safe to execute from untrusted sources.
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4727,18 +4727,17 @@ nsDocShell::Repaint(bool aForce)
 {
     nsCOMPtr<nsIPresShell> presShell;
     GetPresShell(getter_AddRefs(presShell));
     NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
 
     nsIViewManager* viewManager = presShell->GetViewManager();
     NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
 
-    // what about aForce ?
-    NS_ENSURE_SUCCESS(viewManager->UpdateAllViews(0), NS_ERROR_FAILURE);
+    NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetParentWidget(nsIWidget ** parentWidget)
 {
     NS_ENSURE_ARG_POINTER(parentWidget);
 
@@ -7319,17 +7318,17 @@ nsDocShell::RestoreFromHistory()
 
         newVM = shell->GetViewManager();
         if (newVM) {
             // When we insert the root view above the resulting invalidate is
             // dropped because painting is suppressed in the presshell until we
             // call Thaw. So we issue the invalidate here.
             newRootView = newVM->GetRootView();
             if (newRootView) {
-                newVM->UpdateView(newRootView, NS_VMREFRESH_NO_SYNC);
+                newVM->InvalidateView(newRootView);
             }
         }
     }
 
     return privWin->FireDelayedDOMEvents();
 }
 
 NS_IMETHODIMP
--- a/dom/base/Makefile.in
+++ b/dom/base/Makefile.in
@@ -47,24 +47,28 @@ LIBRARY_NAME	= jsdombase_s
 LIBXUL_LIBRARY	= 1
 FORCE_STATIC_LIB = 1
 
 EXTRA_PP_COMPONENTS = \
 		ConsoleAPI.js \
 		ConsoleAPI.manifest \
 		$(NULL)
 
+EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
+		$(NULL)
+
+ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_COMPONENTS = \
 	        Webapps.js \
 	        Webapps.manifest \
 		$(NULL)
 
-EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
-                Webapps.jsm \
+EXTRA_JS_MODULES += Webapps.jsm \
 		$(NULL)
+endif
 
 XPIDLSRCS = \
   nsIEntropyCollector.idl \
   nsIScriptChannel.idl \
   $(NULL)
 
 EXPORTS = \
   nsDOMCID.h \
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -37,18 +37,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 // JavaScript includes
 #include "jsapi.h"
+#include "jsfriendapi.h"
 #include "jsprvtd.h"    // we are using private JS typedefs...
-#include "jscntxt.h"
 #include "jsdbgapi.h"
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
 
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 
 #include "nscore.h"
@@ -5380,17 +5380,17 @@ nsWindowSH::GetProperty(nsIXPConnectWrap
         // the window, so no need to wrap it again).
 
         return NS_SUCCESS_I_DID_SOMETHING;
       }
     }
   }
 
   if (id == sWrappedJSObject_id &&
-      xpc::AccessCheck::isChrome(cx->compartment)) {
+      xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
     obj = JS_ObjectToOuterObject(cx, obj);
     *vp = OBJECT_TO_JSVAL(obj);
     return NS_SUCCESS_I_DID_SOMETHING;
   }
 
   return NS_OK;
 }
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -757,37 +757,16 @@ nsDOMWindowUtils::CycleCollect(nsICycleC
   }
 #endif
 
   nsJSContext::CycleCollectNow(aListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::ProcessUpdates()
-{
-  nsPresContext* presContext = GetPresContext();
-  if (!presContext)
-    return NS_ERROR_UNEXPECTED;
-
-  nsIPresShell* shell = presContext->GetPresShell();
-  if (!shell)
-    return NS_ERROR_UNEXPECTED;
-
-  nsIViewManager *viewManager = shell->GetViewManager();
-  if (!viewManager)
-    return NS_ERROR_UNEXPECTED;
-  
-  nsIViewManager::UpdateViewBatch batch;
-  batch.BeginUpdateViewBatch(viewManager);
-  batch.EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
                                          float aX,
                                          float aY,
                                          PRUint32 aDirection,
                                          PRFloat64 aDelta,
                                          PRInt32 aModifiers)
 {
   if (!IsUniversalXPConnectCapable()) {
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -156,21 +156,23 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFocusedContent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstBlurEvent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstFocusEvent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mWindowBeingLowered)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 nsFocusManager* nsFocusManager::sInstance = nsnull;
 bool nsFocusManager::sMouseFocusesFormControl = false;
+bool nsFocusManager::sTestMode = false;
 
 static const char* kObservedPrefs[] = {
   "accessibility.browsewithcaret",
   "accessibility.tabfocus_applies_to_xul",
   "accessibility.mouse_focuses_formcontrol",
+  "focusmanager.testmode",
   NULL
 };
 
 nsFocusManager::nsFocusManager()
 { }
 
 nsFocusManager::~nsFocusManager()
 {
@@ -193,16 +195,18 @@ nsFocusManager::Init()
 
   nsIContent::sTabFocusModelAppliesToXUL =
     Preferences::GetBool("accessibility.tabfocus_applies_to_xul",
                          nsIContent::sTabFocusModelAppliesToXUL);
 
   sMouseFocusesFormControl =
     Preferences::GetBool("accessibility.mouse_focuses_formcontrol", false);
 
+  sTestMode = Preferences::GetBool("focusmanager.testmode", false);
+
   Preferences::AddWeakObservers(fm, kObservedPrefs);
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     obs->AddObserver(fm, "xpcom-shutdown", true);
   }
 
   return NS_OK;
@@ -230,16 +234,19 @@ nsFocusManager::Observe(nsISupports *aSu
         Preferences::GetBool("accessibility.tabfocus_applies_to_xul",
                              nsIContent::sTabFocusModelAppliesToXUL);
     }
     else if (data.EqualsLiteral("accessibility.mouse_focuses_formcontrol")) {
       sMouseFocusesFormControl =
         Preferences::GetBool("accessibility.mouse_focuses_formcontrol",
                              false);
     }
+    else if (data.EqualsLiteral("focusmanager.testmode")) {
+      sTestMode = Preferences::GetBool("focusmanager.testmode", false);
+    }
   } else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
     mActiveWindow = nsnull;
     mFocusedWindow = nsnull;
     mFocusedContent = nsnull;
     mFirstBlurEvent = nsnull;
     mFirstFocusEvent = nsnull;
     mWindowBeingLowered = nsnull;
     mDelayedBlurFocusEvents.Clear();
@@ -1059,17 +1066,17 @@ nsFocusManager::NotifyFocusStateChange(n
     aContent->AsElement()->RemoveStates(eventState);
   }
 }
 
 // static
 void
 nsFocusManager::EnsureCurrentWidgetFocused()
 {
-  if (!mFocusedWindow)
+  if (!mFocusedWindow || sTestMode)
     return;
 
   // get the main child widget for the focused window and ensure that the
   // platform knows that this widget is focused.
   nsCOMPtr<nsIDocShell> docShell = mFocusedWindow->GetDocShell();
   if (docShell) {
     nsCOMPtr<nsIPresShell> presShell;
     docShell->GetPresShell(getter_AddRefs(presShell));
@@ -1565,17 +1572,17 @@ nsFocusManager::Blur(nsPIDOMWindow* aWin
 
     // if an object/plug-in/remote browser is being blurred, move the system focus
     // to the parent window, otherwise events will still get fired at the plugin.
     // But don't do this if we are blurring due to the window being lowered,
     // otherwise, the parent window can get raised again.
     if (mActiveWindow) {
       nsIFrame* contentFrame = content->GetPrimaryFrame();
       nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
-      if (aAdjustWidgets && objectFrame) {
+      if (aAdjustWidgets && objectFrame && !sTestMode) {
         // note that the presshell's widget is being retrieved here, not the one
         // for the object frame.
         nsIViewManager* vm = presShell->GetViewManager();
         if (vm) {
           nsCOMPtr<nsIWidget> widget;
           vm->GetRootWidget(getter_AddRefs(widget));
           if (widget)
             widget->SetFocus(false);
@@ -1739,17 +1746,17 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
   // own widget and is either already focused or is about to be focused.
   nsCOMPtr<nsIWidget> objectFrameWidget;
   if (aContent) {
     nsIFrame* contentFrame = aContent->GetPrimaryFrame();
     nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
     if (objectFrame)
       objectFrameWidget = objectFrame->GetWidget();
   }
-  if (aAdjustWidgets && !objectFrameWidget) {
+  if (aAdjustWidgets && !objectFrameWidget && !sTestMode) {
     nsIViewManager* vm = presShell->GetViewManager();
     if (vm) {
       nsCOMPtr<nsIWidget> widget;
       vm->GetRootWidget(getter_AddRefs(widget));
       if (widget)
         widget->SetFocus(false);
     }
   }
@@ -1786,17 +1793,17 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
         ScrollIntoView(presShell, aContent, aFlags);
 
       NotifyFocusStateChange(aContent, aWindow->ShouldShowFocusRing(), true);
 
       // if this is an object/plug-in/remote browser, focus its widget.  Note that we might
       // no longer be in the same document, due to the events we fired above when
       // aIsNewDocument.
       if (presShell->GetDocument() == aContent->GetDocument()) {
-        if (aAdjustWidgets && objectFrameWidget)
+        if (aAdjustWidgets && objectFrameWidget && !sTestMode)
           objectFrameWidget->SetFocus(false);
 
         // if the object being focused is a remote browser, activate remote content
         TabParent* remote = GetRemoteForContent(aContent);
         if (remote) {
           remote->Activate();
 #ifdef DEBUG_FOCUS
           printf("*Remote browser activated\n");
@@ -1828,17 +1835,18 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
       }
     }
   }
   else {
     // If the window focus event (fired above when aIsNewDocument) caused
     // the plugin not to be focusable, update the system focus by focusing
     // the root widget.
     if (aAdjustWidgets && objectFrameWidget &&
-        mFocusedWindow == aWindow && mFocusedContent == nsnull) {
+        mFocusedWindow == aWindow && mFocusedContent == nsnull &&
+        !sTestMode) {
       nsIViewManager* vm = presShell->GetViewManager();
       if (vm) {
         nsCOMPtr<nsIWidget> widget;
         vm->GetRootWidget(getter_AddRefs(widget));
         if (widget)
           widget->SetFocus(false);
       }
     }
@@ -1960,16 +1968,25 @@ nsFocusManager::ScrollIntoView(nsIPresSh
 void
 nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
 {
   // don't raise windows that are already raised or are in the process of
   // being lowered
   if (!aWindow || aWindow == mActiveWindow || aWindow == mWindowBeingLowered)
     return;
 
+  if (sTestMode) {
+    // In test mode, emulate the existing window being lowered and the new
+    // window being raised.
+    if (mActiveWindow)
+      WindowLowered(mActiveWindow);
+    WindowRaised(aWindow);
+    return;
+  }
+
 #if defined(XP_WIN) || defined(XP_OS2)
   // Windows would rather we focus the child widget, otherwise, the toplevel
   // widget will always end up being focused. Fortunately, focusing the child
   // widget will also have the effect of raising the window this widget is in.
   // But on other platforms, we can just focus the toplevel widget to raise
   // the window.
   nsCOMPtr<nsPIDOMWindow> childWindow;
   GetFocusedDescendant(aWindow, true, getter_AddRefs(childWindow));
--- a/dom/base/nsFocusManager.h
+++ b/dom/base/nsFocusManager.h
@@ -522,16 +522,18 @@ private:
   // A document which is handling a mouse button down event.
   // When a mouse down event process is finished, ESM sets focus to the target
   // content.  Therefore, while DOM event handlers are handling mouse down
   // events, the handlers should be able to steal focus from any elements even
   // if focus is in chrome content.  So, if this isn't NULL and the caller
   // can access the document node, the caller should succeed in moving focus.
   nsCOMPtr<nsIDocument> mMouseDownEventHandlingDocument;
 
+  static bool sTestMode;
+
   // the single focus manager
   static nsFocusManager* sInstance;
 };
 
 nsresult
 NS_NewFocusManager(nsIFocusManager** aResult);
 
 #endif
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -252,18 +252,16 @@
 #include "mozilla/Telemetry.h"
 #include "nsLocation.h"
 #include "nsWrapperCacheInlines.h"
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
-#include "jscntxt.h" // cx->runtime->structuredCloneCallbacks
-
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDOMLeakPRLog;
 #endif
 
 static const char kStorageEnabled[] = "dom.storage.enabled";
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -6026,17 +6024,17 @@ PostMessageReadStructuredClone(JSContext
                                                     getter_AddRefs(wrapper)))) {
           return JSVAL_TO_OBJECT(val);
         }
       }
     }
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    cx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(cx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->read(cx, reader, tag, data, nsnull);
   }
 
   return JS_FALSE;
 }
 
@@ -6066,17 +6064,17 @@ PostMessageWriteStructuredClone(JSContex
 
     if (scTag)
       return JS_WriteUint32Pair(writer, scTag, 0) &&
              JS_WriteBytes(writer, &supports, sizeof(supports)) &&
              scInfo->event->StoreISupports(supports);
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    cx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(cx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->write(cx, writer, obj, nsnull);
   }
 
   return JS_FALSE;
 }
 
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -32,17 +32,16 @@
  * 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 ***** */
 
-#include "jscntxt.h"
 #include "nsJSEnvironment.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsDOMCID.h"
 #include "nsIServiceManager.h"
@@ -707,18 +706,17 @@ nsJSContext::DOMOperationCallback(JSCont
   // If we get here we're most likely executing an infinite loop in JS,
   // we'll tell the user about this and we'll give the user the option
   // of stopping the execution of the script.
   nsCOMPtr<nsIPrompt> prompt = GetPromptFromContext(ctx);
   NS_ENSURE_TRUE(prompt, JS_FALSE);
 
   // Check if we should offer the option to debug
   JSStackFrame* fp = ::JS_GetScriptedCaller(cx, NULL);
-  bool debugPossible = (fp != nsnull && cx->debugHooks &&
-                          cx->debugHooks->debuggerHandler != nsnull);
+  bool debugPossible = fp && js::CanCallContextDebugHandler(cx);
 #ifdef MOZ_JSDEBUGGER
   // Get the debugger service if necessary.
   if (debugPossible) {
     bool jsds_IsOn = false;
     const char jsdServiceCtrID[] = "@mozilla.org/js/jsd/debugger-service;1";
     nsCOMPtr<jsdIExecutionHook> jsdHook;
     nsCOMPtr<jsdIDebuggerService> jsds = do_GetService(jsdServiceCtrID, &rv);
 
@@ -837,20 +835,17 @@ nsJSContext::DOMOperationCallback(JSCont
     }
 
     ctx->mOperationCallbackTime = PR_Now();
     return JS_TRUE;
   }
   else if ((buttonPressed == 2) && debugPossible) {
     // Debug the script
     jsval rval;
-    switch(cx->debugHooks->debuggerHandler(cx, script, ::JS_GetFramePC(cx, fp),
-                                           &rval,
-                                           cx->debugHooks->
-                                           debuggerHandlerData)) {
+    switch (js::CallContextDebugHandler(cx, script, JS_GetFramePC(cx, fp), &rval)) {
       case JSTRAP_RETURN:
         JS_SetFrameReturnValue(cx, fp, rval);
         return JS_TRUE;
       case JSTRAP_ERROR:
         JS_ClearPendingException(cx);
         return JS_FALSE;
       case JSTRAP_THROW:
         JS_SetPendingException(cx, rval);
@@ -1126,17 +1121,17 @@ nsJSContext::DestroyJSContext()
   mContext = nsnull;
 }
 
 // QueryInterface implementation for nsJSContext
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSContext)
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSContext)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
-  NS_ASSERTION(!tmp->mContext || tmp->mContext->outstandingRequests == 0,
+  NS_ASSERTION(!tmp->mContext || js::GetContextOutstandingRequests(tmp->mContext) == 0,
                "Trying to unlink a context with outstanding requests.");
   tmp->mIsInitialized = false;
   tmp->mGCOnDestruction = false;
   tmp->DestroyJSContext();
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobalObjectRef)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSContext)
   NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSContext, tmp->GetCCRefcnt())
@@ -1156,17 +1151,17 @@ NS_INTERFACE_MAP_END
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsJSContext)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSContext)
 
 nsrefcnt
 nsJSContext::GetCCRefcnt()
 {
   nsrefcnt refcnt = mRefCnt.get();
   if (NS_LIKELY(mContext))
-    refcnt += mContext->outstandingRequests;
+    refcnt += js::GetContextOutstandingRequests(mContext);
   return refcnt;
 }
 
 nsresult
 nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
                                      JSObject* aScopeObject,
                                      nsIPrincipal *aPrincipal,
                                      const char *aURL,
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -36,17 +36,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "IDBObjectStore.h"
 
 #include "nsIJSContextStack.h"
 
-#include "jsclone.h"
+#include "jsfriendapi.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/storage.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMFile.h"
 #include "nsDOMLists.h"
 #include "nsEventDispatcher.h"
@@ -1018,17 +1018,17 @@ IDBObjectStore::StructuredCloneReadCallb
       NS_WARNING("Failed to wrap native!");
       return nsnull;
     }
 
     return JSVAL_TO_OBJECT(wrappedFile);
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    aCx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(aCx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->read(aCx, aReader, aTag, aData, nsnull);
   }
 
   return nsnull;
 }
 
@@ -1099,17 +1099,17 @@ IDBObjectStore::StructuredCloneWriteCall
       cloneWriteInfo->mBlobs.AppendElement(blob);
 
       return true;
     }
   }
 
   // try using the runtime callbacks
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    aCx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(aCx);
   if (runtimeCallbacks) {
     return runtimeCallbacks->write(aCx, aWriter, aObj, nsnull);
   }
 
   return false;
 }
 
 nsresult
--- a/dom/indexedDB/Key.cpp
+++ b/dom/indexedDB/Key.cpp
@@ -34,17 +34,17 @@
  * 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 ***** */
 
 #include "Key.h"
 #include "nsIStreamBufferAccess.h"
-#include "jsdate.h"
+#include "jsfriendapi.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "xpcpublic.h"
 
 USING_INDEXEDDB_NAMESPACE
 
 /*
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -64,17 +64,17 @@ interface nsIDOMHTMLCanvasElement;
 interface nsIDOMEvent;
 interface nsITransferable;
 interface nsIQueryContentEventResult;
 interface nsIDOMWindow;
 interface nsIDOMBlob;
 interface nsIDOMFile;
 interface nsIFile;
 
-[scriptable, uuid(15fcceb0-37ea-11e1-b86c-0800200c9a66)]
+[scriptable, uuid(b9c1f815-c2f2-4607-a060-6a8566581927)]
 interface nsIDOMWindowUtils : nsISupports {
 
   /**
    * Image animation mode of the window. When this attribute's value
    * is changed, the implementation should set all images in the window
    * to the given value. That is, when set to kDontAnimMode, all images
    * will stop animating. The attribute's value must be one of the
    * animationMode values from imgIContainer.
@@ -373,22 +373,16 @@ interface nsIDOMWindowUtils : nsISupport
    * privileges in non-debug builds. Available to all callers in debug builds.
    *
    * @param aListener listener that receives information about the CC graph
    *                  (see @mozilla.org/cycle-collector-logger;1 for a logger
    *                   component)
    */
   void cycleCollect([optional] in nsICycleCollectorListener aListener);
 
-  /**
-   * Force processing of any queued paints
-   */
-
-  void processUpdates();
-
   /** Synthesize a simple gesture event for a window. The event types
    *  supported are: MozSwipeGesture, MozMagnifyGestureStart,
    *  MozMagnifyGestureUpdate, MozMagnifyGesture, MozRotateGestureStart,
    *  MozRotateGestureUpdate, MozRotateGesture, MozPressTapGesture, and
    *  MozTapGesture.
    *
    * Cannot be accessed from unprivileged context (not
    * content-accessible) Will throw a DOM security error if called
--- a/dom/plugins/base/android/ANPSurface.cpp
+++ b/dom/plugins/base/android/ANPSurface.cpp
@@ -161,27 +161,27 @@ static int bytesPerPixel(int32_t format)
     default: return -1;
   }
 }
 
 static bool init() {
   if (gSurfaceFunctions.initialized)
     return true;
 
-  void* handle = dlopen("/system/lib/libsurfaceflinger_client.so", RTLD_LAZY);
+  void* handle = dlopen("libsurfaceflinger_client.so", RTLD_LAZY);
 
   if (!handle) {
     LOG("Failed to open libsurfaceflinger_client.so");
     return false;
   }
 
   gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionEb");
   gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv");
 
-  handle = dlopen("/system/lib/libui.so", RTLD_LAZY);
+  handle = dlopen("libui.so", RTLD_LAZY);
   if (!handle) {
     LOG("Failed to open libui.so");
     return false;
   }
 
   gSurfaceFunctions.regionConstructor = (void* (*)(void*))dlsym(handle, "_ZN7android6RegionC1Ev");
   gSurfaceFunctions.setRegion = (void (*)(void*, ARect const&))dlsym(handle, "_ZN7android6Region3setERKNS_4RectE");
 
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -34,18 +34,16 @@
  * 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 ***** */
 
 #include "base/basictypes.h"
 
 #include "jsapi.h"
-// FIXME(bug 332648): Give me a real API please!
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsJSNPRuntime.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -616,18 +616,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Inv
   }
 
 #ifndef XP_MACOSX
   // Windowed plugins should not be calling NPN_InvalidateRect, but
   // Silverlight does and expects it to "work"
   if (mWidget) {
     mWidget->Invalidate(nsIntRect(invalidRect->left, invalidRect->top,
                                   invalidRect->right - invalidRect->left,
-                                  invalidRect->bottom - invalidRect->top),
-                        false);
+                                  invalidRect->bottom - invalidRect->top));
     return NS_OK;
   }
 #endif
 
   nsPresContext* presContext = mObjectFrame->PresContext();
   nsRect rect(presContext->DevPixelsToAppUnits(invalidRect->left),
               presContext->DevPixelsToAppUnits(invalidRect->top),
               presContext->DevPixelsToAppUnits(invalidRect->right - invalidRect->left),
@@ -649,22 +648,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::Inv
 
 NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(NPRegion invalidRegion)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
 {
-  NS_ENSURE_TRUE(mObjectFrame, NS_ERROR_NULL_POINTER);
-  nsIView* view = mObjectFrame->GetView();
-  if (view) {
-    return view->GetViewManager()->Composite();
-  }
-
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
 {
   if (!mObjectFrame) {
     NS_WARNING("plugin owner has no owner in getting doc's window handle");
     return NS_ERROR_FAILURE;
--- a/dom/sms/src/SmsMessage.cpp
+++ b/dom/sms/src/SmsMessage.cpp
@@ -34,17 +34,17 @@
  * 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 ***** */
 
 #include "SmsMessage.h"
 #include "nsIDOMClassInfo.h"
 #include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
-#include "jsdate.h" // For js_DateGetMsecSinceEpoch
+#include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch
 #include "Constants.h"
 
 DOMCI_DATA(MozSmsMessage, mozilla::dom::sms::SmsMessage)
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
--- a/dom/wifi/libcutils.js
+++ b/dom/wifi/libcutils.js
@@ -1,13 +1,13 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 
 "use strict";
 
 let libcutils = (function () {
-  let library = ctypes.open("/system/lib/libcutils.so");
+  let library = ctypes.open("libcutils.so");
 
   return {
     property_get: library.declare("property_get", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.char.ptr, ctypes.char.ptr),
     property_set: library.declare("property_set", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.char.ptr)
   };
 })();
--- a/dom/wifi/libhardware_legacy.js
+++ b/dom/wifi/libhardware_legacy.js
@@ -1,15 +1,15 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 
 "use strict";
 
 let libhardware_legacy = (function () {
-  let library = ctypes.open("/system/lib/libhardware_legacy.so");
+  let library = ctypes.open("libhardware_legacy.so");
 
   return {
     // Load wifi driver, 0 on success, < 0 on failure.
     load_driver: library.declare("wifi_load_driver", ctypes.default_abi, ctypes.int),
 
     // Unload wifi driver, 0 on success, < 0 on failure.
     unload_driver: library.declare("wifi_unload_driver", ctypes.default_abi, ctypes.int),
 
--- a/dom/wifi/libnetutils.js
+++ b/dom/wifi/libnetutils.js
@@ -1,15 +1,15 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 
 "use strict";
 
 let libnetutils = (function () {
-  let library = ctypes.open("/system/lib/libnetutils.so");
+  let library = ctypes.open("libnetutils.so");
 
   return {
     ifc_enable: library.declare("ifc_enable", ctypes.default_abi, ctypes.int, ctypes.char.ptr),
     ifc_disable: library.declare("ifc_disable", ctypes.default_abi, ctypes.int, ctypes.char.ptr),
     ifc_add_host_route: library.declare("ifc_add_host_route", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int),
     ifc_remove_host_routes: library.declare("ifc_remove_host_routes", ctypes.default_abi, ctypes.int, ctypes.char.ptr),
     ifc_set_default_route: library.declare("ifc_set_default_route", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int),
     ifc_get_default_route: library.declare("ifc_get_default_route", ctypes.default_abi, ctypes.int, ctypes.char.ptr),
--- a/dom/workers/EventTarget.cpp
+++ b/dom/workers/EventTarget.cpp
@@ -34,17 +34,17 @@
  * 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 ***** */
 
 #include "EventTarget.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
+#include "jsfriendapi.h"
 #include "nsTraceRefcnt.h"
 
 #include "WorkerInlines.h"
 
 USING_WORKERS_NAMESPACE
 
 using mozilla::dom::workers::events::EventTarget;
 
--- a/dom/workers/Events.cpp
+++ b/dom/workers/Events.cpp
@@ -37,17 +37,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "Events.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "nsTraceRefcnt.h"
 
 #include "WorkerInlines.h"
 #include "WorkerPrivate.h"
 
 #define PROPERTY_FLAGS \
--- a/dom/workers/Exceptions.cpp
+++ b/dom/workers/Exceptions.cpp
@@ -37,17 +37,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "Exceptions.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 #include "jsprf.h"
 
 #include "nsTraceRefcnt.h"
 
 #include "WorkerInlines.h"
 
 #define PROPERTY_FLAGS \
--- a/dom/workers/File.cpp
+++ b/dom/workers/File.cpp
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "File.h"
 
 #include "nsIDOMFile.h"
 
 #include "jsapi.h"
 #include "jsatom.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 #include "nsCOMPtr.h"
 #include "nsJSUtils.h"
 #include "nsStringGlue.h"
 
 #include "Exceptions.h"
 #include "WorkerInlines.h"
 #include "WorkerPrivate.h"
--- a/dom/workers/FileReaderSync.cpp
+++ b/dom/workers/FileReaderSync.cpp
@@ -38,17 +38,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "FileReaderSync.h"
 
 #include "nsIDOMFile.h"
 
 #include "jsapi.h"
 #include "jsatom.h"
-#include "jscntxt.h"
+#include "jsfriendapi.h"
 #include "jstypedarray.h"
 #include "nsJSUtils.h"
 
 #include "Exceptions.h"
 #include "File.h"
 #include "FileReaderSyncPrivate.h"
 #include "WorkerInlines.h"
 
--- a/dom/workers/ListenerManager.cpp
+++ b/dom/workers/ListenerManager.cpp
@@ -35,18 +35,19 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "ListenerManager.h"
 
+#include "jsalloc.h"
 #include "jsapi.h"
-#include "jscntxt.h"
+#include "jsfriendapi.h"
 #include "js/Vector.h"
 
 #include "Events.h"
 
 using namespace mozilla;
 using dom::workers::events::ListenerManager;
 
 namespace {
@@ -311,16 +312,35 @@ ListenerManager::GetEventListener(JSCont
         return true;
       }
     }
   }
   *aListenerVal = JSVAL_VOID;
   return true;
 }
 
+class ExternallyUsableContextAllocPolicy
+{
+    JSContext *const cx;
+
+  public:
+    ExternallyUsableContextAllocPolicy(JSContext *cx) : cx(cx) {}
+    JSContext *context() const { return cx; }
+    void *malloc_(size_t bytes) {
+        JSAutoRequest ar(cx);
+        return JS_malloc(cx, bytes);
+    }
+    void *realloc_(void *p, size_t oldBytes, size_t bytes) {
+        JSAutoRequest ar(cx);
+        return JS_realloc(cx, p, bytes);
+    }
+    void free_(void *p) { JS_free(cx, p); }
+    void reportAllocOverflow() const { JS_ReportAllocationOverflow(cx); }
+};
+
 bool
 ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
                                JSObject* aEvent, bool* aPreventDefaultCalled)
 {
   if (!events::IsSupportedEventClass(aCx, aEvent)) {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_METHOD,
                          "EventTarget", "dispatchEvent", "Event object");
@@ -362,18 +382,18 @@ ListenerManager::DispatchEvent(JSContext
   ListenerCollection* collection =
     GetCollectionForType(&mCollectionHead,
                          INTERNED_STRING_TO_JSID(aCx, eventType));
   if (!collection) {
     *aPreventDefaultCalled = false;
     return true;
   }
 
-  js::ContextAllocPolicy ap(aCx);
-  js::Vector<jsval, 10, js::ContextAllocPolicy> listeners(ap);
+  ExternallyUsableContextAllocPolicy ap(aCx);
+  js::Vector<jsval, 10, ExternallyUsableContextAllocPolicy> listeners(ap);
 
   for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
        elem != &collection->mListenerHead;
        elem = PR_NEXT_LINK(elem)) {
     Listener* listener = static_cast<Listener*>(elem);
 
     // Listeners that don't want untrusted events will be skipped if this is an
     // untrusted event.
--- a/dom/workers/Location.cpp
+++ b/dom/workers/Location.cpp
@@ -34,17 +34,16 @@
  * 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 ***** */
 
 #include "Location.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "nsTraceRefcnt.h"
 
 #define PROPERTY_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED
 
 USING_WORKERS_NAMESPACE
--- a/dom/workers/Navigator.cpp
+++ b/dom/workers/Navigator.cpp
@@ -34,17 +34,16 @@
  * 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 ***** */
 
 #include "Navigator.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "nsTraceRefcnt.h"
 
 #include "RuntimeService.h"
 
 #define PROPERTY_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED
--- a/dom/workers/Worker.cpp
+++ b/dom/workers/Worker.cpp
@@ -34,17 +34,17 @@
  * 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 ***** */
 
 #include "Worker.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
+#include "jsfriendapi.h"
 
 #include "EventTarget.h"
 #include "RuntimeService.h"
 #include "WorkerPrivate.h"
 
 #include "WorkerInlines.h"
 
 #define PROPERTY_FLAGS \
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -51,17 +51,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsITextToSubURI.h"
 #include "nsITimer.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsIXPConnect.h"
 
-#include "jscntxt.h"
+#include "jsfriendapi.h"
 #include "jsdbgapi.h"
 #include "jsprf.h"
 #include "js/MemoryMetrics.h"
 
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMJSUtils.h"
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "WorkerScope.h"
 
 #include "jsapi.h"
 #include "jsdbgapi.h"
-#include "jscntxt.h"
 
 #include "nsTraceRefcnt.h"
 #include "xpcpublic.h"
 
 #include "ChromeWorkerScope.h"
 #include "Events.h"
 #include "EventTarget.h"
 #include "Exceptions.h"
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -34,17 +34,16 @@
  * 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 ***** */
 
 #include "XMLHttpRequest.h"
 
 #include "jsapi.h"
-#include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "Exceptions.h"
 #include "WorkerPrivate.h"
 #include "XMLHttpRequestPrivate.h"
 
 #include "WorkerInlines.h"
 
--- a/editor/idl/nsIPlaintextEditor.idl
+++ b/editor/idl/nsIPlaintextEditor.idl
@@ -32,17 +32,17 @@
  * 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 ***** */
  
 #include "nsISupports.idl"
 
-[scriptable, uuid(05d312ef-8914-494e-91c9-2be8ed7f8e29)]
+[scriptable, uuid(07b6d070-ccea-4a00-84b4-f4b94dd9eb52)]
 interface nsIPlaintextEditor : nsISupports
 {
 
   // XXX Why aren't these in nsIEditor?
   // only plain text entry is allowed via events
   const long eEditorPlaintextMask       = 0x0001;
   // enter key and CR-LF handled specially
   const long eEditorSingleLineMask      = 0x0002;
@@ -51,39 +51,37 @@ interface nsIPlaintextEditor : nsISuppor
   // editing events are disabled.  Editor may still accept focus.
   const long eEditorReadonlyMask        = 0x0008;
   // all events are disabled (like scrolling).  Editor will not accept focus.
   const long eEditorDisabledMask        = 0x0010;
   // text input is limited to certain character types, use mFilter
   const long eEditorFilterInputMask     = 0x0020;
   // use mail-compose editing rules
   const long eEditorMailMask            = 0x0040;
-  // prevent immediate reflows and view refreshes
-  const long eEditorUseAsyncUpdatesMask = 0x0080;
   // allow the editor to set font: monospace on the root node
-  const long eEditorEnableWrapHackMask  = 0x0100;
+  const long eEditorEnableWrapHackMask  = 0x0080;
   // bit for widgets (form elements)
-  const long eEditorWidgetMask          = 0x0200;
+  const long eEditorWidgetMask          = 0x0100;
   // this HTML editor should not create css styles
-  const long eEditorNoCSSMask           = 0x0400;
+  const long eEditorNoCSSMask           = 0x0200;
   // whether HTML document specific actions are executed or not.
   // e.g., if this flag is set, the editor doesn't handle Tab key.
   // besides, anchors of HTML are not clickable.
-  const long eEditorAllowInteraction    = 0x0800;
+  const long eEditorAllowInteraction    = 0x0400;
   // when this is set, the characters in password editor are always masked.
   // see bug 530367 for the detail.
-  const long eEditorDontEchoPassword    = 0x1000;
+  const long eEditorDontEchoPassword    = 0x0800;
   // when this flag is set, the internal direction of the editor is RTL.
   // if neither of the direction flags are set, the direction is determined
   // from the text control's content node.
-  const long eEditorRightToLeft         = 0x2000;
+  const long eEditorRightToLeft         = 0x1000;
   // when this flag is set, the internal direction of the editor is LTR.
-  const long eEditorLeftToRight         = 0x4000;
+  const long eEditorLeftToRight         = 0x2000;
   // when this flag is set, the editor's text content is not spell checked.
-  const long eEditorSkipSpellCheck      = 0x8000;
+  const long eEditorSkipSpellCheck      = 0x4000;
 
   /*
    * The valid values for newlines handling.
    * Can't change the values unless we remove
    * use of the pref.
    */
   const long eNewlinesPasteIntact                = 0;
   const long eNewlinesPasteToFirst               = 1;
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -4201,25 +4201,16 @@ nsresult nsEditor::BeginUpdateViewBatch(
     nsCOMPtr<nsISelection> selection;
     GetSelection(getter_AddRefs(selection));
 
     if (selection) 
     {
       nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
       selPrivate->StartBatchChanges();
     }
-
-    // Turn off view updating.
-    nsCOMPtr<nsIPresShell> ps = GetPresShell();
-    if (ps) {
-      nsCOMPtr<nsIViewManager> viewManager = ps->GetViewManager();
-      if (viewManager) {
-        mBatch.BeginUpdateViewBatch(viewManager);
-      }
-    }
   }
 
   mUpdateCount++;
 
   return NS_OK;
 }
 
 
@@ -4245,30 +4236,16 @@ nsresult nsEditor::EndUpdateViewBatch()
     nsRefPtr<nsCaret> caret;
     nsCOMPtr<nsIPresShell> presShell = GetPresShell();
 
     if (presShell)
       caret = presShell->GetCaret();
 
     StCaretHider caretHider(caret);
 
-    PRUint32 flags = 0;
-
-    GetFlags(&flags);
-
-    // Turn view updating back on.
-    PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;
-
-    // If we're doing async updates, use NS_VMREFRESH_DEFERRED here, so that
-    // the reflows we caused will get processed before the invalidates.
-    if (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask) {
-      updateFlag = NS_VMREFRESH_DEFERRED;
-    }
-    mBatch.EndUpdateViewBatch(updateFlag);
-
     // Turn selection updating and notifications back on.
 
     nsCOMPtr<nsISelection>selection;
     GetSelection(getter_AddRefs(selection));
 
     if (selection) {
       nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection));
       selPrivate->EndBatchChanges();
@@ -4975,29 +4952,18 @@ nsEditor::CreateTxnForDeleteInsertionPoi
   return result;
 }
 
 nsresult 
 nsEditor::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
                       nsIDOMNode *aEndParent, PRInt32 aEndOffset,
                       nsIDOMRange **aRange)
 {
-  NS_ADDREF(*aRange = new nsRange());
-
-  nsresult result = (*aRange)->SetStart(aStartParent, aStartOffset);
-
-  if (NS_SUCCEEDED(result))
-    result = (*aRange)->SetEnd(aEndParent, aEndOffset);
-
-  if (NS_FAILED(result))
-  {
-    NS_RELEASE((*aRange));
-    *aRange = 0;
-  }
-  return result;
+  return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
+                              aEndOffset, aRange);
 }
 
 nsresult 
 nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -684,21 +684,16 @@ public:
     return (mFlags & nsIPlaintextEditor::eEditorFilterInputMask) != 0;
   }
 
   bool IsMailEditor() const
   {
     return (mFlags & nsIPlaintextEditor::eEditorMailMask) != 0;
   }
 
-  bool UseAsyncUpdate() const
-  {
-    return (mFlags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask) != 0;
-  }
-
   bool IsWrapHackEnabled() const
   {
     return (mFlags & nsIPlaintextEditor::eEditorEnableWrapHackMask) != 0;
   }
 
   bool IsFormWidget() const
   {
     return (mFlags & nsIPlaintextEditor::eEditorWidgetMask) != 0;
@@ -763,17 +758,16 @@ public:
 
 protected:
 
   PRUint32        mModCount;     // number of modifications (for undo/redo stack)
   PRUint32        mFlags;        // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
 
   nsWeakPtr       mSelConWeak;   // weak reference to the nsISelectionController
   PRInt32         mUpdateCount;
-  nsIViewManager::UpdateViewBatch mBatch;
 
   // Spellchecking
   enum Tristate {
     eTriUnset,
     eTriFalse,
     eTriTrue
   }                 mSpellcheckCheckboxState;
   nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -642,16 +642,20 @@ nsEditorEventListener::HandleText(nsIDOM
   textEvent->GetText(composedText);
   textRangeList = textEvent->GetInputRange();
 
   // if we are readonly or disabled, then do nothing.
   if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
     return NS_OK;
   }
 
+  // Transfer the event's trusted-ness to our editor
+  nsCOMPtr<nsIDOMNSEvent> NSEvent = do_QueryInterface(aTextEvent);
+  nsAutoEditorKeypressOperation operation(mEditor, NSEvent);
+
   return mEditor->UpdateIMEComposition(composedText, textRangeList);
 }
 
 /**
  * Drag event implementation
  */
 
 nsresult
--- a/editor/libeditor/base/nsSelectionState.cpp
+++ b/editor/libeditor/base/nsSelectionState.cpp
@@ -697,18 +697,11 @@ nsresult nsRangeStore::StoreRange(nsIDOM
   aRange->GetEndContainer(getter_AddRefs(endNode));
   aRange->GetStartOffset(&startOffset);
   aRange->GetEndOffset(&endOffset);
   return NS_OK;
 }
 
 nsresult nsRangeStore::GetRange(nsRange** outRange)
 {
-  NS_ENSURE_TRUE(outRange, NS_ERROR_NULL_POINTER);
-  *outRange = new nsRange();
-  NS_ADDREF((*outRange));
-
-  nsresult res = (*outRange)->SetStart(startNode, startOffset);
-  if(NS_FAILED(res)) return res;
-
-  res = (*outRange)->SetEnd(endNode, endOffset);
-  return res;
+  return nsRange::CreateRange(startNode, startOffset, endNode, endOffset,
+                              outRange);
 }
--- a/editor/libeditor/base/tests/test_selection_move_commands.xul
+++ b/editor/libeditor/base/tests/test_selection_move_commands.xul
@@ -31,22 +31,26 @@ function execTests() {
   var root = doc.documentElement;
   var body = doc.body;
 
   body.style.fontSize='16px';
   body.style.lineHeight='16px';
   body.style.height='400px';
   body.style.padding='0px';
   body.style.margin='0px';
-  body.style.borderSize='0px';
+  body.style.borderWidth='0px';
 
   var sel = win.getSelection();
   doc.designMode='on';
   body.innerHTML = "1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>";
   win.focus();
+  // Flush out layout to make sure that the subdocument will be the size we
+  // expect by the time we try to scroll it.
+  is(body.getBoundingClientRect().height, 400,
+     "Body height should be what we set it to");
   yield;
 
   function doCommand(cmd) {
     var controller = document.commandDispatcher.getControllerForCommand(cmd);
     if (controller) {
       controller.doCommand(cmd);
     }
   }
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -964,16 +964,17 @@ nsPlaintextEditor::UpdateIMEComposition(
   //   For escape keypress, this causes an empty string to be passed
   //   twice, which freaks out the editor.
 
   // aCompositionString.IsEmpty() && !aTextRangeList:
   //   Some Chinese IMEs for Linux are always composition string and text range
   //   list are empty when listing the Chinese characters. In this case,
   //   we don't need to process composition string too. See bug 271815.
 
+  bool notifyEditorObservers = false;
   if (!aCompositionString.IsEmpty() || (mIMETextNode && aTextRangeList)) {
     mIMETextRangeList = aTextRangeList;
 
     nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
     SetIsIMEComposing(); // We set mIsIMEComposing properly.
 
     rv = InsertText(aCompositionString);
@@ -987,19 +988,22 @@ nsPlaintextEditor::UpdateIMEComposition(
     // second part of 23558 fix:
     if (aCompositionString.IsEmpty()) {
       mIMETextNode = nsnull;
     }
 
     // If still composing, we should fire input event via observer.
     // Note that if committed, we don't need to notify it since it will be
     // notified at followed compositionend event.
-    if (mIsIMEComposing) {
-      NotifyEditorObservers();
-    }
+    // NOTE: We must notify after the auto batch will be gone.
+    notifyEditorObservers = mIsIMEComposing;
+  }
+
+  if (notifyEditorObservers) {
+    NotifyEditorObservers();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsPlaintextEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
 {
--- a/editor/libeditor/text/tests/Makefile.in
+++ b/editor/libeditor/text/tests/Makefile.in
@@ -60,16 +60,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug604532.html \
 		test_bug625452.html \
 		test_bug629172.html \
 		test_bug638596.html \
 		test_bug641466.html \
 		test_bug645914.html \
 		test_bug681229.html \
 		test_bug692520.html \
+		test_bug717147.html \
 		$(NULL)
 
 # disables the key handling test on gtk2 because gtk2 overrides some key events
 # on our editor, and the combinations depend on the system.
 ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 _TEST_FILES += \
 		test_texteditor_keyevent_handling.html \
 		$(NULL)
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/text/tests/test_bug717147.html
@@ -0,0 +1,99 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717147
+-->
+<head>
+  <title>Test for Bug 717147</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717147">Mozilla Bug 717147</a>
+<p id="display"></p>
+<div id="content">
+  <iframe id="formTarget" name="formTarget"></iframe>
+  <form action="data:text/html," target="formTarget">
+    <input name="test" id="initValue"><input type="submit">
+  </form>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 717147 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var formTarget = document.getElementById("formTarget");
+  var initValue = document.getElementById("initValue");
+
+  formTarget.addEventListener("load", function() {
+    var newInput = document.createElement("input");
+    newInput.setAttribute("name", "test");
+    document.body.appendChild(newInput);
+
+    setTimeout(function() {
+      var popupShown = false;
+      function listener() {
+        popupShown = true;
+      }
+      SpecialPowers.addAutoCompletePopupEventListener(window, listener);
+
+      newInput.value = "";
+      newInput.focus();
+
+      synthesizeComposition({ type: "compositionstart" });
+      synthesizeComposition({ type: "compositionupdate", data: "f" });
+      synthesizeText(
+        { "composition":
+          { "string": "f",
+            "clauses":
+            [
+              { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
+            ]
+          },
+          "caret": { "start": 1, "length": 0 }
+        });
+
+      hitEventLoop(function() {
+        ok(!popupShown, "Popup must not be opened during composition");
+
+        synthesizeText(
+          { "composition":
+            { "string": "f",
+              "clauses":
+              [
+                { "length": 0, "attr": 0 }
+              ]
+            },
+            "caret": { "start": 1, "length": 0 }
+          });
+        synthesizeComposition({ type: "compositionend", data: "f" });
+
+        hitEventLoop(function () {
+          ok(popupShown, "Popup must be opened after compositionend");
+
+          SpecialPowers.removeAutoCompletePopupEventListener(window, listener);
+          SimpleTest.finish();
+        }, 100);
+      }, 100);
+    }, 0);
+  }, false);
+
+  initValue.focus();
+  initValue.value = "foo";
+  synthesizeKey("VK_ENTER", {});
+});
+
+function hitEventLoop(func, times) {
+  if (times > 0) {
+    setTimeout(hitEventLoop, 0, func, times - 1);
+  } else {
+    setTimeout(func, 0);
+  }
+}
+
+</script>
+</pre>
+</body>
+</html>
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -2103,125 +2103,86 @@ nsTextServicesDocument::GetDocumentConte
   }
 
   return result;
 }
 
 nsresult
 nsTextServicesDocument::CreateDocumentContentRange(nsIDOMRange **aRange)
 {
-  nsresult result;
-
-  NS_ENSURE_TRUE(aRange, NS_ERROR_NULL_POINTER);
-
-  *aRange = 0;
-
-  nsCOMPtr<nsIDOMNode>node;
-
-  result = GetDocumentContentRootNode(getter_AddRefs(node));
-
-  NS_ENSURE_SUCCESS(result, result);
-
+  *aRange = NULL;
+
+  nsCOMPtr<nsIDOMNode> node;
+  nsresult rv = GetDocumentContentRootNode(getter_AddRefs(node));
+  NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
-  *aRange = new nsRange();
-  NS_ADDREF(*aRange);
-
-  result = (*aRange)->SelectNodeContents(node);
-
-  if (NS_FAILED(result))
-  {
-    NS_RELEASE((*aRange));
-    *aRange = 0;
-    return result;
-  }
-
+  nsRefPtr<nsRange> range = new nsRange();
+
+  rv = range->SelectNodeContents(node);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  range.forget(aRange);
   return NS_OK;
 }
 
 nsresult
 nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode *aParent, PRInt32 aOffset, bool aToStart, nsIDOMRange **aRange)
 {
-  nsresult result;
-
   NS_ENSURE_TRUE(aParent && aRange, NS_ERROR_NULL_POINTER);
 
   *aRange = 0;
 
   NS_ASSERTION(aOffset >= 0, "Invalid offset!");
 
   if (aOffset < 0)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIDOMNode> bodyNode; 
-
-  result = GetDocumentContentRootNode(getter_AddRefs(bodyNode));
-
-  NS_ENSURE_SUCCESS(result, result);
-
+  nsresult rv = GetDocumentContentRootNode(getter_AddRefs(bodyNode));
+  NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(bodyNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMNode> startNode;
   nsCOMPtr<nsIDOMNode> endNode;
   PRInt32 startOffset, endOffset;
 
-  if (aToStart)
-  {
+  if (aToStart) {
     // The range should begin at the start of the document
     // and extend up until (aParent, aOffset).
 
     startNode   = bodyNode;
     startOffset = 0;
-    endNode     = do_QueryInterface(aParent);
+    endNode     = aParent;
     endOffset   = aOffset;
-  }
-  else
-  {
+  } else {
     // The range should begin at (aParent, aOffset) and
     // extend to the end of the document.
 
     nsCOMPtr<nsIDOMNodeList> nodeList;
     PRUint32 nodeListLength;
 
-    startNode   = do_QueryInterface(aParent);
+    startNode   = aParent;
     startOffset = aOffset;
     endNode     = bodyNode;
     endOffset   = 0;
 
-    result = bodyNode->GetChildNodes(getter_AddRefs(nodeList));
-
-    NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
-
-    if (nodeList)
-    {
-      result = nodeList->GetLength(&nodeListLength);
-
-      NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
+    rv = bodyNode->GetChildNodes(getter_AddRefs(nodeList));
+    NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+
+    if (nodeList) {
+      rv = nodeList->GetLength(&nodeListLength);
+      NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
       endOffset = (PRInt32)nodeListLength;
     }
   }
 
-  *aRange = new nsRange();
-  NS_ADDREF((*aRange));
-
-  NS_ENSURE_TRUE(*aRange, NS_ERROR_NULL_POINTER);
-
-  result = (*aRange)->SetStart(startNode, startOffset);
-
-  if (NS_SUCCEEDED(result))
-    result = (*aRange)->SetEnd(endNode, endOffset);
-
-  if (NS_FAILED(result))
-  {
-    NS_RELEASE((*aRange));
-    *aRange = 0;
-  }
-
-  return result;
+  return nsRange::CreateRange(startNode, startOffset, endNode, endOffset,
+                              aRange);
 }
 
 nsresult
 nsTextServicesDocument::CreateDocumentContentIterator(nsIContentIterator **aIterator)
 {
   nsresult result;
 
   NS_ENSURE_TRUE(aIterator, NS_ERROR_NULL_POINTER);
@@ -2435,34 +2396,26 @@ nsTextServicesDocument::HasSameBlockNode
 
   return p1 == p2;
 }
 
 bool
 nsTextServicesDocument::IsTextNode(nsIContent *aContent)
 {
   NS_ENSURE_TRUE(aContent, false);
-
-  nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aContent);
-
-  return IsTextNode(node);
+  return nsIDOMNode::TEXT_NODE == aContent->NodeType();
 }
 
 bool
 nsTextServicesDocument::IsTextNode(nsIDOMNode *aNode)
 {
   NS_ENSURE_TRUE(aNode, false);
 
-  PRUint16 type;
-
-  nsresult result = aNode->GetNodeType(&type);
-
-  NS_ENSURE_SUCCESS(result, false);
-
-  return nsIDOMNode::TEXT_NODE == type;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
+  return IsTextNode(content);
 }
 
 nsresult
 nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, bool aDoUpdate)
 {
   nsresult result = NS_OK;
 
   NS_ENSURE_TRUE(mSelCon && aOffset >= 0 && aLength >= 0, NS_ERROR_FAILURE);
@@ -3307,47 +3260,31 @@ nsTextServicesDocument::GetRangeEndPoint
 }
 
 
 nsresult
 nsTextServicesDocument::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
                                     nsIDOMNode *aEndParent, PRInt32 aEndOffset,
                                     nsIDOMRange **aRange)
 {
-  NS_ADDREF(*aRange = new nsRange());
-
-  nsresult result = (*aRange)->SetStart(aStartParent, aStartOffset);
-
-  if (NS_SUCCEEDED(result))
-    result = (*aRange)->SetEnd(aEndParent, aEndOffset);
-
-  if (NS_FAILED(result))
-  {
-    NS_RELEASE((*aRange));
-    *aRange = 0;
-  }
-
-  return result;
+  return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
+                              aEndOffset, aRange);
 }
 
 nsresult
 nsTextServicesDocument::FirstTextNode(nsIContentIterator *aIterator,
                                       TSDIteratorStatus *aIteratorStatus)
 {
   if (aIteratorStatus)
     *aIteratorStatus = nsTextServicesDocument::eIsDone;
 
   aIterator->First();
 
-  while (!aIterator->IsDone())
-  {
-    nsCOMPtr<nsIContent> content = do_QueryInterface(aIterator->GetCurrentNode());
-
-    if (IsTextNode(content))
-    {
+  while (!aIterator->IsDone()) {
+    if (aIterator->GetCurrentNode()->NodeType() == nsIDOMNode::TEXT_NODE) {
       if (aIteratorStatus)
         *aIteratorStatus = nsTextServicesDocument::eValid;
       break;
     }
 
     aIterator->Next();
   }
 
@@ -3358,22 +3295,18 @@ nsresult
 nsTextServicesDocument::LastTextNode(nsIContentIterator *aIterator,
                                      TSDIteratorStatus *aIteratorStatus)
 {
   if (aIteratorStatus)
     *aIteratorStatus = nsTextServicesDocument::eIsDone;
 
   aIterator->Last();
 
-  while (!aIterator->IsDone())
-  {
-    nsCOMPtr<nsIContent> content = do_QueryInterface(aIterator->GetCurrentNode());
-
-    if (IsTextNode(content))
-    {
+  while (!aIterator->IsDone()) {
+    if (aIterator->GetCurrentNode()->NodeType() == nsIDOMNode::TEXT_NODE) {
       if (aIteratorStatus)
         *aIteratorStatus = nsTextServicesDocument::eValid;
       break;
     }
 
     aIterator->Prev();
   }
 
@@ -3507,17 +3440,17 @@ nsTextServicesDocument::GetFirstTextNode
     // Try to restore the iterator before returning.
     mIterator->PositionAt(node);
     return result;
   }
 
   if (!mIterator->IsDone())
   {
     nsCOMPtr<nsIContent> current = do_QueryInterface(mIterator->GetCurrentNode());
-    current.swap(*aContent);
+    current.forget(aContent);
   }
 
   // Restore the iterator:
 
   return mIterator->PositionAt(node);
 }
 
 nsresult
@@ -3541,17 +3474,17 @@ nsTextServicesDocument::GetFirstTextNode
     // Try to restore the iterator before returning.
     mIterator->PositionAt(node);
     return result;
   }
 
   if (!mIterator->IsDone())
   {
     nsCOMPtr<nsIContent> current = do_QueryInterface(mIterator->GetCurrentNode());
-    current.swap(*aContent);
+    current.forget(aContent);
   }
 
   // Restore the iterator:
   return mIterator->PositionAt(node);
 }
 
 nsresult
 nsTextServicesDocument::CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
@@ -3619,19 +3552,16 @@ nsTextServicesDocument::CreateOffsetTabl
 
           result = node->GetNodeValue(str);
 
           NS_ENSURE_SUCCESS(result, result);
 
           // Add an entry for this text node into the offset table:
 
           OffsetEntry *entry = new OffsetEntry(node, offset, str.Length());
-
-          NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
-
           aOffsetTable->AppendElement(entry);
 
           // If one or both of the endpoints of the iteration range
           // are in the text node for this entry, make sure the entry
           // only accounts for the portion of the text node that is
           // in the range.
 
           PRInt32 startOffset = 0;
@@ -3766,18 +3696,16 @@ nsTextServicesDocument::SplitOffsetEntry
     return NS_ERROR_FAILURE;
 
   PRInt32 oldLength = entry->mLength - aNewEntryLength;
 
   OffsetEntry *newEntry = new OffsetEntry(entry->mNode,
                                           entry->mStrOffset + oldLength,
                                           aNewEntryLength);
 
-  NS_ENSURE_TRUE(newEntry, NS_ERROR_OUT_OF_MEMORY);
-
   if (!mOffsetTable.InsertElementAt(aTableIndex + 1, newEntry))
   {
     delete newEntry;
     return NS_ERROR_FAILURE;
   }
 
    // Adjust entry fields:
 
deleted file mode 100644
--- a/gfx/cairo/cairo/test/Makefile.am
+++ /dev/null
@@ -1,83 +0,0 @@
-# All new test cases go here
-TESTS = 		\
-fill_rule		\
-leaky_polygon		\
-line_width		\
-linear_gradient		\
-move_to_show_surface	\
-text_cache_crash	\
-text_rotate		\
-coverage		\
-clip_twice		\
-pixman_rotate
-
-# And all new tests go here too. I really don't like having to repeat
-# this list. Anyone know a good way to avoid it? Can I use a wildcard
-# here?
-EXTRA_DIST =			\
-fill_rule-ref.png		\
-leaky_polygon-ref.png		\
-line_width-ref.png		\
-linear_gradient-ref.png		\
-move_to_show_surface-ref.png	\
-coverage-ref.png		\
-clip_twice-ref.png		\
-pixman_rotate-ref.png		\
-romedalen.png
-
-# Once we can draw the text_rotate.c test case correctly, we should
-# create and add text_rotate-ref.png to the list of reference PNGs.
-
-# This list is only for known bugs (not regressions). We do need to
-# fix these before the next release, but they are expected to fail for
-# now, so they don't need to hold up any new code commit.
-#
-# When new bugs are found in committed code they can be listed
-# here. New failures due to local, uncommitted code changes are
-# regression bugs that should not be listed here. Instead they should
-# be fixed before the code is committed.
-XFAIL_TESTS =		\
-move_to_show_surface	\
-pixman_rotate		\
-text_rotate
-
-check_PROGRAMS = $(TESTS)
-
-# We're using _GNU_SOURCE to get the prototype for asprintf. This may
-# not be the most portable approach, but it is pragmatic and I'm
-# willing to do something cleaner as soon as it causes someone a
-# problem.
-INCLUDES = -D_GNU_SOURCE -I$(srcdir) $(CAIRO_CFLAGS) -I$(srcdir)/../src
-
-AM_LDFLAGS = $(CAIRO_LIBS) ../src/libcairo.la
-
-cairo_test_lib =\
-buffer_diff.c	\
-buffer_diff.h	\
-cairo_test.c	\
-cairo_test.h	\
-read_png.c	\
-read_png.h	\
-write_png.c	\
-write_png.h	\
-xmalloc.c	\
-xmalloc.h
-
-# ARGH! I have to repeat the list of tests a third time. Maybe it's
-# time to break down and auto-generate the Makefile.am or something
-# from autogen.sh. My, but this is painful...
-fill_rule_SOURCES = fill_rule.c $(cairo_test_lib)
-leaky_polygon_SOURCES = leaky_polygon.c $(cairo_test_lib)
-line_width_SOURCES = line_width.c $(cairo_test_lib)
-linear_gradient_SOURCES = linear_gradient.c $(cairo_test_lib)
-move_to_show_surface_SOURCES = move_to_show_surface.c $(cairo_test_lib)
-text_cache_crash_SOURCES = text_cache_crash.c $(cairo_test_lib)
-text_rotate_SOURCES = text_rotate.c $(cairo_test_lib)
-coverage_SOURCES = coverage.c $(cairo_test_lib)
-clip_twice_SOURCES = clip_twice.c $(cairo_test_lib)
-pixman_rotate_SOURCES = pixman_rotate.c $(cairo_test_lib)
-
-noinst_PROGRAMS = imagediff
-imagediff_SOURCES = imagediff.c $(cairo_test_lib)
-
-CLEANFILES = *-out.png *-diff.png *.log
deleted file mode 100644
--- a/gfx/cairo/cairo/test/Makefile.in
+++ /dev/null
@@ -1,750 +0,0 @@
-# Makefile.in generated by automake 1.9.2 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) $(fill_rule_SOURCES) $(imagediff_SOURCES) $(leaky_polygon_SOURCES) $(line_width_SOURCES) $(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) $(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) $(text_rotate_SOURCES)
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = ..
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-check_PROGRAMS = $(am__EXEEXT_1)
-noinst_PROGRAMS = imagediff$(EXEEXT)
-subdir = test
-DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-am__EXEEXT_1 = fill_rule$(EXEEXT) leaky_polygon$(EXEEXT) \
-	line_width$(EXEEXT) linear_gradient$(EXEEXT) \
-	move_to_show_surface$(EXEEXT) text_cache_crash$(EXEEXT) \
-	text_rotate$(EXEEXT) coverage$(EXEEXT) clip_twice$(EXEEXT) \
-	pixman_rotate$(EXEEXT)
-PROGRAMS = $(noinst_PROGRAMS)
-am__objects_1 = buffer_diff.$(OBJEXT) cairo_test.$(OBJEXT) \
-	read_png.$(OBJEXT) write_png.$(OBJEXT) xmalloc.$(OBJEXT)
-am_clip_twice_OBJECTS = clip_twice.$(OBJEXT) $(am__objects_1)
-clip_twice_OBJECTS = $(am_clip_twice_OBJECTS)
-clip_twice_LDADD = $(LDADD)
-am_coverage_OBJECTS = coverage.$(OBJEXT) $(am__objects_1)
-coverage_OBJECTS = $(am_coverage_OBJECTS)
-coverage_LDADD = $(LDADD)
-am_fill_rule_OBJECTS = fill_rule.$(OBJEXT) $(am__objects_1)
-fill_rule_OBJECTS = $(am_fill_rule_OBJECTS)
-fill_rule_LDADD = $(LDADD)
-am_imagediff_OBJECTS = imagediff.$(OBJEXT) $(am__objects_1)
-imagediff_OBJECTS = $(am_imagediff_OBJECTS)
-imagediff_LDADD = $(LDADD)
-am_leaky_polygon_OBJECTS = leaky_polygon.$(OBJEXT) $(am__objects_1)
-leaky_polygon_OBJECTS = $(am_leaky_polygon_OBJECTS)
-leaky_polygon_LDADD = $(LDADD)
-am_line_width_OBJECTS = line_width.$(OBJEXT) $(am__objects_1)
-line_width_OBJECTS = $(am_line_width_OBJECTS)
-line_width_LDADD = $(LDADD)
-am_linear_gradient_OBJECTS = linear_gradient.$(OBJEXT) \
-	$(am__objects_1)
-linear_gradient_OBJECTS = $(am_linear_gradient_OBJECTS)
-linear_gradient_LDADD = $(LDADD)
-am_move_to_show_surface_OBJECTS = move_to_show_surface.$(OBJEXT) \
-	$(am__objects_1)
-move_to_show_surface_OBJECTS = $(am_move_to_show_surface_OBJECTS)
-move_to_show_surface_LDADD = $(LDADD)
-am_pixman_rotate_OBJECTS = pixman_rotate.$(OBJEXT) $(am__objects_1)
-pixman_rotate_OBJECTS = $(am_pixman_rotate_OBJECTS)
-pixman_rotate_LDADD = $(LDADD)
-am_text_cache_crash_OBJECTS = text_cache_crash.$(OBJEXT) \
-	$(am__objects_1)
-text_cache_crash_OBJECTS = $(am_text_cache_crash_OBJECTS)
-text_cache_crash_LDADD = $(LDADD)
-am_text_rotate_OBJECTS = text_rotate.$(OBJEXT) $(am__objects_1)
-text_rotate_OBJECTS = $(am_text_rotate_OBJECTS)
-text_rotate_LDADD = $(LDADD)
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
-	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	$(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) \
-	$(fill_rule_SOURCES) $(imagediff_SOURCES) \
-	$(leaky_polygon_SOURCES) $(line_width_SOURCES) \
-	$(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) \
-	$(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) \
-	$(text_rotate_SOURCES)
-DIST_SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) \
-	$(fill_rule_SOURCES) $(imagediff_SOURCES) \
-	$(leaky_polygon_SOURCES) $(line_width_SOURCES) \
-	$(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) \
-	$(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) \
-	$(text_rotate_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
-AR = @AR@
-ATSUI_FONT_FEATURE = @ATSUI_FONT_FEATURE@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_HAS_ATSUI_FONT_FALSE = @CAIRO_HAS_ATSUI_FONT_FALSE@
-CAIRO_HAS_ATSUI_FONT_TRUE = @CAIRO_HAS_ATSUI_FONT_TRUE@
-CAIRO_HAS_FT_FONT_FALSE = @CAIRO_HAS_FT_FONT_FALSE@
-CAIRO_HAS_FT_FONT_TRUE = @CAIRO_HAS_FT_FONT_TRUE@
-CAIRO_HAS_GLITZ_SURFACE_FALSE = @CAIRO_HAS_GLITZ_SURFACE_FALSE@
-CAIRO_HAS_GLITZ_SURFACE_TRUE = @CAIRO_HAS_GLITZ_SURFACE_TRUE@
-CAIRO_HAS_PDF_SURFACE_FALSE = @CAIRO_HAS_PDF_SURFACE_FALSE@
-CAIRO_HAS_PDF_SURFACE_TRUE = @CAIRO_HAS_PDF_SURFACE_TRUE@
-CAIRO_HAS_PNG_SURFACE_FALSE = @CAIRO_HAS_PNG_SURFACE_FALSE@
-CAIRO_HAS_PNG_SURFACE_TRUE = @CAIRO_HAS_PNG_SURFACE_TRUE@
-CAIRO_HAS_PS_SURFACE_FALSE = @CAIRO_HAS_PS_SURFACE_FALSE@
-CAIRO_HAS_PS_SURFACE_TRUE = @CAIRO_HAS_PS_SURFACE_TRUE@
-CAIRO_HAS_QUARTZ_SURFACE_FALSE = @CAIRO_HAS_QUARTZ_SURFACE_FALSE@
-CAIRO_HAS_QUARTZ_SURFACE_TRUE = @CAIRO_HAS_QUARTZ_SURFACE_TRUE@
-CAIRO_HAS_WIN32_FONT_FALSE = @CAIRO_HAS_WIN32_FONT_FALSE@
-CAIRO_HAS_WIN32_FONT_TRUE = @CAIRO_HAS_WIN32_FONT_TRUE@
-CAIRO_HAS_WIN32_SURFACE_FALSE = @CAIRO_HAS_WIN32_SURFACE_FALSE@
-CAIRO_HAS_WIN32_SURFACE_TRUE = @CAIRO_HAS_WIN32_SURFACE_TRUE@
-CAIRO_HAS_XCB_SURFACE_FALSE = @CAIRO_HAS_XCB_SURFACE_FALSE@
-CAIRO_HAS_XCB_SURFACE_TRUE = @CAIRO_HAS_XCB_SURFACE_TRUE@
-CAIRO_HAS_XLIB_SURFACE_FALSE = @CAIRO_HAS_XLIB_SURFACE_FALSE@
-CAIRO_HAS_XLIB_SURFACE_TRUE = @CAIRO_HAS_XLIB_SURFACE_TRUE@
-CAIRO_LIBS = @CAIRO_LIBS@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-ENABLE_GTK_DOC_FALSE = @ENABLE_GTK_DOC_FALSE@
-ENABLE_GTK_DOC_TRUE = @ENABLE_GTK_DOC_TRUE@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
-FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
-FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
-FREETYPE_CONFIG = @FREETYPE_CONFIG@
-FREETYPE_LIBS = @FREETYPE_LIBS@
-FREETYPE_REQUIRES = @FREETYPE_REQUIRES@
-FT_FONT_FEATURE = @FT_FONT_FEATURE@
-GLITZ_CFLAGS = @GLITZ_CFLAGS@
-GLITZ_LIBS = @GLITZ_LIBS@
-GLITZ_REQUIRES = @GLITZ_REQUIRES@
-GLITZ_SURFACE_FEATURE = @GLITZ_SURFACE_FEATURE@
-GTK_DOC_USE_LIBTOOL_FALSE = @GTK_DOC_USE_LIBTOOL_FALSE@
-GTK_DOC_USE_LIBTOOL_TRUE = @GTK_DOC_USE_LIBTOOL_TRUE@
-HTML_DIR = @HTML_DIR@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
-MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
-MAKEINFO = @MAKEINFO@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PDF_LIBS = @PDF_LIBS@
-PDF_SURFACE_FEATURE = @PDF_SURFACE_FEATURE@
-PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
-PIXMAN_LIBS = @PIXMAN_LIBS@
-PKG_CONFIG = @PKG_CONFIG@
-PNG_CFLAGS = @PNG_CFLAGS@
-PNG_LIBS = @PNG_LIBS@
-PNG_REQUIRES = @PNG_REQUIRES@
-PNG_SURFACE_FEATURE = @PNG_SURFACE_FEATURE@
-PS_LIBS = @PS_LIBS@
-PS_SURFACE_FEATURE = @PS_SURFACE_FEATURE@
-QUARTZ_SURFACE_FEATURE = @QUARTZ_SURFACE_FEATURE@
-RANLIB = @RANLIB@
-SANITY_CHECKING_FEATURE = @SANITY_CHECKING_FEATURE@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-VERSION_INFO = @VERSION_INFO@
-WIN32_FONT_FEATURE = @WIN32_FONT_FEATURE@
-WIN32_SURFACE_FEATURE = @WIN32_SURFACE_FEATURE@
-XCB_CFLAGS = @XCB_CFLAGS@
-XCB_LIBS = @XCB_LIBS@
-XCB_SURFACE_FEATURE = @XCB_SURFACE_FEATURE@
-XLIB_SURFACE_FEATURE = @XLIB_SURFACE_FEATURE@
-XRENDER_CFLAGS = @XRENDER_CFLAGS@
-XRENDER_LIBS = @XRENDER_LIBS@
-XRENDER_REQUIRES = @XRENDER_REQUIRES@
-X_CFLAGS = @X_CFLAGS@
-X_EXTRA_LIBS = @X_EXTRA_LIBS@
-X_LIBS = @X_LIBS@
-X_PRE_LIBS = @X_PRE_LIBS@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
-am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-
-# All new test cases go here
-TESTS = \
-fill_rule		\
-leaky_polygon		\
-line_width		\
-linear_gradient		\
-move_to_show_surface	\
-text_cache_crash	\
-text_rotate		\
-coverage		\
-clip_twice		\
-pixman_rotate
-
-
-# And all new tests go here too. I really don't like having to repeat
-# this list. Anyone know a good way to avoid it? Can I use a wildcard
-# here?
-EXTRA_DIST = \
-fill_rule-ref.png		\
-leaky_polygon-ref.png		\
-line_width-ref.png		\
-linear_gradient-ref.png		\
-move_to_show_surface-ref.png	\
-coverage-ref.png		\
-clip_twice-ref.png		\
-pixman_rotate-ref.png		\
-romedalen.png
-
-
-# Once we can draw the text_rotate.c test case correctly, we should
-# create and add text_rotate-ref.png to the list of reference PNGs.
-
-# This list is only for known bugs (not regressions). We do need to
-# fix these before the next release, but they are expected to fail for
-# now, so they don't need to hold up any new code commit.
-#
-# When new bugs are found in committed code they can be listed
-# here. New failures due to local, uncommitted code changes are
-# regression bugs that should not be listed here. Instead they should
-# be fixed before the code is committed.
-XFAIL_TESTS = \
-move_to_show_surface	\
-pixman_rotate		\
-text_rotate
-
-
-# We're using _GNU_SOURCE to get the prototype for asprintf. This may
-# not be the most portable approach, but it is pragmatic and I'm
-# willing to do something cleaner as soon as it causes someone a
-# problem.
-INCLUDES = -D_GNU_SOURCE -I$(srcdir) $(CAIRO_CFLAGS) -I$(srcdir)/../src
-AM_LDFLAGS = $(CAIRO_LIBS) ../src/libcairo.la
-cairo_test_lib = \
-buffer_diff.c	\
-buffer_diff.h	\
-cairo_test.c	\
-cairo_test.h	\
-read_png.c	\
-read_png.h	\
-write_png.c	\
-write_png.h	\
-xmalloc.c	\
-xmalloc.h
-
-
-# ARGH! I have to repeat the list of tests a third time. Maybe it's
-# time to break down and auto-generate the Makefile.am or something
-# from autogen.sh. My, but this is painful...
-fill_rule_SOURCES = fill_rule.c $(cairo_test_lib)
-leaky_polygon_SOURCES = leaky_polygon.c $(cairo_test_lib)
-line_width_SOURCES = line_width.c $(cairo_test_lib)
-linear_gradient_SOURCES = linear_gradient.c $(cairo_test_lib)
-move_to_show_surface_SOURCES = move_to_show_surface.c $(cairo_test_lib)
-text_cache_crash_SOURCES = text_cache_crash.c $(cairo_test_lib)
-text_rotate_SOURCES = text_rotate.c $(cairo_test_lib)
-coverage_SOURCES = coverage.c $(cairo_test_lib)
-clip_twice_SOURCES = clip_twice.c $(cairo_test_lib)
-pixman_rotate_SOURCES = pixman_rotate.c $(cairo_test_lib)
-imagediff_SOURCES = imagediff.c $(cairo_test_lib)
-CLEANFILES = *-out.png *-diff.png *.log
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  test/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  test/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-clean-checkPROGRAMS:
-	@list='$(check_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-
-clean-noinstPROGRAMS:
-	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-clip_twice$(EXEEXT): $(clip_twice_OBJECTS) $(clip_twice_DEPENDENCIES) 
-	@rm -f clip_twice$(EXEEXT)
-	$(LINK) $(clip_twice_LDFLAGS) $(clip_twice_OBJECTS) $(clip_twice_LDADD) $(LIBS)
-coverage$(EXEEXT): $(coverage_OBJECTS) $(coverage_DEPENDENCIES) 
-	@rm -f coverage$(EXEEXT)
-	$(LINK) $(coverage_LDFLAGS) $(coverage_OBJECTS) $(coverage_LDADD) $(LIBS)
-fill_rule$(EXEEXT): $(fill_rule_OBJECTS) $(fill_rule_DEPENDENCIES) 
-	@rm -f fill_rule$(EXEEXT)
-	$(LINK) $(fill_rule_LDFLAGS) $(fill_rule_OBJECTS) $(fill_rule_LDADD) $(LIBS)
-imagediff$(EXEEXT): $(imagediff_OBJECTS) $(imagediff_DEPENDENCIES) 
-	@rm -f imagediff$(EXEEXT)
-	$(LINK) $(imagediff_LDFLAGS) $(imagediff_OBJECTS) $(imagediff_LDADD) $(LIBS)
-leaky_polygon$(EXEEXT): $(leaky_polygon_OBJECTS) $(leaky_polygon_DEPENDENCIES) 
-	@rm -f leaky_polygon$(EXEEXT)
-	$(LINK) $(leaky_polygon_LDFLAGS) $(leaky_polygon_OBJECTS) $(leaky_polygon_LDADD) $(LIBS)
-line_width$(EXEEXT): $(line_width_OBJECTS) $(line_width_DEPENDENCIES) 
-	@rm -f line_width$(EXEEXT)
-	$(LINK) $(line_width_LDFLAGS) $(line_width_OBJECTS) $(line_width_LDADD) $(LIBS)
-linear_gradient$(EXEEXT): $(linear_gradient_OBJECTS) $(linear_gradient_DEPENDENCIES) 
-	@rm -f linear_gradient$(EXEEXT)
-	$(LINK) $(linear_gradient_LDFLAGS) $(linear_gradient_OBJECTS) $(linear_gradient_LDADD) $(LIBS)
-move_to_show_surface$(EXEEXT): $(move_to_show_surface_OBJECTS) $(move_to_show_surface_DEPENDENCIES) 
-	@rm -f move_to_show_surface$(EXEEXT)
-	$(LINK) $(move_to_show_surface_LDFLAGS) $(move_to_show_surface_OBJECTS) $(move_to_show_surface_LDADD) $(LIBS)
-pixman_rotate$(EXEEXT): $(pixman_rotate_OBJECTS) $(pixman_rotate_DEPENDENCIES) 
-	@rm -f pixman_rotate$(EXEEXT)
-	$(LINK) $(pixman_rotate_LDFLAGS) $(pixman_rotate_OBJECTS) $(pixman_rotate_LDADD) $(LIBS)
-text_cache_crash$(EXEEXT): $(text_cache_crash_OBJECTS) $(text_cache_crash_DEPENDENCIES) 
-	@rm -f text_cache_crash$(EXEEXT)
-	$(LINK) $(text_cache_crash_LDFLAGS) $(text_cache_crash_OBJECTS) $(text_cache_crash_LDADD) $(LIBS)
-text_rotate$(EXEEXT): $(text_rotate_OBJECTS) $(text_rotate_DEPENDENCIES) 
-	@rm -f text_rotate$(EXEEXT)
-	$(LINK) $(text_rotate_LDFLAGS) $(text_rotate_OBJECTS) $(text_rotate_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer_diff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo_test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip_twice.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coverage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill_rule.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imagediff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/leaky_polygon.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_width.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linear_gradient.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move_to_show_surface.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixman_rotate.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_png.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_cache_crash.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_rotate.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write_png.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
-@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-distclean-libtool:
-	-rm -f libtool
-uninstall-info-am:
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
-	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
-distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-	list='$(DISTFILES)'; for file in $$list; do \
-	  case $$file in \
-	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-	  esac; \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-	    dir="/$$dir"; \
-	    $(mkdir_p) "$(distdir)$$dir"; \
-	  else \
-	    dir=''; \
-	  fi; \
-	  if test -d $$d/$$file; then \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
-	    || exit 1; \
-	  fi; \
-	done
-check-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
-	clean-noinstPROGRAMS mostlyclean-am
-
-distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-libtool distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-exec-am:
-
-install-info: install-info-am
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-info-am
-
-.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
-	clean-checkPROGRAMS clean-generic clean-libtool \
-	clean-noinstPROGRAMS ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-exec install-exec-am \
-	install-info install-info-am install-man install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am uninstall-info-am
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
deleted file mode 100644
--- a/gfx/cairo/cairo/test/README
+++ /dev/null
@@ -1,64 +0,0 @@
-Regression test suite for cairo.
-
-Using this test should be as simple as running:
-
-	make check
-
-assuming that the cairo distribution in the directory above has been
-configured and built. The test suite here goes through some effort to
-run against the locally compiled library rather than any installed
-version.
-
-The test suite needs to be run before any code is committed and before
-any release. Here are the rules governing the use of the suite:
-
-Before committing
------------------
-
-All tests should return a result of PASS or XFAIL. The XFAIL results
-indicate known bugs. The final message should be one of the following:
-
-	All XX tests behaved as expected (YY expected failures)
-	All XX tests passed
-
-If any tests have a status of FAIL, then the new code has caused a
-regression error which should be fixed before the code is committed.
-
-When a new bug is found
------------------------
-A new test case should be added by imitating the style of an existing
-test. This means adding the following files:
-
-	new_bug.c
-	new_bug-ref.png
-
-Where new_bug.c is a minimal program to demonstrate the bug, following
-the style of existing tests. The new_bug-ref.png image should contain
-the desired result of new_bug.c if the bug were fixed.
-
-Makefile.am should be edited, adding new_bug.c to both the TESTS and
-XFAIL_TESTS lists.
-
-When a new feature is added
----------------------------
-It's important for the regression suite to keep pace with development
-of the library. So a new test should be added for each new
-feature. The work involved is similar the work described above for new
-bugs. The only distinction is that the test is expected to pass so it
-should not be added to the XFAIL_TESTS list.
-
-
-When a bug is fixed
--------------------
-The fix should be verified by running the test suite which should
-result in an "unexpected pass" for the test of interest. Rejoice as
-appropriate, then remove the relevant file name from the XFAIL_TESTS
-variable in Makefile.am.
-
-Before releasing
-----------------
-All tests should return a result of PASS meaning all known bugs are
-fixed, resulting in the happy message:
-
-	All XX tests passed
-
deleted file mode 100644
--- a/gfx/cairo/cairo/test/buffer_diff.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* imagediff - Compare two images
- *
- * Copyright © 2004 Richard D. Worth
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Richard Worth
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission.
- * Richard Worth makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- * 
- * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL RICHARD WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Richard D. Worth <richard@theworths.org> */
-
-#include "buffer_diff.h"
-
-/* Image comparison code courttesy of Richard Worth.
- * Returns number of pixels changed.
- * Also fills out a "diff" image intended to visually show where the
- * images differ.
- */
-int
-buffer_diff (char *buf_a, char *buf_b, char *buf_diff,
-	    int width, int height, int stride)
-{
-    int x, y;
-    int total_pixels_changed = 0;
-    unsigned char *row_a, *row_b, *row;
-
-    for (y = 0; y < height; y++)
-    {
-	row_a = buf_a + y * stride;
-	row_b = buf_b + y * stride;
-	row = buf_diff + y * stride;
-	for (x = 0; x < width; x++)
-	{
-	    int channel;
-	    unsigned char value_a, value_b;
-	    int pixel_changed = 0;
-	    for (channel = 0; channel < 4; channel++)
-	    {
-		double diff;
-		value_a = row_a[x * 4 + channel];
-		value_b = row_b[x * 4 + channel];
-		if (value_a != value_b)
-		    pixel_changed = 1;
-		diff = value_a - value_b;
-		row[x * 4 + channel] = 128 + diff / 3.0;
-	    }
-	    if (pixel_changed) {
-		total_pixels_changed++;
-	    } else {
-		row[x*4+0] = 0;
-		row[x*4+1] = 0;
-		row[x*4+2] = 0;
-	    }
-	    row[x * 4 + 3] = 0xff; /* Set ALPHA to 100% (opaque) */
-	}
-    }
-
-    return total_pixels_changed;
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/buffer_diff.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* imagediff - Compare two images
- *
- * Copyright © 2004 Richard D. Worth
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Richard Worth
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission.
- * Richard Worth makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- * 
- * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL RICHARD WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Richard D. Worth <richard@theworths.org> */
-
-#ifndef BUFFER_DIFF_H
-#define BUFFER_DIFF_H
-
-/* Image comparison code courttesy of Richard Worth.
- * Returns number of pixels changed.
- * Also fills out a "diff" image intended to visually show where the
- * images differ.
- */
-int
-buffer_diff (char *buf_a, char *buf_b, char *buf_diff,
-	     int width, int height, int stride);
-
-#endif
deleted file mode 100644
--- a/gfx/cairo/cairo/test/cairo_test.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-#include "cairo_test.h"
-
-#include "buffer_diff.h"
-#include "read_png.h"
-#include "write_png.h"
-#include "xmalloc.h"
-
-#define CAIRO_TEST_LOG_SUFFIX ".log"
-#define CAIRO_TEST_PNG_SUFFIX "-out.png"
-#define CAIRO_TEST_REF_SUFFIX "-ref.png"
-#define CAIRO_TEST_DIFF_SUFFIX "-diff.png"
-
-static void
-xasprintf (char **strp, const char *fmt, ...)
-{
-#ifdef HAVE_VASPRINTF    
-    va_list va;
-    int ret;
-    
-    va_start (va, fmt);
-    ret = vasprintf (strp, fmt, va);
-    va_end (va);
-
-    if (ret < 0) {
-	fprintf (stderr, "Out of memory\n");
-	exit (1);
-    }
-#else /* !HAVE_VASNPRINTF */
-#define BUF_SIZE 1024
-    va_list va;
-    char buffer[BUF_SIZE];
-    int ret;
-    
-    va_start (va, fmt);
-    ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
-    va_end (va);
-
-    if (ret < 0) {
-	fprintf (stderr, "Failure in vsnprintf\n");
-	exit (1);
-    }
-    
-    if (strlen (buffer) == sizeof(buffer) - 1) {
-	fprintf (stderr, "Overflowed fixed buffer\n");
-	exit (1);
-    }
-    
-    *strp = strdup (buffer);
-    if (!*strp) {
-	fprintf (stderr, "Out of memory\n");
-	exit (1);
-    }
-#endif /* !HAVE_VASNPRINTF */
-}
-
-static void
-xunlink (const char *pathname)
-{
-    if (unlink (pathname) < 0 && errno != ENOENT) {
-	fprintf (stderr, "  Error: Cannot remove %s: %s\n",
-		 pathname, strerror (errno));
-	exit (1);
-    }
-}
-
-cairo_test_status_t
-cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
-{
-    cairo_t *cr;
-    int stride;
-    unsigned char *png_buf, *ref_buf, *diff_buf;
-    char *log_name, *png_name, *ref_name, *diff_name;
-    char *srcdir;
-    int pixels_changed;
-    int ref_width, ref_height, ref_stride;
-    read_png_status_t png_status;
-    cairo_test_status_t ret;
-    FILE *png_file;
-    FILE *log_file;
-
-    /* The cairo part of the test is the easiest part */
-    cr = cairo_create ();
-
-    stride = 4 * test->width;
-
-    png_buf = xcalloc (stride * test->height, 1);
-    diff_buf = xcalloc (stride * test->height, 1);
-
-    cairo_set_target_image (cr, png_buf, CAIRO_FORMAT_ARGB32,
-			    test->width, test->height, stride);
-
-    (draw) (cr, test->width, test->height);
-
-    cairo_destroy (cr);
-
-    /* Skip image check for tests with no image (width,height == 0,0) */
-    if (test->width == 0 || test->height == 0) {
-	free (png_buf);
-	free (diff_buf);
-	return CAIRO_TEST_SUCCESS;
-    }
-
-    /* Then we've got a bunch of string manipulation and file I/O for the check */
-    srcdir = getenv ("srcdir");
-    if (!srcdir)
-	srcdir = ".";
-    xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
-    xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX);
-    xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX);
-    xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX);
-
-    png_file = fopen (png_name, "w");
-    write_png_argb32 (png_buf, png_file, test->width, test->height, stride);
-    fclose (png_file);
-
-    xunlink (log_name);
-
-    ref_buf = NULL;
-    png_status = (read_png_argb32 (ref_name, &ref_buf, &ref_width, &ref_height, &ref_stride));
-    if (png_status) {
-	log_file = fopen (log_name, "a");
-	switch (png_status)
-	{
-	case READ_PNG_FILE_NOT_FOUND:
-	    fprintf (log_file, "Error: No reference image found: %s\n", ref_name);
-	    break;
-	case READ_PNG_FILE_NOT_PNG:
-	    fprintf (log_file, "Error: %s is not a png image\n", ref_name);
-	    break;
-	default:
-	    fprintf (log_file, "Error: Failed to read %s\n", ref_name);
-	}
-	fclose (log_file);
-		
-	ret = CAIRO_TEST_FAILURE;
-	goto BAIL;
-    } else {
-    }
-
-    if (test->width != ref_width || test->height != ref_height) {
-	log_file = fopen (log_name, "a");
-	fprintf (log_file,
-		 "Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
-		 "       for %s vs %s\n",
-		 test->width, test->height,
-		 ref_width, ref_height,
-		 png_name, ref_name);
-	fclose (log_file);
-
-	ret = CAIRO_TEST_FAILURE;
-	goto BAIL;
-    }
-
-    pixels_changed = buffer_diff (png_buf, ref_buf, diff_buf,
-				  test->width, test->height, stride);
-    if (pixels_changed) {
-	log_file = fopen (log_name, "a");
-	fprintf (log_file, "Error: %d pixels differ from reference image %s\n",
-		 pixels_changed, ref_name);
-	png_file = fopen (diff_name, "w");
-	write_png_argb32 (diff_buf, png_file, test->width, test->height, stride);
-	fclose (png_file);
-	fclose (log_file);
-
-	ret = CAIRO_TEST_FAILURE;
-	goto BAIL;
-    } else {
-	xunlink (diff_name);
-    }
-
-    ret = CAIRO_TEST_SUCCESS;
-
-BAIL:
-    free (png_buf);
-    free (ref_buf);
-    free (diff_buf);
-    free (log_name);
-    free (png_name);
-    free (ref_name);
-    free (diff_name);
-
-    return ret;
-}
-
-cairo_pattern_t *
-cairo_test_create_png_pattern (cairo_t *cr, const char *filename)
-{
-    cairo_surface_t *image;
-    cairo_pattern_t *pattern;
-    unsigned char *buffer;
-    int w, h, stride;
-    read_png_status_t status;
-    char *srcdir = getenv ("srcdir");
-
-    status = read_png_argb32 (filename, &buffer, &w,&h, &stride);
-    if (status != READ_PNG_SUCCESS) {
-	if (srcdir) {
-	    char *srcdir_filename;
-	    xasprintf (&srcdir_filename, "%s/%s", srcdir, filename);
-	    status = read_png_argb32 (srcdir_filename, &buffer, &w,&h, &stride);
-	    free (srcdir_filename);
-	}
-    }
-    if (status != READ_PNG_SUCCESS)
-	return NULL;
-
-    image = cairo_surface_create_for_image (buffer, CAIRO_FORMAT_ARGB32,
-					    w, h, stride);
-
-    cairo_surface_set_repeat (image, 1);
-
-    pattern = cairo_pattern_create_for_surface (image);
-
-    return pattern;
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/cairo_test.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#ifndef _CAIRO_TEST_H_
-#define _CAIRO_TEST_H_
-
-#include <math.h>
-#include <cairo.h>
-
-typedef enum cairo_test_status {
-    CAIRO_TEST_SUCCESS = 0,
-    CAIRO_TEST_FAILURE
-} cairo_test_status_t;
-
-typedef struct cairo_test {
-    char *name;
-    char *description;
-    int width;
-    int height;
-} cairo_test_t;
-
-typedef void  (*cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
-
-/* cairo_test.c */
-cairo_test_status_t
-cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw);
-
-cairo_pattern_t *
-cairo_test_create_png_pattern (cairo_t *cr, const char *filename);
-
-
-#endif
-
deleted file mode 100644
index ab0ae1aeb158439e272bd6fa7f158ef68918d812..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/clip_twice.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright © 2005 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Kristian Høgsberg <krh@redhat.com>
- */
-
-#include "cairo_test.h"
-
-#define WIDTH 64
-#define HEIGHT 64
-
-cairo_test_t test = {
-    "clip_twice",
-    "Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.",
-    WIDTH, HEIGHT
-};
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_set_alpha (cr, 1.0);
-    cairo_new_path (cr);
-    cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 3, 0, 2 * M_PI);
-    cairo_clip (cr);
-
-    cairo_new_path (cr);
-    cairo_move_to (cr, 0, 0);
-    cairo_line_to (cr, WIDTH / 4, HEIGHT / 2);
-    cairo_line_to (cr, 0, HEIGHT);
-    cairo_line_to (cr, WIDTH, HEIGHT);
-    cairo_line_to (cr, 3 * WIDTH / 4, HEIGHT / 2);
-    cairo_line_to (cr, WIDTH, 0);
-    cairo_close_path (cr);
-    cairo_clip (cr);
-
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-
-    cairo_new_path (cr);
-    cairo_move_to (cr, 0, 0);
-    cairo_line_to (cr, 0, HEIGHT);
-    cairo_line_to (cr, WIDTH / 2, 3 * HEIGHT / 4);
-    cairo_line_to (cr, WIDTH, HEIGHT);
-    cairo_line_to (cr, WIDTH, 0);
-    cairo_line_to (cr, WIDTH / 2, HEIGHT / 4);
-    cairo_close_path (cr);
-    cairo_fill (cr);
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index 9b71040576462d94767ed4591bd9153654ef30b2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/coverage.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright © 2005 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Kristian Høgsberg <krh@redhat.com>
- */
-
-#include <math.h>
-#include "cairo_test.h"
-
-#define WIDTH 64
-#define HEIGHT 64
-#define PAD 10
-
-/* XXX The test image uses Bitstream Vera Sans as the font - how do we
- * ensure that it's available?  Can we ship it with this test? */
-
-const char	fontname[]	= "Bitstream Vera Sans";
-const int	fontsize	= 40;
-const char	png_filename[]	= "romedalen.png";
-
-static void
-set_solid_pattern (cairo_t *cr, int x, int y)
-{
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 1.0);
-}
-
-static void
-set_translucent_pattern (cairo_t *cr, int x, int y)
-{
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 0.5);
-}
-
-static void
-set_gradient_pattern (cairo_t *cr, int x, int y)
-{
-    cairo_pattern_t *pattern;
-
-    pattern =
-	cairo_pattern_create_linear (x, y, x + WIDTH, y + HEIGHT);
-    cairo_pattern_add_color_stop (pattern, 0, 1, 1, 1, 1);
-    cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.4, 1);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
-}
-
-static void
-set_image_pattern (cairo_t *cr, int x, int y)
-{
-    cairo_pattern_t *pattern;
-
-    pattern = cairo_test_create_png_pattern (cr, png_filename);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
-}
-
-static void
-set_translucent_image_pattern (cairo_t *cr, int x, int y)
-{
-    cairo_pattern_t *pattern;
-
-    pattern = cairo_test_create_png_pattern (cr, png_filename);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 0.5);
-}
-
-static void
-draw_text (cairo_t *cr, int x, int y)
-{
-    cairo_rel_move_to (cr, 0, fontsize);
-    cairo_show_text (cr, "Aa");
-}
-
-static void
-draw_polygon (cairo_t *cr, int x, int y)
-{
-    cairo_new_path (cr);
-    cairo_move_to (cr, x, y);
-    cairo_line_to (cr, x, y + HEIGHT);
-    cairo_line_to (cr, x + WIDTH / 2, y + 3 * HEIGHT / 4);
-    cairo_line_to (cr, x + WIDTH, y + HEIGHT);
-    cairo_line_to (cr, x + WIDTH, y);
-    cairo_line_to (cr, x + WIDTH / 2, y + HEIGHT / 4);
-    cairo_close_path (cr);
-    cairo_fill (cr);
-}
-
-static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
-    set_solid_pattern,
-    set_translucent_pattern,
-    set_gradient_pattern,
-    set_image_pattern,
-    set_translucent_image_pattern
-};
-
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
-    draw_text,
-    draw_polygon,
-};
-
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-#define IMAGE_WIDTH (ARRAY_SIZE (pattern_funcs) * (WIDTH + PAD) + PAD)
-#define IMAGE_HEIGHT (ARRAY_SIZE (draw_funcs) * (HEIGHT + PAD) * 2 + PAD)
-
-static cairo_test_t test = {
-    "coverage",
-    "Various coverage test of cairo",
-    IMAGE_WIDTH, IMAGE_HEIGHT
-};
-
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    /* TODO: pattern fill, gradient fill, clipping, gradient clipping,
-       path+solid alpha mask clipping */
-
-    int i, j, x, y;
-
-    cairo_select_font (cr, fontname,
-		       CAIRO_FONT_SLANT_NORMAL,
-		       CAIRO_FONT_WEIGHT_BOLD);
-    cairo_scale_font (cr, fontsize);
-
-    for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
-	for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
-	    x = i * (WIDTH + PAD) + PAD;
-	    y = j * (HEIGHT + PAD) + PAD;
-	    cairo_move_to (cr, x, y);
-	    pattern_funcs[i] (cr, x, y);
-	    draw_funcs[j] (cr, x, y);
-	}
-    }
-
-    for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
-	for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
-	    x = i * (WIDTH + PAD) + PAD;
-	    y = (ARRAY_SIZE (draw_funcs) + j) * (HEIGHT + PAD) + PAD;
-
-	    cairo_save (cr);
-
-	    cairo_set_alpha (cr, 1.0);
-	    cairo_new_path (cr);
-	    cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
-		       WIDTH / 3, 0, 2 * M_PI);
-	    cairo_clip (cr);
-
-	    cairo_move_to (cr, x, y);
-	    pattern_funcs[i] (cr, x, y);
-	    draw_funcs[j] (cr, x, y);
-
-	    cairo_restore (cr);
-
-	}
-    }
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index e2e10d4a89fa2d46ac86c3b7d94ea5d91e2220d6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/fill_rule.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-/* Bug history
- *
- * 2004-10-27  Carl Worth  <cworth@cworth.org>
- *
- *   There's currently a regression bug in the tessellation code. This
- *   causes each of these simple star shapes to be filled incorrectly.
- *
- *   It looks like right now we can get this test to pass by doing:
- *
- *       cvs update -r 1.16 src/cairo_traps.c
- *
- *   But we don't want to revert that change permanently since it
- *   really does correct some bugs. It must be that the old version of
- *   the code is masking some other bugs in the tessellation code. My
- *   current plan is to back this revision up for the next snapshot,
- *   but not to list the test as an expected failure since I'm
- *   planning on doing the new tessellator which should fix this
- *   problem.
- *
- * 2005-01-11 Carl Worth <cworth@cworth.org>
- *
- *   Keith committed some fixes that fix the original size-20
- *   star_path:
- *
- * 	* src/cairo_wideint.c: (_cairo_int32x32_64_mul),
- *	(_cairo_int64x64_128_mul):
- *	* src/cairo_wideint.h:
- *	int32x32_64_mul and int64x64_128_mul are different from their
- *	unsigned compatriots
- *
- * 2005-01-12 Carl Worth <cworth@cworth.org>
- *
- *   Going back to the SVG test suite, however, the original star
- *   shape is still broken. Adding both shapes now as little_star_path
- *   and big_star_path.
- *
- */
-
-#include "cairo_test.h"
-
-#define LITTLE_STAR_SIZE 20
-#define BIG_STAR_SIZE    80
-
-cairo_test_t test = {
-    "fill_rule",
-    "Tests cairo_set_full_rule with some star shapes",
-    BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3
-};
-
-/* The SVG start trimmed down, but still showing the bug (originally) */
-static void
-little_star_path (cairo_t *cr)
-{
-    cairo_move_to (cr, 10, 0);
-    cairo_rel_line_to (cr, 6, 20);
-    cairo_rel_line_to (cr, -16, -12);
-    cairo_rel_line_to (cr, 20, 0);
-    cairo_rel_line_to (cr, -16, 12);
-}
-
-/* The star shape from the SVG test suite. This was is still buggy even after
-   we got little_star_path working. */
-static void
-big_star_path (cairo_t *cr)
-{
-    cairo_move_to (cr, 40, 0);
-    cairo_rel_line_to (cr, 25, 80);
-    cairo_rel_line_to (cr, -65, -50);
-    cairo_rel_line_to (cr, 80, 0);
-    cairo_rel_line_to (cr, -65, 50);
-    cairo_close_path (cr);
-}
-
-/* Fill the same path twice, once with each fill rule */
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_set_rgb_color (cr, 1, 0, 0);
-
-    cairo_translate (cr, 1, 1);
-    little_star_path (cr);
-    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-    cairo_fill (cr);
-
-    cairo_translate (cr, LITTLE_STAR_SIZE + 1, 0);
-    little_star_path (cr);
-    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-    cairo_fill (cr);
-
-    cairo_translate (cr, -(LITTLE_STAR_SIZE + 1), LITTLE_STAR_SIZE + 1);
-    big_star_path (cr);
-    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-    cairo_fill (cr);
-
-    cairo_translate (cr, BIG_STAR_SIZE + 1, 0);
-    big_star_path (cr);
-    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-    cairo_fill (cr);
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/imagediff.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* imagediff - Compare two images
- *
- * Copyright © 2004 Richard D. Worth
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Richard Worth
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission.
- * Richard Worth makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- * 
- * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL RICHARD WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Richard D. Worth <richard@theworths.org> */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "buffer_diff.h"
-#include "read_png.h"
-#include "write_png.h"
-#include "xmalloc.h"
-
-int 
-main (int argc, char *argv[])
-{
-    unsigned char *buffer_a;
-    unsigned int width_a, height_a, stride_a;
-    unsigned char *buffer_b;
-    unsigned int width_b, height_b, stride_b;
-
-    unsigned char *buffer;
-    unsigned int width, height, stride;
-    int buffer_size, total_pixels_changed;
-
-    if (argc < 2) {
-	fprintf (stderr, "Usage: %s image1.png image2.png\n", argv[0]);
-	fprintf (stderr, "Computes an output image designed to present a \"visual diff\" such that even\n");
-	fprintf (stderr, "small errors in single pixels are readily apparent in the output.\n");
-	fprintf (stderr, "The output image is written on stdout.\n");
-	exit (1);
-    }
-
-    read_png_argb32 (argv[1], &buffer_a, &width_a, &height_a, &stride_a);
-    read_png_argb32 (argv[2], &buffer_b, &width_b, &height_b, &stride_b);
-
-    if ((width_a == width_b) && (height_a == height_b) && (stride_a == stride_b))
-    {
-	width = width_a;
-	height = height_a;
-	stride = stride_a;
-    } else {
-	fprintf (stderr, "Error. Both images must be the same size\n");
-	return 1;
-    }
-
-    buffer_size = stride * height;
-    buffer = xmalloc (buffer_size);
-    
-    total_pixels_changed = buffer_diff (buffer_a, buffer_b, buffer,
-					width_a, height_a, stride_a);
-
-
-    if (total_pixels_changed)
-	fprintf (stderr, "Total pixels changed: %d\n", total_pixels_changed);
-    write_png_argb32 (buffer, stdout, width, height, stride);
-
-    free (buffer);
-
-    return 0;
-}
-
-
-
deleted file mode 100644
index 0daabe15ab3ffa15afbeddeb749b2c5bb81b365b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/leaky_polygon.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright © 2005 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-/* Bug history
- *
- * 2005-01-07 Carl Worth <cworth@cworth.org>
- *
- *   Bug reported:
- *
- *     From: Chris <fltk@functionalfuture.com>
- *     Subject: [cairo] Render to image buffer artifacts
- *     To: cairo@cairographics.org
- *     Date: Fri, 07 Jan 2005 02:22:28 -0500
- *
- *     I've attached the code and image that shows this off.  Scaling at
- *     different levels seems to change the corruption.
- *
- *     For some reason there are artifacts in the alpha channel.  I don't know
- *     if that's the only place, but the alpha channel looks bad.
- *
- *     If you run the code and parse the attached image, directing stdout to a
- *     file, you can see in the lower left corner there are alpha values where
- *     it should be transparent.
- *     [...]
- *
- * 2005-01-11 Carl Worth <cworth@cworth.org>
- *
- *   I trimmed the original test case down to the code that appears here.
- *
- */
-
-#include "cairo_test.h"
-
-#define WIDTH 21
-#define HEIGHT 21
-
-cairo_test_t test = {
-    "leaky_polygon",
-    "Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha",
-    WIDTH, HEIGHT
-};
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_scale (cr, 1.0/(1<<16), 1.0/(1<<16));
-
-    cairo_move_to (cr, 131072,39321);
-    cairo_line_to (cr, 1103072,1288088);
-    cairo_line_to (cr, 1179648,1294990);
-    cairo_close_path (cr);
-
-    cairo_fill (cr);
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index ddcd929d8e679358ee35541c567a93c4dca4fde7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/line_width.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#include "cairo_test.h"
-
-#define LINES 5
-#define LINE_LENGTH 10
-#define IMAGE_WIDTH 2 * LINE_LENGTH + 6
-#define IMAGE_HEIGHT ((LINES+4)*LINES)/2 + 2
-
-cairo_test_t test = {
-    "line_width",
-    "Tests cairo_set_line_width",
-    IMAGE_WIDTH, IMAGE_HEIGHT
-};
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    int i;
-
-    cairo_set_rgb_color (cr, 0, 0, 0);
-    cairo_translate (cr, 2, 2);
-
-    for (i=0; i < LINES; i++) {
-	cairo_set_line_width (cr, i+1);
-	cairo_move_to (cr, 0, 0);
-	cairo_rel_line_to (cr, LINE_LENGTH, 0);
-	cairo_stroke (cr);
-	cairo_move_to (cr, LINE_LENGTH + 2, 0.5);
-	cairo_rel_line_to (cr, LINE_LENGTH, 0);
-	cairo_stroke (cr);
-	cairo_translate (cr, 0, i+3);
-    }
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index 77904144d50fd38a70da37b78d7a1efff9e102c2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/linear_gradient.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright © 2005 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Owen Taylor <otaylor@redhat.com>
- */
-
-#include "cairo_test.h"
-#include "stdio.h"
-
-/* The test matrix is
- *
- * A) Horizontal   B) 5°          C) 45°          D) Vertical
- * 1) Rotated 0°   2) Rotated 45° C) Rotated 90°
- * a) 2 stop       b) 3 stop
- *
- *  A1a   B1a  C1a  D1a
- *  A2a   B2a  C2a  D2a
- *  A3a   B3a  C3a  D3a
- *  A1b   B1b  C1b  D1b
- *  A2b   B2b  C2b  D2b
- *  A3b   B3b  C3b  D3b
- */
-
-static const double gradient_angles[] = { 0, 45, 90 };
-#define N_GRADIENT_ANGLES 3
-static const double rotate_angles[] = { 0, 45, 90 };
-#define N_ROTATE_ANGLES 3
-static const int n_stops[] = { 2, 3 };
-#define N_N_STOPS 2
-
-#define UNIT_SIZE 75
-#define UNIT_SIZE 75
-#define PAD 5
-
-#define WIDTH  N_GRADIENT_ANGLES * UNIT_SIZE + (N_GRADIENT_ANGLES + 1) * PAD
-#define HEIGHT N_N_STOPS * N_ROTATE_ANGLES * UNIT_SIZE + (N_N_STOPS * N_ROTATE_ANGLES + 1) * PAD
-
-cairo_test_t test = {
-    "linear_gradient",
-    "Tests the drawing of linear gradients",
-    WIDTH, HEIGHT
-};
-
-static void
-draw_unit (cairo_t *cr,
-	   double   gradient_angle,
-	   double   rotate_angle,
-	   int      n_stops)
-{
-    cairo_pattern_t *pattern;
-
-    cairo_rectangle (cr, 0, 0, 1, 1);
-    cairo_clip (cr);
-    cairo_new_path(cr);
-    
-    cairo_set_rgb_color (cr, 0.0, 0.0, 0.0);
-    cairo_rectangle (cr, 0, 0, 1, 1);
-    cairo_fill (cr);
-    
-    cairo_translate (cr, 0.5, 0.5);
-    cairo_scale (cr, 1 / 1.5, 1 / 1.5);
-    cairo_rotate (cr, rotate_angle);
-    
-    pattern = cairo_pattern_create_linear (-0.5 * cos (gradient_angle),  -0.5 * sin (gradient_angle),
- 					    0.5 * cos (gradient_angle),   0.5 * sin (gradient_angle));
-
-    if (n_stops == 2) {
-	cairo_pattern_add_color_stop (pattern, 0.,
-				      0.3, 0.3, 0.3,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 1.,
-				      1.0, 1.0, 1.0,
-				      1.0);
-    } else {
-	cairo_pattern_add_color_stop (pattern, 0.,
-				      1.0, 0.0, 0.0,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 0.5,
-				      1.0, 1.0, 1.0,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 1.,
-				      0.0, 0.0, 1.0,
-				      1.0);
-    }
-
-    cairo_set_pattern (cr, pattern);
-    cairo_pattern_destroy (pattern);
-    cairo_rectangle (cr, -0.5, -0.5, 1, 1);
-    cairo_fill (cr);
-}
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    int i, j, k;
-
-    cairo_set_rgb_color (cr, 0.5, 0.5, 0.5);
-    cairo_rectangle (cr, 0, 0, width, height);
-    cairo_fill (cr);
-
-    for (i = 0; i < N_GRADIENT_ANGLES; i++)
-	for (j = 0; j < N_ROTATE_ANGLES; j++)
-	  for (k = 0; k < N_N_STOPS; k++) {
-		cairo_save (cr);
-		cairo_translate (cr,
-				 PAD + (PAD + UNIT_SIZE) * i,
-				 PAD + (PAD + UNIT_SIZE) * (N_ROTATE_ANGLES * k + j));
-		cairo_scale (cr, UNIT_SIZE, UNIT_SIZE);
-		
-		draw_unit (cr,
-			   gradient_angles[i] * M_PI / 180.,
-			   rotate_angles[j] * M_PI / 180.,
-			   n_stops[k]);
-		cairo_restore (cr);
-	    }
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index 765adc4a48835d273043c0d18be61eda17d88088..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/move_to_show_surface.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-/* Bug history
- *
- * 2004-10-25  Carl Worth  <cworth@cworth.org>
- *
- *   It looks like cairo_show_surface has no effect if it follows a
- *   call to cairo_move_to to any coordinate other than 0,0. A little
- *   bit of poking around suggests this isn't a regression, (at least
- *   not since the last pixman snapshot).
- *
- */
-
-
-#include "cairo_test.h"
-
-cairo_test_t test = {
-    "move_to_show_surface",
-    "Tests calls to cairo_show_surface after cairo_move_to",
-    2, 2
-};
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_surface_t *surface;
-    uint32_t colors[4] = {
-	0xffffffff, 0xffff0000,
-	0xff00ff00, 0xff0000ff
-    };
-    int i;
-
-    for (i=0; i < 4; i++) {
-	surface = cairo_surface_create_for_image ((char *) &colors[i],
-						  CAIRO_FORMAT_ARGB32, 1, 1, 4);
-	cairo_move_to (cr, i % 2, i / 2);
-	cairo_show_surface (cr, surface, 1, 1);
-	cairo_surface_destroy (surface);
-    }
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
index 7e47a4d8f52eec624af0eff8b651e32ca2c4a6ff..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/pixman_rotate.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <cairo.h>
-#include <cairo-png.h>
-#include <cairo-pdf.h>
-
-#include "cairo_test.h"
-
-#define WIDTH	32
-#define HEIGHT	WIDTH
-
-#define IMAGE_WIDTH	(3 * WIDTH)
-#define IMAGE_HEIGHT	IMAGE_WIDTH
-
-cairo_test_t test = {
-    "pixman_rotate",
-    "Exposes pixman off-by-one error when rotating",
-    IMAGE_WIDTH, IMAGE_HEIGHT
-};
-
-/* Draw the word cairo at NUM_TEXT different angles */
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_surface_t *target, *stamp;
-
-    target = cairo_current_target_surface (cr);
-    cairo_surface_reference (target);
-
-    stamp = cairo_surface_create_similar (target, CAIRO_FORMAT_ARGB32,
-					  WIDTH, HEIGHT);
-    cairo_set_target_surface (cr, stamp);
-    cairo_new_path (cr);
-    cairo_rectangle (cr, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2);
-    cairo_set_rgb_color (cr, 1, 0, 0);
-    cairo_set_alpha (cr, 0.8);
-    cairo_fill (cr);
-
-    cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
-    cairo_set_line_width (cr, 2);
-    cairo_set_rgb_color (cr, 0, 0, 0);
-    cairo_set_alpha (cr, 1);
-    cairo_stroke (cr);
-
-    cairo_set_target_surface (cr, target);
-
-    /* Draw a translucent rectangle for reference where the rotated
-     * image should be. */
-    cairo_new_path (cr);
-    cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT);
-    cairo_set_rgb_color (cr, 1, 1, 0);
-    cairo_set_alpha (cr, 0.3);
-    cairo_fill (cr);
-
-#if 1 /* Set to 0 to generate reference image */
-    cairo_translate (cr, 2 * WIDTH, 2 * HEIGHT);
-    cairo_rotate (cr, M_PI);
-#else
-    cairo_translate (cr, WIDTH, HEIGHT);
-#endif
-
-    cairo_set_alpha (cr, 1);
-    cairo_show_surface (cr, stamp, WIDTH + 2, HEIGHT + 2);
-
-    cairo_show_page (cr);
-
-    cairo_surface_destroy (stamp);
-    cairo_surface_destroy (target);
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/read_png.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright © 2003 USC, Information Sciences Institute
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * University of Southern California not be used in advertising or
- * publicity pertaining to distribution of the software without
- * specific, written prior permission. The University of Southern
- * California makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- *
- * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
- * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@isi.edu>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <png.h>
-
-#include "read_png.h"
-#include "xmalloc.h"
-
-static void
-premultiply_data (png_structp   png,
-                  png_row_infop row_info,
-                  png_bytep     data)
-{
-    int i;
-
-    for (i = 0; i < row_info->rowbytes; i += 4) {
-	unsigned char  *base = &data[i];
-	unsigned char  blue = base[0];
-	unsigned char  green = base[1];
-	unsigned char  red = base[2];
-	unsigned char  alpha = base[3];
-	unsigned long	p;
-
-	red = ((unsigned) red * (unsigned) alpha + 127) / 255;
-	green = ((unsigned) green * (unsigned) alpha + 127) / 255;
-	blue = ((unsigned) blue * (unsigned) alpha + 127) / 255;
-	p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
-	memcpy (base, &p, sizeof (unsigned long));
-    }
-}
-
-read_png_status_t
-read_png_argb32 (const char         *filename,
-		 unsigned char      **data,
-		 unsigned int       *width,
-		 unsigned int       *height,
-		 unsigned int	    *stride)
-{
-    int i;
-    FILE *file;
-    static const int PNG_SIG_SIZE = 8;
-    unsigned char png_sig[PNG_SIG_SIZE];
-    int sig_bytes;
-    png_struct *png;
-    png_info *info;
-    png_uint_32 png_width, png_height;
-    int depth, color_type, interlace;
-    unsigned int pixel_size;
-    png_byte **row_pointers;
-
-    file = fopen (filename, "rb");
-    if (file == NULL) {
-	return READ_PNG_FILE_NOT_FOUND;
-    }
-
-    sig_bytes = fread (png_sig, 1, PNG_SIG_SIZE, file);
-    if (png_check_sig (png_sig, sig_bytes) == 0) {
-        fclose (file);
-	return READ_PNG_FILE_NOT_PNG;
-    }
-
-    /* XXX: Perhaps we'll want some other error handlers? */
-    png = png_create_read_struct (PNG_LIBPNG_VER_STRING,
-                                  NULL,
-                                  NULL,
-                                  NULL);
-    if (png == NULL) {
-        fclose (file);
-	return READ_PNG_NO_MEMORY;
-    }
-
-    info = png_create_info_struct (png);
-    if (info == NULL) {
-        fclose (file);
-        png_destroy_read_struct (&png, NULL, NULL);
-	return READ_PNG_NO_MEMORY;
-    }
-
-    png_init_io (png, file);
-    png_set_sig_bytes (png, sig_bytes);
-
-    png_read_info (png, info);
-
-    png_get_IHDR (png, info,
-                  &png_width, &png_height, &depth,
-                  &color_type, &interlace, NULL, NULL);
-    *width = png_width;
-    *height = png_height;
-    *stride = 4 * png_width;
-
-
-    /* convert palette/gray image to rgb */
-    if (color_type == PNG_COLOR_TYPE_PALETTE)
-        png_set_palette_to_rgb (png);
-
-    /* expand gray bit depth if needed */
-    if (color_type == PNG_COLOR_TYPE_GRAY && depth < 8)
-        png_set_gray_1_2_4_to_8 (png);
-    /* transform transparency to alpha */
-    if (png_get_valid(png, info, PNG_INFO_tRNS))
-        png_set_tRNS_to_alpha (png);
-
-    if (depth == 16)
-        png_set_strip_16 (png);
-
-    if (depth < 8)
-        png_set_packing (png);
-
-    /* convert grayscale to RGB */
-    if (color_type == PNG_COLOR_TYPE_GRAY
-        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-        png_set_gray_to_rgb (png);
-
-    if (interlace != PNG_INTERLACE_NONE)
-        png_set_interlace_handling (png);
-
-    png_set_bgr (png);
-    png_set_filler (png, 0xff, PNG_FILLER_AFTER);
-
-    png_set_read_user_transform_fn (png, premultiply_data);
-
-    png_read_update_info (png, info);
-
-    pixel_size = 4;
-    *data = xmalloc (png_width * png_height * pixel_size);
-
-    row_pointers = malloc (png_height * sizeof(char *));
-    for (i=0; i < png_height; i++)
-        row_pointers[i] = (png_byte *) (*data + i * png_width * pixel_size);
-
-    png_read_image (png, row_pointers);
-    png_read_end (png, info);
-
-    free (row_pointers);
-    fclose (file);
-
-    png_destroy_read_struct (&png, &info, NULL);
-
-    return READ_PNG_SUCCESS;
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/read_png.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright © 2003 USC, Information Sciences Institute
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * University of Southern California not be used in advertising or
- * publicity pertaining to distribution of the software without
- * specific, written prior permission. The University of Southern
- * California makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- *
- * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
- * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@isi.edu>
- */
-
-#ifndef READ_PNG_H
-#define READ_PNG_H
-
-typedef enum {
-    READ_PNG_SUCCESS = 0,
-    READ_PNG_FILE_NOT_FOUND,
-    READ_PNG_FILE_NOT_PNG,
-    READ_PNG_NO_MEMORY
-} read_png_status_t;
-
-read_png_status_t
-read_png_argb32 (const char         *filename,
-		 unsigned char      **data,
-		 unsigned int       *width,
-		 unsigned int       *height,
-		 unsigned int	    *stride);
-
-#endif
deleted file mode 100644
index 0c41eb0cfd29177c4ff83b4bcf99f7bec6a96c97..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/gfx/cairo/cairo/test/text_cache_crash.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-/* Bug history
- *
- * 2004-11-04 Ned Konz <ned@squeakland.org>
- *
- *   Reported bug on mailing list:
- *
- *	From: Ned Konz <ned@squeakland.org>
- *	To: cairo@cairographics.org
- *	Date: Thu, 4 Nov 2004 09:49:38 -0800
- *	Subject: [cairo] getting assertions [cairo_cache.c:143: _entry_destroy:
- *	        Assertion `cache->used_memory > entry->memory' failed]
- *
- *	The attached program dies on me with the assert
- *
- *	$ ./testCairo
- *	testCairo: cairo_cache.c:143: _entry_destroy: Assertion `cache->used_memory > entry->memory' failed.
- *
- * 2004-11-04 Carl Worth <cworth@cworth.org>
- *
- *   I trimmed down Ned's example to the folllowing test while still
- *   maintaining the assertion.
- *
- *   Oh, actually, it looks like I may have triggered something
- *   slightly different:
- *
- *	text_cache_crash: cairo_cache.c:422: _cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed.
- *
- *   I'll have to go back and try the original test after I fix this.
- *
- * 2004-11-13 Carl Worth <cworth@cworth.org>
- *
- *   Found the bug. cairo_gstate_select_font was noticing when the
- *   same font was selected twice in a row and was erroneously failing
- *   to free the old reference. Committed a fix and verified it also
- *   fixed the orginal test case.
- */
-
-#include "cairo_test.h"
-
-cairo_test_t test = {
-    "text_cache_crash",
-    "Test case for bug causing an assertion failure in _cairo_cache_lookup",
-    0, 0,
-};
-#include <cairo.h>
-
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    /* Once there was a bug that choked when selecting the same font twice. */
-    cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
-    cairo_scale_font(cr, 40.0);
-
-    cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
-    cairo_scale_font(cr, 40.0);
-    cairo_move_to(cr, 10, 50);
-    cairo_show_text(cr, "hello");
-
-    /* Then there was a bug that choked when selecting a font too big
-     * for the cache. */
-
-/* XXX: Sometimes this leads to an assertion:
-
-_cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed.
-Aborted
-
-   But other times my machine hangs completely only to return to life
-   several minutes later with some programs missing. This seems like
-   the out-of-memory killer to me.
-
-   It seems like I usually get the assertion when I run
-   ./text_cache_crash directly and I usually get the machine hang when
-   I run "make check" but I don't know if there's a perfect
-   correlation there.
-
-   So there's a bad bug here somewhere that really needs to be fixed.
-   But in the meantime, I need "make check" not to destory work, so
-   I'm commenting this test out for now.
-
-    cairo_scale_font (cr, 500);
-    cairo_show_text (cr, "hello");
-*/
-}
-
-int
-main (void)
-{
-    int ret;
-
-    ret = cairo_test (&test, draw);
-
-    /* It's convenient to be able to free all memory (including
-     * statically allocated memory). This makes it quite easy to use
-     * tools such as valgrind to verify that there are no memory leaks
-     * whatsoever.
-     *
-     * But I'm not sure what would be a sensible cairo API function
-     * for this. The cairo_destroy_caches call below is just something
-     * I made as a local modification to cairo.
-     */
-    /*
-    cairo_destroy_caches ();
-    FcFini ();
-    */
-
-    return ret;
-}
-
deleted file mode 100644
--- a/gfx/cairo/cairo/test/text_rotate.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-/* Bug history
- *
- * 2004-11-03 Steve Chaplin <stevech1097@yahoo.com.au>
- *
- *   Reported bug on mailing list:
- *
- *	From: Steve Chaplin <stevech1097@yahoo.com.au>
- *	To: cairo@cairographics.org
- *	Date: Thu, 04 Nov 2004 00:00:17 +0800
- *	Subject: [cairo] Rotated text bug on drawable target
- *
- * 	The attached file draws text rotated 90 degrees first to a PNG file and
- *	then to a drawable. The PNG file looks fine, the text on the drawable is
- *	unreadable.
- *
- *	Steve
- *
- * 2004-11-03 Carl Worth <cworth@cworth.org>
- *
- *   Looks like the major problems with this bg appeared in the great
- *   font rework between 0.1.23 and 0.2.0. And it looks like we need
- *   to fix the regression test suite to test the xlib target (since
- *   the bug does not show up in the png backend).
- *
- *   Hmm... Actually, things don't look perfect even in the PNG
- *   output. Look at how that 'o' moves around. It's particularly off
- *   in the case where it's rotated by PI.
- *
- *   And I'm still not sure about what to do for test cases with
- *   text--a new version of freetype will change everything. We may
- *   need to add a simple backend for stroked fonts and add a simple
- *   builtin font to cairo for pixel-perfect tests with text.
- */
-
-#include "cairo_test.h"
-
-#define WIDTH  150
-#define HEIGHT 150
-#define NUM_TEXT 20
-#define TEXT_SIZE 12
-
-cairo_test_t test = {
-    "text_rotate",
-    "Tests show_text under various rotations",
-    WIDTH, HEIGHT
-};
-
-/* Draw the word cairo at NUM_TEXT different angles */
-static void
-draw (cairo_t *cr, int width, int height)
-{
-    int i, x_off, y_off;
-    cairo_text_extents_t extents;
-    static char text[] = "cairo";
-
-    cairo_select_font (cr, "Bitstream Vera Sans",
-		       CAIRO_FONT_SLANT_NORMAL,
-		       CAIRO_FONT_WEIGHT_NORMAL);
-    cairo_scale_font (cr, TEXT_SIZE);
-
-    cairo_set_rgb_color (cr, 0,0,0);
-
-    cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0);
-
-    cairo_text_extents (cr, text, &extents);
-
-    if (NUM_TEXT == 1) {
-	x_off = y_off = 0;
-    } else {
-	y_off = - round (extents.height / 2.0);
-	x_off = round ((extents.height+1) / (2 * tan (M_PI/NUM_TEXT)));
-    }
-  
-    for (i=0; i < NUM_TEXT; i++) {
-	cairo_save (cr);
-	cairo_rotate (cr, 2*M_PI*i/NUM_TEXT);
-	cairo_set_line_width (cr, 1.0);
-	cairo_rectangle (cr, x_off - 0.5, y_off - 0.5, extents.width + 1, extents.height + 1);
-	cairo_set_rgb_color (cr, 1, 0, 0);
-	cairo_stroke (cr);
-	cairo_move_to (cr, x_off - extents.x_bearing, y_off - extents.y_bearing);
-	cairo_set_rgb_color (cr, 0, 0, 0);
-	cairo_show_text (cr, "cairo");
-	cairo_restore (cr);
-    }
-}
-
-int
-main (void)
-{
-    return cairo_test (&test, draw);
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/write_png.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright © 2003 USC, Information Sciences Institute
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * University of Southern California not be used in advertising or
- * publicity pertaining to distribution of the software without
- * specific, written prior permission. The University of Southern
- * California makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- *
- * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
- * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <png.h>
-
-#include "write_png.h"
-
-static void
-unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data)
-{
-    int i;
-
-    for (i = 0; i < row_info->rowbytes; i += 4) {
-        unsigned char *b = &data[i];
-        unsigned int pixel;
-        unsigned char alpha;
-
-	memcpy (&pixel, b, sizeof (unsigned int));
-	alpha = (pixel & 0xff000000) >> 24;
-        if (alpha == 0) {
-	    b[0] = b[1] = b[2] = b[3] = 0;
-	} else {
-            b[0] = (((pixel & 0x0000ff) >>  0) * 255 + alpha / 2) / alpha;
-            b[1] = (((pixel & 0x00ff00) >>  8) * 255 + alpha / 2) / alpha;
-            b[2] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
-	    b[3] = alpha;
-	}
-    }
-}
-
-void
-write_png_argb32 (char *buffer, FILE *file,
-		  int width, int height, int stride)
-{
-    int i;
-    png_struct *png;
-    png_info *info;
-    png_byte **rows;
-    png_color_16 white;
-    
-    rows = malloc (height * sizeof(png_byte*));
-
-    for (i = 0; i < height; i++) {
-	rows[i] = buffer + i * stride;
-    }
-
-    png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    info = png_create_info_struct (png);
-
-    png_init_io (png, file);
-    png_set_IHDR (png, info,
-		  width, height, 8,
-		  PNG_COLOR_TYPE_RGB_ALPHA, 
-		  PNG_INTERLACE_NONE,
-		  PNG_COMPRESSION_TYPE_DEFAULT,
-		  PNG_FILTER_TYPE_DEFAULT);
-
-    white.red = 0xff;
-    white.blue = 0xff;
-    white.green = 0xff;
-    png_set_bKGD (png, info, &white);
-
-    png_set_write_user_transform_fn (png, unpremultiply_data);
-    png_set_bgr (png);
-
-    png_write_info (png, info);
-    png_write_image (png, rows);
-    png_write_end (png, info);
-
-    png_destroy_write_struct (&png, &info);
-
-    free (rows);
-}
deleted file mode 100644
--- a/gfx/cairo/cairo/test/write_png.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright © 2003 USC, Information Sciences Institute
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * University of Southern California not be used in advertising or
- * publicity pertaining to distribution of the software without
- * specific, written prior permission. The University of Southern
- * California makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- *
- * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
- * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@isi.edu>
- */
-
-#ifndef WRITE_PNG_H
-#define WRITE_PNG_H
-
-void
-write_png_argb32 (char *buffer, FILE * file,
-		  int width, int height, int stride);
-
-#endif
deleted file mode 100644
--- a/gfx/cairo/cairo/test/xmalloc.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "xmalloc.h"
-
-void *
-xmalloc (size_t size)
-{
-    void *buf;
-
-    buf = malloc (size);
-    if (!buf) {
-	fprintf (stderr, "Error: Out of memory. Exiting.\n");
-	exit (1);
-    }
-
-    return buf;
-}
-
-void *
-xcalloc (size_t nmemb, size_t size)
-{
-    void *buf;
-
-    buf = calloc (nmemb, size);
-    if (!buf) {
-	fprintf (stderr, "Error: Out of memory. Exiting\n");
-	exit (1);
-    }
-
-    return buf;
-}
-
deleted file mode 100644
--- a/gfx/cairo/cairo/test/xmalloc.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#ifndef _XMALLOC_H_
-#define _XMALLOC_H_
-
-void *
-xmalloc (size_t size);
-
-void *
-xcalloc (size_t nmemb, size_t size);
-
-#endif
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -64,21 +64,21 @@
 #endif
 
 #if defined(ANDROID)
 /* from widget */
 #if defined(MOZ_WIDGET_ANDROID)
 #include "AndroidBridge.h"
 #endif
 #include <android/log.h>
-#define EGL_LIB "/system/lib/libEGL.so"
-#define GLES2_LIB "/system/lib/libGLESv2.so"
+#define EGL_LIB "libEGL.so"
+#define GLES2_LIB "libGLESv2.so"
 #else
-#define EGL_LIB "/usr/lib/libEGL.so"
-#define GLES2_LIB "/usr/lib/libGLESv2.so"
+#define EGL_LIB "libEGL.so.1"
+#define GLES2_LIB "libGLESv2.so.2"
 #endif
 
 typedef void *EGLNativeDisplayType;
 typedef void *EGLNativePixmapType;
 typedef void *EGLNativeWindowType;
 
 #elif defined(XP_WIN)
 
--- a/gfx/harfbuzz/src/hb-ot-layout-gsub-private.hh
+++ b/gfx/harfbuzz/src/hb-ot-layout-gsub-private.hh
@@ -371,19 +371,19 @@ struct Ligature
     if (first_was_mark && found_non_mark)
       c->guess_glyph_class (HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
 
     /* Allocate new ligature id */
     unsigned int lig_id = allocate_lig_id (c->buffer);
     c->buffer->info[c->buffer->i].lig_comp() = 0;
     c->buffer->info[c->buffer->i].lig_id() = lig_id;
 
-    if (j == c->buffer->i + i) /* No input glyphs skipped */
+    if (j < c->buffer->i + count) /* No input glyphs skipped */
     {
-      c->replace_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
+      c->replace_glyphs_be16 (count, 1, (const uint16_t *) &ligGlyph);
     }
     else
     {
       c->replace_glyph (ligGlyph);
 
       /* Now we must do a second loop to copy the skipped glyphs to
 	 `out' and assign component values to it.  We start with the
 	 glyph after the first component.  Glyphs between component
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -2980,24 +2980,24 @@ protected:
 };
 
 void
 BasicShadowImageLayer::Swap(const SharedImage& aNewFront,
                             SharedImage* aNewBack)
 {
   nsRefPtr<gfxASurface> surface =
     BasicManager()->OpenDescriptor(aNewFront);
-  // Destroy mFrontBuffer if size different
-  bool needDrop = false;
+  // Destroy mFrontBuffer if size different or image type is different
+  bool surfaceConfigChanged = surface->GetSize() != mSize;
   if (IsSurfaceDescriptorValid(mFrontBuffer)) {
     nsRefPtr<gfxASurface> front = BasicManager()->OpenDescriptor(mFrontBuffer);
-    needDrop = surface->GetSize() != mSize ||
-               surface->GetContentType() != front->GetContentType();
+    surfaceConfigChanged = surfaceConfigChanged ||
+                           surface->GetContentType() != front->GetContentType();
   }
-  if (needDrop) {
+  if (surfaceConfigChanged) {
     DestroyFrontBuffer();
     mSize = surface->GetSize();
   }
 
   // If mFrontBuffer
   if (IsSurfaceDescriptorValid(mFrontBuffer)) {
     *aNewBack = mFrontBuffer;
   } else {
@@ -3102,23 +3102,23 @@ BasicShadowCanvasLayer::Initialize(const
 void
 BasicShadowCanvasLayer::Swap(const CanvasSurface& aNewFront, bool needYFlip,
                              CanvasSurface* aNewBack)
 {
   nsRefPtr<gfxASurface> surface =
     BasicManager()->OpenDescriptor(aNewFront);
   // Destroy mFrontBuffer if size different
   gfxIntSize sz = surface->GetSize();
-  bool needDrop = false;
+  bool surfaceConfigChanged = sz != gfxIntSize(mBounds.width, mBounds.height);
   if (IsSurfaceDescriptorValid(mFrontSurface)) {
     nsRefPtr<gfxASurface> front = BasicManager()->OpenDescriptor(mFrontSurface);
-    needDrop = sz != gfxIntSize(mBounds.width, mBounds.height) ||
-               surface->GetContentType() != front->GetContentType();
+    surfaceConfigChanged = surfaceConfigChanged ||
+                           surface->GetContentType() != front->GetContentType();
   }
-  if (needDrop) {
+  if (surfaceConfigChanged) {
     DestroyFrontBuffer();
     mBounds.SetRect(0, 0, sz.width, sz.height);
   }
 
   mNeedsYFlip = needYFlip;
   // If mFrontBuffer
   if (IsSurfaceDescriptorValid(mFrontSurface)) {
     *aNewBack = mFrontSurface;
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -64,28 +64,30 @@
 #include "gfxScriptItemizer.h"
 #include "gfxUnicodeProperties.h"
 #include "nsMathUtils.h"
 #include "nsBidiUtils.h"
 #include "nsUnicodeRange.h"
 #include "nsCompressedCharMap.h"
 #include "nsStyleConsts.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/Services.h"
 
 #include "cairo.h"
 #include "gfxFontTest.h"
 
 #include "harfbuzz/hb-blob.h"
 
 #include "nsCRT.h"
 
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
+using mozilla::services::GetObserverService;
 
 gfxFontCache *gfxFontCache::gGlobalCache = nsnull;
 
 #ifdef DEBUG_roc
 #define DEBUG_TEXT_RUN_STORAGE_METRICS
 #endif
 
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
@@ -949,16 +951,49 @@ gfxFontFamily::FindFont(const nsAString&
     for (PRUint32 i = 0; i < numFonts; i++) {
         gfxFontEntry *fe = mAvailableFonts[i].get();
         if (fe && fe->Name() == aPostscriptName)
             return fe;
     }
     return nsnull;
 }
 
+/*
+ * gfxFontCache - global cache of gfxFont instances.
+ * Expires unused fonts after a short interval;
+ * notifies fonts to age their cached shaped-word records;
+ * observes memory-pressure notification and tells fonts to clear their
+ * shaped-word caches to free up memory.
+ */
+
+// Observer for the memory-pressure notification, to trigger
+// flushing of the shaped-word caches
+class MemoryPressureObserver : public nsIObserver,
+                               public nsSupportsWeakReference
+{
+public:
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIOBSERVER
+};
+
+NS_IMPL_ISUPPORTS2(MemoryPressureObserver, nsIObserver, nsISupportsWeakReference)
+
+NS_IMETHODIMP
+MemoryPressureObserver::Observe(nsISupports *aSubject,
+                                const char *aTopic,
+                                const PRUnichar *someData)
+{
+    if (!nsCRT::strcmp(aTopic, "memory-pressure")) {
+        gfxFontCache *fontCache = gfxFontCache::GetCache();
+        if (fontCache) {
+            fontCache->FlushShapedWordCaches();
+        }
+    }
+    return NS_OK;
+}
 
 nsresult
 gfxFontCache::Init()
 {
     NS_ASSERTION(!gGlobalCache, "Where did this come from?");
     gGlobalCache = new gfxFontCache();
     return gGlobalCache ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
@@ -981,16 +1016,22 @@ gfxFontCache::Shutdown()
     printf("Number of simple glyph extent setups that fell back to tight=%d\n", gGlyphExtentsSetupFallBackToTight);
 #endif
 }
 
 gfxFontCache::gfxFontCache()
     : nsExpirationTracker<gfxFont,3>(FONT_TIMEOUT_SECONDS * 1000)
 {
     mFonts.Init();
+
+    nsCOMPtr<nsIObserverService> obs = GetObserverService();
+    if (obs) {
+        obs->AddObserver(new MemoryPressureObserver, "memory-pressure", false);
+    }
+
     mWordCacheExpirationTimer = do_CreateInstance("@mozilla.org/timer;1");
     if (mWordCacheExpirationTimer) {
         mWordCacheExpirationTimer->
             InitWithFuncCallback(WordCacheExpirationTimerCallback, this,
                                  SHAPED_WORD_TIMEOUT_SECONDS * 1000,
                                  nsITimer::TYPE_REPEATING_SLACK);
     }
 }
@@ -1097,16 +1138,24 @@ gfxFontCache::AgeCachedWordsForFont(Hash
 /*static*/
 void
 gfxFontCache::WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache)
 {
     gfxFontCache* cache = static_cast<gfxFontCache*>(aCache);
     cache->mFonts.EnumerateEntries(AgeCachedWordsForFont, nsnull);
 }
 
+/*static*/
+PLDHashOperator
+gfxFontCache::ClearCachedWordsForFont(HashEntry* aHashEntry, void* aUserData)
+{
+    aHashEntry->mFont->ClearCachedWords();
+    return PL_DHASH_NEXT;
+}
+
 void
 gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, bool aOtherIsOnLeft)
 {
     mAscent = NS_MAX(mAscent, aOther.mAscent);
     mDescent = NS_MAX(mDescent, aOther.mDescent);
     if (aOtherIsOnLeft) {
         mBoundingBox =
             (mBoundingBox + gfxPoint(aOther.mAdvanceWidth, 0)).Union(aOther.mBoundingBox);
@@ -3323,19 +3372,23 @@ void gfxFontGroup::ComputeRanges(nsTArra
 {
     aRanges.Clear();
 
     if (aLength == 0) {
         return;
     }
 
     PRUint32 prevCh = 0;
-    gfxFont *prevFont = nsnull;
     PRUint8 matchType = 0;
 
+    // initialize prevFont to the group's primary font, so that this will be
+    // used for string-initial control chars, etc rather than risk hitting font
+    // fallback for these (bug 716229)
+    gfxFont *prevFont = GetFontAt(0);
+
     for (PRUint32 i = 0; i < aLength; i++) {
 
         const PRUint32 origI = i; // save off in case we increase for surrogate
 
         // set up current ch
         PRUint32 ch = aString[i];
 
         // in 16-bit case only, check for surrogate pair
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -727,16 +727,20 @@ public:
     // Cleans out the hashtable and removes expired fonts waiting for cleanup.
     // Other gfxFont objects may be still in use but they will be pushed
     // into the expiration queues and removed.
     void Flush() {
         mFonts.Clear();
         AgeAllGenerations();
     }
 
+    void FlushShapedWordCaches() {
+        mFonts.EnumerateEntries(ClearCachedWordsForFont, nsnull);
+    }
+
 protected:
     void DestroyFont(gfxFont *aFont);
 
     static gfxFontCache *gGlobalCache;
 
     struct Key {
         const gfxFontEntry* mFontEntry;
         const gfxFontStyle* mStyle;
@@ -762,16 +766,17 @@ protected:
         }
         enum { ALLOW_MEMMOVE = true };
 
         gfxFont* mFont;
     };
 
     nsTHashtable<HashEntry> mFonts;
 
+    static PLDHashOperator ClearCachedWordsForFont(HashEntry* aHashEntry, void*);
     static PLDHashOperator AgeCachedWordsForFont(HashEntry* aHashEntry, void*);
     static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
     nsCOMPtr<nsITimer>      mWordCacheExpirationTimer;
 };
 
 class THEBES_API gfxTextRunFactory {
     NS_INLINE_DECL_REFCOUNTING(gfxTextRunFactory)
 
@@ -1400,16 +1405,23 @@ public:
     // Called by the gfxFontCache timer to increment the age of all the words,
     // so that they'll expire after a sufficient period of non-use
     void AgeCachedWords() {
         if (mWordCache.IsInitialized()) {
             (void)mWordCache.EnumerateEntries(AgeCacheEntry, this);
         }
     }
 
+    // Discard all cached word records; called on memory-pressure notification.
+    void ClearCachedWords() {
+        if (mWordCache.IsInitialized()) {
+            mWordCache.Clear();
+        }
+    }
+
 protected:
     // Call the appropriate shaper to generate glyphs for aText and store
     // them into aShapedWord.
     // The length of the text is aShapedWord->Length().
     virtual bool ShapeWord(gfxContext *aContext,
                            gfxShapedWord *aShapedWord,
                            const PRUnichar *aText,
                            bool aPreferPlatformShaping = false);
--- a/intl/uconv/ucvja/japanese.map
+++ b/intl/uconv/ucvja/japanese.map
@@ -72,33 +72,39 @@ static const PRUint16 gIndexJis0208[] = 
     6486,   6580,   6674,   6768,   6862,   6956,   7050,   7144,
     7238,   7332,   7426,   7520,   7614,      0,      0,      0,
        0,   7708,   7802,   7896,   7990,      0,      0, 0xFFFD,
 };
 static const PRUint16 * const gIndex[] = {
   gIndexShiftJis, gIndexJis0208
 };
 
+// IE-compatible handling of undefined codepoints:
+// 0x80 --> U+0080
+// 0xa0 --> U+F8F0
+// 0xfd --> U+F8F1
+// 0xfe --> U+F8F2
+// 0xff --> U+F8F3
 static const PRUint16 gCP932IndexShiftJis[] = {
   0xFFFD,   8648,    376,    564,    752,      0,      0,    940,
     1128,   1316,   1504,   1692,   1880,   2068,   2256,   2444,
     2632,   2820,   3008,   3196,   3384,   3572,   3760,   3948,
     4136,   4324,   4512,   4700,   4888,   5076,   5264,   5452,
-  0xFFFD, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
+  0xF8F0, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
   0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
   0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
   0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
   0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
   0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
   0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
   0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
     5640,   5828,   6016,   6204,   6392,   6580,   6768,   6956,
     7144,   7332,   7520,      0,      0,   7708,   7896,      0,
   0xE000, 0xE0BC, 0xE178, 0xE234, 0xE2F0, 0xE3AC, 0xE468, 0xE524,
-  0xE5E0, 0xE69C,   8084,   8272,   8460, 0xFFFD, 0xFFFD, 0xFFFD,
+  0xE5E0, 0xE69C,   8084,   8272,   8460, 0xF8F1, 0xF8F2, 0xF8F3,
 };
 static const PRUint16 gCP932IndexJis0208[] = {
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD,   8648,   8742,    376,    470,    564,    658,    752,
      846,      0,      0,      0,      0,    940,      0,      0,
@@ -117,28 +123,28 @@ static const PRUint16 * const gCP932Inde
   gCP932IndexShiftJis, gCP932IndexJis0208
 };
 
 static const PRUint16 gIBM943IndexShiftJis[] = {
   0xFFFD,   8836,    376,    564,    752,      0,      0,    940,
     1128,   1316,   1504,   1692,   1880,   2068,   2256,   2444,
     2632,   2820,   3008,   3196,   3384,   3572,   3760,   3948,
     4136,   4324,   4512,   4700,   4888,   5076,   5264,   5452,
-  0xFFFD, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
+  0xF8F0, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
   0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
   0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
   0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
   0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
   0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
   0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
   0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
     5640,   5828,   6016,   6204,   6392,   6580,   6768,   6956,
     7144,   7332,   7520,      0,      0,   7708,   9024,      0,
   0xE000, 0xE0BC, 0xE178, 0xE234, 0xE2F0, 0xE3AC, 0xE468, 0xE524,
-  0xE5E0, 0xE69C,   9212,   8272,   8460, 0xFFFD, 0xFFFD, 0xFFFD,
+  0xE5E0, 0xE69C,   9212,   8272,   8460, 0xF8F1, 0xF8F2, 0xF8F3,
 };
 static const PRUint16 gIBM943IndexJis0208[] = {
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
   0xFFFD,   8836,   8742,    376,    470,    564,    658,    752,
      846,      0,      0,      0,      0,    940,      0,      0,
--- a/intl/uconv/ucvja/nsJapaneseToUnicode.cpp
+++ b/intl/uconv/ucvja/nsJapaneseToUnicode.cpp
@@ -37,16 +37,19 @@
 #include "nsJapaneseToUnicode.h"
 
 #include "nsUCSupport.h"
 
 #include "japanese.map"
 
 #include "nsICharsetConverterManager.h"
 #include "nsIServiceManager.h"
+
+#include "mozilla/Assertions.h"
+
 static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
 
 #ifdef XP_OS2
   // HTML5-incompliant behavior for OS/2, see bug 108136
   // This is bogus. The right fix would be working around the font problems
   // in OS/2 gfx, since this "fix" introduces script-visible DOM differences
   // between the platforms.
   #define SJIS_INDEX gIBM943Index[0]
@@ -100,80 +103,43 @@ NS_IMETHODIMP nsShiftJISToUnicode::Conve
       175,  176,  177,  178,  179,  180,  181,  182,  /* 0xf0 */
       183,  184,  185,  186,  187, 0xFF, 0xFF, 0xFF,  /* 0xf8 */
    };
 
    const unsigned char* srcEnd = (unsigned char*)aSrc + *aSrcLen;
    const unsigned char* src =(unsigned char*) aSrc;
    PRUnichar* destEnd = aDest + *aDestLen;
    PRUnichar* dest = aDest;
-   while((src < srcEnd))
-   {
-       switch(mState)
-       {
-
+   while (src < srcEnd) {
+       switch (mState) {
           case 0:
-          if(*src & 0x80)
-          {
-            mData = SJIS_INDEX[*src & 0x7F];
-            if(mData < 0xE000 )
-            {
-               mState = 1; // two bytes 
-            } else {
-               if( mData > 0xFF00)
-               {
-                 if(0xFFFD == mData) {
-                   // IE-compatible handling of undefined codepoints:
-                   // 0x80 --> U+0080
-                   // 0xa0 --> U+F8F0
-                   // 0xfd --> U+F8F1
-                   // 0xfe --> U+F8F2
-                   // 0xff --> U+F8F3
-                   switch (*src) {
-                     case 0x80:
-                       *dest++ = (PRUnichar) *src;
-                       break;
-
-                     case 0xa0:
-                       *dest++ = (PRUnichar) 0xf8f0;
-                       break;
-
-                     case 0xfd:
-                     case 0xfe:
-                     case 0xff:
-                       *dest++ = (PRUnichar) 0xf8f1 + 
-                                   (*src - (unsigned char)(0xfd));
-                       break;
-
-                     default:
-                       if (mErrBehavior == kOnError_Signal)
-                         goto error_invalidchar;
-                       *dest++ = SJIS_UNMAPPED;
-                   }
-                   if(dest >= destEnd)
-                     goto error1;
-                 } else {
-                   *dest++ = mData; // JIS 0201
-                   if(dest >= destEnd)
-                     goto error1;
-                 }
-               } else {
-                 mState = 2; // EUDC
-               }
+          if (*src <= 0x80) {
+            // ASCII
+            *dest++ = (PRUnichar) *src;
+            if (dest >= destEnd) {
+              goto error1;
             }
           } else {
-            // ASCII
-            *dest++ = (PRUnichar) *src;
-            if(dest >= destEnd)
-              goto error1;
+            mData = SJIS_INDEX[*src & 0x7F];
+            if (mData < 0xE000) {
+              mState = 1; // two bytes
+            } else if (mData < 0xF000) {
+              mState = 2; // EUDC
+            } else {
+              *dest++ = mData; // JIS 0201
+              if (dest >= destEnd) {
+                goto error1;
+              }
+            }
           }
           break;
 
           case 1: // Index to table
           {
+            MOZ_ASSERT(mData < 0xE000);
             PRUint8 off = sbIdx[*src];
 
             // Error handling: in the case where the second octet is not in the
             // valid ranges 0x40-0x7E 0x80-0xFC, unconsume the invalid octet and
             // interpret it as the ASCII value. In the case where the second
             // octet is in the valid range but there is no mapping for the
             // 2-octet sequence, do not unconsume.
             if(0xFF == off) {
@@ -193,16 +159,17 @@ NS_IMETHODIMP nsShiftJISToUnicode::Conve
             mState = 0;
             if(dest >= destEnd)
               goto error1;
           }
           break;
 
           case 2: // EUDC
           {
+            MOZ_ASSERT(0xE000 <= mData && mData < 0xF000);
             PRUint8 off = sbIdx[*src];
 
             // Error handling as in case 1
             if(0xFF == off) {
                src--;
                if (mErrBehavior == kOnError_Signal)
                  goto error_invalidchar;
 
--- a/ipc/chromium/Makefile.in
+++ b/ipc/chromium/Makefile.in
@@ -314,20 +314,22 @@ CSRCS += \
 endif # }
 
 endif # }
 
 endif # }
 
 ifneq (86,$(findstring 86,$(OS_TEST))) # {
 ifneq (arm,$(findstring arm,$(OS_TEST))) # {
+ifneq (mips,$(findstring mips,$(OS_TEST))) # {
 # Use mutex-backed atomics
 CPPSRCS += atomicops_internals_mutex.cc
 endif # }
 endif # }
+endif # }
 
 OS_CXXFLAGS += $(TK_CFLAGS)
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_NATIVE_LIBEVENT # {
 export::
 	mkdir -p $(DIST)/third_party/libevent
--- a/ipc/chromium/src/base/atomicops.h
+++ b/ipc/chromium/src/base/atomicops.h
@@ -131,13 +131,15 @@ Atomic64 Release_Load(volatile const Ato
 #if defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_msvc.h"
 #elif defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_macosx.h"
 #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_gcc.h"
 #elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY)
 #include "base/atomicops_internals_arm_gcc.h"
+#elif defined(COMPILER_GCC) && defined(ARCH_CPU_MIPS)
+#include "base/atomicops_internals_mips_gcc.h"
 #else
 #include "base/atomicops_internals_mutex.h"
 #endif
 
 #endif  // BASE_ATOMICOPS_H_
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -2843,16 +2843,21 @@ class _GenerateProtocolActorCode(ipdl.as
         default = StmtBlock()
         default.addstmt(StmtReturn(_Result.NotKnown))
         self.asyncSwitch.addcase(DefaultLabel(), default)
         if toplevel.talksSync():
             self.syncSwitch.addcase(DefaultLabel(), default)
             if toplevel.talksRpc():
                 self.rpcSwitch.addcase(DefaultLabel(), default)
 
+        # FIXME/bug 535053: only manager protocols and non-manager
+        # protocols with union types need Lookup().  we'll give it to
+        # all for the time being (simpler)
+        if 1 or ptype.isManager():
+            self.cls.addstmts(self.implementManagerIface())
 
         def makeHandlerMethod(name, switch, hasReply, dispatches=0):
             params = [ Decl(Type('Message', const=1, ref=1), msgvar.name) ]
             if hasReply:
                 params.append(Decl(Type('Message', ref=1, ptr=1),
                                    replyvar.name))
             
             method = MethodDefn(MethodDecl(name, virtual=True,
@@ -3005,21 +3010,16 @@ class _GenerateProtocolActorCode(ipdl.as
         # OnChannelConnected()
         onconnected = MethodDefn(MethodDecl('OnChannelConnected',
                                             params=[ Decl(Type.INT32, 'pid') ]))
         if not ptype.isToplevel():
             onconnected.addstmt(
                 _runtimeAbort("'OnConnected' called on non-toplevel actor"))
 
         self.cls.addstmts([ onconnected, Whitespace.NL ])
-        # FIXME/bug 535053: only manager protocols and non-manager
-        # protocols with union types need Lookup().  we'll give it to
-        # all for the time being (simpler)
-        if 1 or ptype.isManager():
-            self.cls.addstmts(self.implementManagerIface())
 
         # User-facing shmem methods
         self.cls.addstmts(self.makeShmemIface())
 
         if (ptype.isToplevel() and ptype.talksRpc()):
 
             processnative = MethodDefn(
                 MethodDecl('ProcessNativeEventsInRPCCall', ret=Type.VOID))
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -188,66 +188,55 @@ INSTALLED_HEADERS = \
 		$(CURDIR)/jsautokw.h \
 		js.msg \
 		jsalloc.h \
 		jsapi.h \
 		jsatom.h \
 		jsclass.h \
 		jsclist.h \
 		jsclone.h \
-		jscntxt.h \
 		jscompat.h \
-		jscrashreport.h \
-		jsdate.h \
 		jsdbgapi.h \
 		jsdhash.h \
 		jsfriendapi.h \
 		jsgc.h \
 		jscell.h \
 		jsgcchunk.h \
 		jsgcstats.h \
 		jshash.h \
 		jslock.h \
 		json.h \
 		jsopcode.tbl \
 		jsopcode.h \
 		jsproxy.h \
 		jsprf.h \
-		jspropertycache.h \
-		jspropertytree.h \
 		jsproto.tbl \
 		jsprvtd.h \
 		jspubtd.h \
-		jsreflect.h \
 		jsstdint.h \
-		jsstr.h \
 		jstypedarray.h \
 		jstypes.h \
 		jsutil.h \
 		jsversion.h \
 		jswrapper.h \
 		jsxdrapi.h \
 		jsval.h \
-		prmjtime.h \
 		$(NULL)
 
 ######################################################
 # BEGIN exported headers that are only exported
 #       because of inclusion by an INSTALLED_HEADER
 #
 EXPORTS_NAMESPACES += vm ds gc
 
 EXPORTS_vm = \
 		String.h \
-		StackSpace.h \
-		Unicode.h  \
 		$(NULL)
 
 EXPORTS_ds = \
-		LifoAlloc.h \
 		BitArray.h \
 		$(NULL)
 
 EXPORTS_gc = \
 		Statistics.h \
 		Barrier.h \
 		$(NULL)
 
@@ -328,16 +317,19 @@ endif
 endif
 endif
 ifeq (arm, $(TARGET_CPU))
 #CPPSRCS		+= only_on_arm.cpp
 endif
 ifeq (sparc, $(findstring sparc,$(TARGET_CPU)))
 ASFILES +=	TrampolineSparc.s
 endif
+ifeq (mips, $(findstring mips,$(TARGET_CPU)))
+CPPSRCS +=	TrampolineMIPS.cpp
+endif
 #
 # END enclude sources for the method JIT
 #############################################
 
 endif
 
 ###############################################
 # BEGIN include sources for V8 dtoa
@@ -356,17 +348,17 @@ CPPSRCS += 	checks.cc \
 
 #
 # END enclude sources for V8 dtoa
 #############################################
 
 # For architectures without YARR JIT, PCRE is faster than the YARR
 # interpreter (bug 684559).
 
-ifeq (,$(filter arm% sparc %86 x86_64,$(TARGET_CPU)))
+ifeq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU)))
 
 VPATH +=        $(srcdir)/yarr/pcre \
 		$(NULL)
 
 CPPSRCS += \
                 pcre_compile.cpp \
                 pcre_exec.cpp \
                 pcre_tables.cpp \
new file mode 100644
--- /dev/null
+++ b/js/src/assembler/assembler/MIPSAssembler.h
@@ -0,0 +1,1089 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 University of Szeged
+ * All rights reserved.
+ * Copyright (C) 2010 MIPS Technologies, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY MIPS TECHNOLOGIES, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL MIPS TECHNOLOGIES, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MIPSAssembler_h
+#define MIPSAssembler_h
+
+#if ENABLE(ASSEMBLER) && CPU(MIPS)
+
+#include "AssemblerBuffer.h"
+#include "assembler/wtf/Assertions.h"
+#include "assembler/wtf/SegmentedVector.h"
+
+#include "methodjit/Logging.h"
+#define IPFX  "        %s"
+#define ISPFX "        "
+#ifdef JS_METHODJIT_SPEW
+# define MAYBE_PAD (isOOLPath ? ">  " : "")
+# define PRETTY_PRINT_OFFSET(os) (((os)<0)?"-":""), (((os)<0)?-(os):(os))
+# define FIXME_INSN_PRINTING                                \
+    do {                                                    \
+        js::JaegerSpew(js::JSpew_Insns,                     \
+                       ISPFX "FIXME insn printing %s:%d\n", \
+                       __FILE__, __LINE__);                 \
+    } while (0)
+#else
+# define MAYBE_PAD ""
+# define FIXME_INSN_PRINTING ((void) 0)
+# define PRETTY_PRINT_OFFSET(os) "", 0
+#endif
+
+namespace JSC {
+
+typedef uint32_t MIPSWord;
+
+namespace MIPSRegisters {
+typedef enum {
+    r0 = 0,
+    r1,
+    r2,
+    r3,
+    r4,
+    r5,
+    r6,
+    r7,
+    r8,
+    r9,
+    r10,
+    r11,
+    r12,
+    r13,
+    r14,
+    r15,
+    r16,
+    r17,
+    r18,
+    r19,
+    r20,
+    r21,
+    r22,
+    r23,
+    r24,
+    r25,
+    r26,
+    r27,
+    r28,
+    r29,
+    r30,
+    r31,
+    zero = r0,
+    at = r1,
+    v0 = r2,
+    v1 = r3,
+    a0 = r4,
+    a1 = r5,
+    a2 = r6,
+    a3 = r7,
+    t0 = r8,
+    t1 = r9,
+    t2 = r10,
+    t3 = r11,
+    t4 = r12,
+    t5 = r13,
+    t6 = r14,
+    t7 = r15,
+    s0 = r16,
+    s1 = r17,
+    s2 = r18,
+    s3 = r19,
+    s4 = r20,
+    s5 = r21,
+    s6 = r22,
+    s7 = r23,
+    t8 = r24,
+    t9 = r25,
+    k0 = r26,
+    k1 = r27,
+    gp = r28,
+    sp = r29,
+    fp = r30,
+    ra = r31
+} RegisterID;
+
+typedef enum {
+    f0 = 0,
+    f1,
+    f2,
+    f3,
+    f4,
+    f5,
+    f6,
+    f7,
+    f8,
+    f9,
+    f10,
+    f11,
+    f12,
+    f13,
+    f14,
+    f15,
+    f16,
+    f17,
+    f18,
+    f19,
+    f20,
+    f21,
+    f22,
+    f23,
+    f24,
+    f25,
+    f26,
+    f27,
+    f28,
+    f29,
+    f30,
+    f31
+} FPRegisterID;
+
+} // namespace MIPSRegisters
+
+class MIPSAssembler {
+public:
+    typedef MIPSRegisters::RegisterID RegisterID;
+    typedef MIPSRegisters::FPRegisterID FPRegisterID;
+    typedef SegmentedVector<int, 64> Jumps;
+    unsigned char *buffer() const { return m_buffer.buffer(); }
+    bool oom() const { return m_buffer.oom(); }
+
+#ifdef JS_METHODJIT_SPEW
+    bool isOOLPath;
+    MIPSAssembler() : isOOLPath(false) { }
+#else
+    MIPSAssembler() { }
+#endif
+
+    // MIPS instruction opcode field position
+    enum {
+        OP_SH_RD = 11,
+        OP_SH_RT = 16,
+        OP_SH_RS = 21,
+        OP_SH_SHAMT = 6,
+        OP_SH_CODE = 16,
+        OP_SH_FD = 6,
+        OP_SH_FS = 11,
+        OP_SH_FT = 16
+    };
+
+    class JmpSrc {
+        friend class MIPSAssembler;
+    public:
+        JmpSrc()
+            : m_offset(-1)
+        {
+        }
+
+    private:
+        JmpSrc(int offset)
+            : m_offset(offset)
+        {
+        }
+
+        int m_offset;
+    };
+
+    class JmpDst {
+        friend class MIPSAssembler;
+    public:
+        JmpDst()
+            : m_offset(-1)
+            , m_used(false)
+        {
+        }
+
+        bool isUsed() const { return m_used; }
+        void used() { m_used = true; }
+        bool isValid() const { return m_offset != -1; }
+    private:
+        JmpDst(int offset)
+            : m_offset(offset)
+            , m_used(false)
+        {
+            ASSERT(m_offset == offset);
+        }
+
+        int m_offset : 31;
+        int m_used : 1;
+    };
+
+    void emitInst(MIPSWord op)
+    {
+        void* oldBase = m_buffer.data();
+
+        m_buffer.putInt(op);
+
+        void* newBase = m_buffer.data();
+        if (oldBase != newBase)
+            relocateJumps(oldBase, newBase);
+    }
+
+    void nop()
+    {
+        emitInst(0x00000000);
+    }
+
+    /* Need to insert one load data delay nop for mips1.  */
+    void loadDelayNop()
+    {
+#if WTF_MIPS_ISA(1)
+        nop();
+#endif
+    }
+
+    /* Need to insert one coprocessor access delay nop for mips1.  */
+    void copDelayNop()
+    {
+#if WTF_MIPS_ISA(1)
+        nop();
+#endif
+    }
+
+    void movz(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x0000000a | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void move(RegisterID rd, RegisterID rs)
+    {
+        /* addu */
+        emitInst(0x00000021 | (rd << OP_SH_RD) | (rs << OP_SH_RS));
+    }
+
+    /* Set an immediate value to a register.  This may generate 1 or 2
+       instructions.  */
+    void li(RegisterID dest, int imm)
+    {
+        if (imm >= -32768 && imm <= 32767)
+            addiu(dest, MIPSRegisters::zero, imm);
+        else if (imm >= 0 && imm < 65536)
+            ori(dest, MIPSRegisters::zero, imm);
+        else {
+            lui(dest, imm >> 16);
+            if (imm & 0xffff)
+                ori(dest, dest, imm);
+        }
+    }
+
+    void lui(RegisterID rt, int imm)
+    {
+        emitInst(0x3c000000 | (rt << OP_SH_RT) | (imm & 0xffff));
+    }
+
+    void addiu(RegisterID rt, RegisterID rs, int imm)
+    {
+        emitInst(0x24000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (imm & 0xffff));
+    }
+
+    void addu(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000021 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void subu(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000023 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void mult(RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000018 | (rs << OP_SH_RS) | (rt << OP_SH_RT));
+    }
+
+    void div(RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x0000001a | (rs << OP_SH_RS) | (rt << OP_SH_RT));
+    }
+
+    void mfhi(RegisterID rd)
+    {
+        emitInst(0x00000010 | (rd << OP_SH_RD));
+    }
+
+    void mflo(RegisterID rd)
+    {
+        emitInst(0x00000012 | (rd << OP_SH_RD));
+    }
+
+    void mul(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+#if WTF_MIPS_ISA_AT_LEAST(32) 
+        emitInst(0x70000002 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+#else
+        mult(rs, rt);
+        mflo(rd);
+#endif
+    }
+
+    void andInsn(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000024 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void andi(RegisterID rt, RegisterID rs, int imm)
+    {
+        emitInst(0x30000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (imm & 0xffff));
+    }
+
+    void nor(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000027 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void orInsn(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000025 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void ori(RegisterID rt, RegisterID rs, int imm)
+    {
+        emitInst(0x34000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (imm & 0xffff));
+    }
+
+    void xorInsn(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x00000026 | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void xori(RegisterID rt, RegisterID rs, int imm)
+    {
+        emitInst(0x38000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (imm & 0xffff));
+    }
+
+    void slt(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x0000002a | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void sltu(RegisterID rd, RegisterID rs, RegisterID rt)
+    {
+        emitInst(0x0000002b | (rd << OP_SH_RD) | (rs << OP_SH_RS)
+                 | (rt << OP_SH_RT));
+    }
+
+    void sltiu(RegisterID rt, RegisterID rs, int imm)
+    {
+        emitInst(0x2c000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (imm & 0xffff));
+    }
+
+    void sll(RegisterID rd, RegisterID rt, int shamt)
+    {
+        emitInst(0x00000000 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | ((shamt & 0x1f) << OP_SH_SHAMT));
+    }
+
+    void sllv(RegisterID rd, RegisterID rt, int rs)
+    {
+        emitInst(0x00000004 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | (rs << OP_SH_RS));
+    }
+
+    void sra(RegisterID rd, RegisterID rt, int shamt)
+    {
+        emitInst(0x00000003 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | ((shamt & 0x1f) << OP_SH_SHAMT));
+    }
+
+    void srav(RegisterID rd, RegisterID rt, RegisterID rs)
+    {
+        emitInst(0x00000007 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | (rs << OP_SH_RS));
+    }
+
+    void srl(RegisterID rd, RegisterID rt, int shamt)
+    {
+        emitInst(0x00000002 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | ((shamt & 0x1f) << OP_SH_SHAMT));
+    }
+
+    void srlv(RegisterID rd, RegisterID rt, RegisterID rs)
+    {
+        emitInst(0x00000006 | (rd << OP_SH_RD) | (rt << OP_SH_RT)
+                 | (rs << OP_SH_RS));
+    }
+
+    void lb(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x80000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lbu(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x90000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lw(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x8c000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lwl(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x88000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lwr(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x98000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lh(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x84000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void lhu(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0x94000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        loadDelayNop();
+    }
+
+    void sb(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0xa0000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void sh(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0xa4000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void sw(RegisterID rt, RegisterID rs, int offset)
+    {
+        emitInst(0xac000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void jr(RegisterID rs)
+    {
+        emitInst(0x00000008 | (rs << OP_SH_RS));
+    }
+
+    void jalr(RegisterID rs)
+    {
+        emitInst(0x0000f809 | (rs << OP_SH_RS));
+    }
+
+    void jal()
+    {
+        emitInst(0x0c000000);
+    }
+
+    void bkpt()
+    {
+        int value = 512; /* BRK_BUG */
+        emitInst(0x0000000d | ((value & 0x3ff) << OP_SH_CODE));
+    }
+
+    void bgez(RegisterID rs, int imm)
+    {
+        emitInst(0x04010000 | (rs << OP_SH_RS) | (imm & 0xffff));
+    }
+
+    void bltz(RegisterID rs, int imm)
+    {
+        emitInst(0x04000000 | (rs << OP_SH_RS) | (imm & 0xffff));
+    }
+
+    void beq(RegisterID rs, RegisterID rt, int imm)
+    {
+        emitInst(0x10000000 | (rs << OP_SH_RS) | (rt << OP_SH_RT) | (imm & 0xffff));
+    }
+
+    void bne(RegisterID rs, RegisterID rt, int imm)
+    {
+        emitInst(0x14000000 | (rs << OP_SH_RS) | (rt << OP_SH_RT) | (imm & 0xffff));
+    }
+
+    void bc1t()
+    {
+        emitInst(0x45010000);
+    }
+
+    void bc1f()
+    {
+        emitInst(0x45000000);
+    }
+
+    JmpSrc newJmpSrc()
+    {
+        return JmpSrc(m_buffer.size());
+    }
+
+    void appendJump()
+    {
+        m_jumps.append(m_buffer.size());
+    }
+
+    void movd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200006 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void addd(FPRegisterID fd, FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200000 | (fd << OP_SH_FD) | (fs << OP_SH_FS)
+                 | (ft << OP_SH_FT));
+    }
+
+    void subd(FPRegisterID fd, FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200001 | (fd << OP_SH_FD) | (fs << OP_SH_FS)
+                 | (ft << OP_SH_FT));
+    }
+
+    void muld(FPRegisterID fd, FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200002 | (fd << OP_SH_FD) | (fs << OP_SH_FS)
+                 | (ft << OP_SH_FT));
+    }
+
+    void divd(FPRegisterID fd, FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200003 | (fd << OP_SH_FD) | (fs << OP_SH_FS)
+                 | (ft << OP_SH_FT));
+    }
+
+    void negd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200007 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void absd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200005 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void lwc1(FPRegisterID ft, RegisterID rs, int offset)
+    {
+        emitInst(0xc4000000 | (ft << OP_SH_FT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+        copDelayNop();
+    }
+
+    void ldc1(FPRegisterID ft, RegisterID rs, int offset)
+    {
+        emitInst(0xd4000000 | (ft << OP_SH_FT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void swc1(FPRegisterID ft, RegisterID rs, int offset)
+    {
+        emitInst(0xe4000000 | (ft << OP_SH_FT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void sdc1(FPRegisterID ft, RegisterID rs, int offset)
+    {
+        emitInst(0xf4000000 | (ft << OP_SH_FT) | (rs << OP_SH_RS)
+                 | (offset & 0xffff));
+    }
+
+    void mtc1(RegisterID rt, FPRegisterID fs)
+    {
+        emitInst(0x44800000 | (fs << OP_SH_FS) | (rt << OP_SH_RT));
+        copDelayNop();
+    }
+
+    void mthc1(RegisterID rt, FPRegisterID fs)
+    {
+        emitInst(0x44e00000 | (fs << OP_SH_FS) | (rt << OP_SH_RT));
+        copDelayNop();
+    }
+
+    void mfc1(RegisterID rt, FPRegisterID fs)
+    {
+        emitInst(0x44000000 | (fs << OP_SH_FS) | (rt << OP_SH_RT));
+        copDelayNop();
+    }
+
+    void sqrtd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200004 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void truncwd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x4620000d | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void cvtdw(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46800021 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void cvtds(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46000021 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void cvtsd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200020 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void cvtwd(FPRegisterID fd, FPRegisterID fs)
+    {
+        emitInst(0x46200024 | (fd << OP_SH_FD) | (fs << OP_SH_FS));
+    }
+
+    void ceqd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200032 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cngtd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x4620003f | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cnged(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x4620003d | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cltd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x4620003c | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cled(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x4620003e | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cueqd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200033 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void coled(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200036 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void coltd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200034 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void culed(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200037 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    void cultd(FPRegisterID fs, FPRegisterID ft)
+    {
+        emitInst(0x46200035 | (fs << OP_SH_FS) | (ft << OP_SH_FT));
+        copDelayNop();
+    }
+
+    // General helpers
+
+    JmpDst label()
+    {
+        return JmpDst(m_buffer.size());
+    }
+
+    JmpDst align(int alignment)
+    {
+        while (!m_buffer.isAligned(alignment))
+            bkpt();
+
+        return label();
+    }
+
+    static void* getRelocatedAddress(void* code, JmpSrc jump)
+    {
+        ASSERT(jump.m_offset != -1);
+        void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + jump.m_offset);
+        return b;
+    }
+
+    static void* getRelocatedAddress(void* code, JmpDst label)
+    {
+        void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + label.m_offset);
+        return b;
+    }
+
+    static int getDifferenceBetweenLabels(JmpDst from, JmpDst to)
+    {
+        return to.m_offset - from.m_offset;
+    }
+
+    static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to)
+    {
+        return to.m_offset - from.m_offset;
+    }
+
+    static int getDifferenceBetweenLabels(JmpSrc from, JmpDst to)
+    {
+        return to.m_offset - from.m_offset;
+    }
+
+    // Assembler admin methods:
+
+    size_t size() const
+    {
+        return m_buffer.size();
+    }
+
+    void executableCopy(void* buffer)
+    {
+        memcpy(buffer, m_buffer.data(), m_buffer.size());
+        relocateJumps(m_buffer.data(), buffer);
+    }
+
+    void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind)
+    {
+        void *result = m_buffer.executableAllocAndCopy(allocator, poolp, kind);
+        if (!result)
+          return 0;
+
+        relocateJumps(m_buffer.data(), result);
+        return result;
+    }
+
+    static unsigned getCallReturnOffset(JmpSrc call)
+    {
+        // The return address is after a call and a delay slot instruction
+        return call.m_offset;
+    }
+
+    // Linking & patching:
+    //
+    // 'link' and 'patch' methods are for use on unprotected code - such as the code
+    // within the AssemblerBuffer, and code being patched by the patch buffer.  Once
+    // code has been finalized it is (platform support permitting) within a non-
+    // writable region of memory; to modify the code in an execute-only execuable
+    // pool the 'repatch' and 'relink' methods should be used.
+
+    void linkJump(JmpSrc from, JmpDst to)
+    {
+        ASSERT(to.m_offset != -1);
+        ASSERT(from.m_offset != -1);
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + from.m_offset);
+        MIPSWord* toPos = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + to.m_offset);
+
+        ASSERT(!(*(insn - 1)) && !(*(insn - 2)) && !(*(insn - 3)) && !(*(insn - 5)));
+        insn = insn - 6;
+        linkWithOffset(insn, toPos);
+    }
+
+    static void linkJump(void* code, JmpSrc from, void* to)
+    {
+        ASSERT(from.m_offset != -1);
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
+
+        ASSERT(!(*(insn - 1)) && !(*(insn - 2)) && !(*(insn - 3)) && !(*(insn - 5)));
+        insn = insn - 6;
+        linkWithOffset(insn, to);
+    }
+
+    static bool canRelinkJump(void* from, void* to)
+    {
+        return true;
+    }
+
+    static void linkCall(void* code, JmpSrc from, void* to)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
+        linkCallInternal(insn, to);
+    }
+
+    static void linkPointer(void* code, JmpDst from, void* to)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
+        ASSERT((*insn & 0xffe00000) == 0x3c000000); // lui
+        *insn = (*insn & 0xffff0000) | ((reinterpret_cast<intptr_t>(to) >> 16) & 0xffff);
+        insn++;
+        ASSERT((*insn & 0xfc000000) == 0x34000000); // ori
+        *insn = (*insn & 0xffff0000) | (reinterpret_cast<intptr_t>(to) & 0xffff);
+    }
+
+    static void relinkJump(void* from, void* to)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(from);
+
+        ASSERT(!(*(insn - 1)) && !(*(insn - 5)));
+        insn = insn - 6;
+        int flushSize = linkWithOffset(insn, to);
+
+        ExecutableAllocator::cacheFlush(insn, flushSize);
+    }
+
+    static void relinkCall(void* from, void* to)
+    {
+        void* start;
+        int size = linkCallInternal(from, to);
+        if (size == sizeof(MIPSWord))
+            start = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(from) - 2 * sizeof(MIPSWord));
+        else
+            start = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(from) - 4 * sizeof(MIPSWord));
+
+        ExecutableAllocator::cacheFlush(start, size);
+    }
+
+    static void repatchInt32(void* from, int32_t to)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(from);
+        ASSERT((*insn & 0xffe00000) == 0x3c000000); // lui
+        *insn = (*insn & 0xffff0000) | ((to >> 16) & 0xffff);
+        insn++;
+        ASSERT((*insn & 0xfc000000) == 0x34000000); // ori
+        *insn = (*insn & 0xffff0000) | (to & 0xffff);
+        insn--;
+        ExecutableAllocator::cacheFlush(insn, 2 * sizeof(MIPSWord));
+    }
+
+    static void repatchPointer(void* from, void* to)
+    {
+        repatchInt32(from, reinterpret_cast<int32_t>(to));
+    }
+
+    static void repatchLoadPtrToLEA(void* from)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(from);
+        insn = insn + 3;
+        ASSERT((*insn & 0xfc000000) == 0x8c000000); // lw
+        /* lw -> addiu */
+        *insn = 0x24000000 | (*insn & 0x03ffffff);
+
+        ExecutableAllocator::cacheFlush(insn, sizeof(MIPSWord));
+    }
+
+    static void repatchLEAToLoadPtr(void* from)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(from);
+        insn = insn + 3;
+        if ((*insn & 0xfc000000) == 0x8c000000)
+          return; // Valid lw instruction
+
+        ASSERT((*insn & 0xfc000000) == 0x24000000); // addiu
+        /* addiu -> lw */
+        *insn = 0x8c000000 | (*insn & 0x03ffffff);
+
+        ExecutableAllocator::cacheFlush(insn, sizeof(MIPSWord));
+    }
+
+private:
+
+    /* Update each jump in the buffer of newBase.  */
+    void relocateJumps(void* oldBase, void* newBase)
+    {
+        // Check each jump
+        for (Jumps::Iterator iter = m_jumps.begin(); iter != m_jumps.end(); ++iter) {
+            int pos = *iter;
+            MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(newBase) + pos);
+            insn = insn + 2;
+            // Need to make sure we have 5 valid instructions after pos
+            if ((unsigned int)pos >= m_buffer.size() - 5 * sizeof(MIPSWord))
+                continue;
+
+            if ((*insn & 0xfc000000) == 0x08000000) { // j
+                int offset = *insn & 0x03ffffff;
+                int oldInsnAddress = (int)insn - (int)newBase + (int)oldBase;
+                int topFourBits = (oldInsnAddress + 4) >> 28;
+                int oldTargetAddress = (topFourBits << 28) | (offset << 2);
+                int newTargetAddress = oldTargetAddress - (int)oldBase + (int)newBase;
+                int newInsnAddress = (int)insn;
+                if (((newInsnAddress + 4) >> 28) == (newTargetAddress >> 28))
+                    *insn = 0x08000000 | ((newTargetAddress >> 2) & 0x3ffffff);
+                else {
+                    /* lui */
+                    *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((newTargetAddress >> 16) & 0xffff);
+                    /* ori */
+                    *(insn + 1) = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (newTargetAddress & 0xffff);
+                    /* jr */
+                    *(insn + 2) = 0x00000008 | (MIPSRegisters::t9 << OP_SH_RS);
+                }
+            } else if ((*insn & 0xffe00000) == 0x3c000000) { // lui
+                int high = (*insn & 0xffff) << 16;
+                int low = *(insn + 1) & 0xffff;
+                int oldTargetAddress = high | low;
+                int newTargetAddress = oldTargetAddress - (int)oldBase + (int)newBase;
+                /* lui */
+                *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((newTargetAddress >> 16) & 0xffff);
+                /* ori */
+                *(insn + 1) = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (newTargetAddress & 0xffff);
+            }
+        }
+    }
+
+    static int linkWithOffset(MIPSWord* insn, void* to)
+    {
+        ASSERT((*insn & 0xfc000000) == 0x10000000 // beq
+               || (*insn & 0xfc000000) == 0x14000000 // bne
+               || (*insn & 0xffff0000) == 0x45010000 // bc1t
+               || (*insn & 0xffff0000) == 0x45000000); // bc1f
+        intptr_t diff = (reinterpret_cast<intptr_t>(to)
+                         - reinterpret_cast<intptr_t>(insn) - 4) >> 2;
+
+        if (diff < -32768 || diff > 32767 || *(insn + 2) != 0x10000003) {
+            /*
+                Convert the sequence:
+                  beq $2, $3, target
+                  nop
+                  b 1f
+                  nop
+                  nop
+                  nop
+                1:
+
+                to the new sequence if possible:
+                  bne $2, $3, 1f
+                  nop
+                  j    target
+                  nop
+                  nop
+                  nop
+                1:
+
+                OR to the new sequence:
+                  bne $2, $3, 1f
+                  nop
+                  lui $25, target >> 16
+                  ori $25, $25, target & 0xffff
+                  jr $25
+                  nop
+                1:
+
+                Note: beq/bne/bc1t/bc1f are converted to bne/beq/bc1f/bc1t.
+            */
+
+            if (*(insn + 2) == 0x10000003) {
+                if ((*insn & 0xfc000000) == 0x10000000) // beq
+                    *insn = (*insn & 0x03ff0000) | 0x14000005; // bne
+                else if ((*insn & 0xfc000000) == 0x14000000) // bne
+                    *insn = (*insn & 0x03ff0000) | 0x10000005; // beq
+                else if ((*insn & 0xffff0000) == 0x45010000) // bc1t
+                    *insn = 0x45000005; // bc1f
+                else if ((*insn & 0xffff0000) == 0x45000000) // bc1f
+                    *insn = 0x45010005; // bc1t
+                else
+                    ASSERT(0);
+            }
+
+            insn = insn + 2;
+            if ((reinterpret_cast<intptr_t>(insn) + 4) >> 28
+                == reinterpret_cast<intptr_t>(to) >> 28) {
+                *insn = 0x08000000 | ((reinterpret_cast<intptr_t>(to) >> 2) & 0x3ffffff);
+                *(insn + 1) = 0;
+                return 4 * sizeof(MIPSWord);
+            }
+
+            intptr_t newTargetAddress = reinterpret_cast<intptr_t>(to);
+            /* lui */
+            *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((newTargetAddress >> 16) & 0xffff);
+            /* ori */
+            *(insn + 1) = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (newTargetAddress & 0xffff);
+            /* jr */
+            *(insn + 2) = 0x00000008 | (MIPSRegisters::t9 << OP_SH_RS);
+            return 5 * sizeof(MIPSWord);
+        }
+
+        *insn = (*insn & 0xffff0000) | (diff & 0xffff);
+        return sizeof(MIPSWord);
+    }
+
+    static int linkCallInternal(void* from, void* to)
+    {
+        MIPSWord* insn = reinterpret_cast<MIPSWord*>(from);
+        insn = insn - 4;
+
+        if ((*(insn + 2) & 0xfc000000) == 0x0c000000) { // jal
+            if ((reinterpret_cast<intptr_t>(from) - 4) >> 28
+                == reinterpret_cast<intptr_t>(to) >> 28) {
+                *(insn + 2) = 0x0c000000 | ((reinterpret_cast<intptr_t>(to) >> 2) & 0x3ffffff);
+                return sizeof(MIPSWord);
+            }
+
+            /* lui $25, (to >> 16) & 0xffff */
+            *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((reinterpret_cast<intptr_t>(to) >> 16) & 0xffff);
+            /* ori $25, $25, to & 0xffff */
+            *(insn + 1) = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (reinterpret_cast<intptr_t>(to) & 0xffff);
+            /* jalr $25 */
+            *(insn + 2) = 0x0000f809 | (MIPSRegisters::t9 << OP_SH_RS);
+            return 3 * sizeof(MIPSWord);
+        }
+
+        ASSERT((*insn & 0xffe00000) == 0x3c000000); // lui
+        ASSERT((*(insn + 1) & 0xfc000000) == 0x34000000); // ori
+
+        /* lui */
+        *insn = (*insn & 0xffff0000) | ((reinterpret_cast<intptr_t>(to) >> 16) & 0xffff);
+        /* ori */
+        *(insn + 1) = (*(insn + 1) & 0xffff0000) | (reinterpret_cast<intptr_t>(to) & 0xffff);
+        return 2 * sizeof(MIPSWord);
+    }
+
+    AssemblerBuffer m_buffer;
+    Jumps m_jumps;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(ASSEMBLER) && CPU(MIPS)
+
+#endif // MIPSAssembler_h
new file mode 100644
--- /dev/null
+++ b/js/src/assembler/assembler/MacroAssemblerMIPS.h
@@ -0,0 +1,2790 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 MIPS Technologies, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY MIPS TECHNOLOGIES, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL MIPS TECHNOLOGIES, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MacroAssemblerMIPS_h
+#define MacroAssemblerMIPS_h
+
+#if ENABLE(ASSEMBLER) && CPU(MIPS)
+
+#include "AbstractMacroAssembler.h"
+#include "MIPSAssembler.h"
+
+namespace JSC {
+
+class MacroAssemblerMIPS : public AbstractMacroAssembler<MIPSAssembler> {
+public:
+    typedef MIPSRegisters::FPRegisterID FPRegisterID;
+
+    MacroAssemblerMIPS()
+        : m_fixedWidth(false)
+    {
+    }
+
+    static const Scale ScalePtr = TimesFour;
+    static const unsigned int TotalRegisters = 24; // Count from $0 to $23
+						   // to leave the bitmask for
+						   // 8 FP registers.
+
+    // For storing immediate number
+    static const RegisterID immTempRegister = MIPSRegisters::t0;
+    // For storing data loaded from the memory
+    static const RegisterID dataTempRegister = MIPSRegisters::t1;
+    // For storing address base
+    static const RegisterID addrTempRegister = MIPSRegisters::t2;
+    // For storing compare result
+    static const RegisterID cmpTempRegister = MIPSRegisters::t3;
+    // For storing data loaded from the memory
+    static const RegisterID dataTemp2Register = MIPSRegisters::t4;
+
+    // FP temp register
+    static const FPRegisterID fpTempRegister = MIPSRegisters::f16;
+
+    enum Condition {
+        Equal,
+        NotEqual,
+        Above,
+        AboveOrEqual,
+        Below,
+        BelowOrEqual,
+        GreaterThan,
+        GreaterThanOrEqual,
+        LessThan,
+        LessThanOrEqual,
+        Overflow,
+        Signed,
+        Zero,
+        NonZero
+    };
+
+    enum DoubleCondition {
+        DoubleEqual,
+        DoubleNotEqual,
+        DoubleGreaterThan,
+        DoubleGreaterThanOrEqual,
+        DoubleLessThan,
+        DoubleLessThanOrEqual,
+        DoubleEqualOrUnordered,
+        DoubleNotEqualOrUnordered,
+        DoubleGreaterThanOrUnordered,
+        DoubleGreaterThanOrEqualOrUnordered,
+        DoubleLessThanOrUnordered,
+        DoubleLessThanOrEqualOrUnordered
+    };
+
+    static const RegisterID stackPointerRegister = MIPSRegisters::sp;
+    static const RegisterID returnAddressRegister = MIPSRegisters::ra;
+
+    // Integer arithmetic operations:
+    //
+    // Operations are typically two operand - operation(source, srcDst)
+    // For many operations the source may be an Imm32, the srcDst operand
+    // may often be a memory location (explictly described using an Address
+    // object).
+
+    void lea(Address address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.addiu(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                addiu   dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.addiu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void lea(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                addiu   dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.addiu(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                addiu   dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.addiu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void add32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.addu(dest, dest, src);
+    }
+
+    void add32(TrustedImm32 imm, RegisterID dest)
+    {
+        add32(imm, dest, dest);
+    }
+
+    void add32(TrustedImm32 imm, RegisterID src, RegisterID dest)
+    {
+        if (!imm.m_isPointer && imm.m_value >= -32768 && imm.m_value <= 32767
+            && !m_fixedWidth) {
+            /*
+              addiu     dest, src, imm
+            */
+            m_assembler.addiu(dest, src, imm.m_value);
+        } else {
+            /*
+              li        immTemp, imm
+              addu      dest, src, immTemp
+            */
+            move(imm, immTempRegister);
+            m_assembler.addu(dest, src, immTempRegister);
+        }
+    }
+
+    void add32(TrustedImm32 imm, Address address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+              lw        dataTemp, offset(base)
+              li        immTemp, imm
+              addu      dataTemp, dataTemp, immTemp
+              sw        dataTemp, offset(base)
+            */
+            m_assembler.lw(dataTempRegister, address.base, address.offset);
+            if (!imm.m_isPointer
+                && imm.m_value >= -32768 && imm.m_value <= 32767
+                && !m_fixedWidth)
+                m_assembler.addiu(dataTempRegister, dataTempRegister,
+                                  imm.m_value);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.addu(dataTempRegister, dataTempRegister,
+                                 immTempRegister);
+            }
+            m_assembler.sw(dataTempRegister, address.base, address.offset);
+        } else {
+            /*
+              lui       addrTemp, (offset + 0x8000) >> 16
+              addu      addrTemp, addrTemp, base
+              lw        dataTemp, (offset & 0xffff)(addrTemp)
+              li        immtemp, imm
+              addu      dataTemp, dataTemp, immTemp
+              sw        dataTemp, (offset & 0xffff)(addrTemp)
+            */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lw(dataTempRegister, addrTempRegister, address.offset);
+
+            if (imm.m_value >= -32768 && imm.m_value <= 32767 && !m_fixedWidth)
+                m_assembler.addiu(dataTempRegister, dataTempRegister,
+                                  imm.m_value);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.addu(dataTempRegister, dataTempRegister,
+                                 immTempRegister);
+            }
+            m_assembler.sw(dataTempRegister, addrTempRegister, address.offset);
+        }
+    }
+
+    void add32(Address src, RegisterID dest)
+    {
+        load32(src, dataTempRegister);
+        add32(dataTempRegister, dest);
+    }
+
+    void add32(RegisterID src, Address dest)
+    {
+        if (dest.offset >= -32768 && dest.offset <= 32767 && !m_fixedWidth) {
+            /*
+              lw        dataTemp, offset(base)
+              addu      dataTemp, dataTemp, src
+              sw        dataTemp, offset(base)
+            */
+            m_assembler.lw(dataTempRegister, dest.base, dest.offset);
+            m_assembler.addu(dataTempRegister, dataTempRegister, src);
+            m_assembler.sw(dataTempRegister, dest.base, dest.offset);
+        } else {
+            /*
+              lui       addrTemp, (offset + 0x8000) >> 16
+              addu      addrTemp, addrTemp, base
+              lw        dataTemp, (offset & 0xffff)(addrTemp)
+              addu      dataTemp, dataTemp, src
+              sw        dataTemp, (offset & 0xffff)(addrTemp)
+            */
+            m_assembler.lui(addrTempRegister, (dest.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, dest.base);
+            m_assembler.lw(dataTempRegister, addrTempRegister, dest.offset);
+            m_assembler.addu(dataTempRegister, dataTempRegister, src);
+            m_assembler.sw(dataTempRegister, addrTempRegister, dest.offset);
+        }
+    }
+
+    void add32(TrustedImm32 imm, AbsoluteAddress address)
+    {
+        /*
+           li   addrTemp, address
+           li   immTemp, imm
+           lw   dataTemp, 0(addrTemp)
+           addu dataTemp, dataTemp, immTemp
+           sw   dataTemp, 0(addrTemp)
+        */
+        move(ImmPtr(address.m_ptr), addrTempRegister);
+        m_assembler.lw(dataTempRegister, addrTempRegister, 0);
+        if (!imm.m_isPointer && imm.m_value >= -32768 && imm.m_value <= 32767
+            && !m_fixedWidth)
+            m_assembler.addiu(dataTempRegister, dataTempRegister, imm.m_value);
+        else {
+            move(imm, immTempRegister);
+            m_assembler.addu(dataTempRegister, dataTempRegister, immTempRegister);
+        }
+        m_assembler.sw(dataTempRegister, addrTempRegister, 0);
+    }
+
+    // If src is (0x7FF7FFFF<<1), we will convert it to (0x7FF80000<<1).
+    void setShiftedCanonicalNaN(RegisterID src, RegisterID dest)
+    {
+        /*
+           li   dataTemp, (0x7FF80000<<1)
+           li   immTemp, (0x7FF7FFFF<<1)
+           xor  immTemp, immTemp, src
+           move dest, src
+           movz dest, dataTemp, immTemp
+        */
+        move(TrustedImm32(0x7FF80000 << 1), dataTempRegister);
+        move(TrustedImm32(0x7FF7FFFF << 1), immTempRegister);
+        xor32(src, immTempRegister);
+        move(src, dest);
+        m_assembler.movz(dest, dataTempRegister, immTempRegister);
+    }
+
+    void and32(Address src, RegisterID dest)
+    {
+        load32(src, dataTempRegister);
+        m_assembler.andInsn(dest, dest, dataTempRegister);
+    }
+
+    void and32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.andInsn(dest, dest, src);
+    }
+
+    void and32(TrustedImm32 imm, RegisterID dest)
+    {
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+            move(MIPSRegisters::zero, dest);
+        else if (!imm.m_isPointer && imm.m_value > 0 && imm.m_value < 65535
+                 && !m_fixedWidth)
+            m_assembler.andi(dest, dest, imm.m_value);
+        else {
+            /*
+              li        immTemp, imm
+              and       dest, dest, immTemp
+            */
+            move(imm, immTempRegister);
+            m_assembler.andInsn(dest, dest, immTempRegister);
+        }
+    }
+
+    void lshift32(TrustedImm32 imm, RegisterID dest)
+    {
+        m_assembler.sll(dest, dest, imm.m_value);
+    }
+
+    void lshift32(RegisterID shiftAmount, RegisterID dest)
+    {
+        m_assembler.sllv(dest, dest, shiftAmount);
+    }
+
+    void mul32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.mul(dest, dest, src);
+    }
+
+    void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest)
+    {
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+            move(MIPSRegisters::zero, dest);
+        else if (!imm.m_isPointer && imm.m_value == 1 && !m_fixedWidth)
+            move(src, dest);
+        else {
+            /*
+                li      dataTemp, imm
+                mul     dest, src, dataTemp
+            */
+            move(imm, dataTempRegister);
+            m_assembler.mul(dest, src, dataTempRegister);
+        }
+    }
+
+    void neg32(RegisterID srcDest)
+    {
+        m_assembler.subu(srcDest, MIPSRegisters::zero, srcDest);
+    }
+
+    void not32(RegisterID srcDest)
+    {
+        m_assembler.nor(srcDest, srcDest, MIPSRegisters::zero);
+    }
+
+    void or32(Address src, RegisterID dest)
+    {
+        load32(src, dataTempRegister);
+        m_assembler.orInsn(dest, dest, dataTempRegister);
+    }
+
+    void or32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.orInsn(dest, dest, src);
+    }
+
+    void or32(TrustedImm32 imm, RegisterID dest)
+    {
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+            return;
+
+        if (!imm.m_isPointer && imm.m_value > 0 && imm.m_value < 65535
+            && !m_fixedWidth) {
+            m_assembler.ori(dest, dest, imm.m_value);
+            return;
+        }
+
+        /*
+            li      dataTemp, imm
+            or      dest, dest, dataTemp
+        */
+        move(imm, dataTempRegister);
+        m_assembler.orInsn(dest, dest, dataTempRegister);
+    }
+
+    void rshift32(RegisterID shiftAmount, RegisterID dest)
+    {
+        m_assembler.srav(dest, dest, shiftAmount);
+    }
+
+    void rshift32(TrustedImm32 imm, RegisterID dest)
+    {
+        m_assembler.sra(dest, dest, imm.m_value);
+    }
+
+    void urshift32(RegisterID shiftAmount, RegisterID dest)
+    {
+        m_assembler.srlv(dest, dest, shiftAmount);
+    }
+
+    void urshift32(TrustedImm32 imm, RegisterID dest)
+    {
+        m_assembler.srl(dest, dest, imm.m_value);
+    }
+
+    void sub32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.subu(dest, dest, src);
+    }
+
+    void sub32(TrustedImm32 imm, RegisterID dest)
+    {
+        if (!imm.m_isPointer && imm.m_value >= -32767 && imm.m_value <= 32768
+            && !m_fixedWidth) {
+            /*
+              addiu     dest, src, imm
+            */
+            m_assembler.addiu(dest, dest, -imm.m_value);
+        } else {
+            /*
+              li        immTemp, imm
+              subu      dest, src, immTemp
+            */
+            move(imm, immTempRegister);
+            m_assembler.subu(dest, dest, immTempRegister);
+        }
+    }
+
+    void sub32(TrustedImm32 imm, Address address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+              lw        dataTemp, offset(base)
+              li        immTemp, imm
+              subu      dataTemp, dataTemp, immTemp
+              sw        dataTemp, offset(base)
+            */
+            m_assembler.lw(dataTempRegister, address.base, address.offset);
+            if (!imm.m_isPointer
+                && imm.m_value >= -32767 && imm.m_value <= 32768
+                && !m_fixedWidth)
+                m_assembler.addiu(dataTempRegister, dataTempRegister,
+                                  -imm.m_value);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.subu(dataTempRegister, dataTempRegister,
+                                 immTempRegister);
+            }
+            m_assembler.sw(dataTempRegister, address.base, address.offset);
+        } else {
+            /*
+              lui       addrTemp, (offset + 0x8000) >> 16
+              addu      addrTemp, addrTemp, base
+              lw        dataTemp, (offset & 0xffff)(addrTemp)
+              li        immtemp, imm
+              subu      dataTemp, dataTemp, immTemp
+              sw        dataTemp, (offset & 0xffff)(addrTemp)
+            */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lw(dataTempRegister, addrTempRegister, address.offset);
+
+            if (!imm.m_isPointer
+                && imm.m_value >= -32767 && imm.m_value <= 32768
+                && !m_fixedWidth)
+                m_assembler.addiu(dataTempRegister, dataTempRegister,
+                                  -imm.m_value);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.subu(dataTempRegister, dataTempRegister,
+                                 immTempRegister);
+            }
+            m_assembler.sw(dataTempRegister, addrTempRegister, address.offset);
+        }
+    }
+
+    void sub32(Address src, RegisterID dest)
+    {
+        load32(src, dataTempRegister);
+        sub32(dataTempRegister, dest);
+    }
+
+    void sub32(TrustedImm32 imm, AbsoluteAddress address)
+    {
+        /*
+           li   addrTemp, address
+           li   immTemp, imm
+           lw   dataTemp, 0(addrTemp)
+           subu dataTemp, dataTemp, immTemp
+           sw   dataTemp, 0(addrTemp)
+        */
+        move(ImmPtr(address.m_ptr), addrTempRegister);
+        m_assembler.lw(dataTempRegister, addrTempRegister, 0);
+
+        if (!imm.m_isPointer && imm.m_value >= -32767 && imm.m_value <= 32768
+            && !m_fixedWidth) {
+            m_assembler.addiu(dataTempRegister, dataTempRegister,
+                              -imm.m_value);
+        } else {
+            move(imm, immTempRegister);
+            m_assembler.subu(dataTempRegister, dataTempRegister, immTempRegister);
+        }
+        m_assembler.sw(dataTempRegister, addrTempRegister, 0);
+    }
+
+    void xor32(Address src, RegisterID dest)
+    {
+        load32(src, dataTempRegister);
+        m_assembler.xorInsn(dest, dest, dataTempRegister);
+    }
+
+    void xor32(RegisterID src, RegisterID dest)
+    {
+        m_assembler.xorInsn(dest, dest, src);
+    }
+
+    void xor32(TrustedImm32 imm, RegisterID dest)
+    {
+        /*
+            li  immTemp, imm
+            xor dest, dest, immTemp
+        */
+        move(imm, immTempRegister);
+        m_assembler.xorInsn(dest, dest, immTempRegister);
+    }
+
+    void load16SignExtend(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lh(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lh      dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lh(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load16ZeroExtend(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lhu(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lhu     dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load16SignExtend(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lh      dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lh(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lh      dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lh(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load16ZeroExtend(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lhu     dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lhu     dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load8SignExtend(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lb(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lb      dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lb(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load8ZeroExtend(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lbu(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lbu     dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lbu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load8SignExtend(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lb      dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lb(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lb      dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lb(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load8ZeroExtend(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lbu     dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lbu(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lbu     dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lbu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void negDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.negd(dest, src);
+    }
+
+    void absDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.absd(dest, src);
+    }
+
+    void sqrtDouble(FPRegisterID src, FPRegisterID dst)
+    {
+        m_assembler.sqrtd(dst, src);
+    }
+
+    // Memory access operations:
+    //
+    // Loads are of the form load(address, destination) and stores of the form
+    // store(source, address).  The source for a store may be an Imm32.  Address
+    // operand objects to loads and store will be implicitly constructed if a
+    // register is passed.
+
+    /* Need to use zero-extened load byte for load8.  */
+    void load8(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lbu(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lbu     dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lbu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load32(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lw(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lw      dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lw(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load32(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lw      dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lw(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lw      dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lw(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32764
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                (Big-Endian)
+                lwl     dest, address.offset(addrTemp)
+                lwr     dest, address.offset+3(addrTemp)
+                (Little-Endian)
+                lwl     dest, address.offset+3(addrTemp)
+                lwr     dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+#if CPU(BIG_ENDIAN)
+            m_assembler.lwl(dest, addrTempRegister, address.offset);
+            m_assembler.lwr(dest, addrTempRegister, address.offset + 3);
+#else
+            m_assembler.lwl(dest, addrTempRegister, address.offset + 3);
+            m_assembler.lwr(dest, addrTempRegister, address.offset);
+
+#endif
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, address.offset >> 16
+                ori     immTemp, immTemp, address.offset & 0xffff
+                addu    addrTemp, addrTemp, immTemp
+                (Big-Endian)
+                lw      dest, 0(addrTemp)
+                lw      dest, 3(addrTemp)
+                (Little-Endian)
+                lw      dest, 3(addrTemp)
+                lw      dest, 0(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, address.offset >> 16);
+            m_assembler.ori(immTempRegister, immTempRegister, address.offset);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+#if CPU(BIG_ENDIAN)
+            m_assembler.lwl(dest, addrTempRegister, 0);
+            m_assembler.lwr(dest, addrTempRegister, 3);
+#else
+            m_assembler.lwl(dest, addrTempRegister, 3);
+            m_assembler.lwr(dest, addrTempRegister, 0);
+#endif
+        }
+    }
+
+    void load32(void* address, RegisterID dest)
+    {
+        /*
+            li  addrTemp, address
+            lw  dest, 0(addrTemp)
+        */
+        move(ImmPtr(address), addrTempRegister);
+        m_assembler.lw(dest, addrTempRegister, 0);
+    }
+
+    DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest)
+    {
+        m_fixedWidth = true;
+        /*
+            lui addrTemp, address.offset >> 16
+            ori addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            lw  dest, 0(addrTemp)
+        */
+        DataLabel32 dataLabel(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.lw(dest, addrTempRegister, 0);
+        m_fixedWidth = false;
+        return dataLabel;
+    }
+
+    void load64WithPatch(Address address, RegisterID tag, RegisterID payload, int tag_offset, int payload_offset)
+    {
+        m_fixedWidth = true;
+        /*
+            lui         addrTemp, address.offset >> 16
+            ori         addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            lw          tag, tag_offset(addrTemp)
+            lw          payload, payload_offset(addrTemp)
+        */
+        Label label(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.lw(tag, addrTempRegister, tag_offset);
+        m_assembler.lw(payload, addrTempRegister, payload_offset);
+        m_fixedWidth = false;
+    }
+
+    void store64WithPatch(Address address, RegisterID tag, RegisterID payload, int tag_offset, int payload_offset)
+    {
+        m_fixedWidth = true;
+        /*
+            lui         addrTemp, address.offset >> 16
+            ori         addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            sw          tag, tag_offset(addrTemp)
+            sw          payload, payload_offset(addrTemp)
+        */
+        Label label(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_fixedWidth = false;
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.sw(tag, addrTempRegister, tag_offset);
+        m_assembler.sw(payload, addrTempRegister, payload_offset);
+    }
+
+    void store64WithPatch(Address address, Imm32 tag, RegisterID payload, int tag_offset, int payload_offset)
+    {
+        m_fixedWidth = true;
+        /*
+            lui         addrTemp, address.offset >> 16
+            ori         addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            li          immTemp, tag
+            sw          immTemp, tag_offset(addrTemp)
+            sw          payload, payload_offset(addrTemp)
+        */
+        Label label(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_fixedWidth = false;
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        move(tag, immTempRegister);
+        m_assembler.sw(immTempRegister, addrTempRegister, tag_offset);
+        m_assembler.sw(payload, addrTempRegister, payload_offset);
+    }
+
+    void store64WithPatch(Address address, Imm32 tag, Imm32 payload, int tag_offset, int payload_offset)
+    {
+        m_fixedWidth = true;
+        /*
+            lui         addrTemp, address.offset >> 16
+            ori         addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            li          immTemp, tag
+            sw          immTemp, tag_offset(addrTemp)
+            li          immTemp, payload
+            sw          immTemp, payload_offset(addrTemp)
+        */
+        Label label(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_fixedWidth = false;
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        move(tag, immTempRegister);
+        m_assembler.sw(immTempRegister, addrTempRegister, tag_offset);
+        move(payload, immTempRegister);
+        m_assembler.sw(immTempRegister, addrTempRegister, payload_offset);
+    }
+
+    Label loadPtrWithPatchToLEA(Address address, RegisterID dest)
+    {
+        m_fixedWidth = true;
+        /*
+            lui         addrTemp, address.offset >> 16
+            ori         addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            lw          dest, 0(addrTemp)
+        */
+        Label label(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.lw(dest, addrTempRegister, 0);
+        m_fixedWidth = false;
+        return label;
+    }
+
+    /* Need to use zero-extened load half-word for load16.  */
+    void load16(ImplicitAddress address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.lhu(dest, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lhu     dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    /* Need to use zero-extened load half-word for load16.  */
+    void load16(BaseIndex address, RegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lhu     dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lhu     dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lhu(dest, addrTempRegister, address.offset);
+        }
+    }
+
+    DataLabel32 store32WithAddressOffsetPatch(RegisterID src, Address address)
+    {
+        m_fixedWidth = true;
+        /*
+            lui addrTemp, address.offset >> 16
+            ori addrTemp, addrTemp, address.offset & 0xffff
+            addu        addrTemp, addrTemp, address.base
+            sw  src, 0(addrTemp)
+        */
+        DataLabel32 dataLabel(this);
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.sw(src, addrTempRegister, 0);
+        m_fixedWidth = false;
+        return dataLabel;
+    }
+
+    void store8(RegisterID src, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.sb(src, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sb      src, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sb(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store8(RegisterID src, BaseIndex address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                sb      src, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sb(src, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                sb      src, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.sb(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store8(TrustedImm32 imm, BaseIndex address)
+    {
+        if (!imm.m_isPointer && !imm.m_value)
+            store8(MIPSRegisters::zero, address);
+        else {
+            move(imm, immTempRegister);
+            store8(immTempRegister, address);
+        }
+    }
+
+    void store8(TrustedImm32 imm, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            if (!imm.m_isPointer && !imm.m_value)
+                m_assembler.sb(MIPSRegisters::zero, address.base,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sb(immTempRegister, address.base, address.offset);
+            }
+        } else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sb      immTemp, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+                m_assembler.sb(MIPSRegisters::zero, addrTempRegister,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sb(immTempRegister, addrTempRegister,
+                               address.offset);
+            }
+        }
+    }
+
+    void store8(RegisterID src, void* address)
+    {
+        /*
+            li  addrTemp, address
+            sb  src, 0(addrTemp)
+        */
+        move(ImmPtr(address), addrTempRegister);
+        m_assembler.sb(src, addrTempRegister, 0);
+    }
+
+    void store8(TrustedImm32 imm, void* address)
+    {
+        /*
+            li  immTemp, imm
+            li  addrTemp, address
+            sb  src, 0(addrTemp)
+        */
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth) {
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sb(MIPSRegisters::zero, addrTempRegister, 0);
+        } else {
+            move(imm, immTempRegister);
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sb(immTempRegister, addrTempRegister, 0);
+        }
+    }
+
+    void store16(RegisterID src, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.sh(src, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sh      src, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sh(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store16(RegisterID src, BaseIndex address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                sh      src, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sh(src, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                sh      src, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.sh(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store16(TrustedImm32 imm, BaseIndex address)
+    {
+        if (!imm.m_isPointer && !imm.m_value)
+            store16(MIPSRegisters::zero, address);
+        else {
+            move(imm, immTempRegister);
+            store16(immTempRegister, address);
+        }
+    }
+
+    void store16(TrustedImm32 imm, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            if (!imm.m_isPointer && !imm.m_value)
+                m_assembler.sh(MIPSRegisters::zero, address.base,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sh(immTempRegister, address.base, address.offset);
+            }
+        } else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sh      immTemp, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+                m_assembler.sh(MIPSRegisters::zero, addrTempRegister,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sh(immTempRegister, addrTempRegister,
+                               address.offset);
+            }
+        }
+    }
+
+    void store16(RegisterID src, void* address)
+    {
+        /*
+            li  addrTemp, address
+            sh  src, 0(addrTemp)
+        */
+        move(ImmPtr(address), addrTempRegister);
+        m_assembler.sh(src, addrTempRegister, 0);
+    }
+
+    void store16(TrustedImm32 imm, void* address)
+    {
+        /*
+            li  immTemp, imm
+            li  addrTemp, address
+            sh  src, 0(addrTemp)
+        */
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth) {
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sh(MIPSRegisters::zero, addrTempRegister, 0);
+        } else {
+            move(imm, immTempRegister);
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sh(immTempRegister, addrTempRegister, 0);
+        }
+    }
+
+    void store32(RegisterID src, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.sw(src, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sw      src, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sw(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store32(RegisterID src, BaseIndex address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                sw      src, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sw(src, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                sw      src, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.sw(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void store32(TrustedImm32 imm, BaseIndex address)
+    {
+        if (!imm.m_isPointer && !imm.m_value)
+            store32(MIPSRegisters::zero, address);
+        else {
+            move(imm, immTempRegister);
+            store32(immTempRegister, address);
+        }
+    }
+
+    void store32(TrustedImm32 imm, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            if (!imm.m_isPointer && !imm.m_value)
+                m_assembler.sw(MIPSRegisters::zero, address.base,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sw(immTempRegister, address.base, address.offset);
+            }
+        } else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sw      immTemp, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+                m_assembler.sw(MIPSRegisters::zero, addrTempRegister,
+                               address.offset);
+            else {
+                move(imm, immTempRegister);
+                m_assembler.sw(immTempRegister, addrTempRegister,
+                               address.offset);
+            }
+        }
+    }
+
+    void store32(RegisterID src, void* address)
+    {
+        /*
+            li  addrTemp, address
+            sw  src, 0(addrTemp)
+        */
+        move(ImmPtr(address), addrTempRegister);
+        m_assembler.sw(src, addrTempRegister, 0);
+    }
+
+    void store32(TrustedImm32 imm, void* address)
+    {
+        /*
+            li  immTemp, imm
+            li  addrTemp, address
+            sw  src, 0(addrTemp)
+        */
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth) {
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sw(MIPSRegisters::zero, addrTempRegister, 0);
+        } else {
+            move(imm, immTempRegister);
+            move(ImmPtr(address), addrTempRegister);
+            m_assembler.sw(immTempRegister, addrTempRegister, 0);
+        }
+    }
+
+    // Floating-point operations:
+
+    bool supportsFloatingPoint() const
+    {
+#if WTF_MIPS_DOUBLE_FLOAT
+        return true;
+#else
+        return false;
+#endif
+    }
+
+    bool supportsFloatingPointTruncate() const
+    {
+#if WTF_MIPS_DOUBLE_FLOAT && WTF_MIPS_ISA_AT_LEAST(2)
+        return true;
+#else
+        return false;
+#endif
+    }
+
+    bool supportsFloatingPointSqrt() const
+    {
+#if WTF_MIPS_DOUBLE_FLOAT && WTF_MIPS_ISA_AT_LEAST(2)
+        return true;
+#else
+        return false;
+#endif
+    }
+
+    // Stack manipulation operations:
+    //
+    // The ABI is assumed to provide a stack abstraction to memory,
+    // containing machine word sized units of data.  Push and pop
+    // operations add and remove a single register sized unit of data
+    // to or from the stack.  Peek and poke operations read or write
+    // values on the stack, without moving the current stack position.
+
+    void pop(RegisterID dest)
+    {
+        m_assembler.lw(dest, MIPSRegisters::sp, 0);
+        m_assembler.addiu(MIPSRegisters::sp, MIPSRegisters::sp, 4);
+    }
+
+    void push(RegisterID src)
+    {
+        m_assembler.addiu(MIPSRegisters::sp, MIPSRegisters::sp, -4);
+        m_assembler.sw(src, MIPSRegisters::sp, 0);
+    }
+
+    void push(Address address)
+    {
+        load32(address, dataTempRegister);
+        push(dataTempRegister);
+    }
+
+    void push(TrustedImm32 imm)
+    {
+        move(imm, immTempRegister);
+        push(immTempRegister);
+    }
+
+    // Register move operations:
+    //
+    // Move values in registers.
+
+    void move(TrustedImm32 imm, RegisterID dest)
+    {
+        if (!imm.m_isPointer && !imm.m_value && !m_fixedWidth)
+            move(MIPSRegisters::zero, dest);
+        else if (imm.m_isPointer || m_fixedWidth) {
+            m_assembler.lui(dest, imm.m_value >> 16);
+            m_assembler.ori(dest, dest, imm.m_value);
+        } else
+            m_assembler.li(dest, imm.m_value);
+    }
+
+    void move(RegisterID src, RegisterID dest)
+    {
+        if (src != dest || m_fixedWidth)
+            m_assembler.move(dest, src);
+    }
+
+    void move(TrustedImmPtr imm, RegisterID dest)
+    {
+        move(Imm32(imm), dest);
+    }
+
+    void swap(RegisterID reg1, RegisterID reg2)
+    {
+        move(reg1, immTempRegister);
+        move(reg2, reg1);
+        move(immTempRegister, reg2);
+    }
+
+    void signExtend32ToPtr(RegisterID src, RegisterID dest)
+    {
+        if (src != dest || m_fixedWidth)
+            move(src, dest);
+    }
+
+    void zeroExtend32ToPtr(RegisterID src, RegisterID dest)
+    {
+        if (src != dest || m_fixedWidth)
+            move(src, dest);
+    }
+
+    // Forwards / external control flow operations:
+    //
+    // This set of jump and conditional branch operations return a Jump
+    // object which may linked at a later point, allow forwards jump,
+    // or jumps that will require external linkage (after the code has been
+    // relocated).
+    //
+    // For branches, signed <, >, <= and >= are denoted as l, g, le, and ge
+    // respecitvely, for unsigned comparisons the names b, a, be, and ae are
+    // used (representing the names 'below' and 'above').
+    //
+    // Operands to the comparision are provided in the expected order, e.g.
+    // jle32(reg1, Imm32(5)) will branch if the value held in reg1, when
+    // treated as a signed 32bit value, is less than or equal to 5.
+    //
+    // jz and jnz test whether the first operand is equal to zero, and take
+    // an optional second operand of a mask under which to perform the test.
+
+    Jump branch8(Condition cond, Address left, TrustedImm32 right)
+    {
+        // Make sure the immediate value is unsigned 8 bits.
+        ASSERT(!(right.m_value & 0xFFFFFF00));
+        load8(left, dataTempRegister);
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branch32(Condition cond, RegisterID left, RegisterID right)
+    {
+        if (cond == Equal || cond == Zero)
+            return branchEqual(left, right);
+        if (cond == NotEqual || cond == NonZero)
+            return branchNotEqual(left, right);
+        if (cond == Above) {
+            m_assembler.sltu(cmpTempRegister, right, left);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == AboveOrEqual) {
+            m_assembler.sltu(cmpTempRegister, left, right);
+            return branchEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Below) {
+            m_assembler.sltu(cmpTempRegister, left, right);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == BelowOrEqual) {
+            m_assembler.sltu(cmpTempRegister, right, left);
+            return branchEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == GreaterThan) {
+            m_assembler.slt(cmpTempRegister, right, left);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == GreaterThanOrEqual) {
+            m_assembler.slt(cmpTempRegister, left, right);
+            return branchEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == LessThan) {
+            m_assembler.slt(cmpTempRegister, left, right);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == LessThanOrEqual) {
+            m_assembler.slt(cmpTempRegister, right, left);
+            return branchEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Overflow) {
+            /*
+                xor     cmpTemp, left, right
+                bgez    No_overflow, cmpTemp    # same sign bit -> no overflow
+                nop
+                subu    cmpTemp, left, right
+                xor     cmpTemp, cmpTemp, left
+                bgez    No_overflow, cmpTemp    # same sign bit -> no overflow
+                nop
+                b       Overflow
+                nop
+                nop
+                nop
+                nop
+                nop
+              No_overflow:
+            */
+            m_assembler.xorInsn(cmpTempRegister, left, right);
+            m_assembler.bgez(cmpTempRegister, 11);
+            m_assembler.nop();
+            m_assembler.subu(cmpTempRegister, left, right);
+            m_assembler.xorInsn(cmpTempRegister, cmpTempRegister, left);
+            m_assembler.bgez(cmpTempRegister, 7);
+            m_assembler.nop();
+            return jump();
+        }
+        if (cond == Signed) {
+            m_assembler.subu(cmpTempRegister, left, right);
+            // Check if the result is negative.
+            m_assembler.slt(cmpTempRegister, cmpTempRegister,
+                            MIPSRegisters::zero);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        ASSERT(0);
+
+        return Jump();
+    }
+
+    Jump branch32(Condition cond, RegisterID left, TrustedImm32 right)
+    {
+        move(right, immTempRegister);
+        return branch32(cond, left, immTempRegister);
+    }
+
+    Jump branch32(Condition cond, RegisterID left, Address right)
+    {
+        load32(right, dataTempRegister);
+        return branch32(cond, left, dataTempRegister);
+    }
+
+    Jump branch32(Condition cond, Address left, RegisterID right)
+    {
+        load32(left, dataTempRegister);
+        return branch32(cond, dataTempRegister, right);
+    }
+
+    Jump branch32(Condition cond, Address left, TrustedImm32 right)
+    {
+        load32(left, dataTempRegister);
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branch32(Condition cond, BaseIndex left, TrustedImm32 right)
+    {
+        load32(left, dataTempRegister);
+        // Be careful that the previous load32() uses immTempRegister.
+        // So, we need to put move() after load32().
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branch32WithUnalignedHalfWords(Condition cond, BaseIndex left, TrustedImm32 right)
+    {
+        load32WithUnalignedHalfWords(left, dataTempRegister);
+        // Be careful that the previous load32WithUnalignedHalfWords()
+        // uses immTempRegister.
+        // So, we need to put move() after load32WithUnalignedHalfWords().
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branch32(Condition cond, AbsoluteAddress left, RegisterID right)
+    {
+        load32(left.m_ptr, dataTempRegister);
+        return branch32(cond, dataTempRegister, right);
+    }
+
+    Jump branch32(Condition cond, AbsoluteAddress left, TrustedImm32 right)
+    {
+        load32(left.m_ptr, dataTempRegister);
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branch16(Condition cond, BaseIndex left, RegisterID right)
+    {
+        load16(left, dataTempRegister);
+        return branch32(cond, dataTempRegister, right);
+    }
+
+    Jump branch16(Condition cond, BaseIndex left, TrustedImm32 right)
+    {
+        ASSERT(!(right.m_value & 0xFFFF0000));
+        load16(left, dataTempRegister);
+        // Be careful that the previous load16() uses immTempRegister.
+        // So, we need to put move() after load16().
+        move(right, immTempRegister);
+        return branch32(cond, dataTempRegister, immTempRegister);
+    }
+
+    Jump branchTest32(Condition cond, RegisterID reg, RegisterID mask)
+    {
+        ASSERT((cond == Zero) || (cond == NonZero));
+        m_assembler.andInsn(cmpTempRegister, reg, mask);
+        if (cond == Zero)
+            return branchEqual(cmpTempRegister, MIPSRegisters::zero);
+        return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+    }
+
+    Jump branchTest32(Condition cond, RegisterID reg, Imm32 mask = Imm32(-1))
+    {
+        ASSERT((cond == Zero) || (cond == NonZero));
+        if (mask.m_value == -1 && !m_fixedWidth) {
+            if (cond == Zero)
+                return branchEqual(reg, MIPSRegisters::zero);
+            return branchNotEqual(reg, MIPSRegisters::zero);
+        }
+        move(mask, immTempRegister);
+        return branchTest32(cond, reg, immTempRegister);
+    }
+
+    Jump branchTest32(Condition cond, Address address, Imm32 mask = Imm32(-1))
+    {
+        load32(address, dataTempRegister);
+        return branchTest32(cond, dataTempRegister, mask);
+    }
+
+    Jump branchTest32(Condition cond, BaseIndex address, Imm32 mask = Imm32(-1))
+    {
+        load32(address, dataTempRegister);
+        return branchTest32(cond, dataTempRegister, mask);
+    }
+
+    Jump branchTest8(Condition cond, Address address, Imm32 mask = Imm32(-1))
+    {
+        load8(address, dataTempRegister);
+        return branchTest32(cond, dataTempRegister, mask);
+    }
+
+    Jump jump()
+    {
+        return branchEqual(MIPSRegisters::zero, MIPSRegisters::zero);
+    }
+
+    void jump(RegisterID target)
+    {
+        m_assembler.jr(target);
+        m_assembler.nop();
+    }
+
+    void jump(Address address)
+    {
+        m_fixedWidth = true;
+        load32(address, MIPSRegisters::t9);
+        m_assembler.jr(MIPSRegisters::t9);
+        m_assembler.nop();
+        m_fixedWidth = false;
+    }
+
+    void jump(BaseIndex address)
+    {
+        load32(address, MIPSRegisters::t9);
+        m_assembler.jr(MIPSRegisters::t9);
+        m_assembler.nop();
+    }
+
+    // Arithmetic control flow operations:
+    //
+    // This set of conditional branch operations branch based
+    // on the result of an arithmetic operation.  The operation
+    // is performed as normal, storing the result.
+    //
+    // * jz operations branch if the result is zero.
+    // * jo operations branch if the (signed) arithmetic
+    //   operation caused an overflow to occur.
+
+    Jump branchAdd32(Condition cond, RegisterID src, RegisterID dest)
+    {
+        ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
+        if (cond == Overflow) {
+            /*
+                move    dest, dataTemp
+                xor     cmpTemp, dataTemp, src
+                bltz    cmpTemp, No_overflow    # diff sign bit -> no overflow
+                addu    dest, dataTemp, src
+                xor     cmpTemp, dest, dataTemp
+                bgez    cmpTemp, No_overflow    # same sign big -> no overflow
+                nop
+                b       Overflow
+                nop
+                nop
+                nop
+                nop
+                nop
+            No_overflow:
+            */
+            move(dest, dataTempRegister);
+            m_assembler.xorInsn(cmpTempRegister, dataTempRegister, src);
+            m_assembler.bltz(cmpTempRegister, 10);
+            m_assembler.addu(dest, dataTempRegister, src);
+            m_assembler.xorInsn(cmpTempRegister, dest, dataTempRegister);
+            m_assembler.bgez(cmpTempRegister, 7);
+            m_assembler.nop();
+            return jump();
+        }
+        if (cond == Signed) {
+            add32(src, dest);
+            // Check if dest is negative.
+            m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Zero) {
+            add32(src, dest);
+            return branchEqual(dest, MIPSRegisters::zero);
+        }
+        if (cond == NonZero) {
+            add32(src, dest);
+            return branchNotEqual(dest, MIPSRegisters::zero);
+        }
+        ASSERT(0);
+        return Jump();
+    }
+
+    Jump branchAdd32(Condition cond, Imm32 imm, RegisterID dest)
+    {
+        move(imm, immTempRegister);
+        return branchAdd32(cond, immTempRegister, dest);
+    }
+
+    Jump branchAdd32(Condition cond, Address src, RegisterID dest)
+    {
+        load32(src, immTempRegister);
+        return branchAdd32(cond, immTempRegister, dest);
+    }
+
+    Jump branchMul32(Condition cond, RegisterID src, RegisterID dest)
+    {
+        ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
+        if (cond == Overflow) {
+            /*
+                mult    src, dest
+                mfhi    dataTemp
+                mflo    dest
+                sra     addrTemp, dest, 31
+                beq     dataTemp, addrTemp, No_overflow # all sign bits (bit 63 to bit 31) are the same -> no overflow
+                nop
+                b       Overflow
+                nop
+                nop
+                nop
+                nop
+                nop
+            No_overflow:
+            */
+            m_assembler.mult(src, dest);
+            m_assembler.mfhi(dataTempRegister);
+            m_assembler.mflo(dest);
+            m_assembler.sra(addrTempRegister, dest, 31);
+            m_assembler.beq(dataTempRegister, addrTempRegister, 7);
+            m_assembler.nop();
+            return jump();
+        }
+        if (cond == Signed) {
+            mul32(src, dest);
+            // Check if dest is negative.
+            m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Zero) {
+            mul32(src, dest);
+            return branchEqual(dest, MIPSRegisters::zero);
+        }
+        if (cond == NonZero) {
+            mul32(src, dest);
+            return branchNotEqual(dest, MIPSRegisters::zero);
+        }
+        ASSERT(0);
+        return Jump();
+    }
+
+    Jump branchMul32(Condition cond, Imm32 imm, RegisterID src, RegisterID dest)
+    {
+        move(imm, immTempRegister);
+        move(src, dest);
+        return branchMul32(cond, immTempRegister, dest);
+    }
+
+    Jump branchSub32(Condition cond, RegisterID src, RegisterID dest)
+    {
+        ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
+        if (cond == Overflow) {
+            /*
+                move    dest, dataTemp
+                xor     cmpTemp, dataTemp, src
+                bgez    cmpTemp, No_overflow    # same sign bit -> no overflow
+                subu    dest, dataTemp, src
+                xor     cmpTemp, dest, dataTemp
+                bgez    cmpTemp, No_overflow    # same sign bit -> no overflow
+                nop
+                b       Overflow
+                nop
+                nop
+                nop
+                nop
+                nop
+            No_overflow:
+            */
+            move(dest, dataTempRegister);
+            m_assembler.xorInsn(cmpTempRegister, dataTempRegister, src);
+            m_assembler.bgez(cmpTempRegister, 10);
+            m_assembler.subu(dest, dataTempRegister, src);
+            m_assembler.xorInsn(cmpTempRegister, dest, dataTempRegister);
+            m_assembler.bgez(cmpTempRegister, 7);
+            m_assembler.nop();
+            return jump();
+        }
+        if (cond == Signed) {
+            sub32(src, dest);
+            // Check if dest is negative.
+            m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Zero) {
+            sub32(src, dest);
+            return branchEqual(dest, MIPSRegisters::zero);
+        }
+        if (cond == NonZero) {
+            sub32(src, dest);
+            return branchNotEqual(dest, MIPSRegisters::zero);
+        }
+        ASSERT(0);
+        return Jump();
+    }
+
+    Jump branchSub32(Condition cond, Imm32 imm, RegisterID dest)
+    {
+        move(imm, immTempRegister);
+        return branchSub32(cond, immTempRegister, dest);
+    }
+
+    Jump branchSub32(Condition cond, Address src, RegisterID dest)
+    {
+        load32(src, immTempRegister);
+        return branchSub32(cond, immTempRegister, dest);
+    }
+
+    Jump branchSub32(Condition cond, Imm32 imm, Address dest)
+    {
+	// Save the original value at dest to dataTemp2Register
+        load32(dest, dataTemp2Register);
+
+        // Calculate the result and save it to dest
+        sub32(imm, dest);
+
+        return branchSub32(cond, imm, dataTemp2Register);
+    }
+
+    Jump branchOr32(Condition cond, RegisterID src, RegisterID dest)
+    {
+        ASSERT((cond == Signed) || (cond == Zero) || (cond == NonZero));
+        if (cond == Signed) {
+            or32(src, dest);
+            // Check if dest is negative.
+            m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero);
+            return branchNotEqual(cmpTempRegister, MIPSRegisters::zero);
+        }
+        if (cond == Zero) {
+            or32(src, dest);
+            return branchEqual(dest, MIPSRegisters::zero);
+        }
+        if (cond == NonZero) {
+            or32(src, dest);
+            return branchNotEqual(dest, MIPSRegisters::zero);
+        }
+        ASSERT(0);
+        return Jump();
+    }
+
+    // Miscellaneous operations:
+
+    void breakpoint()
+    {
+        m_assembler.bkpt();
+    }
+
+    Call nearCall()
+    {
+        /* We need two words for relaxation.  */
+        m_assembler.nop();
+        m_assembler.nop();
+        m_assembler.jal();
+        m_assembler.nop();
+        return Call(m_assembler.newJmpSrc(), Call::LinkableNear);
+    }
+
+    Call call()
+    {
+        m_assembler.lui(MIPSRegisters::t9, 0);
+        m_assembler.ori(MIPSRegisters::t9, MIPSRegisters::t9, 0);
+        m_assembler.jalr(MIPSRegisters::t9);
+        m_assembler.nop();
+        return Call(m_assembler.newJmpSrc(), Call::Linkable);
+    }
+
+    Call call(RegisterID target)
+    {
+        m_assembler.jalr(target);
+        m_assembler.nop();
+        return Call(m_assembler.newJmpSrc(), Call::None);
+    }
+
+    Call call(Address address)
+    {
+        m_fixedWidth = true;
+        load32(address, MIPSRegisters::t9);
+        m_assembler.jalr(MIPSRegisters::t9);
+        m_assembler.nop();
+        m_fixedWidth = false;
+        return Call(m_assembler.newJmpSrc(), Call::None);
+    }
+
+    void ret()
+    {
+        m_assembler.jr(MIPSRegisters::ra);
+        m_assembler.nop();
+    }
+
+    void set8(Condition cond, RegisterID left, RegisterID right, RegisterID dest)
+    {
+        set32(cond, left, right, dest);
+    }
+
+    void set8(Condition cond, RegisterID left, Imm32 right, RegisterID dest)
+    {
+        move(right, immTempRegister);
+        set32(cond, left, immTempRegister, dest);
+    }
+
+    void set32(Condition cond, RegisterID left, RegisterID right, RegisterID dest)
+    {
+        if (cond == Equal || cond == Zero) {
+            m_assembler.xorInsn(dest, left, right);
+            m_assembler.sltiu(dest, dest, 1);
+        } else if (cond == NotEqual || cond == NonZero) {
+            m_assembler.xorInsn(dest, left, right);
+            m_assembler.sltu(dest, MIPSRegisters::zero, dest);
+        } else if (cond == Above)
+            m_assembler.sltu(dest, right, left);
+        else if (cond == AboveOrEqual) {
+            m_assembler.sltu(dest, left, right);
+            m_assembler.xori(dest, dest, 1);
+        } else if (cond == Below)
+            m_assembler.sltu(dest, left, right);
+        else if (cond == BelowOrEqual) {
+            m_assembler.sltu(dest, right, left);
+            m_assembler.xori(dest, dest, 1);
+        } else if (cond == GreaterThan)
+            m_assembler.slt(dest, right, left);
+        else if (cond == GreaterThanOrEqual) {
+            m_assembler.slt(dest, left, right);
+            m_assembler.xori(dest, dest, 1);
+        } else if (cond == LessThan)
+            m_assembler.slt(dest, left, right);
+        else if (cond == LessThanOrEqual) {
+            m_assembler.slt(dest, right, left);
+            m_assembler.xori(dest, dest, 1);
+        } else if (cond == Overflow) {
+            /*
+                xor     cmpTemp, left, right
+                bgez    Done, cmpTemp   # same sign bit -> no overflow
+                move    dest, 0
+                subu    cmpTemp, left, right
+                xor     cmpTemp, cmpTemp, left # diff sign bit -> overflow
+                slt     dest, cmpTemp, 0
+              Done:
+            */
+            m_assembler.xorInsn(cmpTempRegister, left, right);
+            m_assembler.bgez(cmpTempRegister, 4);
+            m_assembler.move(dest, MIPSRegisters::zero);
+            m_assembler.subu(cmpTempRegister, left, right);
+            m_assembler.xorInsn(cmpTempRegister, cmpTempRegister, left);
+            m_assembler.slt(dest, cmpTempRegister, MIPSRegisters::zero);
+        } else if (cond == Signed) {
+            m_assembler.subu(dest, left, right);
+            // Check if the result is negative.
+            m_assembler.slt(dest, dest, MIPSRegisters::zero);
+        }
+    }
+
+    void set32(Condition cond, Address left, Imm32 right, RegisterID dest)
+    {
+        load32(left, dataTempRegister);
+        move(right, immTempRegister);
+        set32(cond, dataTempRegister, immTempRegister, dest);
+    }
+
+    void set32(Condition cond, RegisterID left, Imm32 right, RegisterID dest)
+    {
+        move(right, immTempRegister);
+        set32(cond, left, immTempRegister, dest);
+    }
+
+    void set32(Condition cond, Address left, RegisterID right, RegisterID dest)
+    {
+        load32(left, immTempRegister);
+        set32(cond, immTempRegister, right, dest);
+    }
+
+    void set32(Condition cond, RegisterID left, Address right, RegisterID dest)
+    {
+        load32(right, immTempRegister);
+        set32(cond, left, immTempRegister, dest);
+    }
+
+    void setTest8(Condition cond, Address address, Imm32 mask, RegisterID dest)
+    {
+        ASSERT((cond == Zero) || (cond == NonZero));
+        load8(address, dataTempRegister);
+        if (mask.m_value == -1 && !m_fixedWidth) {
+            if (cond == Zero)
+                m_assembler.sltiu(dest, dataTempRegister, 1);
+            else
+                m_assembler.sltu(dest, MIPSRegisters::zero, dataTempRegister);
+        } else {
+            move(mask, immTempRegister);
+            m_assembler.andInsn(cmpTempRegister, dataTempRegister,
+                                immTempRegister);
+            if (cond == Zero)
+                m_assembler.sltiu(dest, cmpTempRegister, 1);
+            else
+                m_assembler.sltu(dest, MIPSRegisters::zero, cmpTempRegister);
+        }
+    }
+
+    void setTest32(Condition cond, Address address, Imm32 mask, RegisterID dest)
+    {
+        ASSERT((cond == Zero) || (cond == NonZero));
+        load32(address, dataTempRegister);
+        if (mask.m_value == -1 && !m_fixedWidth) {
+            if (cond == Zero)
+                m_assembler.sltiu(dest, dataTempRegister, 1);
+            else
+                m_assembler.sltu(dest, MIPSRegisters::zero, dataTempRegister);
+        } else {
+            move(mask, immTempRegister);
+            m_assembler.andInsn(cmpTempRegister, dataTempRegister,
+                                immTempRegister);
+            if (cond == Zero)
+                m_assembler.sltiu(dest, cmpTempRegister, 1);
+            else
+                m_assembler.sltu(dest, MIPSRegisters::zero, cmpTempRegister);
+        }
+    }
+
+    DataLabel32 moveWithPatch(TrustedImm32 imm, RegisterID dest)
+    {
+        m_fixedWidth = true;
+        DataLabel32 label(this);
+        move(imm, dest);
+        m_fixedWidth = false;
+        return label;
+    }
+
+    DataLabelPtr moveWithPatch(TrustedImmPtr initialValue, RegisterID dest)
+    {
+        m_fixedWidth = true;
+        DataLabelPtr label(this);
+        move(initialValue, dest);
+        m_fixedWidth = false;
+        return label;
+    }
+
+    Jump branch32WithPatch(Condition cond, RegisterID left, TrustedImm32 right, DataLabel32& dataLabel)
+    {
+        m_fixedWidth = true;
+        dataLabel = moveWithPatch(right, immTempRegister);
+        Jump temp = branch32(cond, left, immTempRegister);
+        m_fixedWidth = false;
+        return temp;
+    }
+
+    Jump branch32FixedLength(Condition cond, RegisterID left, TrustedImm32 right)
+    {
+        m_fixedWidth = true;
+        move(right, immTempRegister);
+        Jump temp = branch32(cond, left, immTempRegister);
+        m_fixedWidth = false;
+        return temp;
+    }
+
+    Jump branch32WithPatch(Condition cond, Address left, TrustedImm32 right, DataLabel32& dataLabel)
+    {
+        m_fixedWidth = true;
+        load32(left, dataTempRegister);
+        dataLabel = moveWithPatch(right, immTempRegister);
+        Jump temp = branch32(cond, dataTempRegister, immTempRegister);
+        m_fixedWidth = false;
+        return temp;
+    }
+
+    Jump branchPtrWithPatch(Condition cond, RegisterID left, DataLabelPtr& dataLabel, ImmPtr initialRightValue = ImmPtr(0))
+    {
+        m_fixedWidth = true;
+        dataLabel = moveWithPatch(initialRightValue, immTempRegister);
+        Jump temp = branch32(cond, left, immTempRegister);
+        m_fixedWidth = false;
+        return temp;
+    }
+
+    Jump branchPtrWithPatch(Condition cond, Address left, DataLabelPtr& dataLabel, ImmPtr initialRightValue = ImmPtr(0))
+    {
+        m_fixedWidth = true;
+        load32(left, dataTempRegister);
+        dataLabel = moveWithPatch(initialRightValue, immTempRegister);
+        Jump temp = branch32(cond, dataTempRegister, immTempRegister);
+        m_fixedWidth = false;
+        return temp;
+    }
+
+    DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, ImplicitAddress address)
+    {
+        m_fixedWidth = true;
+        DataLabelPtr dataLabel = moveWithPatch(initialValue, dataTempRegister);
+        store32(dataTempRegister, address);
+        m_fixedWidth = false;
+        return dataLabel;
+    }
+
+    DataLabelPtr storePtrWithPatch(ImplicitAddress address)
+    {
+        return storePtrWithPatch(ImmPtr(0), address);
+    }
+
+    Call tailRecursiveCall()
+    {
+        // Like a normal call, but don't update the returned address register
+        m_fixedWidth = true;
+        move(Imm32(0), MIPSRegisters::t9);
+        m_assembler.jr(MIPSRegisters::t9);
+        m_assembler.nop();
+        m_fixedWidth = false;
+        return Call(m_assembler.newJmpSrc(), Call::Linkable);
+    }
+
+    Call makeTailRecursiveCall(Jump oldJump)
+    {
+        oldJump.link(this);
+        return tailRecursiveCall();
+    }
+
+    void moveDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.movd(dest, src);
+    }
+
+    void loadFloat(ImplicitAddress address, FPRegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            m_assembler.lwc1(dest, address.base, address.offset);
+            m_assembler.cvtds(dest, dest);
+        } else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                lwc1    dest, (offset & 0xffff)(addrTemp)
+                cvt.d.s dest, dest
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lwc1(dest, addrTempRegister, address.offset);
+            m_assembler.cvtds(dest, dest);
+        }
+    }
+
+    void loadFloat(BaseIndex address, FPRegisterID dest)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lwc1    dest, address.offset(addrTemp)
+                cvt.d.s dest, dest
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lwc1(dest, addrTempRegister, address.offset);
+            m_assembler.cvtds(dest, dest);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                lwc1    dest, (address.offset & 0xffff)(addrTemp)
+                cvt.d.s dest, dest
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lwc1(dest, addrTempRegister, address.offset);
+            m_assembler.cvtds(dest, dest);
+        }
+    }
+
+    DataLabelPtr loadFloat(const void* address, FPRegisterID dest)
+    {
+        DataLabelPtr label = moveWithPatch(ImmPtr(address), addrTempRegister);
+        /*
+            lwc1        dest, 0(addrTemp)
+            cvt.d.s     dest, dest
+        */
+        m_assembler.lwc1(dest, addrTempRegister, 0);
+        m_assembler.cvtds(dest, dest);
+        return label;
+    }
+
+    void loadDouble(ImplicitAddress address, FPRegisterID dest)
+    {
+#if WTF_MIPS_ISA(1)
+        /*
+            li          addrTemp, address.offset
+            addu        addrTemp, addrTemp, base
+            lwc1        dest, 0(addrTemp)
+            lwc1        dest+1, 4(addrTemp)
+         */
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.lwc1(dest, addrTempRegister, 0);
+        m_assembler.lwc1(FPRegisterID(dest + 1), addrTempRegister, 4);
+#else
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            m_assembler.ldc1(dest, address.base, address.offset);
+        } else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                ldc1    dest, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.ldc1(dest, addrTempRegister, address.offset);
+        }
+#endif
+    }
+
+    void loadDouble(BaseIndex address, FPRegisterID dest)
+    {
+#if WTF_MIPS_ISA(1)
+        if (address.offset >= -32768 && address.offset <= 32763
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lwc1    dest, address.offset(addrTemp)
+                lwc1    dest+1, address.offset+4(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lwc1(dest, addrTempRegister, address.offset);
+            m_assembler.lwc1(FPRegisterID(dest + 1), addrTempRegister, address.offset + 4);
+        } else {
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                li      immTemp, address.offset
+                addu    addrTemp, addrTemp, immTemp
+                lwc1    dest, 0(addrTemp)
+                lwc1    dest+1, 4(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.li(immTempRegister, address.offset);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.lwc1(dest, addrTempRegister, 0);
+            m_assembler.lwc1(FPRegisterID(dest + 1), addrTempRegister, 4);
+#else
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth) {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                ldc1    dest, address.offset(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.ldc1(dest, addrTempRegister, address.offset);
+        } else {
+            /*
+                sll     addrTemp, address.index, address.scale
+                addu    addrTemp, addrTemp, address.base
+                lui     immTemp, (address.offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, immTemp
+                ldc1    dest, (address.offset & 0xffff)(addrTemp)
+            */
+            m_assembler.sll(addrTempRegister, address.index, address.scale);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister,
+                             immTempRegister);
+            m_assembler.ldc1(dest, addrTempRegister, address.offset);
+        }
+#endif
+    }
+
+    DataLabelPtr loadDouble(const void* address, FPRegisterID dest)
+    {
+        DataLabelPtr label = moveWithPatch(ImmPtr(address), addrTempRegister);
+#if WTF_MIPS_ISA(1)
+        /*
+            lwc1        dest, 0(addrTemp)
+            lwc1        dest+1, 4(addrTemp)
+         */
+        m_assembler.lwc1(dest, addrTempRegister, 0);
+        m_assembler.lwc1(FPRegisterID(dest + 1), addrTempRegister, 4);
+#else
+        /*
+            ldc1        dest, 0(addrTemp)
+        */
+        m_assembler.ldc1(dest, addrTempRegister, 0);
+#endif
+        return label;
+    }
+
+    void storeFloat(FPRegisterID src, BaseIndex address)
+    {
+        lea(address, addrTempRegister);
+        m_assembler.swc1(src, addrTempRegister, 0);
+    }
+
+    void storeFloat(FPRegisterID src, ImplicitAddress address)
+    {
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.swc1(src, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                swc1    src, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.swc1(src, addrTempRegister, address.offset);
+        }
+    }
+
+    void storeFloat(ImmDouble imm, Address address)
+    {
+        union {
+            float f;
+            uint32_t u32;
+        } u;
+        u.f = imm.u.d;
+        store32(Imm32(u.u32), address);
+    }
+
+    void storeFloat(ImmDouble imm, BaseIndex address)
+    {
+        union {
+            float f;
+            uint32_t u32;
+        } u;
+        u.f = imm.u.d;
+        store32(Imm32(u.u32), address);
+    }
+
+    void storeDouble(FPRegisterID src, BaseIndex address)
+    {
+        lea(address, addrTempRegister);
+#if WTF_MIPS_ISA(1)
+        m_assembler.swc1(src, addrTempRegister, 0);
+        m_assembler.swc1(FPRegisterID(src + 1), addrTempRegister, 4);
+#else
+        m_assembler.sdc1(src, addrTempRegister, 0);
+#endif
+    }
+
+    void storeDouble(FPRegisterID src, ImplicitAddress address)
+    {
+#if WTF_MIPS_ISA(1)
+        /*
+            li          addrTemp, address.offset
+            addu        addrTemp, addrTemp, base
+            swc1        dest, 0(addrTemp)
+            swc1        dest+1, 4(addrTemp)
+         */
+        move(Imm32(address.offset), addrTempRegister);
+        m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+        m_assembler.swc1(src, addrTempRegister, 0);
+        m_assembler.swc1(FPRegisterID(src + 1), addrTempRegister, 4);
+#else
+        if (address.offset >= -32768 && address.offset <= 32767
+            && !m_fixedWidth)
+            m_assembler.sdc1(src, address.base, address.offset);
+        else {
+            /*
+                lui     addrTemp, (offset + 0x8000) >> 16
+                addu    addrTemp, addrTemp, base
+                sdc1    src, (offset & 0xffff)(addrTemp)
+              */
+            m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16);
+            m_assembler.addu(addrTempRegister, addrTempRegister, address.base);
+            m_assembler.sdc1(src, addrTempRegister, address.offset);
+        }
+#endif
+    }
+
+    void storeDouble(ImmDouble imm, Address address)
+    {
+#if CPU(BIG_ENDIAN)
+        store32(Imm32(imm.u.s.msb), address);
+        store32(Imm32(imm.u.s.lsb), Address(address.base, address.offset + 4));
+#else
+        store32(Imm32(imm.u.s.lsb), address);
+        store32(Imm32(imm.u.s.msb), Address(address.base, address.offset + 4));
+#endif
+    }
+
+    void storeDouble(ImmDouble imm, BaseIndex address)
+    {
+#if CPU(BIG_ENDIAN)
+        store32(Imm32(imm.u.s.msb), address);
+        store32(Imm32(imm.u.s.lsb),
+                BaseIndex(address.base, address.index, address.scale, address.offset + 4));
+#else
+        store32(Imm32(imm.u.s.lsb), address);
+        store32(Imm32(imm.u.s.msb),
+                BaseIndex(address.base, address.index, address.scale, address.offset + 4));
+#endif
+    }
+
+    void addDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.addd(dest, dest, src);
+    }
+
+    void addDouble(Address src, FPRegisterID dest)
+    {
+        loadDouble(src, fpTempRegister);
+        m_assembler.addd(dest, dest, fpTempRegister);
+    }
+
+    void subDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.subd(dest, dest, src);
+    }
+
+    void subDouble(Address src, FPRegisterID dest)
+    {
+        loadDouble(src, fpTempRegister);
+        m_assembler.subd(dest, dest, fpTempRegister);
+    }
+
+    void mulDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.muld(dest, dest, src);
+    }
+
+    void mulDouble(Address src, FPRegisterID dest)
+    {
+        loadDouble(src, fpTempRegister);
+        m_assembler.muld(dest, dest, fpTempRegister);
+    }
+
+    void divDouble(FPRegisterID src, FPRegisterID dest)
+    {
+