Bug 848754 - GC: Remove relaxed root checking infrastructure r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 08 Mar 2013 08:54:59 +0000
changeset 131860 b7c5623df2283f89b799e24a3933f6e6164c7556
parent 131859 fa78767a3e78c3e18f0b3afeea472bcab65957b2
child 131861 6cae06155037ee729e3c53ad3bd2c43fca4a042b
push idunknown
push userunknown
push dateunknown
reviewersterrence
bugs848754
milestone22.0a1
Bug 848754 - GC: Remove relaxed root checking infrastructure r=terrence
js/public/RootingAPI.h
js/src/jit-test/tests/sunspider/check-crypto-md5.js
js/src/jit-test/tests/sunspider/check-crypto-sha1.js
js/src/jit-test/tests/v8-v5/check-crypto.js
js/src/jsapi.cpp
js/src/jscntxt.h
js/src/jsgcinlines.h
js/src/shell/js.cpp
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -760,31 +760,27 @@ Handle<T>::Handle(MutableHandle<S> &root
 
 template <typename T>
 inline
 MutableHandle<T>::MutableHandle(Rooted<T> *root)
 {
     ptr = root->address();
 }
 
-JS_FRIEND_API(bool) NeedRelaxedRootChecks();
-
 } /* namespace JS */
 
 namespace js {
 
 /*
  * Hook for dynamic root analysis. Checks the native stack and poisons
  * references to GC things which have not been rooted.
  */
-inline void MaybeCheckStackRoots(JSContext *cx, bool relax = true)
+inline void MaybeCheckStackRoots(JSContext *cx)
 {
 #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
-    if (relax && JS::NeedRelaxedRootChecks())
-        return;
     JS::CheckStackRoots(cx);
 #endif
 }
 
 namespace gc {
 struct Cell;
 } /* namespace gc */
 
--- a/js/src/jit-test/tests/sunspider/check-crypto-md5.js
+++ b/js/src/jit-test/tests/sunspider/check-crypto-md5.js
@@ -278,15 +278,10 @@ And, Montague, come you this afternoon,\
 To know our further pleasure in this case,\n\
 To old Free-town, our common judgment-place.\n\
 Once more, on pain of death, all men depart."
 
 for (var i = 0; i <4; i++) {
     plainText += plainText;
 }
 
-// root checks performed during integer conversion operations can poison
-// crypto integers in this test.
-if (relaxRootChecks)
-  relaxRootChecks();
-
 var md5Output = hex_md5(plainText);
 assertEq(md5Output, "a831e91e0f70eddcb70dc61c6f82f6cd")
--- a/js/src/jit-test/tests/sunspider/check-crypto-sha1.js
+++ b/js/src/jit-test/tests/sunspider/check-crypto-sha1.js
@@ -216,15 +216,10 @@ Which, but their children's end, nought 
 Is now the two hours' traffic of our stage;\n\
 The which if you with patient ears attend,\n\
 What here shall miss, our toil shall strive to mend.";
 
 for (var i = 0; i <4; i++) {
     plainText += plainText;
 }
 
-// root checks performed during integer conversion operations can poison
-// crypto integers in this test.
-if (relaxRootChecks)
-  relaxRootChecks();
-
 var sha1Output = hex_sha1(plainText);
 assertEq(sha1Output, "2524d264def74cce2498bf112bedf00e6c0b796d")
--- a/js/src/jit-test/tests/v8-v5/check-crypto.js
+++ b/js/src/jit-test/tests/v8-v5/check-crypto.js
@@ -1,8 +1,12 @@
+// |jit-test| slow;
+// This test times out in rooting analyis builds, and so is marked slow so that
+// it's not run as part of the rooting analysis tests on tinderbox.
+
 /*
  * Copyright (c) 2003-2005  Tom Wu
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
@@ -1702,17 +1706,12 @@ function check_correctness(text, hash) {
   RSA.setPublic(nValue, eValue);
   RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value, coeffValue);
   var encrypted = RSA.encrypt(text);
   var decrypted = RSA.decrypt(encrypted);
   assertEq( encrypted, hash );
   assertEq( decrypted, text );
 }
 
-// Too much time is taken checking roots on each ToNumber when interpreting the
-// crypto kernel in this benchmark.
-if (relaxRootChecks)
-    relaxRootChecks();
-
 // All 'correct' hashes here come from v8's javascript shell built off of tag 2.3.4
 check_correctness("Hello! I am some text.", "142b19b40fee712ab9468be296447d38c7dfe81a7850f11ae6aa21e49396a4e90bd6ba4aa385105e15960a59f95447dfad89671da6e08ed42229939583753be84d07558abb4feee4d46a92fd31d962679a1a5f4bf0fb7af414b9a756e18df7e6d1e96971cc66769f3b27d61ad932f2211373e0de388dc040557d4c3c3fe74320");
 check_correctness("PLEASE ENCRYPT ME. I AM TEXT. I AM DIEING TO BE ENCRYPTED. OH WHY WONT YOU ENCRYPT ME!?", "490c1fae87d7046296e4b34b357912a72cb7c38c0da3198f1ac3aad3489662ce02663ec5ea1be58ae73a275f3096b16c491f3520ebf822df6c65cc95e28be1cc0a4454dfba3fdd402c3a9de0db2f308989bfc1a7fada0dd680db76d24b2d96bd6b7e7d7e7f962deb953038bae06092f7bb9bcb40bba4ec92e040df32f98e035e");
 check_correctness("x","46c1b7cf202171b1b588e9ecf250e768dcf3b300490e859d508f708e702ef799bc496b9fac7634d60a82644653c5fd25b808393b234567116b8890d5f119c7c74dae7c97c8e40ba78ca2dc3e3d78ce859a7fa3815f42c27d0607eafc3940896abb6019cc28b2ff875531ed581a6351728a8df0d607b7c2c26265bf3dddbe4f84");
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -666,35 +666,25 @@ static JSBool js_NewRuntimeWasCalled = J
 mozilla::ThreadLocal<PerThreadData *> js::TlsPerThreadData;
 
 #ifdef DEBUG
 JS_FRIEND_API(bool)
 JS::isGCEnabled()
 {
     return !TlsPerThreadData.get()->suppressGC;
 }
-
-JS_FRIEND_API(bool)
-JS::NeedRelaxedRootChecks()
-{
-    return TlsPerThreadData.get()->gcRelaxRootChecks;
-}
 #else
 JS_FRIEND_API(bool) JS::isGCEnabled() { return true; }
-JS_FRIEND_API(bool) JS::NeedRelaxedRootChecks() { return false; }
 #endif
 
 static const JSSecurityCallbacks NullSecurityCallbacks = { };
 
 PerThreadData::PerThreadData(JSRuntime *runtime)
   : PerThreadDataFriendFields(),
     runtime_(runtime),
-#ifdef DEBUG
-    gcRelaxRootChecks(false),
-#endif
     ionTop(NULL),
     ionJSContext(NULL),
     ionStackLimit(0),
     ionActivation(NULL),
     asmJSActivationStack_(NULL),
 # ifdef JS_THREADSAFE
     asmJSActivationStackLock_(NULL),
 # endif
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -459,18 +459,16 @@ class PerThreadData : public js::PerThre
 #ifdef DEBUG
     struct SavedGCRoot {
         void *thing;
         JSGCTraceKind kind;
 
         SavedGCRoot(void *thing, JSGCTraceKind kind) : thing(thing), kind(kind) {}
     };
     js::Vector<SavedGCRoot, 0, js::SystemAllocPolicy> gcSavedRoots;
-
-    bool                gcRelaxRootChecks;
 #endif
 
     /*
      * If Ion code is on the stack, and has called into C++, this will be
      * aligned to an Ion exit frame.
      */
     uint8_t             *ionTop;
     JSContext           *ionJSContext;
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -486,17 +486,17 @@ NewGCThing(JSContext *cx, AllocKind kind
     JS_OOM_POSSIBLY_FAIL_REPORT(cx);
 
 #ifdef JS_GC_ZEAL
     if (cx->runtime->needZealousGC() && allowGC)
         js::gc::RunDebugGC(cx);
 #endif
 
     if (allowGC)
-        MaybeCheckStackRoots(cx, /* relax = */ false);
+        MaybeCheckStackRoots(cx);
 
     JS::Zone *zone = cx->zone();
     T *t = static_cast<T *>(zone->allocator.arenas.allocateFromFreeList(kind, thingSize));
     if (!t)
         t = static_cast<T *>(js::gc::ArenaLists::refillFreeList<allowGC>(cx, kind));
 
     JS_ASSERT_IF(t && zone->wasGCStarted() && (zone->isGCMarking() || zone->isGCSweeping()),
                  t->arenaHeader()->allocatedDuringIncremental);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3448,32 +3448,16 @@ EnableStackWalkingAssertion(JSContext *c
     cx->stackIterAssertionEnabled = JSVAL_TO_BOOLEAN(JS_ARGV(cx, vp)[0]);
 #endif
 
     JS_SET_RVAL(cx, vp, UndefinedValue());
     return true;
 }
 
 static JSBool
-RelaxRootChecks(JSContext *cx, unsigned argc, jsval *vp)
-{
-    if (argc > 0) {
-        JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_INVALID_ARGS,
-                             "relaxRootChecks");
-        return false;
-    }
-
-#ifdef DEBUG
-    cx->mainThread().gcRelaxRootChecks = true;
-#endif
-
-    return true;
-}
-
-static JSBool
 GetMaxArgs(JSContext *cx, unsigned arg, jsval *vp)
 {
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(StackSpace::ARGS_LENGTH_MAX));
     return true;
 }
 
 static JSBool
 ObjectEmulatingUndefined(JSContext *cx, unsigned argc, jsval *vp)
