Skip to content

Commit db9124f

Browse files
authored
Apply format changes from #2048 (#2059)
Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
1 parent 87636dc commit db9124f

198 files changed

Lines changed: 22447 additions & 13655 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/abi/js.h

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
#ifndef wasm_abi_abi_h
1818
#define wasm_abi_abi_h
1919

20-
#include "wasm.h"
2120
#include "asmjs/shared-constants.h"
21+
#include "wasm.h"
2222

2323
namespace wasm {
2424

2525
namespace ABI {
2626

27-
enum class LegalizationLevel {
28-
Full = 0,
29-
Minimal = 1
30-
};
27+
enum class LegalizationLevel { Full = 0, Minimal = 1 };
3128

3229
inline std::string getLegalizationPass(LegalizationLevel level) {
3330
if (level == LegalizationLevel::Full) {
@@ -39,51 +36,52 @@ inline std::string getLegalizationPass(LegalizationLevel level) {
3936

4037
namespace wasm2js {
4138

42-
extern cashew::IString SCRATCH_LOAD_I32,
43-
SCRATCH_STORE_I32,
44-
SCRATCH_LOAD_I64,
45-
SCRATCH_STORE_I64,
46-
SCRATCH_LOAD_F32,
47-
SCRATCH_STORE_F32,
48-
SCRATCH_LOAD_F64,
49-
SCRATCH_STORE_F64;
39+
extern cashew::IString SCRATCH_LOAD_I32;
40+
extern cashew::IString SCRATCH_STORE_I32;
41+
extern cashew::IString SCRATCH_LOAD_I64;
42+
extern cashew::IString SCRATCH_STORE_I64;
43+
extern cashew::IString SCRATCH_LOAD_F32;
44+
extern cashew::IString SCRATCH_STORE_F32;
45+
extern cashew::IString SCRATCH_LOAD_F64;
46+
extern cashew::IString SCRATCH_STORE_F64;
5047

5148
// The wasm2js scratch memory helpers let us read and write to scratch memory
5249
// for purposes of implementing things like reinterpret, etc.
5350
// The optional "specific" parameter is a specific function we want. If not
5451
// provided, we create them all.
55-
inline void ensureScratchMemoryHelpers(Module* wasm, cashew::IString specific = cashew::IString()) {
56-
auto ensureImport = [&](Name name, const std::vector<Type> params, Type result) {
57-
if (wasm->getFunctionOrNull(name)) return;
58-
if (specific.is() && name != specific) return;
59-
auto func = make_unique<Function>();
60-
func->name = name;
61-
func->params = params;
62-
func->result = result;
63-
func->module = ENV;
64-
func->base = name;
65-
wasm->addFunction(std::move(func));
66-
};
52+
inline void
53+
ensureScratchMemoryHelpers(Module* wasm,
54+
cashew::IString specific = cashew::IString()) {
55+
auto ensureImport =
56+
[&](Name name, const std::vector<Type> params, Type result) {
57+
if (wasm->getFunctionOrNull(name))
58+
return;
59+
if (specific.is() && name != specific)
60+
return;
61+
auto func = make_unique<Function>();
62+
func->name = name;
63+
func->params = params;
64+
func->result = result;
65+
func->module = ENV;
66+
func->base = name;
67+
wasm->addFunction(std::move(func));
68+
};
6769

68-
ensureImport(SCRATCH_LOAD_I32, { i32 }, i32);
69-
ensureImport(SCRATCH_STORE_I32, { i32, i32 }, none);
70+
ensureImport(SCRATCH_LOAD_I32, {i32}, i32);
71+
ensureImport(SCRATCH_STORE_I32, {i32, i32}, none);
7072
ensureImport(SCRATCH_LOAD_I64, {}, i64);
71-
ensureImport(SCRATCH_STORE_I64, { i64 }, none);
73+
ensureImport(SCRATCH_STORE_I64, {i64}, none);
7274
ensureImport(SCRATCH_LOAD_F32, {}, f32);
73-
ensureImport(SCRATCH_STORE_F32, { f32 }, none);
75+
ensureImport(SCRATCH_STORE_F32, {f32}, none);
7476
ensureImport(SCRATCH_LOAD_F64, {}, f64);
75-
ensureImport(SCRATCH_STORE_F64, { f64 }, none);
77+
ensureImport(SCRATCH_STORE_F64, {f64}, none);
7678
}
7779

7880
inline bool isScratchMemoryHelper(cashew::IString name) {
79-
return name == SCRATCH_LOAD_I32 ||
80-
name == SCRATCH_STORE_I32 ||
81-
name == SCRATCH_LOAD_I64 ||
82-
name == SCRATCH_STORE_I64 ||
83-
name == SCRATCH_LOAD_F32 ||
84-
name == SCRATCH_STORE_F32 ||
85-
name == SCRATCH_LOAD_F64 ||
86-
name == SCRATCH_STORE_F64;
81+
return name == SCRATCH_LOAD_I32 || name == SCRATCH_STORE_I32 ||
82+
name == SCRATCH_LOAD_I64 || name == SCRATCH_STORE_I64 ||
83+
name == SCRATCH_LOAD_F32 || name == SCRATCH_STORE_F32 ||
84+
name == SCRATCH_LOAD_F64 || name == SCRATCH_STORE_F64;
8785
}
8886

8987
} // namespace wasm2js

src/abi/stack.h

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@
1717
#ifndef wasm_abi_stack_h
1818
#define wasm_abi_stack_h
1919

20-
#include "wasm.h"
21-
#include "wasm-builder.h"
22-
#include "shared-constants.h"
20+
#include "abi.h"
2321
#include "asmjs/shared-constants.h"
2422
#include "ir/find_all.h"
2523
#include "ir/global-utils.h"
26-
#include "abi.h"
24+
#include "shared-constants.h"
25+
#include "wasm-builder.h"
26+
#include "wasm.h"
2727

2828
namespace wasm {
2929

3030
namespace ABI {
3131

32-
enum {
33-
StackAlign = 16
34-
};
32+
enum { StackAlign = 16 };
3533

3634
inline Index stackAlign(Index size) {
3735
return (size + StackAlign - 1) & -StackAlign;
3836
}
3937

4038
// Allocate some space on the stack, and assign it to a local.
41-
// The local will have the same constant value in all the function, so you can just
42-
// local.get it anywhere there.
43-
inline void getStackSpace(Index local, Function* func, Index size, Module& wasm) {
44-
auto* stackPointer = GlobalUtils::getGlobalInitializedToImport(wasm, ENV, "STACKTOP");
39+
// The local will have the same constant value in all the function, so you can
40+
// just local.get it anywhere there.
41+
inline void
42+
getStackSpace(Index local, Function* func, Index size, Module& wasm) {
43+
auto* stackPointer =
44+
GlobalUtils::getGlobalInitializedToImport(wasm, ENV, "STACKTOP");
4545
if (!stackPointer) {
4646
Fatal() << "getStackSpace: failed to find the stack pointer";
4747
}
@@ -50,34 +50,21 @@ inline void getStackSpace(Index local, Function* func, Index size, Module& wasm)
5050
// TODO: find existing stack usage, and add on top of that - carefully
5151
Builder builder(wasm);
5252
auto* block = builder.makeBlock();
53-
block->list.push_back(
54-
builder.makeSetLocal(
55-
local,
56-
builder.makeGetGlobal(stackPointer->name, PointerType)
57-
)
58-
);
53+
block->list.push_back(builder.makeSetLocal(
54+
local, builder.makeGetGlobal(stackPointer->name, PointerType)));
5955
// TODO: add stack max check
6056
Expression* added;
6157
if (PointerType == i32) {
62-
added = builder.makeBinary(
63-
AddInt32,
64-
builder.makeGetLocal(local, PointerType),
65-
builder.makeConst(Literal(int32_t(size)))
66-
);
58+
added = builder.makeBinary(AddInt32,
59+
builder.makeGetLocal(local, PointerType),
60+
builder.makeConst(Literal(int32_t(size))));
6761
} else {
6862
WASM_UNREACHABLE();
6963
}
70-
block->list.push_back(
71-
builder.makeSetGlobal(
72-
stackPointer->name,
73-
added
74-
)
75-
);
64+
block->list.push_back(builder.makeSetGlobal(stackPointer->name, added));
7665
auto makeStackRestore = [&]() {
77-
return builder.makeSetGlobal(
78-
stackPointer->name,
79-
builder.makeGetLocal(local, PointerType)
80-
);
66+
return builder.makeSetGlobal(stackPointer->name,
67+
builder.makeGetLocal(local, PointerType));
8168
};
8269
// add stack restores to the returns
8370
FindAllPointers<Return> finder(func->body);
@@ -89,9 +76,8 @@ inline void getStackSpace(Index local, Function* func, Index size, Module& wasm)
8976
auto temp = builder.addVar(func, ret->value->type);
9077
block->list.push_back(builder.makeSetLocal(temp, ret->value));
9178
block->list.push_back(makeStackRestore());
92-
block->list.push_back(builder.makeReturn(
93-
builder.makeGetLocal(temp, ret->value->type)
94-
));
79+
block->list.push_back(
80+
builder.makeReturn(builder.makeGetLocal(temp, ret->value->type)));
9581
block->finalize();
9682
*ptr = block;
9783
} else {

src/abi/wasm-object.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
namespace wasm {
2626

2727
namespace ABI {
28-
enum LinkType : unsigned {
29-
WASM_STACK_POINTER = 0x1,
30-
WASM_SYMBOL_INFO = 0x2,
31-
WASM_DATA_SIZE = 0x3,
32-
WASM_DATA_ALIGNMENT = 0x4,
33-
WASM_SEGMENT_INFO = 0x5,
34-
WASM_INIT_FUNCS = 0x6,
35-
};
28+
enum LinkType : unsigned {
29+
WASM_STACK_POINTER = 0x1,
30+
WASM_SYMBOL_INFO = 0x2,
31+
WASM_DATA_SIZE = 0x3,
32+
WASM_DATA_ALIGNMENT = 0x4,
33+
WASM_SEGMENT_INFO = 0x5,
34+
WASM_INIT_FUNCS = 0x6,
35+
};
3636
} // namespace ABI
3737

3838
} // namespace wasm

0 commit comments

Comments
 (0)