Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asm2wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
for (unsigned i = 1; i < body->size(); i++) {
if (body[i][0] == DEFUN) numFunctions++;
}
optimizingBuilder = std::unique_ptr<OptimizingIncrementalModuleBuilder>(new OptimizingIncrementalModuleBuilder(&wasm, numFunctions));
optimizingBuilder = make_unique<OptimizingIncrementalModuleBuilder>(&wasm, numFunctions);
}

// first pass - do almost everything, but function imports and indirect calls
Expand Down
2 changes: 1 addition & 1 deletion src/cfg/Relooper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Branch::Branch(wasm::Expression* ConditionInit, wasm::Expression* CodeInit) : An

Branch::Branch(std::vector<wasm::Index>&& ValuesInit, wasm::Expression* CodeInit) : Ancestor(nullptr), Code(CodeInit) {
if (ValuesInit.size() > 0) {
SwitchValues = std::unique_ptr<std::vector<wasm::Index>>(new std::vector<wasm::Index>(ValuesInit));
SwitchValues = wasm::make_unique<std::vector<wasm::Index>>(ValuesInit);
}
// otherwise, it is the default
}
Expand Down
2 changes: 1 addition & 1 deletion src/passes/LowerIfElse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct LowerIfElse : public WalkerPass<PostWalker<LowerIfElse, Visitor<LowerIfEl

void prepare(PassRunner* runner, Module *module) override {
allocator = runner->allocator;
namer = std::unique_ptr<NameManager>(new NameManager());
namer = make_unique<NameManager>();
namer->run(runner, module);
}

Expand Down
2 changes: 1 addition & 1 deletion src/passes/LowerInt64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct LowerInt64 : public Pass {

void prepare(PassRunner* runner, Module *module) override {
allocator = runner->allocator;
namer = std::unique_ptr<NameManager>(new NameManager());
namer = make_unique<NameManager>();
namer->run(runner, module);
}

Expand Down
7 changes: 4 additions & 3 deletions src/support/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "threads.h"
#include "compiler-support.h"
#include "utilities.h"


// debugging tools
Expand All @@ -47,7 +48,7 @@ static std::unique_ptr<ThreadPool> pool;

Thread::Thread() {
assert(!ThreadPool::get()->isRunning());
thread = std::unique_ptr<std::thread>(new std::thread(mainLoop, this));
thread = make_unique<std::thread>(mainLoop, this);
}

Thread::~Thread() {
Expand Down Expand Up @@ -110,7 +111,7 @@ void ThreadPool::initialize(size_t num) {
ready.store(threads.size()); // initial state before first resetThreadsAreReady()
resetThreadsAreReady();
for (size_t i = 0; i < num; i++) {
threads.emplace_back(std::unique_ptr<Thread>(new Thread()));
threads.emplace_back(make_unique<Thread>());
}
DEBUG_POOL("initialize() waiting\n");
condition.wait(lock, [this]() { return areThreadsReady(); });
Expand All @@ -127,7 +128,7 @@ size_t ThreadPool::getNumCores() {

ThreadPool* ThreadPool::get() {
if (!pool) {
pool = std::unique_ptr<ThreadPool>(new ThreadPool());
pool = make_unique<ThreadPool>();
pool->initialize(getNumCores());
}
return pool.get();
Expand Down
15 changes: 11 additions & 4 deletions src/wasm-module-building.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ class OptimizingIncrementalModuleBuilder {
public:
// numFunctions must be equal to the number of functions allocated, or higher. Knowing
// this bounds helps avoid locking.
OptimizingIncrementalModuleBuilder(Module* wasm, Index numFunctions) : wasm(wasm), numFunctions(numFunctions), nextFunction(0), finishing(false) {
OptimizingIncrementalModuleBuilder(Module* wasm, Index numFunctions)
: wasm(wasm), numFunctions(numFunctions), endMarker(nullptr), list(nullptr), nextFunction(0),
numWorkers(0), liveWorkers(0), activeWorkers(0), availableFuncs(0), finishedFuncs(0),
finishing(false) {
if (numFunctions == 0) {
// special case: no functions to be optimized. Don't create any threads.
return;
}

// prepare work list
endMarker = new Function();
list = new std::atomic<Function*>[numFunctions];
Expand Down Expand Up @@ -139,7 +147,7 @@ class OptimizingIncrementalModuleBuilder {
private:
void createWorker() {
DEBUG_THREAD("create a worker");
threads.emplace_back(std::unique_ptr<std::thread>(new std::thread(workerMain, this)));
threads.emplace_back(make_unique<std::thread>(workerMain, this));
}

void wakeWorker() {
Expand Down Expand Up @@ -197,9 +205,8 @@ class OptimizingIncrementalModuleBuilder {
passRunner.runFunction(func);
}

static void workerMain(void* param) {
static void workerMain(OptimizingIncrementalModuleBuilder* self) {
DEBUG_THREAD("workerMain");
OptimizingIncrementalModuleBuilder* self = (OptimizingIncrementalModuleBuilder*)param;
{
std::lock_guard<std::mutex> lock(self->mutex);
self->liveWorkers++;
Expand Down
4 changes: 4 additions & 0 deletions test/empty.asm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function EmptyModule() {
'use asm';
return {};
}
4 changes: 4 additions & 0 deletions test/empty.fromasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(module
(memory 256 256)
(export "memory" memory)
)
4 changes: 4 additions & 0 deletions test/empty.fromasm.imprecise
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(module
(memory 256 256)
(export "memory" memory)
)
4 changes: 4 additions & 0 deletions test/empty.fromasm.imprecise.no-opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(module
(memory 256 256)
(export "memory" memory)
)
4 changes: 4 additions & 0 deletions test/empty.fromasm.no-opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(module
(memory 256 256)
(export "memory" memory)
)