Summary:
Pull Request resolved: https://github.com/facebook/hermes/pull/458

Update all uses outside llvh to std::make_unique.

Reviewed By: dulinriley

Differential Revision: D26495331

fbshipit-source-id: a5f8a74ccc462a1ebe36bd7ee2675ba0f543bb6b
This commit is contained in:
Neil Dhar 2021-02-23 19:50:18 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 0c936774e2
Коммит 46c325308c
43 изменённых файлов: 81 добавлений и 92 удалений

Просмотреть файл

@ -26,8 +26,7 @@ bool compileJS(
// Note that we are relying the zero termination provided by str.data(),
// because the parser requires it.
auto res = hbc::BCProviderFromSrc::createBCProviderFromSrc(
hermes::make_unique<hermes::Buffer>(
(const uint8_t *)str.data(), str.size()),
std::make_unique<hermes::Buffer>((const uint8_t *)str.data(), str.size()),
sourceURL,
flags);
if (!res.first)

Просмотреть файл

@ -394,7 +394,7 @@ std::unique_ptr<const jsi::Buffer> bufConvert(
std::unique_ptr<llvh::MemoryBuffer> data_;
};
return llvh::make_unique<const OwnedMemoryBuffer>(std::move(buf));
return std::make_unique<const OwnedMemoryBuffer>(std::move(buf));
}
static bool isAllZeroSourceHash(const ::hermes::SHA1 sourceHash) {

Просмотреть файл

@ -1276,7 +1276,7 @@ void HermesRuntime::debugJavaScript(
void HermesRuntime::registerForProfiling() {
vm::Runtime &runtime = impl(this)->runtime_;
runtime.samplingProfiler_ =
::hermes::make_unique<::hermes::vm::SamplingProfiler>(&runtime);
std::make_unique<::hermes::vm::SamplingProfiler>(&runtime);
}
void HermesRuntime::unregisterForProfiling() {
@ -1897,7 +1897,7 @@ jsi::Function HermesRuntimeImpl::createFunctionFromHostFunction(
unsigned int paramCount,
jsi::HostFunctionType func) {
return maybeRethrow([&] {
auto context = ::hermes::make_unique<HFContext>(std::move(func), *this);
auto context = std::make_unique<HFContext>(std::move(func), *this);
auto hostfunc =
createFunctionFromHostFunction(context.get(), name, paramCount);
context.release();

Просмотреть файл

@ -229,7 +229,7 @@ class Context {
parser::PreParsedBufferInfo *getPreParsedBufferInfo(uint32_t bufferId) {
if (!preParsed_)
preParsed_ = llvh::make_unique<parser::PreParsedData>();
preParsed_ = std::make_unique<parser::PreParsedData>();
return preParsed_->getBufferInfo(bufferId);
}

Просмотреть файл

@ -60,7 +60,7 @@ struct PreParsedData {
bufferInfo.resize(bufferId + 1);
}
if (!bufferInfo[bufferId]) {
bufferInfo[bufferId] = llvh::make_unique<PreParsedBufferInfo>();
bufferInfo[bufferId] = std::make_unique<PreParsedBufferInfo>();
}
return bufferInfo[bufferId].get();
}

Просмотреть файл

@ -71,7 +71,7 @@ class Regex {
template <typename NodeType, typename... Args>
NodeType *appendNode(Args &&...args) {
std::unique_ptr<NodeType> node =
hermes::make_unique<NodeType>(std::forward<Args>(args)...);
std::make_unique<NodeType>(std::forward<Args>(args)...);
NodeType *nodePtr = node.get();
nodeHolder_.push_back(std::move(node));
nodes_.push_back(nodePtr);
@ -381,7 +381,7 @@ void Regex<Traits>::pushLookaround(
if (!forwards) {
Node::reverseNodeList(exp);
}
nodeHolder_.push_back(hermes::make_unique<GoalNode>());
nodeHolder_.push_back(std::make_unique<GoalNode>());
exp.push_back(nodeHolder_.back().get());
appendNode<LookaroundNode>(
std::move(exp), mexpBegin, mexpEnd, invert, forwards);

Просмотреть файл

@ -42,12 +42,6 @@ ForwardIt uninitializedCopyN(InputIt src, Size count, ForwardIt dst) {
return std::uninitialized_copy_n(src, count, dst);
}
/// make_unique substitute that allows its use in C++11.
template <class T, class... Args>
std::unique_ptr<T> make_unique(Args &&...args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
/// std::min and std::max are only made constexpr in C++14.
template <class T>
constexpr const T &max(const T &a, const T &b) {

Просмотреть файл

@ -82,7 +82,7 @@ class BacktrackingBumpPtrAllocator {
public:
explicit BacktrackingBumpPtrAllocator() {
state_ = new State();
slabs_.push_back(llvh::make_unique<Slab>());
slabs_.push_back(std::make_unique<Slab>());
}
~BacktrackingBumpPtrAllocator() {
while (state_)

Просмотреть файл

@ -217,7 +217,7 @@ class Deserializer {
assert(
buffer_->getBufferStart() + offset_ + size < buffer_->getBufferEnd() &&
"Deserialize read out of range");
auto resPtr = llvh::make_unique<const BufferFromSharedBuffer>(
auto resPtr = std::make_unique<const BufferFromSharedBuffer>(
reinterpret_cast<const uint8_t *>(buffer_->getBufferStart()) + offset_,
size,
buffer_);

Просмотреть файл

@ -165,7 +165,7 @@ class BytecodeFormConverter {
BytecodeForm sourceForm)
: bytes_(bytes), fields_(fields) {
auto res = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
hermes::make_unique<Buffer>(bytes.data(), bytes.size()), sourceForm);
std::make_unique<Buffer>(bytes.data(), bytes.size()), sourceForm);
if (!res.first) {
hermes_fatal(res.second.c_str());
}

Просмотреть файл

@ -309,7 +309,7 @@ std::unique_ptr<BytecodeModule> BytecodeModuleGenerator::generate() {
#ifdef HERMESVM_LEAN
llvm_unreachable("Lazy support compiled out");
#else
auto lazyData = llvh::make_unique<LazyCompilationData>();
auto lazyData = std::make_unique<LazyCompilationData>();
lazyData->parentScope = F->getLazyScope();
lazyData->nodeKind = F->getLazySource().nodeKind;
lazyData->paramYield = F->getLazySource().paramYield;

Просмотреть файл

@ -186,7 +186,7 @@ BCProviderFromSrc::createBCProviderFromSrc(
bool isLargeFile =
buffer->size() >= context->getPreemptiveFileCompilationThreshold();
int fileBufId = context->getSourceErrorManager().addNewSourceBuffer(
llvh::make_unique<HermesLLVMMemoryBuffer>(std::move(buffer), sourceURL));
std::make_unique<HermesLLVMMemoryBuffer>(std::move(buffer), sourceURL));
if (sourceMap != nullptr) {
auto sourceMapTranslator =
std::make_shared<SourceMapTranslator>(context->getSourceErrorManager());

Просмотреть файл

@ -663,7 +663,7 @@ class OutputStream {
return false;
}
fdos_ = llvh::make_unique<raw_fd_ostream>(tempName_, EC, openFlags);
fdos_ = std::make_unique<raw_fd_ostream>(tempName_, EC, openFlags);
if (EC) {
llvh::errs() << "Failed to open file " << tempName_ << ": "
<< EC.message() << '\n';
@ -1340,7 +1340,7 @@ std::unique_ptr<hbc::BCProviderFromBuffer> loadBaseBytecodeProvider(
return nullptr;
}
// Transfer ownership to an owned memory buffer.
auto ownedBuf = llvh::make_unique<OwnedMemoryBuffer>(std::move(fileBuf));
auto ownedBuf = std::make_unique<OwnedMemoryBuffer>(std::move(fileBuf));
auto ret = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
std::move(ownedBuf));
if (!ret.first) {
@ -1465,7 +1465,7 @@ std::unique_ptr<Context::ResolutionTable> readResolutionTable(
using namespace ::hermes::parser;
auto result = hermes::make_unique<Context::ResolutionTable>();
auto result = std::make_unique<Context::ResolutionTable>();
JSONObject *resolutionTable =
llvh::dyn_cast_or_null<JSONObject>(metadata->get("resolutionTable"));
@ -1654,7 +1654,7 @@ CompileResult processBytecodeFile(std::unique_ptr<llvh::MemoryBuffer> fileBuf) {
std::string filename = fileBuf->getBufferIdentifier();
std::unique_ptr<hbc::BCProviderFromBuffer> bytecode;
auto buffer = llvh::make_unique<OwnedMemoryBuffer>(std::move(fileBuf));
auto buffer = std::make_unique<OwnedMemoryBuffer>(std::move(fileBuf));
auto ret =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(std::move(buffer));
if (!ret.first) {

Просмотреть файл

@ -107,7 +107,7 @@ loadSegment(void *ctx, vm::Runtime *runtime, vm::NativeArgs args) {
}
auto ret = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<OwnedMemoryBuffer>(std::move(*fileBufRes)));
std::make_unique<OwnedMemoryBuffer>(std::move(*fileBufRes)));
if (!ret.first) {
return runtime->raiseTypeError("Error deserializing bytecode");
}
@ -169,7 +169,7 @@ serializeVM(void *ctx, vm::Runtime *runtime, vm::NativeArgs args) {
const auto *fileName = reinterpret_cast<std::string *>(ctx);
std::error_code EC;
serializeStream =
llvh::make_unique<llvh::raw_fd_ostream>(llvh::StringRef(*fileName), EC);
std::make_unique<llvh::raw_fd_ostream>(llvh::StringRef(*fileName), EC);
if (EC) {
return runtime->raiseTypeError(
TwineChar16("Could not write to file located at ") +
@ -194,7 +194,7 @@ serializeVM(void *ctx, vm::Runtime *runtime, vm::NativeArgs args) {
}
std::error_code EC;
serializeStream =
llvh::make_unique<llvh::raw_fd_ostream>(llvh::StringRef(fileName), EC);
std::make_unique<llvh::raw_fd_ostream>(llvh::StringRef(fileName), EC);
if (EC) {
return runtime->raiseTypeError(
TwineChar16("Could not write to file located at ") +
@ -421,7 +421,7 @@ bool executeHBCBytecodeImpl(
}
if (shouldRecordGCStats) {
statSampler = llvh::make_unique<vm::StatSamplingThread>(
statSampler = std::make_unique<vm::StatSamplingThread>(
std::chrono::milliseconds(100));
}

Просмотреть файл

@ -28,7 +28,7 @@ using namespace hermes;
Dependencies *hermes::hermesExtractDependencies(
const char *source,
size_t sourceSize) {
std::unique_ptr<Dependencies> result = hermes::make_unique<Dependencies>();
std::unique_ptr<Dependencies> result = std::make_unique<Dependencies>();
auto context = std::make_shared<Context>();
#if HERMES_PARSE_JSX

Просмотреть файл

@ -105,7 +105,7 @@ std::unique_ptr<SourceMap> SourceMapParser::parse(
sm.error(genericLoc, "Failed to parse source map mappings");
return nullptr;
}
return llvh::make_unique<SourceMap>(
return std::make_unique<SourceMap>(
sourceRoot,
std::move(sources),
std::move(lines),

Просмотреть файл

@ -104,8 +104,8 @@ PageAccessTracker::PageAccessTracker(
bufStartPage_(bufStartPage),
totalPages_(totalPages),
signal_(signal) {
accessedPageIds_ = llvh::make_unique<unsigned int[]>(totalPages);
accessedMicros_ = llvh::make_unique<unsigned int[]>(totalPages);
accessedPageIds_ = std::make_unique<unsigned int[]>(totalPages);
accessedMicros_ = std::make_unique<unsigned int[]>(totalPages);
}
void PageAccessTracker::recordPageAccess(void *accessedAddr, uint32_t micros) {

Просмотреть файл

@ -98,7 +98,7 @@ LLVMDisassembler::Impl::Impl(
streamer_.reset(target->createAsmStreamer(
*ctx_,
llvh::make_unique<llvh::formatted_raw_ostream>(OS_),
std::make_unique<llvh::formatted_raw_ostream>(OS_),
/*asmverbose*/ true,
/*useDwarfDirectory*/ true,
IP.release(),

Просмотреть файл

@ -104,7 +104,7 @@ NativeDisassembler::~NativeDisassembler() {}
std::unique_ptr<NativeDisassembler> NativeDisassembler::create(
const char *triple,
unsigned int asmOutputVariant) {
return llvh::make_unique<NativeDisassemblerImpl>(triple, asmOutputVariant);
return std::make_unique<NativeDisassemblerImpl>(triple, asmOutputVariant);
}
} // namespace vm

Просмотреть файл

@ -444,7 +444,7 @@ CallResult<HermesValue> intlServiceConstructor(
return ExecutionStatus::EXCEPTION;
}
auto native = make_unique<T>();
auto native = std::make_unique<T>();
if (LLVM_UNLIKELY(
native->initialize(runtime, *localesRes, *optionsRes) ==
ExecutionStatus::EXCEPTION)) {

Просмотреть файл

@ -117,7 +117,7 @@ void InlineCacheProfiler::dumpHiddenClassProperties(
std::unique_ptr<InlineCacheProfiler::ICMissList>
InlineCacheProfiler::getRankedInlineCachingMisses() {
std::unique_ptr<InlineCacheProfiler::ICMissList> icInfoList =
hermes::make_unique<InlineCacheProfiler::ICMissList>();
std::make_unique<InlineCacheProfiler::ICMissList>();
// rank inline caching miss information
for (auto itr = cacheMisses_.begin(); itr != cacheMisses_.end(); ++itr) {
icInfoList->push_back(*itr);

Просмотреть файл

@ -174,7 +174,7 @@ Runtime::Runtime(
crashMgr_(runtimeConfig.getCrashMgr()),
crashCallbackKey_(
crashMgr_->registerCallback([this](int fd) { crashCallback(fd); })),
codeCoverageProfiler_(hermes::make_unique<CodeCoverageProfiler>(this)),
codeCoverageProfiler_(std::make_unique<CodeCoverageProfiler>(this)),
gcEventCallback_(runtimeConfig.getGCConfig().getCallback()),
allowFunctionToStringWithRuntimeSource_(
runtimeConfig.getAllowFunctionToStringWithRuntimeSource()) {
@ -238,7 +238,7 @@ Runtime::Runtime(
LLVM_DEBUG(llvh::dbgs() << "Runtime initialized\n");
if (runtimeConfig.getEnableSampleProfiling())
samplingProfiler_ = make_unique<SamplingProfiler>(this);
samplingProfiler_ = std::make_unique<SamplingProfiler>(this);
return;
}
@ -346,7 +346,7 @@ Runtime::Runtime(
initJSBuiltins(builtins_, jsBuiltinsObj);
if (runtimeConfig.getEnableSampleProfiling())
samplingProfiler_ = make_unique<SamplingProfiler>(this);
samplingProfiler_ = std::make_unique<SamplingProfiler>(this);
LLVM_DEBUG(llvh::dbgs() << "Runtime initialized\n");
}
@ -1032,7 +1032,7 @@ Handle<JSObject> Runtime::runInternalBytecode() {
auto module = getInternalBytecode();
std::pair<std::unique_ptr<hbc::BCProvider>, std::string> bcResult =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<Buffer>(module.data(), module.size()));
std::make_unique<Buffer>(module.data(), module.size()));
if (LLVM_UNLIKELY(!bcResult.first)) {
hermes_fatal((llvh::Twine("Error running internal bytecode: ") +
bcResult.second.c_str())
@ -2299,7 +2299,7 @@ void Runtime::enableAllocationLocationTracker(
std::vector<GCBase::AllocationLocationTracker::HeapStatsUpdate>)>
fragmentCallback) {
if (!stackTracesTree_) {
stackTracesTree_ = make_unique<StackTracesTree>();
stackTracesTree_ = std::make_unique<StackTracesTree>();
}
stackTracesTree_->syncWithRuntimeStack(this);
getHeap().enableHeapProfiler(std::move(fragmentCallback));

Просмотреть файл

@ -235,7 +235,7 @@ void StackTracesTree::pushCallStack(
auto nameID =
nameStr.empty() ? anonymousFunctionID_ : strings_->insert(nameStr);
auto newNode = hermes::make_unique<StackTracesTreeNode>(
auto newNode = std::make_unique<StackTracesTreeNode>(
nextNodeID_++, head_, sourceLoc, codeBlock, ip, nameID);
auto newNodePtr = newNode.get();
nodes_.emplace_back(std::move(newNode));

Просмотреть файл

@ -1221,7 +1221,7 @@ HadesGC::HadesGC(
provider_(std::move(provider)),
oldGen_{this},
backgroundExecutor_{
kConcurrentGC ? llvh::make_unique<Executor>() : nullptr},
kConcurrentGC ? std::make_unique<Executor>() : nullptr},
promoteYGToOG_{!gcConfig.getAllocInYoung()},
revertToYGAtTTI_{gcConfig.getRevertToYGAtTTI()},
occupancyTarget_(gcConfig.getOccupancyTarget()),
@ -1455,7 +1455,7 @@ void HadesGC::oldGenCollection(std::string cause) {
// call the destructor here so that the analytics callback is invoked from the
// mutator thread. This might also be done from checkTripwireAndResetStats.
ogCollectionStats_ =
llvh::make_unique<CollectionStats>(this, std::move(cause), "old");
std::make_unique<CollectionStats>(this, std::move(cause), "old");
// NOTE: Leave CPU time as zero if the collection isn't concurrent, as the
// times aren't useful.
if (kConcurrentGC)
@ -2256,7 +2256,7 @@ void HadesGC::youngGenEvacuateImpl(Acceptor &acceptor, bool doCompaction) {
void HadesGC::youngGenCollection(
std::string cause,
bool forceOldGenCollection) {
ygCollectionStats_ = llvh::make_unique<CollectionStats>(this, cause, "young");
ygCollectionStats_ = std::make_unique<CollectionStats>(this, cause, "young");
ygCollectionStats_->beginCPUTimeSection();
ygCollectionStats_->setBeginTime();
// Acquire the GC lock for the duration of the YG collection.

Просмотреть файл

@ -82,7 +82,7 @@ EMSCRIPTEN_KEEPALIVE
extern "C" Dependencies *hermesExtractDependencies(
const char *source,
size_t sourceSize) {
std::unique_ptr<Dependencies> result = hermes::make_unique<Dependencies>();
std::unique_ptr<Dependencies> result = std::make_unique<Dependencies>();
auto context = std::make_shared<Context>();
#if HERMES_PARSE_JSX

Просмотреть файл

@ -114,7 +114,7 @@ extern "C" CompileResult *hermesCompileToBytecode(
const char *sourceURL,
const char *sourceMapData,
size_t sourceMapSize) {
auto compileRes = hermes::make_unique<CompileResult>();
auto compileRes = std::make_unique<CompileResult>();
std::unique_ptr<SourceMap> sourceMap;
if (source[sourceSize - 1] != 0) {
@ -144,8 +144,7 @@ extern "C" CompileResult *hermesCompileToBytecode(
// Note that we are relying the zero termination provided by str.data(),
// because the parser requires it.
auto res = hbc::BCProviderFromSrc::createBCProviderFromSrc(
hermes::make_unique<hermes::Buffer>(
(const uint8_t *)source, sourceSize - 1),
std::make_unique<hermes::Buffer>((const uint8_t *)source, sourceSize - 1),
sourceURL ? sourceURL : "",
std::move(sourceMap),
flags);

Просмотреть файл

@ -500,7 +500,7 @@ bool attribute(
(uintptr_t)input->getBufferStart());
uintptr_t bundleStart = (uintptr_t)input->getBuffer().data();
auto hermesBuffer = llvh::make_unique<hermes::MemoryBuffer>(input.get());
auto hermesBuffer = std::make_unique<hermes::MemoryBuffer>(input.get());
auto ret = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
std::move(hermesBuffer));
if (!ret.first) {

Просмотреть файл

@ -80,7 +80,7 @@ static ExecutionStatus diffFiles(
fileBufs.size());
for (uint32_t i = 0; i < fileBufs.size(); ++i) {
auto buffer = llvh::make_unique<MemoryBuffer>(fileBufs[i].get());
auto buffer = std::make_unique<MemoryBuffer>(fileBufs[i].get());
const auto *fileHeader =
reinterpret_cast<const hbc::BytecodeFileHeader *>(buffer->data());

Просмотреть файл

@ -472,7 +472,7 @@ int main(int argc, char **argv) {
}
auto buffer =
llvh::make_unique<hermes::MemoryBuffer>(fileBufOrErr.get().get());
std::make_unique<hermes::MemoryBuffer>(fileBufOrErr.get().get());
const uint8_t *bytecodeStart = buffer->data();
auto ret =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(std::move(buffer));

Просмотреть файл

@ -36,7 +36,7 @@ extern "C" ParseResult *hermesParse(
bool detectFlow,
bool tokens,
bool allowReturnOutsideFunction) {
std::unique_ptr<ParseResult> result = hermes::make_unique<ParseResult>();
std::unique_ptr<ParseResult> result = std::make_unique<ParseResult>();
if (source[sourceSize - 1] != 0) {
result->error_ = "Input source must be zero-terminated";
return result.release();
@ -60,7 +60,7 @@ extern "C" ParseResult *hermesParse(
context->setAllowReturnOutsideFunction(allowReturnOutsideFunction);
std::unique_ptr<parser::JSParser> jsParser =
hermes::make_unique<parser::JSParser>(
std::make_unique<parser::JSParser>(
*context, fileBufId, parser::FullParse);
jsParser->setStoreComments(true);
jsParser->setStoreTokens(tokens);

Просмотреть файл

@ -81,7 +81,7 @@ int main(int argc, char **argv) {
return -1;
}
auto buffer = llvh::make_unique<MemoryBuffer>(FileBufOrErr.get().get());
auto buffer = std::make_unique<MemoryBuffer>(FileBufOrErr.get().get());
auto ret =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(std::move(buffer));

Просмотреть файл

@ -280,7 +280,7 @@ int main(int argc, char **argv) {
options.gcConfigBuilder.withShouldRecordStats(false);
options.shouldTrackIO = false;
std::error_code ec;
auto os = ::hermes::make_unique<llvh::raw_fd_ostream>(
auto os = std::make_unique<llvh::raw_fd_ostream>(
cl::Trace.c_str(),
ec,
llvh::sys::fs::CD_CreateAlways,

Просмотреть файл

@ -1178,7 +1178,7 @@ TEST_F(SynthTraceSerializationTest, EndExecHasRetval) {
TEST_F(SynthTraceSerializationTest, TraceHeader) {
std::string result;
auto resultStream = ::hermes::make_unique<llvh::raw_string_ostream>(result);
auto resultStream = std::make_unique<llvh::raw_string_ostream>(result);
const ::hermes::vm::RuntimeConfig conf;
std::unique_ptr<TracingHermesRuntime> rt(makeTracingHermesRuntime(
makeHermesRuntime(conf), conf, std::move(resultStream)));
@ -1257,7 +1257,7 @@ TEST_F(SynthTraceSerializationTest, TraceHeader) {
TEST_F(SynthTraceSerializationTest, FullTrace) {
std::string result;
auto resultStream = ::hermes::make_unique<llvh::raw_string_ostream>(result);
auto resultStream = std::make_unique<llvh::raw_string_ostream>(result);
const ::hermes::vm::RuntimeConfig conf;
std::unique_ptr<TracingHermesRuntime> rt(makeTracingHermesRuntime(
makeHermesRuntime(conf),
@ -1326,7 +1326,7 @@ TEST_F(SynthTraceSerializationTest, FullTraceWithDateAndMath) {
const ::hermes::vm::RuntimeConfig conf =
::hermes::vm::RuntimeConfig::Builder().withTraceEnabled(true).build();
std::string result;
auto resultStream = ::hermes::make_unique<llvh::raw_string_ostream>(result);
auto resultStream = std::make_unique<llvh::raw_string_ostream>(result);
std::unique_ptr<TracingHermesRuntime> rt(makeTracingHermesRuntime(
makeHermesRuntime(conf), conf, std::move(resultStream)));
@ -1383,8 +1383,7 @@ TEST_F(SynthTraceSerializationTest, TracePreservesStringAllocs) {
const ::hermes::vm::RuntimeConfig conf =
::hermes::vm::RuntimeConfig::Builder().withTraceEnabled(true).build();
std::string traceResult;
auto resultStream =
::hermes::make_unique<llvh::raw_string_ostream>(traceResult);
auto resultStream = std::make_unique<llvh::raw_string_ostream>(traceResult);
std::unique_ptr<TracingHermesRuntime> rt(makeTracingHermesRuntime(
makeHermesRuntime(conf), conf, std::move(resultStream)));
@ -1423,7 +1422,7 @@ function f(s) {
tracing::TraceInterpreter::ExecuteOptions options;
std::string replayTraceStr;
auto replayTraceStream =
::hermes::make_unique<llvh::raw_string_ostream>(replayTraceStr);
std::make_unique<llvh::raw_string_ostream>(replayTraceStr);
std::unique_ptr<TracingHermesRuntime> rt2(makeTracingHermesRuntime(
makeHermesRuntime(conf),
conf,

Просмотреть файл

@ -109,7 +109,7 @@ TEST(HBCBytecodeGen, IntegrationTest) {
EXPECT_GE(globalFunctionOffsetExpected, 0);
auto bytecode = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<StringBuffer>(OS.str()))
std::make_unique<StringBuffer>(OS.str()))
.first;
int functionCnt = bytecode->getFunctionCount();
@ -183,7 +183,7 @@ TEST(HBCBytecodeGen, StripDebugInfo) {
// Verify debug info absent from decoded BM.
std::unique_ptr<hbc::BCProvider> strippedBC =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<StringBuffer>(strippedOS.str()))
std::make_unique<StringBuffer>(strippedOS.str()))
.first;
ASSERT_EQ(strippedBC->getFunctionCount(), BM->getNumFunctions());
for (uint32_t i = 0, max = BM->getNumFunctions(); i < max; i++) {
@ -236,7 +236,7 @@ TEST(HBCBytecodeGen, StringTableTest) {
BS.serialize(*BM, SHA1{});
auto bytecode = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<StringBuffer>(OS.str()))
std::make_unique<StringBuffer>(OS.str()))
.first;
EXPECT_EQ(bytecode->getStringCount(), 5u);
@ -297,7 +297,7 @@ TEST(HBCBytecodeGen, ExceptionTableTest) {
BS.serialize(*BM, SHA1{});
auto bytecode = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<StringBuffer>(OS.str()))
std::make_unique<StringBuffer>(OS.str()))
.first;
ASSERT_EQ(bytecode->getExceptionTable(0).size(), 3u);
@ -345,7 +345,7 @@ TEST(HBCBytecodeGen, ArrayBufferTest) {
BS.serialize(*BM, SHA1{});
auto bytecode = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<StringBuffer>(OS.str()))
std::make_unique<StringBuffer>(OS.str()))
.first;
ASSERT_EQ(bytecode->getArrayBuffer().size(), 10u);
@ -457,13 +457,12 @@ TEST(HBCBytecodeGen, SerializeBytecodeOptions) {
auto bytecodeVecStaticBuiltins =
bytecodeForSource("print('hello world');", flags);
auto bytecodeDefault =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<VectorBuffer>(bytecodeVecDefault))
.first;
auto bytecodeDefault = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
std::make_unique<VectorBuffer>(bytecodeVecDefault))
.first;
auto bytecodeStaticBuiltins =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<VectorBuffer>(bytecodeVecStaticBuiltins))
std::make_unique<VectorBuffer>(bytecodeVecStaticBuiltins))
.first;
ASSERT_TRUE(bytecodeDefault);
ASSERT_TRUE(bytecodeStaticBuiltins);
@ -475,13 +474,12 @@ TEST(HBCBytecodeGen, BytecodeOptionHasAsync) {
auto bytecodeVecNoAsync = bytecodeForSource("function foo(){}");
auto bytecodeVecHasAsync = bytecodeForSource("async function foo(){}");
auto bytecodeNoAsync =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<VectorBuffer>(bytecodeVecNoAsync))
.first;
auto bytecodeNoAsync = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
std::make_unique<VectorBuffer>(bytecodeVecNoAsync))
.first;
auto bytecodeHasAsync =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<VectorBuffer>(bytecodeVecHasAsync))
std::make_unique<VectorBuffer>(bytecodeVecHasAsync))
.first;
ASSERT_TRUE(bytecodeNoAsync);
ASSERT_TRUE(bytecodeHasAsync);

Просмотреть файл

@ -39,7 +39,7 @@ TEST_F(BytecodeProviderTest, IdentifierHashesPreserved) {
const std::vector<uint8_t> bytecode = bytecodeForSource(source.str().c_str());
std::shared_ptr<BCProviderFromBuffer> bcProvider =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<Buffer>(&bytecode[0], bytecode.size()))
std::make_unique<Buffer>(&bytecode[0], bytecode.size()))
.first;
ASSERT_NE(nullptr, bcProvider);

Просмотреть файл

@ -34,7 +34,7 @@ TEST_F(DecoratedObjectTest, DecoratedObjectFinalizerRunsOnce) {
(void)runtime->makeHandle(DecoratedObject::create(
runtime,
Handle<JSObject>::vmcast(&runtime->objectPrototype),
llvh::make_unique<TestDecoration>(counter)));
std::make_unique<TestDecoration>(counter)));
runtime->collect("test");
// should not have been finalized yet
EXPECT_EQ(0, *counter);
@ -55,9 +55,9 @@ TEST_F(DecoratedObjectTest, ChangeDecoration) {
auto handle = runtime->makeHandle(DecoratedObject::create(
runtime,
Handle<JSObject>::vmcast(&runtime->objectPrototype),
llvh::make_unique<TestDecoration>(counter)));
std::make_unique<TestDecoration>(counter)));
EXPECT_EQ(0, *counter);
handle->setDecoration(llvh::make_unique<TestDecoration>(counter));
handle->setDecoration(std::make_unique<TestDecoration>(counter));
// Old decoration was deallocated.
EXPECT_EQ(1, *counter);
}
@ -83,7 +83,7 @@ TEST_F(DecoratedObjectTest, AdditionalSlots) {
auto handle = runtime->makeHandle(DecoratedObject::create(
runtime,
Handle<JSObject>::vmcast(&runtime->objectPrototype),
llvh::make_unique<TestDecoration>(counter),
std::make_unique<TestDecoration>(counter),
2));
DecoratedObject::setAdditionalSlotValue(
*handle, runtime, 0, HermesValue::encodeDoubleValue(10));

Просмотреть файл

@ -70,7 +70,7 @@ TEST_F(GCLazySegmentNCTest, MaterializeAll) {
/// Could not allocate every segment to cover the whole heap, but can allocate
/// enough segments for the used portion of the heap.
TEST_F(GCLazySegmentNCTest, MaterializeEnough) {
auto provider = llvh::make_unique<LimitedStorageProvider>(
auto provider = std::make_unique<LimitedStorageProvider>(
DummyRuntime::defaultProvider(), kHeapVALimited);
auto runtime =
DummyRuntime::create(getMetadataTable(), kGCConfig, std::move(provider));
@ -89,7 +89,7 @@ TEST_F(GCLazySegmentNCTest, MaterializeEnough) {
/// collection, but we could not materialize a segment, so we must do a full
/// collection instead.
TEST_F(GCLazySegmentNCTest, YoungGenNoMaterialize) {
auto provider = llvh::make_unique<LimitedStorageProvider>(
auto provider = std::make_unique<LimitedStorageProvider>(
DummyRuntime::defaultProvider(), kHeapVALimited);
auto runtime =
DummyRuntime::create(getMetadataTable(), kGCConfig, std::move(provider));
@ -162,7 +162,7 @@ TEST_F(GCLazySegmentNCTest, OldGenAllocMaterialize) {
/// We failed to materialize a segment that we needed to allocate in.
TEST_F(GCLazySegmentNCDeathTest, FailToMaterialize) {
auto provider = llvh::make_unique<LimitedStorageProvider>(
auto provider = std::make_unique<LimitedStorageProvider>(
DummyRuntime::defaultProvider(), kHeapVALimited);
auto runtime =
DummyRuntime::create(getMetadataTable(), kGCConfig, std::move(provider));
@ -180,7 +180,7 @@ TEST_F(GCLazySegmentNCDeathTest, FailToMaterialize) {
}
TEST_F(GCLazySegmentNCDeathTest, FailToMaterializeContinue) {
auto provider = llvh::make_unique<LimitedStorageProvider>(
auto provider = std::make_unique<LimitedStorageProvider>(
DummyRuntime::defaultProvider(), kHeapVALimited);
auto runtime =
DummyRuntime::create(getMetadataTable(), kGCConfig, std::move(provider));

Просмотреть файл

@ -204,7 +204,7 @@ TEST(GCOOMTest, VALimitFullGC) {
const GCConfig config = TestGCConfigFixedSize(kHeapSizeHint);
// Only space for two segments.
auto provider = llvh::make_unique<LimitedStorageProvider>(
auto provider = std::make_unique<LimitedStorageProvider>(
DummyRuntime::defaultProvider(), AlignedStorage::size() * 2);
auto runtime =

Просмотреть файл

@ -120,7 +120,7 @@ TEST_F(GCSegmentRangeTest, FuseEarlyTermination) {
{ // Now make sure a fused version of Generator will not restart after a
// failure.
auto r = GCSegmentRange::fuse(llvh::make_unique<Generator>());
auto r = GCSegmentRange::fuse(std::make_unique<Generator>());
for (size_t i = 0; i < FAIL; ++i) {
EXPECT_NE(nullptr, r->next());
}

Просмотреть файл

@ -1116,7 +1116,7 @@ struct ChromeStackTreeNode {
llvh::cast<JSONNumber>(traceNodes[i + 1])->getValue();
auto children = llvh::cast<JSONArray>(traceNodes[i + 4]);
auto treeNode =
hermes::make_unique<ChromeStackTreeNode>(parent, functionInfoIndex);
std::make_unique<ChromeStackTreeNode>(parent, functionInfoIndex);
idNodeMap.emplace(id, treeNode.get());
treeNode->children_ = parse(*children, treeNode.get(), idNodeMap);
res.emplace_back(std::move(treeNode));

Просмотреть файл

@ -96,7 +96,7 @@ struct StackTracesTreeTest : public RuntimeTestFixtureBase {
bytecodeForSource(code.c_str(), TestCompileFlags{}, &sourceMapGen);
std::shared_ptr<hbc::BCProviderFromBuffer> bcProvider =
hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
llvh::make_unique<Buffer>(&bytecode[0], bytecode.size()))
std::make_unique<Buffer>(&bytecode[0], bytecode.size()))
.first;
auto runRes = runtime->runBytecode(
std::move(bcProvider),

Просмотреть файл

@ -30,7 +30,7 @@ struct NullStorageProvider : public StorageProvider {
/* static */
std::unique_ptr<NullStorageProvider> NullStorageProvider::create() {
return llvh::make_unique<NullStorageProvider>();
return std::make_unique<NullStorageProvider>();
}
llvh::ErrorOr<void *> NullStorageProvider::newStorageImpl(const char *) {

Просмотреть файл

@ -32,7 +32,7 @@ std::unique_ptr<GC> DummyRuntime::makeHeap(
std::shared_ptr<CrashManager> crashMgr,
std::shared_ptr<StorageProvider> provider,
experiments::VMExperimentFlags experiments) {
return llvh::make_unique<
return std::make_unique<
#ifdef HERMESVM_GC_RUNTIME
// For RuntimeGC tests, just always use GenGC.
GenGC