зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1321014 - Switch Tag to Annotate, r=nika
--HG-- extra : rebase_source : 644e91673141f7ea7390822ab053a6c5f7fbe28f
This commit is contained in:
Родитель
9a558ab703
Коммит
9e8c72fba3
|
@ -12,25 +12,25 @@
|
|||
#ifdef XGILL_PLUGIN
|
||||
|
||||
// Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
|
||||
# define JS_HAZ_GC_THING __attribute__((tag("GC Thing")))
|
||||
# define JS_HAZ_GC_THING __attribute__((annotate("GC Thing")))
|
||||
|
||||
// Mark a type as holding a pointer to a GC thing (eg JS::Value has this
|
||||
// annotation.)
|
||||
# define JS_HAZ_GC_POINTER __attribute__((tag("GC Pointer")))
|
||||
# define JS_HAZ_GC_POINTER __attribute__((annotate("GC Pointer")))
|
||||
|
||||
// Mark a type as a rooted pointer, suitable for use on the stack (eg all
|
||||
// Rooted<T> instantiations should have this.)
|
||||
# define JS_HAZ_ROOTED __attribute__((tag("Rooted Pointer")))
|
||||
# define JS_HAZ_ROOTED __attribute__((annotate("Rooted Pointer")))
|
||||
|
||||
// Mark a type as something that should not be held live across a GC, but which
|
||||
// is not itself a GC pointer.
|
||||
# define JS_HAZ_GC_INVALIDATED __attribute__((tag("Invalidated by GC")))
|
||||
# define JS_HAZ_GC_INVALIDATED __attribute__((annotate("Invalidated by GC")))
|
||||
|
||||
// Mark a class as a base class of rooted types, eg CustomAutoRooter. All
|
||||
// descendants of this class will be considered rooted, though classes that
|
||||
// merely contain these as a field member will not be. "Inherited" by
|
||||
// templatized types with MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS
|
||||
# define JS_HAZ_ROOTED_BASE __attribute__((tag("Rooted Base")))
|
||||
# define JS_HAZ_ROOTED_BASE __attribute__((annotate("Rooted Base")))
|
||||
|
||||
// Mark a type that would otherwise be considered a GC Pointer (eg because it
|
||||
// contains a JS::Value field) as a non-GC pointer. It is handled almost the
|
||||
|
@ -39,18 +39,18 @@
|
|||
// but makes sense for something like ErrorResult, which only contains a GC
|
||||
// pointer when it holds an exception (and it does its own rooting,
|
||||
// conditionally.)
|
||||
# define JS_HAZ_NON_GC_POINTER __attribute__((tag("Suppressed GC Pointer")))
|
||||
# define JS_HAZ_NON_GC_POINTER __attribute__((annotate("Suppressed GC Pointer")))
|
||||
|
||||
// Mark a function as something that runs a garbage collection, potentially
|
||||
// invalidating GC pointers.
|
||||
# define JS_HAZ_GC_CALL __attribute__((tag("GC Call")))
|
||||
# define JS_HAZ_GC_CALL __attribute__((annotate("GC Call")))
|
||||
|
||||
// Mark an RAII class as suppressing GC within its scope.
|
||||
# define JS_HAZ_GC_SUPPRESSED __attribute__((tag("Suppress GC")))
|
||||
# define JS_HAZ_GC_SUPPRESSED __attribute__((annotate("Suppress GC")))
|
||||
|
||||
// Mark a function as one that can run script if called. This obviously
|
||||
// subsumes JS_HAZ_GC_CALL, since anything that can run script can GC.`
|
||||
# define JS_HAZ_CAN_RUN_SCRIPT __attribute__((tag("Can run script")))
|
||||
# define JS_HAZ_CAN_RUN_SCRIPT __attribute__((annotate("Can run script")))
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ function printOnce(line)
|
|||
// Note that sixgill will only store certain attributes (annotation-names), so
|
||||
// this won't be *all* the attributes in the source, just the ones that sixgill
|
||||
// watches for.
|
||||
function getAnnotations(body)
|
||||
function getAllAttributes(body)
|
||||
{
|
||||
var all_annotations = {};
|
||||
for (var v of (body.DefineVariable || [])) {
|
||||
|
@ -62,12 +62,12 @@ function getAnnotations(body)
|
|||
}
|
||||
|
||||
// Get just the annotations understood by the hazard analysis.
|
||||
function getTags(functionName, body) {
|
||||
function getAnnotations(functionName, body) {
|
||||
var tags = new Set();
|
||||
var annotations = getAnnotations(body);
|
||||
if (functionName in annotations) {
|
||||
for (var [ annName, annValue ] of annotations[functionName]) {
|
||||
if (annName == 'Tag')
|
||||
var attributes = getAllAttributes(body);
|
||||
if (functionName in attributes) {
|
||||
for (var [ annName, annValue ] of attributes[functionName]) {
|
||||
if (annName == 'annotate')
|
||||
tags.add(annValue);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ function processBody(functionName, body)
|
|||
if (!('PEdge' in body))
|
||||
return;
|
||||
|
||||
for (var tag of getTags(functionName, body).values())
|
||||
|
||||
for (var tag of getAnnotations(functionName, body).values())
|
||||
print("T " + memo(functionName) + " " + tag);
|
||||
|
||||
// Set of all callees that have been output so far, in order to suppress
|
||||
|
|
|
@ -38,7 +38,7 @@ var rootedPointers = {};
|
|||
function processCSU(csu, body)
|
||||
{
|
||||
for (let { 'Name': [ annType, tag ] } of (body.Annotation || [])) {
|
||||
if (annType != 'Tag')
|
||||
if (annType != 'annotate')
|
||||
continue;
|
||||
|
||||
if (tag == 'GC Pointer')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define ANNOTATE(property) __attribute__((tag(property)))
|
||||
#define ANNOTATE(property) __attribute__((annotate(property)))
|
||||
|
||||
struct Cell { int f; } ANNOTATE("GC Thing");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define ANNOTATE(property) __attribute__((tag(property)))
|
||||
#define ANNOTATE(property) __attribute__((annotate(property)))
|
||||
|
||||
struct Cell { int f; } ANNOTATE("GC Thing");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define ANNOTATE(property) __attribute__((tag(property)))
|
||||
#define ANNOTATE(property) __attribute__((annotate(property)))
|
||||
|
||||
namespace js {
|
||||
namespace gc {
|
||||
|
|
|
@ -22,12 +22,12 @@ assert('other2' in body['Variables'])
|
|||
js_GC = test.process_body(test.load_db_entry("src_body", re.compile(r'js_GC'))[0])
|
||||
annotations = js_GC['Variables']['void js_GC()']['Annotation']
|
||||
assert(annotations)
|
||||
found_call_tag = False
|
||||
found_call_annotate = False
|
||||
for annotation in annotations:
|
||||
(annType, value) = annotation['Name']
|
||||
if annType == 'Tag' and value == 'GC Call':
|
||||
found_call_tag = True
|
||||
assert(found_call_tag)
|
||||
if annType == 'annotate' and value == 'GC Call':
|
||||
found_call_annotate = True
|
||||
assert(found_call_annotate)
|
||||
|
||||
# Test type annotations
|
||||
|
||||
|
@ -37,7 +37,7 @@ assert(cell['Kind'] == 'Struct')
|
|||
annotations = cell['Annotation']
|
||||
assert(len(annotations) == 1)
|
||||
(tag, value) = annotations[0]['Name']
|
||||
assert(tag == 'Tag')
|
||||
assert(tag == 'annotate')
|
||||
assert(value == 'GC Thing')
|
||||
|
||||
# Check JSObject inheritance.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define ANNOTATE(property) __attribute__((tag(property)))
|
||||
#define ANNOTATE(property) __attribute__((annotate(property)))
|
||||
|
||||
struct Cell { int f; } ANNOTATE("GC Thing");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define ANNOTATE(property) __attribute__((tag(property)))
|
||||
#define ANNOTATE(property) __attribute__((annotate(property)))
|
||||
|
||||
extern void GC() ANNOTATE("GC Call");
|
||||
|
||||
|
@ -16,11 +16,29 @@ typedef void (*func_t)();
|
|||
|
||||
class Base {
|
||||
public:
|
||||
int dummy;
|
||||
int ANNOTATE("field annotation") dummy;
|
||||
virtual void someGC() = 0;
|
||||
func_t functionField;
|
||||
|
||||
// For now, this is just to verify that the plugin doesn't crash. The
|
||||
// analysis code does not yet look at this annotation or output it anywhere
|
||||
// (though it *is* being recorded.)
|
||||
static float testAnnotations() ANNOTATE("static func");
|
||||
|
||||
// Similar, though sixgill currently completely ignores parameter annotations.
|
||||
static double testParamAnnotations(Cell& ANNOTATE("param annotation") ANNOTATE("second param annot") cell) ANNOTATE("static func") ANNOTATE("second func");
|
||||
};
|
||||
|
||||
float Base::testAnnotations()
|
||||
{
|
||||
asm("");
|
||||
}
|
||||
|
||||
double Base::testParamAnnotations(Cell& cell)
|
||||
{
|
||||
asm("");
|
||||
}
|
||||
|
||||
class Super : public Base {
|
||||
public:
|
||||
virtual void noneGC() = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ gcc_version=6.4.0
|
|||
gcc_ext=xz
|
||||
binutils_version=2.28.1
|
||||
binutils_ext=xz
|
||||
sixgill_rev=630e2025191d
|
||||
sixgill_rev=bc0ef9258470
|
||||
sixgill_repo=https://hg.mozilla.org/users/sfink_mozilla.com/sixgill
|
||||
|
||||
. $data_dir/build-gcc.sh
|
||||
|
|
Загрузка…
Ссылка в новой задаче