Bug 781439: Trim js/src/jit-test/tests/debug/Environment-find-06.js, and remove assertions. r=luke
authorJim Blandy <jimb@mozilla.com>
Tue, 18 Sep 2012 11:31:15 -0700
changeset 107505 4030896316bd2ec68d8e9c513e5d0a6fe1026fe2
parent 107504 4eba7041ee9d2277370b7101ab6535f7174e788a
child 107506 e041c4098d4a391895d95590fe7d6ac404052668
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersluke
bugs781439
milestone18.0a1
Bug 781439: Trim js/src/jit-test/tests/debug/Environment-find-06.js, and remove assertions. r=luke slotCount() is O(n) on BlockObjects, so that, when used from a loop, those assertions brought about quadratic behavior. The test creates 'let' blocks with thousands of bindings, making the quadratic behavior show. The assertions are unnecessary, as getSlotRef and setSlot do their own bounds checking. I believe the test can be just as effective with smaller 'let' blocks.
js/src/jit-test/tests/debug/Environment-find-06.js
js/src/vm/ScopeObject-inl.h
--- a/js/src/jit-test/tests/debug/Environment-find-06.js
+++ b/js/src/jit-test/tests/debug/Environment-find-06.js
@@ -15,17 +15,17 @@ function test1(code) {
         assertEq(env.parent !== null, true);
         hits++;
     };
     g.eval(code);
     assertEq(hits, 1);
 }
 
 var manyNames = '';
-for (var i = 0; i < 4096; i++)
+for (var i = 0; i < 2048; i++)
     manyNames += 'x' + i + ', ';
 manyNames += 'X';
 
 function test2(code) {
     print(code + " : one");
     test1(code.replace('@@', 'X'));
     print(code + " : many");
     test1(code.replace('@@', manyNames));
--- a/js/src/vm/ScopeObject-inl.h
+++ b/js/src/vm/ScopeObject-inl.h
@@ -124,24 +124,22 @@ inline unsigned
 BlockObject::localIndexToSlot(const Bindings &bindings, unsigned i)
 {
     return RESERVED_SLOTS + (i - (bindings.numVars() + stackDepth()));
 }
 
 inline const Value &
 BlockObject::slotValue(unsigned i)
 {
-    JS_ASSERT(i < slotCount());
     return getSlotRef(RESERVED_SLOTS + i);
 }
 
 inline void
 BlockObject::setSlotValue(unsigned i, const Value &v)
 {
-    JS_ASSERT(i < slotCount());
     setSlot(RESERVED_SLOTS + i, v);
 }
 
 inline void
 StaticBlockObject::initPrevBlockChainFromParser(StaticBlockObject *prev)
 {
     setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(prev));
 }