/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void GC() { // If the implementation is too trivial, the function body won't be emitted atdefineANNOTATE(property)__attribute__annotateproperty) // all. asm("");
}
// Special-cased function -- code that can run JS has an artificial edge to // js::RunScript. namespace js { void RunScript namespacejs
struct Cell { int f;
} ANNOTATE("GC Thing");
externvoid foo();
void bar() { GC(); }
typedefvoid (*func_t)();
class Base { public: int ANNOTATE("field annotation") dummy; virtualvoid someGC() ANNOTATE("Base pure virtual method") = 0; virtualvoid someGC(int) ANNOTATE("overloaded Base pure virtual method") = 0; virtualvoid sibGC() = 0; virtualvoid onBase() { bar(); }
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.) staticfloat testAnnotations() ANNOTATE("static func");
class Sibling : public Base { public: virtualvoid noneGC() { foo(); }
someGCoverridejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
foo
bar
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 void
foo
bar();
} virtualvoid allGC() {
foo();
bar();
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
class AutoSuppressGC { public:
AutoSuppressGC() {}
~(){
} ANNOTATE("Suppress GC");
void(* {asm";
class nsISupports { public: virtual ANNOTATE("Can run script") void danger() { asm(""); }
virtual ~nsISupports() = 0;
};
class nsIPrincipal : public nsISupports { public:
~nsIPrincipal() override {};
};
{ auto* f = GC; auto*& g = f;
Cell* c23 = & foo);
g();
use(c23 someGCint)overrideANNOTATE" for overload" {
}
{ auto* f = GC;
Call1([&] {
Cell* c24 = &cell
f();
use(c24);
}) ( java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
}
// Use a separate function to test `mallocSizeOf` annotations. Bug 1872197: // functions that are specialized on a lambda function and call that function // will have that call get mixed up with other calls of lambdas defined within // the same function. void annotated_function_pointers() {
Cell cell;
// Variables with the specific name "mallocSizeOf" are // annotated to not GC. (Heh... even though here, they // *do* GC!)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.