Skip to content

Commit

Permalink
Bug 1814295 - Add tests for aggregate initializers (support added in …
Browse files Browse the repository at this point in the history
…sixgill) r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D171647
  • Loading branch information
hotsphink committed Mar 15, 2023
1 parent 231aa8b commit 30bc408
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
26 changes: 26 additions & 0 deletions js/src/devtools/rootAnalysis/t/hazards/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class AutoSuppressGC {
AutoSuppressGC() {}
};

class AutoCheckCannotGC {
public:
AutoCheckCannotGC() {}
~AutoCheckCannotGC() { asm(""); }
} ANNOTATE("Invalidated by GC");

extern void GC() ANNOTATE("GC Call");
extern void invisible();

Expand Down Expand Up @@ -463,3 +469,23 @@ Cell* refptr_test5() {
RefPtr<int> r;
return nullptr; // returning immobile value, so no hazard
}

std::pair<bool, AutoCheckCannotGC> pair_returning_function() {
return std::make_pair(true, AutoCheckCannotGC());
}

void aggr_init_unsafe() {
// nogc will be live after the call, so across the GC.
auto [ok, nogc] = pair_returning_function();
GC();
}

void aggr_init_safe() {
// The analysis should be able to tell that nogc is only live after the call,
// not before. (This is to check for a problem where the return value was
// getting stored into a different temporary than the local nogc variable,
// and so its initialization was never seen and so it was assumed to be live
// throughout the function.)
GC();
auto [ok, nogc] = pair_returning_function();
}
11 changes: 7 additions & 4 deletions js/src/devtools/rootAnalysis/t/hazards/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
assert "<returnvalue>" in hazmap
assert "this" in hazmap

# All hazards should be in f(), loopy(), safevals(), method(), and refptr_test{1,3,4}()
assert hazmap["cell2"].function == "Cell* f()"
haz_functions = set(haz.function for haz in hazards)
print(haz_functions)
assert len(haz_functions) == 7

# Check that the correct GC call is reported for each hazard. (cell3 has a
# hazard from two different GC calls; it doesn't really matter which is
Expand Down Expand Up @@ -100,3 +96,10 @@
methhaz = byfunc["int32 Subcell::method()"]
assert "this" in methhaz
assert methhaz["this"].type == "Subcell*"

haz_functions = set(haz.function for haz in hazards)

# aggr_init tests.

assert "void aggr_init_safe()" not in haz_functions
assert "void aggr_init_unsafe()" in haz_functions
2 changes: 1 addition & 1 deletion js/src/devtools/rootAnalysis/t/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def binpath(self, prog):
def compile(self, source, options=""):
env = os.environ
env["CCACHE_DISABLE"] = "1"
cmd = "{CXX} -c {source} -O3 -std=c++11 -fplugin={sixgill} -fplugin-arg-xgill-mangle=1 {options}".format( # NOQA: E501
cmd = "{CXX} -c {source} -O3 -std=c++17 -fplugin={sixgill} -fplugin-arg-xgill-mangle=1 {options}".format( # NOQA: E501
source=self.infile(source),
CXX=self.cfg.cxx,
sixgill=self.cfg.sixgill_plugin,
Expand Down

0 comments on commit 30bc408

Please sign in to comment.