mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
6629d22907
- Bug 1170717 - Move heapState check up to readBarrier; r=jonco (b9c4df5ea) - Bug 1163908 - Export GL draw data to layerscope for drawing heat-map view. r=:djg (cf078d4fd) - Bug 1161372 - Add EventRegions on LayerScope. r=dglastonbury (49fc29e8a) - Files as of Bug 1138721 - Application reputation should check mac file extensions. r=mmc (4b76de8d8) - Bug 1024774 - Part 0: Upgrade the protobuf library. r=mmc,glandium (c98c08fbd) - Bug 1149397 - JS::ubi::Node::edges should return a mozilla::UniquePtr; r=jimb (32f755867) - Bug 1110039 - Part 1 - Add nsLayoutUtils::ClampRectToScrollFrames. r=roc (a8812c287) - Bug 1110039 - Part 2.1 - Add logger facility. r=roc (1a400bb1f) - Bug 1110039 - Part 2.2 - Add AccessibleCaret. r=roc (d8c2c759f) - Bug 1110039 - Part 2.3 - Add AccessibleCaretManager. r=roc (ba8ad6424) - Bug 1110039 - Part 2.4 - Add AccessibleCaretEventHub. r=roc (db4ef1fe6) - Bug 1110039 - Part 2.5 - Add all files to build system. r=roc (bee54dc43) - fix nsRefPtr includes - but build still broken (423d9f32d) - Bug 1110039 - Part 3 - Add gtest for AccessibleCaretEventHub. r=roc (cdf0df240) - Bug 1110039 - Part 4 - Hook new classes into the system. r=roc (438a4df68) - Bug 1109183 - Fix imports of the marionette client and remove spurious entry from sys.path provided by mach. r=ahal (86b814562) - Bug 1110039 - Part 5 - Reuse marionette tests for AccessibleCaret. r=roc (d5cd35016) - Bug 1110039 followup: Add 'override' keyword to Name() decl in Access# (cd0d9b0f6) - Bug 1140994 - Notify gaia to hide selection bubble when scrolling without APZ. r=roc (ca15626fa) - Bug 1143665 - Remove the ambiguous scroll position being passed around in scroll started/stop notifications. r=roc,ehsan (ce8f1d2a9) - Bug 1140238 - Part 1: Add a test to drag first caret over non-selectable. r=automatedtester (4080723fe) - Bug 1140238 - Part 2: Adjust ranges after changing selection direction. r=mats (add1f155d) - Bug 1140238 - Part 3: Clear maintain selection when dragging caret. r=mats (0aba36f24) - Bug 1024774 - Part 2: Implement a google::protobuf::ZeroCopyOutputStream wrapper around nsIOutputStream; r=jimb (30c6272d2) - Bug 1024774 - Part 3: Serialize heap snapshots. r=jimb (9d0c8f6ec) - Bug 1024774 - Part 1: Add the ChromeUtils WebIDL interface. r=bholley (8e81e8344) - Bug 1024774 - Part 4: Add an xpcshell test for saving heap snapshots. r=jimb (6e0a07069) - Bug 1024774 - Part 5: Add GTests for core dump serialization. r=jimb (79315c540) - clean up spurious char (9a1f9bc18) - Bug 1121528 - Avoid the inspector going blank when quickly navigating; r=bgrins (f4cff269f) - Bug 1155168 - Always use the same actor pool. r=ochameau (3e6cc5504) - Bug 1137527 - Part 1: Make the memory actor emit events for garbage collection. r=jryans (6dcdb18f8) - Bug 1137527 - Part 2: Add a test for GC MemoryActor events. r=jryans (df2bcf120) - Bug 1024774 - Part 6: Add a mochitest-chrome sanity check test. r=bholley (4b5bffe79) - Bug 1024774 - Part 7: Add HeapSnapshot WebIDL interface; r=bholley (7b5ae703a) - Bug 1024774 - Part 8: Add JS::ubi::Node::isLive; r=jimb (42a965f56) - Bug 1024774 - Part 9: Deserialize heap snapshots; r=jimb (fb3edfbc0) - Bug 1024774 - Part 10: Add an xpcshell test for reading heap snapshots. r=jimb (09c3390a1) - Bug 1024774 - Part 11: Implement a JS::ubi::Node specialization for DeserializedNode; r=jimb (d73362efe) - Bug 1024774 - Part 12: Add a GTest for the JS::ubi::Node specialization for DeserializedNode; r=jimb (4415acb73) - Bug 1024774 - Part 13: Change to new SpiderMonkey style from bug 1144366; r=me (15c4bcf87) - Bug 1024774 - Part 14: Ignore protobuf indirect calls in the GC hazard analysis; r=sfink (c5b141c59) - Bug 1024774 - Followup: Don't redefine the Debugger property in xpcshell tests; r=jorendorff (dc4f1f109) - Bug 1169791 - Strongly type NoteJSRoot; r=mccr8 (ba722a44f) - Bug 1169791 - Strongly type MergeZone; r=mccr8 (a118cf612) - Bug 1169791 - Strongly type GetTenuredGCThingZone; r=jonco, r=mccr8 (a4da82aea) - Bug 1171780 - We no longer need to cast out of barrieried types in GC; r=jonco (be83218fa) - Bug 1144361: Re-enable JIT code randomization on Win64. r=jandem (6c88b4312) - pointer style (458344bcd) - Bug 1156914 - Fix the MacroAssembler::pushValue(const Address&) footgun on 32 bit platforms. (r=jandem) (52d5c351d) - Bug 1156030 - Remove some obsolete static assertion macros from the tree; r=Waldo (84d8f3fea) - pointer style (ac3c92ce1) - Bug 1151323 - Handle loading unboxed int32 properties into floating point registers, r=jandem. (790920f3d) - Bug 1023297 - Use explicit constructors for ARM-specific classes. r=jandem (f7f12cd76) - Bug 1164229 - Rename ARM SetCond_ to SBit. r=efaust (c55e1d535) - Bug 977805 - Add an option to mark JIT pages as non-writable. r=luke bug 977805 - add missing #include. r=jandem (384abd6ad) - Bug 1173992 - Add ARM64 build support. r=glandium (540a7c784) - Bug 1170750 - Replace %f by %.16g in js/src. r=jandem (48f808c73) - Bug 1170750 - Use mfbt snprintf_literal instead of sprintf. r=jandem (3b2016484) - Bug 1170750 - jsprf.cpp: Sort headers properly. r=me (0956cd3a5) - Bug 923717 - Use structured control flow when testing for the forceInlineCaches option, r=nbp. (fc1dcef6e) - Bug 1158044 - Remove unused TypeWrapper class and untemplatize/cleanup some code. r=bhackett (a4d5de646) - Bug 1169355 - Remove unnecessary assertion, r=jandem. (f55c99552) - Bug 1162986 - Allow objects to be turned into singletons dynamically, r=jandem. (9c683e420) - Bug 1169731 - [[Call]] on a class constructor should throw. (r=jandem) (470895e3f) and fix for shared-js in UbiNode.h
195 lines
5.6 KiB
C++
195 lines
5.6 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "HeapSnapshot.h"
|
|
|
|
#include <google/protobuf/io/coded_stream.h>
|
|
#include <google/protobuf/io/gzip_stream.h>
|
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
|
|
|
#include "mozilla/devtools/DeserializedNode.h"
|
|
#include "mozilla/dom/HeapSnapshotBinding.h"
|
|
|
|
#include "CoreDump.pb.h"
|
|
#include "nsCycleCollectionParticipant.h"
|
|
#include "nsCRTGlue.h"
|
|
#include "nsISupportsImpl.h"
|
|
|
|
namespace mozilla {
|
|
namespace devtools {
|
|
|
|
using ::google::protobuf::io::ArrayInputStream;
|
|
using ::google::protobuf::io::CodedInputStream;
|
|
using ::google::protobuf::io::GzipInputStream;
|
|
using ::google::protobuf::io::ZeroCopyInputStream;
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HeapSnapshot)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HeapSnapshot)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HeapSnapshot)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(HeapSnapshot)
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(HeapSnapshot)
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(HeapSnapshot)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HeapSnapshot)
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
/* virtual */ JSObject*
|
|
HeapSnapshot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return dom::HeapSnapshotBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
/* static */ already_AddRefed<HeapSnapshot>
|
|
HeapSnapshot::Create(JSContext* cx,
|
|
dom::GlobalObject& global,
|
|
const uint8_t* buffer,
|
|
uint32_t size,
|
|
ErrorResult& rv)
|
|
{
|
|
nsRefPtr<HeapSnapshot> snapshot = new HeapSnapshot(cx, global.GetAsSupports());
|
|
if (!snapshot->init(buffer, size)) {
|
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
|
return nullptr;
|
|
}
|
|
return snapshot.forget();
|
|
}
|
|
|
|
template<typename MessageType>
|
|
static bool
|
|
parseMessage(ZeroCopyInputStream& stream, MessageType& message)
|
|
{
|
|
// We need to create a new `CodedInputStream` for each message so that the
|
|
// 64MB limit is applied per-message rather than to the whole stream.
|
|
CodedInputStream codedStream(&stream);
|
|
|
|
// Because protobuf messages aren't self-delimiting, we serialize each message
|
|
// preceeded by its size in bytes. When deserializing, we read this size and
|
|
// then limit reading from the stream to the given byte size. If we didn't,
|
|
// then the first message would consume the entire stream.
|
|
|
|
uint32_t size = 0;
|
|
if (NS_WARN_IF(!codedStream.ReadVarint32(&size)))
|
|
return false;
|
|
|
|
auto limit = codedStream.PushLimit(size);
|
|
if (NS_WARN_IF(!message.ParseFromCodedStream(&codedStream)) ||
|
|
NS_WARN_IF(!codedStream.ConsumedEntireMessage()))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
codedStream.PopLimit(limit);
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
HeapSnapshot::saveNode(const protobuf::Node& node)
|
|
{
|
|
UniquePtr<DeserializedNode> dn(DeserializedNode::Create(node, *this));
|
|
if (!dn)
|
|
return false;
|
|
return nodes.put(dn->id, Move(dn));
|
|
}
|
|
|
|
static inline bool
|
|
StreamHasData(GzipInputStream& stream)
|
|
{
|
|
// Test for the end of the stream. The protobuf library gives no way to tell
|
|
// the difference between an underlying read error and the stream being
|
|
// done. All we can do is attempt to read data and extrapolate guestimations
|
|
// from the result of that operation.
|
|
|
|
const void* buf;
|
|
int size;
|
|
bool more = stream.Next(&buf, &size);
|
|
if (!more)
|
|
// Could not read any more data. We are optimistic and assume the stream is
|
|
// just exhausted and there is not an underlying IO error, since this
|
|
// function is only called at message boundaries.
|
|
return false;
|
|
|
|
// There is more data still available in the stream. Return the data we read
|
|
// to the stream and let the parser get at it.
|
|
stream.BackUp(size);
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
HeapSnapshot::init(const uint8_t* buffer, uint32_t size)
|
|
{
|
|
if (!nodes.init() || !strings.init())
|
|
return false;
|
|
|
|
ArrayInputStream stream(buffer, size);
|
|
GzipInputStream gzipStream(&stream);
|
|
|
|
// First is the metadata.
|
|
|
|
protobuf::Metadata metadata;
|
|
if (!parseMessage(gzipStream, metadata))
|
|
return false;
|
|
if (metadata.has_timestamp())
|
|
timestamp.emplace(metadata.timestamp());
|
|
|
|
// Next is the root node.
|
|
|
|
protobuf::Node root;
|
|
if (!parseMessage(gzipStream, root))
|
|
return false;
|
|
|
|
// Although the id is optional in the protobuf format for future proofing, we
|
|
// can't currently do anything without it.
|
|
if (NS_WARN_IF(!root.has_id()))
|
|
return false;
|
|
rootId = root.id();
|
|
|
|
if (NS_WARN_IF(!saveNode(root)))
|
|
return false;
|
|
|
|
// Finally, the rest of the nodes in the core dump.
|
|
|
|
while (StreamHasData(gzipStream)) {
|
|
protobuf::Node node;
|
|
if (!parseMessage(gzipStream, node))
|
|
return false;
|
|
if (NS_WARN_IF(!saveNode(node)))
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
const char16_t*
|
|
HeapSnapshot::borrowUniqueString(const char16_t* duplicateString, size_t length)
|
|
{
|
|
MOZ_ASSERT(duplicateString);
|
|
UniqueStringHashPolicy::Lookup lookup(duplicateString, length);
|
|
auto ptr = strings.lookupForAdd(lookup);
|
|
|
|
if (!ptr) {
|
|
UniqueString owned(NS_strndup(duplicateString, length));
|
|
if (!owned || !strings.add(ptr, Move(owned)))
|
|
return nullptr;
|
|
}
|
|
|
|
MOZ_ASSERT(ptr->get() != duplicateString);
|
|
return ptr->get();
|
|
}
|
|
|
|
|
|
} // namespace devtools
|
|
} // namespace mozilla
|