From 9e8c72fba3848a13373e4d0207435c8a857ee63b Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Thu, 19 Jul 2018 21:16:48 -0700 Subject: [PATCH] Bug 1321014 - Switch Tag to Annotate, r=nika --HG-- extra : rebase_source : 644e91673141f7ea7390822ab053a6c5f7fbe28f --- js/public/GCAnnotations.h | 18 +++++++-------- .../devtools/rootAnalysis/computeCallgraph.js | 15 +++++++------ .../devtools/rootAnalysis/computeGCTypes.js | 2 +- .../rootAnalysis/t/exceptions/source.cpp | 2 +- .../rootAnalysis/t/hazards/source.cpp | 2 +- .../rootAnalysis/t/sixgill-tree/source.cpp | 2 +- .../rootAnalysis/t/sixgill-tree/test.py | 10 ++++----- .../rootAnalysis/t/suppression/source.cpp | 2 +- .../rootAnalysis/t/virtual/source.cpp | 22 +++++++++++++++++-- .../misc/build-gcc-sixgill-plugin-linux.sh | 2 +- 10 files changed, 48 insertions(+), 29 deletions(-) diff --git a/js/public/GCAnnotations.h b/js/public/GCAnnotations.h index 7b8f9becd43f..c97e7603b8f0 100644 --- a/js/public/GCAnnotations.h +++ b/js/public/GCAnnotations.h @@ -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 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 diff --git a/js/src/devtools/rootAnalysis/computeCallgraph.js b/js/src/devtools/rootAnalysis/computeCallgraph.js index adca7c8d2871..5f07e78c8e15 100644 --- a/js/src/devtools/rootAnalysis/computeCallgraph.js +++ b/js/src/devtools/rootAnalysis/computeCallgraph.js @@ -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 diff --git a/js/src/devtools/rootAnalysis/computeGCTypes.js b/js/src/devtools/rootAnalysis/computeGCTypes.js index db4419a941fa..249c54316e88 100644 --- a/js/src/devtools/rootAnalysis/computeGCTypes.js +++ b/js/src/devtools/rootAnalysis/computeGCTypes.js @@ -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') diff --git a/js/src/devtools/rootAnalysis/t/exceptions/source.cpp b/js/src/devtools/rootAnalysis/t/exceptions/source.cpp index 4eac2084165f..0dd2518d67bf 100644 --- a/js/src/devtools/rootAnalysis/t/exceptions/source.cpp +++ b/js/src/devtools/rootAnalysis/t/exceptions/source.cpp @@ -1,4 +1,4 @@ -#define ANNOTATE(property) __attribute__((tag(property))) +#define ANNOTATE(property) __attribute__((annotate(property))) struct Cell { int f; } ANNOTATE("GC Thing"); diff --git a/js/src/devtools/rootAnalysis/t/hazards/source.cpp b/js/src/devtools/rootAnalysis/t/hazards/source.cpp index 7f84a99db7c2..a4922c268560 100644 --- a/js/src/devtools/rootAnalysis/t/hazards/source.cpp +++ b/js/src/devtools/rootAnalysis/t/hazards/source.cpp @@ -1,4 +1,4 @@ -#define ANNOTATE(property) __attribute__((tag(property))) +#define ANNOTATE(property) __attribute__((annotate(property))) struct Cell { int f; } ANNOTATE("GC Thing"); diff --git a/js/src/devtools/rootAnalysis/t/sixgill-tree/source.cpp b/js/src/devtools/rootAnalysis/t/sixgill-tree/source.cpp index 2de9ef4bb90b..e520b182f5be 100644 --- a/js/src/devtools/rootAnalysis/t/sixgill-tree/source.cpp +++ b/js/src/devtools/rootAnalysis/t/sixgill-tree/source.cpp @@ -1,4 +1,4 @@ -#define ANNOTATE(property) __attribute__((tag(property))) +#define ANNOTATE(property) __attribute__((annotate(property))) namespace js { namespace gc { diff --git a/js/src/devtools/rootAnalysis/t/sixgill-tree/test.py b/js/src/devtools/rootAnalysis/t/sixgill-tree/test.py index 8b47bcca996f..2a9a6e56d94a 100644 --- a/js/src/devtools/rootAnalysis/t/sixgill-tree/test.py +++ b/js/src/devtools/rootAnalysis/t/sixgill-tree/test.py @@ -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. diff --git a/js/src/devtools/rootAnalysis/t/suppression/source.cpp b/js/src/devtools/rootAnalysis/t/suppression/source.cpp index e7b41b4cb326..0d281857ea12 100644 --- a/js/src/devtools/rootAnalysis/t/suppression/source.cpp +++ b/js/src/devtools/rootAnalysis/t/suppression/source.cpp @@ -1,4 +1,4 @@ -#define ANNOTATE(property) __attribute__((tag(property))) +#define ANNOTATE(property) __attribute__((annotate(property))) struct Cell { int f; } ANNOTATE("GC Thing"); diff --git a/js/src/devtools/rootAnalysis/t/virtual/source.cpp b/js/src/devtools/rootAnalysis/t/virtual/source.cpp index 08b84e106021..e298378de9d2 100644 --- a/js/src/devtools/rootAnalysis/t/virtual/source.cpp +++ b/js/src/devtools/rootAnalysis/t/virtual/source.cpp @@ -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; diff --git a/taskcluster/scripts/misc/build-gcc-sixgill-plugin-linux.sh b/taskcluster/scripts/misc/build-gcc-sixgill-plugin-linux.sh index 5d306b3c77f2..3e42065415be 100755 --- a/taskcluster/scripts/misc/build-gcc-sixgill-plugin-linux.sh +++ b/taskcluster/scripts/misc/build-gcc-sixgill-plugin-linux.sh @@ -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