Files
roytam1 6885f7ffc2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1185749 - Implement a DynamicTraceable HashMap subclass that can be used with Rooted; r=jonco (3f84bdb30)
- Bug 1186609 - Implement a DynamicTraceable Vector subclass for use with Rooted; r=sfink (fa5b47e5b)
- Bug 1155985 - Set FieldInto::mType just before storing to reserved slot. r=jonco, a=abillings (34dbc3ca0)
- Bug 1156295 - Refactor GC rooting in StructType::DefineInternal() r=terrence (ec40a1701)
- Bug 1185755 - Use Rooted to simplify FieldInfoHash rooting; r=jonco (8dc66d7cd)
- Bug 1189072 - Make DefaultTracer for struct types call T::trace; r=fitzgen (96f79bc6f)
- Bug 1149294 - Part 1: Don't trace permanent atoms and well known symbols that are owned by a parent JSRuntime inside SimpeEdgeVectorTracer; r=terrence (7ce049a33)
- Bug 1149294 - Part 2: expose ChromeUtils and HeapSnapshot to workers; r=bholley (5737cd923)
- Bug 1147679 - Use PR_GetFileInfo64 when deserializing heap snapshots; r=jimb (1ce8cd241)
- Bug 1147680 - Use PR_MemMap when deserializing heap snapshots; r=jimb (04e5a370d)
- Bug 1149294 - Part 3: Split thread-safe methods on ChromeUtils out in to a new (4967637e2)
- Bug 1173829. Fix some compile issues in code generated by bindings codegen for non-concrete interfaces. r=peterv (3e0f93640)
- Bug 1170274 - A better string parser for nsGenericHTMLElement::GetURIListAttr, r=ehsan (8c1595d29)
- Bug 1170274 - patch 2 - A better string parser for nsGenericHTMLElement::GetURIListAttr, r=ehsan CLOSED TREE (5626d631f)
- Bug 1096550 - Update content scale when swapping remote tabs between windows. r=roc. (ed974edf4)
- Bug 1180017: Give GCCellPtr is<T> and as<T> methods, replacing isFoo and toFoo methods. Fix callers. r=terrence (b95645bbb)
- pointer style (a46b905fe)
- pointer style (cb548fd44)
- Bug 1151182 - Fix type for JSOP_THROWMSG documentation comment. r=efaust (f9bce9df7)
- Bug 1077318 - Part 2: Fix the order of include in AsmJSModule.cpp. r=evilpie (a61716e33)
- Bug 1155006: Fix unified build sensitivities in js/src. r=shu (b0f166ec9)
- Bug 988463 - Add in support for tracelogging on ARM. r=h4writer (10345729b)
- Bug 1190077 - Move RDTSC and prmjtime.* to vm/Time.*. r=nbp (b72c1f366)
2021-04-27 09:19:42 +08:00

63 lines
1.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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 http://mozilla.org/MPL/2.0/. */
#include "mozilla/devtools/AutoMemMap.h"
#include "nsDebug.h"
namespace mozilla {
namespace devtools {
AutoMemMap::~AutoMemMap()
{
if (addr) {
NS_WARN_IF(PR_MemUnmap(addr, size()) != PR_SUCCESS);
addr = nullptr;
}
if (fileMap) {
NS_WARN_IF(PR_CloseFileMap(fileMap) != PR_SUCCESS);
fileMap = nullptr;
}
if (fd) {
NS_WARN_IF(PR_Close(fd) != PR_SUCCESS);
fd = nullptr;
}
}
nsresult
AutoMemMap::init(const char* filePath, PRIntn flags, PRIntn mode, PRFileMapProtect prot)
{
MOZ_ASSERT(!fd);
MOZ_ASSERT(!fileMap);
MOZ_ASSERT(!addr);
if (PR_GetFileInfo64(filePath, &fileInfo) != PR_SUCCESS)
return NS_ERROR_FILE_NOT_FOUND;
// Check if the file is too big to memmap.
if (fileInfo.size > int64_t(UINT32_MAX))
return NS_ERROR_INVALID_ARG;
auto length = uint32_t(fileInfo.size);
fd = PR_Open(filePath, flags, flags);
if (!fd)
return NS_ERROR_UNEXPECTED;
fileMap = PR_CreateFileMap(fd, fileInfo.size, prot);
if (!fileMap)
return NS_ERROR_UNEXPECTED;
addr = PR_MemMap(fileMap, 0, length);
if (!addr)
return NS_ERROR_UNEXPECTED;
return NS_OK;
}
} // namespace devtools
} // namespace mozilla