Cache some values in PreprocessorDelegate
Cache some values in PreprocessorDelegate

Summary:Re-apply this, except using weakMemoize so that we don't run out of memory. As
it turns out PreprocessorDelegate (and BuildRule) are held in memory forever. I
verified that the performance increase still exists, and that big builds don't
go into GC hell.

Original Summary:

These values were being recomputed for every file, when they don't vary across
all files (with the same type/args) of a library. They contribute to over half
of the self-time spent in running the rule (not including the compiler
invocation itself), and is significant when compiling small files in libraries
with many dependencies.

Test Plan:existing tests pass.

Data from a library of 870 objc files used to test this (from trace and log):

Before: total 54 seconds (build 38 sec),  100-150ms overhead per file
After: total 42.7 seconds (build 28 sec), 40ms overhead per file

Build a large app and make sure there's no GC slowdown (by attaching to the JVM and looking at GC statistics.)

Reviewed By: Coneko

fb-gh-sync-id: 6c64e11
shipit-source-id: 6c64e11

rmaz/buck,shybovycha/buck,robbertvanginkel/buck,grumpyjames/buck,romanoid/buck,SeleniumHQ/buck,k21/buck,darkforestzero/buck,JoelMarcey/buck,rowillia/buck,zpao/buck,nguyentruongtho/buck,rowillia/buck,zhan-xiong/buck,daedric/buck,clonetwin26/buck,JoelMarcey/buck,brettwooldridge/buck,zhan-xiong/buck,facebook/buck,vschs007/buck,k21/buck,k21/buck,vschs007/buck,darkforestzero/buck,rowillia/buck,rmaz/buck,zhan-xiong/buck,Addepar/buck,janicduplessis/buck,shybovycha/buck,zhan-xiong/buck,janicduplessis/buck,robbertvanginkel/buck,dsyang/buck,shs96c/buck,marcinkwiatkowski/buck,sdwilsh/buck,shybovycha/buck,JoelMarcey/buck,justinmuller/buck,k21/buck,rmaz/buck,dsyang/buck,robbertvanginkel/buck,brettwooldridge/buck,k21/buck,clonetwin26/buck,brettwooldridge/buck,raviagarwal7/buck,robbertvanginkel/buck,SeleniumHQ/buck,SeleniumHQ/buck,clonetwin26/buck,nguyentruongtho/buck,ilya-klyuchnikov/buck,brettwooldridge/buck,marcinkwiatkowski/buck,daedric/buck,marcinkwiatkowski/buck,janicduplessis/buck,vschs007/buck,Addepar/buck,LegNeato/buck,clonetwin26/buck,SeleniumHQ/buck,davido/buck,zhan-xiong/buck,janicduplessis/buck,rmaz/buck,brettwooldridge/buck,sdwilsh/buck,grumpyjames/buck,bocon13/buck,Addepar/buck,kageiit/buck,grumpyjames/buck,raviagarwal7/buck,dsyang/buck,OkBuilds/buck,OkBuilds/buck,shs96c/buck,dsyang/buck,Dominator008/buck,rmaz/buck,rmaz/buck,romanoid/buck,SeleniumHQ/buck,JoelMarcey/buck,sdwilsh/buck,raviagarwal7/buck,robbertvanginkel/buck,SeleniumHQ/buck,Dominator008/buck,bocon13/buck,janicduplessis/buck,illicitonion/buck,bocon13/buck,LegNeato/buck,SeleniumHQ/buck,justinmuller/buck,vschs007/buck,shybovycha/buck,nguyentruongtho/buck,illicitonion/buck,shs96c/buck,JoelMarcey/buck,rmaz/buck,illicitonion/buck,vschs007/buck,bocon13/buck,k21/buck,LegNeato/buck,robbertvanginkel/buck,justinmuller/buck,shs96c/buck,vschs007/buck,JoelMarcey/buck,OkBuilds/buck,SeleniumHQ/buck,vschs007/buck,zhan-xiong/buck,brettwooldridge/buck,grumpyjames/buck,clonetwin26/buck,raviagarwal7/buck,k21/buck,rmaz/buck,marcinkwiatkowski/buck,brettwooldridge/buck,OkBuilds/buck,robbertvanginkel/buck,justinmuller/buck,OkBuilds/buck,rowillia/buck,darkforestzero/buck,rowillia/buck,davido/buck,brettwooldridge/buck,janicduplessis/buck,darkforestzero/buck,JoelMarcey/buck,rowillia/buck,shybovycha/buck,Addepar/buck,illicitonion/buck,k21/buck,vschs007/buck,rowillia/buck,illicitonion/buck,vschs007/buck,Dominator008/buck,illicitonion/buck,dsyang/buck,OkBuilds/buck,zhan-xiong/buck,nguyentruongtho/buck,clonetwin26/buck,zpao/buck,SeleniumHQ/buck,clonetwin26/buck,k21/buck,darkforestzero/buck,Dominator008/buck,LegNeato/buck,daedric/buck,k21/buck,JoelMarcey/buck,sdwilsh/buck,romanoid/buck,shybovycha/buck,nguyentruongtho/buck,dsyang/buck,kageiit/buck,ilya-klyuchnikov/buck,clonetwin26/buck,Dominator008/buck,brettwooldridge/buck,Dominator008/buck,justinmuller/buck,Addepar/buck,dsyang/buck,shs96c/buck,zpao/buck,rowillia/buck,grumpyjames/buck,k21/buck,illicitonion/buck,zpao/buck,marcinkwiatkowski/buck,romanoid/buck,darkforestzero/buck,OkBuilds/buck,darkforestzero/buck,facebook/buck,ilya-klyuchnikov/buck,zpao/buck,darkforestzero/buck,Dominator008/buck,ilya-klyuchnikov/buck,OkBuilds/buck,ilya-klyuchnikov/buck,justinmuller/buck,Addepar/buck,raviagarwal7/buck,dsyang/buck,shs96c/buck,shybovycha/buck,nguyentruongtho/buck,LegNeato/buck,clonetwin26/buck,facebook/buck,justinmuller/buck,romanoid/buck,Dominator008/buck,raviagarwal7/buck,raviagarwal7/buck,bocon13/buck,sdwilsh/buck,shybovycha/buck,marcinkwiatkowski/buck,OkBuilds/buck,raviagarwal7/buck,JoelMarcey/buck,marcinkwiatkowski/buck,SeleniumHQ/buck,rmaz/buck,OkBuilds/buck,brettwooldridge/buck,brettwooldridge/buck,grumpyjames/buck,sdwilsh/buck,sdwilsh/buck,davido/buck,robbertvanginkel/buck,romanoid/buck,grumpyjames/buck,romanoid/buck,ilya-klyuchnikov/buck,JoelMarcey/buck,LegNeato/buck,ilya-klyuchnikov/buck,zpao/buck,daedric/buck,janicduplessis/buck,grumpyjames/buck,Dominator008/buck,OkBuilds/buck,justinmuller/buck,dsyang/buck,rowillia/buck,davido/buck,shybovycha/buck,rmaz/buck,rowillia/buck,kageiit/buck,darkforestzero/buck,davido/buck,Addepar/buck,daedric/buck,raviagarwal7/buck,janicduplessis/buck,kageiit/buck,clonetwin26/buck,illicitonion/buck,bocon13/buck,raviagarwal7/buck,zhan-xiong/buck,shs96c/buck,facebook/buck,justinmuller/buck,sdwilsh/buck,dsyang/buck,shs96c/buck,raviagarwal7/buck,darkforestzero/buck,janicduplessis/buck,LegNeato/buck,OkBuilds/buck,daedric/buck,illicitonion/buck,rowillia/buck,davido/buck,marcinkwiatkowski/buck,romanoid/buck,shybovycha/buck,kageiit/buck,janicduplessis/buck,shybovycha/buck,daedric/buck,bocon13/buck,zhan-xiong/buck,daedric/buck,davido/buck,marcinkwiatkowski/buck,JoelMarcey/buck,illicitonion/buck,rmaz/buck,darkforestzero/buck,JoelMarcey/buck,dsyang/buck,k21/buck,LegNeato/buck,Addepar/buck,SeleniumHQ/buck,Addepar/buck,janicduplessis/buck,davido/buck,clonetwin26/buck,justinmuller/buck,brettwooldridge/buck,daedric/buck,rowillia/buck,shybovycha/buck,SeleniumHQ/buck,clonetwin26/buck,robbertvanginkel/buck,romanoid/buck,justinmuller/buck,shs96c/buck,ilya-klyuchnikov/buck,illicitonion/buck,ilya-klyuchnikov/buck,daedric/buck,Dominator008/buck,davido/buck,LegNeato/buck,zhan-xiong/buck,brettwooldridge/buck,zhan-xiong/buck,clonetwin26/buck,ilya-klyuchnikov/buck,davido/buck,zpao/buck,grumpyjames/buck,bocon13/buck,LegNeato/buck,robbertvanginkel/buck,daedric/buck,SeleniumHQ/buck,robbertvanginkel/buck,Addepar/buck,Dominator008/buck,marcinkwiatkowski/buck,Addepar/buck,vschs007/buck,sdwilsh/buck,raviagarwal7/buck,Dominator008/buck,davido/buck,grumpyjames/buck,LegNeato/buck,zhan-xiong/buck,rmaz/buck,vschs007/buck,kageiit/buck,nguyentruongtho/buck,daedric/buck,justinmuller/buck,shs96c/buck,raviagarwal7/buck,facebook/buck,robbertvanginkel/buck,romanoid/buck,davido/buck,justinmuller/buck,romanoid/buck,bocon13/buck,sdwilsh/buck,shybovycha/buck,shs96c/buck,vschs007/buck,zhan-xiong/buck,OkBuilds/buck,shs96c/buck,darkforestzero/buck,romanoid/buck,grumpyjames/buck,vschs007/buck,grumpyjames/buck,dsyang/buck,romanoid/buck,darkforestzero/buck,janicduplessis/buck,robbertvanginkel/buck,sdwilsh/buck,JoelMarcey/buck,dsyang/buck,k21/buck,sdwilsh/buck,Addepar/buck,davido/buck,ilya-klyuchnikov/buck,shs96c/buck,daedric/buck,LegNeato/buck,ilya-klyuchnikov/buck,rmaz/buck,marcinkwiatkowski/buck,bocon13/buck,kageiit/buck,illicitonion/buck,sdwilsh/buck,marcinkwiatkowski/buck,LegNeato/buck,bocon13/buck,marcinkwiatkowski/buck,Addepar/buck,facebook/buck,illicitonion/buck,bocon13/buck,ilya-klyuchnikov/buck,facebook/buck