Commit 8c8c6205 authored by Wes Kocher's avatar Wes Kocher
Browse files

Backed out 8 changesets (bug 1028418) for assertions in SavedStacks.cpp:103 CLOSED TREE

Backed out changeset 8f20146ce3c8 (bug 1028418)
Backed out changeset f6e78ff75f4b (bug 1028418)
Backed out changeset caf840e71590 (bug 1028418)
Backed out changeset ba47cb00a938 (bug 1028418)
Backed out changeset 3f298220d712 (bug 1028418)
Backed out changeset 7c2555a6e32e (bug 1028418)
Backed out changeset ed9287cd152a (bug 1028418)
Backed out changeset 88a5c0415403 (bug 1028418)
parent 7080a119
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -609,10 +609,6 @@ class DispatchWrapper
  public:
    // Mimic a pointer type, so that we can drop into Rooted.
    MOZ_IMPLICIT DispatchWrapper(const T& initial) : tracer(&T::trace), storage(initial) {}
    MOZ_IMPLICIT DispatchWrapper(T&& initial)
      : tracer(&T::trace),
        storage(mozilla::Forward<T>(initial))
    { }
    T* operator &() { return &storage; }
    const T* operator &() const { return &storage; }
    operator T&() { return storage; }
+0 −4
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ class ArrayObject;
class GlobalObject;
class PlainObject;
class ScriptSourceObject;
class SavedFrame;
class Shape;
class ObjectGroup;

@@ -34,14 +33,12 @@ typedef JS::Handle<JSLinearString*> HandleLinearString;
typedef JS::Handle<PropertyName*>      HandlePropertyName;
typedef JS::Handle<ArrayObject*>       HandleArrayObject;
typedef JS::Handle<PlainObject*>       HandlePlainObject;
typedef JS::Handle<SavedFrame*>        HandleSavedFrame;
typedef JS::Handle<ScriptSourceObject*> HandleScriptSource;

typedef JS::MutableHandle<Shape*>      MutableHandleShape;
typedef JS::MutableHandle<JSAtom*>     MutableHandleAtom;
typedef JS::MutableHandle<NativeObject*> MutableHandleNativeObject;
typedef JS::MutableHandle<PlainObject*> MutableHandlePlainObject;
typedef JS::MutableHandle<SavedFrame*> MutableHandleSavedFrame;

typedef JS::Rooted<NativeObject*>      RootedNativeObject;
typedef JS::Rooted<Shape*>             RootedShape;
@@ -52,7 +49,6 @@ typedef JS::Rooted<PropertyName*> RootedPropertyName;
typedef JS::Rooted<ArrayObject*>       RootedArrayObject;
typedef JS::Rooted<GlobalObject*>      RootedGlobalObject;
typedef JS::Rooted<PlainObject*>       RootedPlainObject;
typedef JS::Rooted<SavedFrame*>        RootedSavedFrame;
typedef JS::Rooted<ScriptSourceObject*> RootedScriptSource;

} /* namespace js */
+0 −35
Original line number Diff line number Diff line
// Test that the SavedFrame caching doesn't get messed up in the presence of
// cross-compartment calls.

const funcSource = "function call(f) { return f(); }";

const g1 = newGlobal();
const g2 = newGlobal();

g1.eval(funcSource);
g2.eval(funcSource);
eval(funcSource);

function doSaveStack() {
  return saveStack();
}

const captureStacksAcrossCompartmens = () =>
  [this, g1, g2].map(g => g.call(doSaveStack));

(function f0() {
  const stacks = [];

  for (var i = 0; i < 2; i++)
    stacks.push(...captureStacksAcrossCompartmens());

  const [s1, s2, s3, s4, s5, s6] = stacks;

  assertEq(s1 != s2, true);
  assertEq(s2 != s3, true);
  assertEq(s3 != s1, true);

  assertEq(s1, s4);
  assertEq(s2, s5);
  assertEq(s3, s6);
}());
+0 −38
Original line number Diff line number Diff line
// Test that the SavedFrame caching doesn't mess up counts. Specifically, that
// if we capture only the first n frames of a stack, we don't cache that stack
// and return it for when someone else captures another stack and asks for more
// frames than that last time.

function stackLength(stack) {
  return stack === null
    ? 0
    : 1 + stackLength(stack.parent);
}

(function f0() {
  (function f1() {
    (function f2() {
      (function f3() {
        (function f4() {
          (function f5() {
            (function f6() {
              (function f7() {
                (function f8() {
                  (function f9() {
                    const s1 = saveStack(3);
                    const s2 = saveStack(5);
                    const s3 = saveStack(0 /* no limit */);

                    assertEq(stackLength(s1), 3);
                    assertEq(stackLength(s2), 5);
                    assertEq(stackLength(s3), 11);
                  }());
                }());
              }());
            }());
          }());
        }());
      }());
    }());
  }());
}());
+57 −68
Original line number Diff line number Diff line
@@ -3,19 +3,14 @@

const FUZZ_FACTOR = 3;

function isAboutEq(actual, expected) {
  return Math.abs(actual - expected) <= FUZZ_FACTOR;
function assertAboutEq(actual, expected) {
  if (Math.abs(actual - expected) > FUZZ_FACTOR)
    throw new Error("Assertion failed: expected about " + expected + ", got " + actual +
                    ". FUZZ_FACTOR = " + FUZZ_FACTOR);
}

var stacks = [];

(function () {
  // Use an IIFE here so that we don't keep these saved stacks alive in the
  // frame cache when we test that they all go away at the end of the test.

  var startCount = getSavedFrameCount();
  print("startCount = " + startCount);

stacks.push(saveStack());
stacks.push(saveStack());
stacks.push(saveStack());
@@ -68,13 +63,7 @@ var stacks = [];
stacks.push(saveStack());
stacks.push(saveStack());

  gc();

  var endCount = getSavedFrameCount();
  print("endCount = " + endCount);

  assertEq(isAboutEq(endCount - startCount, 50), true);
}());
assertAboutEq(getSavedFrameCount(), 50);

while (stacks.length) {
  stacks.pop();
@@ -84,4 +73,4 @@ gc();
stacks = null;
gc();

assertEq(isAboutEq(getSavedFrameCount(), 0), true);
assertAboutEq(getSavedFrameCount(), 0);
Loading