author Jan de Mooij <>
Sat, 12 Jan 2019 10:50:04 +0000
changeset 453631 cfa1c48c717048f00eb4811b5719cd716eb1e5b3
parent 450554 09c71a7cf75aeaf2963050e315276fb9a866fd62
permissions -rw-r--r--
Bug 1518753 part 5 - Stop using JSProtoKey for initial shapes. r=tcampbell I added this optimization in bug 1299107 to share more shapes across compartments. Unfortunately this doesn't play well with same-compartment realms (ICs can misbehave) because it relies on compartments being isolated from each other. I think we should remove this optimization: * Fixing the IC issue is impossible without deoptimizing everything. * I added it mainly for chrome globals. The shared-JSM-global work has eliminated the need for this there. * Same-compartment realms win memory back by eliminating CCWs etc. * It's quite a lot of complicated code. Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at */

// Original author:

#ifndef gtest_ringbuffer_dumper_h__
#define gtest_ringbuffer_dumper_h__

#include "mozilla/SyncRunnable.h"

#define GTEST_HAS_RTTI 0
#include "gtest/gtest.h"

#include "mtransport_test_utils.h"
#include "runnable_utils.h"
#include "rlogconnector.h"

using mozilla::RLogConnector;
using mozilla::WrapRunnable;

namespace test {
class RingbufferDumper : public ::testing::EmptyTestEventListener {
  explicit RingbufferDumper(MtransportTestUtils* test_utils)
      : test_utils_(test_utils) {}

  void ClearRingBuffer_s() {
    // Set limit to zero to clear the ringbuffer

  void DestroyRingBuffer_s() { RLogConnector::DestroyInstance(); }

  void DumpRingBuffer_s() {
    std::deque<std::string> logs;
    // Get an unlimited number of log lines, with no filter
    RLogConnector::GetInstance()->GetAny(0, &logs);
    for (auto l = logs.begin(); l != logs.end(); ++l) {
      std::cout << *l << std::endl;

  virtual void OnTestStart(const ::testing::TestInfo& testInfo) override {
        WrapRunnable(this, &RingbufferDumper::ClearRingBuffer_s));

  virtual void OnTestEnd(const ::testing::TestInfo& testInfo) override {
        WrapRunnable(this, &RingbufferDumper::DestroyRingBuffer_s));

  // Called after a failed assertion or a SUCCEED() invocation.
  virtual void OnTestPartResult(
      const ::testing::TestPartResult& testResult) override {
    if (testResult.failed()) {
      // Dump (and empty) the RLogConnector
          WrapRunnable(this, &RingbufferDumper::DumpRingBuffer_s));

  MtransportTestUtils* test_utils_;

}  // namespace test

#endif  // gtest_ringbuffer_dumper_h__