@@ -3816,22 +3800,16 @@ static JSFunctionSpecWithHelp shell_func
 "  code.  If your test isn't ridiculously thorough, such that performing this\n"
 "  assertion increases test duration by an order of magnitude, you shouldn't\n"
 "  use this."),
 
     JS_FN_HELP("getMaxArgs", GetMaxArgs, 0, 0,
 "getMaxArgs()",
 "  Return the maximum number of supported args for a call."),
 
-    JS_FN_HELP("relaxRootChecks", RelaxRootChecks, 0, 0,
-"relaxRootChecks()",
-"  Tone down the frequency with which the dynamic rooting analysis checks for\n"
-"  rooting hazards. This is helpful to reduce the time taken when interpreting\n"
-"  heavily numeric code."),
-
     JS_FN_HELP("objectEmulatingUndefined", ObjectEmulatingUndefined, 0, 0,
 "objectEmulatingUndefined()",
 "  Return a new object obj for which typeof obj === \"undefined\", obj == null\n"
 "  and obj == undefined (and vice versa for !=), and ToBoolean(obj) === false.\n"),
 
     JS_FN_HELP("getSelfHostedValue", GetSelfHostedValue, 1, 0,
 "getSelfHostedValue()",
 "  Get a self-hosted value by its name. Note that these values don't get \n"