diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-10-09 11:23:32 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-10-13 13:21:27 -0700 |
commit | 36e5729db554afaea6fe9b23f3caa87b6c8cc80d (patch) | |
tree | 482b20ea2fcb0a6d5d112af75623eb690c12f9cb /expr.cc | |
parent | f2a0a72d1fd1ee7b6f37754eef8886dcaafa22d0 (diff) | |
download | android_build_kati-36e5729db554afaea6fe9b23f3caa87b6c8cc80d.tar.gz android_build_kati-36e5729db554afaea6fe9b23f3caa87b6c8cc80d.tar.bz2 android_build_kati-36e5729db554afaea6fe9b23f3caa87b6c8cc80d.zip |
Keep track of stack usage, report line that used the most
This won't keep track of everything, but was useful in tracking down
some recursive variables in the android build that shouldn't have been
recursive (they were using 1MB+ of stack).
Change-Id: I5e6b70480cffbebb09dfd72276017559480da948
Diffstat (limited to 'expr.cc')
-rw-r--r-- | expr.cc | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -52,7 +52,8 @@ class Literal : public Value { StringPiece val() const { return s_; } - virtual void Eval(Evaluator*, string* s) const override { + virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); s->append(s_.begin(), s_.end()); } @@ -79,6 +80,7 @@ class Expr : public Value { void AddValue(Value* v) { vals_.push_back(v); } virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); for (Value* v : vals_) { v->Eval(ev, s); } @@ -119,6 +121,7 @@ class SymRef : public Value { virtual ~SymRef() {} virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); Var* v = ev->LookupVar(name_); v->Used(ev, name_); v->Eval(ev, s); @@ -138,6 +141,7 @@ class VarRef : public Value { virtual ~VarRef() { delete name_; } virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); ev->IncrementEvalDepth(); const string&& name = name_->Eval(ev); ev->DecrementEvalDepth(); @@ -166,6 +170,7 @@ class VarSubst : public Value { } virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); ev->IncrementEvalDepth(); const string&& name = name_->Eval(ev); Symbol sym = Intern(name); @@ -205,6 +210,7 @@ class Func : public Value { } virtual void Eval(Evaluator* ev, string* s) const override { + ev->CheckStack(); LOG("Invoke func %s(%s)", name(), JoinValues(args_, ",").c_str()); ev->IncrementEvalDepth(); fi_->func(args_, ev, s); |