Commit 9e877285 authored by vegorov@chromium.org's avatar vegorov@chromium.org

In gcmole assume that methods exiting VM can cause GC.

Detect those methods by reference to StateTag::EXTERNAL in their bodies.

R=fschneider@google.com

Review URL: https://chromiumcodereview.appspot.com/9420046

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10738 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e4236378
...@@ -69,6 +69,21 @@ static bool InV8Namespace(const clang::NamedDecl* decl) { ...@@ -69,6 +69,21 @@ static bool InV8Namespace(const clang::NamedDecl* decl) {
} }
static std::string EXTERNAL("EXTERNAL");
static std::string STATE_TAG("enum v8::internal::StateTag");
static bool IsExternalVMState(const clang::ValueDecl* var) {
const clang::EnumConstantDecl* enum_constant =
dyn_cast<clang::EnumConstantDecl>(var);
if (enum_constant != NULL && enum_constant->getNameAsString() == EXTERNAL) {
clang::QualType type = enum_constant->getType();
return (type.getAsString() == STATE_TAG);
}
return false;
}
struct Resolver { struct Resolver {
explicit Resolver(clang::ASTContext& ctx) explicit Resolver(clang::ASTContext& ctx)
: ctx_(ctx), decl_ctx_(ctx.getTranslationUnitDecl()) { : ctx_(ctx), decl_ctx_(ctx.getTranslationUnitDecl()) {
...@@ -121,6 +136,13 @@ class CalleesPrinter : public clang::RecursiveASTVisitor<CalleesPrinter> { ...@@ -121,6 +136,13 @@ class CalleesPrinter : public clang::RecursiveASTVisitor<CalleesPrinter> {
return true; return true;
} }
virtual bool VisitDeclRefExpr(clang::DeclRefExpr* expr) {
// If function mentions EXTERNAL VMState add artificial garbage collection
// mark.
if (IsExternalVMState(expr->getDecl())) AddCallee("CollectGarbage");
return true;
}
void AnalyzeFunction(const clang::FunctionDecl* f) { void AnalyzeFunction(const clang::FunctionDecl* f) {
MangledName name; MangledName name;
if (InV8Namespace(f) && GetMangledName(ctx_, f, &name)) { if (InV8Namespace(f) && GetMangledName(ctx_, f, &name)) {
...@@ -278,6 +300,10 @@ class ExprEffect { ...@@ -278,6 +300,10 @@ class ExprEffect {
return reinterpret_cast<Environment*>(effect_ & ~kAllEffects); return reinterpret_cast<Environment*>(effect_ & ~kAllEffects);
} }
static ExprEffect GC() {
return ExprEffect(kCausesGC, NULL);
}
private: private:
ExprEffect(int effect, Environment* env) ExprEffect(int effect, Environment* env)
: effect_((effect & kAllEffects) | : effect_((effect & kAllEffects) |
...@@ -790,6 +816,9 @@ class FunctionAnalyzer { ...@@ -790,6 +816,9 @@ class FunctionAnalyzer {
ExprEffect Use(const clang::Expr* parent, ExprEffect Use(const clang::Expr* parent,
const clang::ValueDecl* var, const clang::ValueDecl* var,
const Environment& env) { const Environment& env) {
if (IsExternalVMState(var)) {
return ExprEffect::GC();
}
return Use(parent, var->getType(), var->getNameAsString(), env); return Use(parent, var->getType(), var->getNameAsString(), env);
} }
......
...@@ -106,7 +106,6 @@ function InvokeClangPluginForEachFile(filenames, cfg, func) ...@@ -106,7 +106,6 @@ function InvokeClangPluginForEachFile(filenames, cfg, func)
cfg.plugin_args, cfg.plugin_args,
cfg.triple, cfg.triple,
cfg.arch_define) cfg.arch_define)
for _, filename in ipairs(filenames) do for _, filename in ipairs(filenames) do
log("-- %s", filename) log("-- %s", filename)
local action = cmd_line .. " src/" .. filename .. " 2>&1" local action = cmd_line .. " src/" .. filename .. " 2>&1"
...@@ -218,7 +217,13 @@ local WHITELIST = { ...@@ -218,7 +217,13 @@ local WHITELIST = {
-- Callsites of such functions are safe as long as they are properly -- Callsites of such functions are safe as long as they are properly
-- check return value and propagate the Failure to the caller. -- check return value and propagate the Failure to the caller.
-- It should be possible to extend GCMole to understand this. -- It should be possible to extend GCMole to understand this.
"Heap.*AllocateFunctionPrototype" "Heap.*AllocateFunctionPrototype",
-- Ignore all StateTag methods.
"StateTag",
-- Ignore printing of elements transition.
"PrintElementsTransition"
}; };
local function AddCause(name, cause) local function AddCause(name, cause)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment