Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b9ca885
work
kripken Apr 4, 2024
b06f76e
work
kripken Apr 5, 2024
a75e5c1
work
kripken Apr 5, 2024
b86fcf3
builds
kripken Apr 5, 2024
3e728e6
todo
kripken Apr 5, 2024
5dfda8d
formt
kripken Apr 5, 2024
336dfcb
work
kripken Apr 5, 2024
fba8353
fix.comment
kripken Apr 5, 2024
dfe819d
typo
kripken Apr 5, 2024
517d02d
fix compiler warnings
kripken Apr 5, 2024
4608b29
exciting
kripken Apr 5, 2024
347ebe0
yolo
kripken Apr 5, 2024
90cabde
yolo
kripken Apr 5, 2024
eef7df5
prep
kripken Apr 5, 2024
86c98ad
work
kripken Apr 5, 2024
a51a7cb
test
kripken Apr 5, 2024
3b44e01
twork
kripken Apr 5, 2024
e21ce34
fix
kripken Apr 5, 2024
2962579
work
kripken Apr 5, 2024
1e01201
work
kripken Apr 5, 2024
6a39f6a
work
kripken Apr 5, 2024
faad72d
work
kripken Apr 5, 2024
d5383ad
work
kripken Apr 5, 2024
bfab495
work
kripken Apr 5, 2024
fd102dd
fix
kripken Apr 5, 2024
0dd4970
work
kripken Apr 5, 2024
4bd7a37
work
kripken Apr 5, 2024
bdb88d6
work
kripken Apr 5, 2024
3a195cf
work
kripken Apr 5, 2024
1b1cc3b
work
kripken Apr 5, 2024
996ab05
work
kripken Apr 5, 2024
7ebb094
test
kripken Apr 5, 2024
00616b8
fix
kripken Apr 5, 2024
e6480d6
format
kripken Apr 5, 2024
bffbdd8
fix
kripken Apr 5, 2024
1c9e1c5
commento
kripken Apr 5, 2024
d11f563
Merge remote-tracking branch 'origin/main' into heap2local.nfc.2
kripken Apr 6, 2024
db6780f
test
kripken Apr 6, 2024
e833122
test
kripken Apr 6, 2024
8a0431a
work
kripken Apr 8, 2024
c793aa8
test
kripken Apr 8, 2024
bfceeb8
work
kripken Apr 8, 2024
9b2be22
test?
kripken Apr 8, 2024
58253c7
fix
kripken Apr 8, 2024
08fe484
undo
kripken Apr 8, 2024
41c0765
nicer
kripken Apr 8, 2024
37de9a5
comment
kripken Apr 8, 2024
c6387b5
test.bad
kripken Apr 8, 2024
82038d3
test.bad
kripken Apr 8, 2024
de4c680
work
kripken Apr 8, 2024
22a18fb
work
kripken Apr 8, 2024
e6b8fcf
work
kripken Apr 8, 2024
606da66
work
kripken Apr 8, 2024
a06ac62
format
kripken Apr 8, 2024
7a57798
Merge remote-tracking branch 'origin/main' into heap2local.nfc.2
kripken Apr 9, 2024
f1e9013
fix
kripken Apr 9, 2024
5c17188
clarify
kripken Apr 9, 2024
becbf61
feedback
kripken Apr 9, 2024
4e279b0
feedback: remove unused code
kripken Apr 9, 2024
568856c
feedback: fix
kripken Apr 9, 2024
83b3b0b
feedback: test
kripken Apr 9, 2024
1e02354
feedback: test
kripken Apr 9, 2024
627da24
Merge branch 'heap2local.nfc.2' into heap2local.3
kripken Apr 9, 2024
560ad8b
Merge remote-tracking branch 'origin/main' into heap2local.3
kripken Apr 9, 2024
4433489
Another test was optimized, it appears
kripken Apr 9, 2024
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
Prev Previous commit
Next Next commit
work
  • Loading branch information
kripken committed Apr 8, 2024
commit 606da6624eb43d87a6c672ffb848bf8fae05527d
28 changes: 18 additions & 10 deletions src/passes/Heap2Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,20 @@ struct Struct2Local : PostWalker<Struct2Local> {
curr->finalize();
}

// Add a mask for packed fields. We add masks on sets rather than on gets
// because gets tend to be more numerous both in code appearances and in
// runtime execution. As a result of masking on sets, the value in the local
// is always the masked value (which is also nice for debugging,
// incidentally).
Expression* addMask(Expression* value, const Field& field) {
if (!field.isPacked()) {
return value;
}

auto mask = Bits::lowBitMask(field.getByteSize() * 8);
return builder.makeBinary(AndInt32, value, builder.makeConst(int32_t(mask)));
}

void visitStructNew(StructNew* curr) {
if (curr != allocation) {
return;
Expand Down Expand Up @@ -695,6 +709,7 @@ struct Struct2Local : PostWalker<Struct2Local> {
// Copy them to the normal ones.
for (Index i = 0; i < tempIndexes.size(); i++) {
auto* value = builder.makeLocalGet(tempIndexes[i], fields[i].type);
// Add a mask on the values we write.
contents.push_back(builder.makeLocalSet(
localIndexes[i],
addMask(value, fields[i])));
Expand All @@ -706,8 +721,11 @@ struct Struct2Local : PostWalker<Struct2Local> {
// defaults.
} else {
// Set the default values.
//
// Note that we must assign the defaults because we might be in a loop,
// that is, there might be a previous value.
//
// Note there is no need to mask as these are zeros anyhow.
for (Index i = 0; i < localIndexes.size(); i++) {
contents.push_back(builder.makeLocalSet(
localIndexes[i],
Expand Down Expand Up @@ -797,16 +815,6 @@ struct Struct2Local : PostWalker<Struct2Local> {
builder.makeDrop(curr->ref),
builder.makeLocalGet(localIndexes[curr->index], type)));
}

// Add a mask for packed fields.
Expression* addMask(Expression* value, const Field& field) {
if (!field.isPacked()) {
return value;
}

auto mask = Bits::lowBitMask(field.getByteSize() * 8);
return builder.makeBinary(AndInt32, value, builder.makeConst(int32_t(mask)));
}
};

// An optimizer that handles the rewriting to turn a nonescaping array
Expand Down