Commit 7f11d463 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Add the ability to compile with profiler guided optimizations on Windows

It is now possible to experiment with profiler guided optimizations when building V8. First build an instrumented sample shell:

  > scons pgo=instrument sample=shell

Then run the JavaScript code to optimize for using that sample shell. Finally build an optimized sample shell.

  > scons pgo=optimize sample=shell

Currently this does not work when building V8 as a DLL due to scons deleting v8.exp prior to the pgo=optimize step.

Due to a bug in Visual Studio (seen in version 2008) the function MessageDispatchHelperThread::Run() in debug.cc needs to be empty for this to work.
Review URL: http://codereview.chromium.org/652114

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3934 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b1e705aa
...@@ -255,8 +255,16 @@ LIBRARY_FLAGS = { ...@@ -255,8 +255,16 @@ LIBRARY_FLAGS = {
}, },
'msvcltcg:on': { 'msvcltcg:on': {
'CCFLAGS': ['/GL'], 'CCFLAGS': ['/GL'],
'LINKFLAGS': ['/LTCG'],
'ARFLAGS': ['/LTCG'], 'ARFLAGS': ['/LTCG'],
'pgo:off': {
'LINKFLAGS': ['/LTCG'],
},
'pgo:instrument': {
'LINKFLAGS': ['/LTCG:PGI']
},
'pgo:optimize': {
'LINKFLAGS': ['/LTCG:PGO']
}
} }
} }
} }
...@@ -527,7 +535,15 @@ SAMPLE_FLAGS = { ...@@ -527,7 +535,15 @@ SAMPLE_FLAGS = {
}, },
'msvcltcg:on': { 'msvcltcg:on': {
'CCFLAGS': ['/GL'], 'CCFLAGS': ['/GL'],
'pgo:off': {
'LINKFLAGS': ['/LTCG'], 'LINKFLAGS': ['/LTCG'],
},
},
'pgo:instrument': {
'LINKFLAGS': ['/LTCG:PGI']
},
'pgo:optimize': {
'LINKFLAGS': ['/LTCG:PGO']
} }
}, },
'arch:ia32': { 'arch:ia32': {
...@@ -711,6 +727,11 @@ SIMPLE_OPTIONS = { ...@@ -711,6 +727,11 @@ SIMPLE_OPTIONS = {
'values': ['arm', 'thumb2', 'none'], 'values': ['arm', 'thumb2', 'none'],
'default': 'none', 'default': 'none',
'help': 'generate thumb2 instructions instead of arm instructions (default)' 'help': 'generate thumb2 instructions instead of arm instructions (default)'
},
'pgo': {
'values': ['off', 'instrument', 'optimize'],
'default': 'off',
'help': 'select profile guided optimization variant',
} }
} }
...@@ -798,6 +819,8 @@ def VerifyOptions(env): ...@@ -798,6 +819,8 @@ def VerifyOptions(env):
Abort("Shared Object soname not applicable for Windows.") Abort("Shared Object soname not applicable for Windows.")
if env['soname'] == 'on' and env['library'] == 'static': if env['soname'] == 'on' and env['library'] == 'static':
Abort("Shared Object soname not applicable for static library.") Abort("Shared Object soname not applicable for static library.")
if env['os'] != 'win32' and env['pgo'] != 'off':
Abort("Profile guided optimization only supported on Windows.")
for (name, option) in SIMPLE_OPTIONS.iteritems(): for (name, option) in SIMPLE_OPTIONS.iteritems():
if (not option.get('default')) and (name not in ARGUMENTS): if (not option.get('default')) and (name not in ARGUMENTS):
message = ("A value for option %s must be specified (%s)." % message = ("A value for option %s must be specified (%s)." %
...@@ -883,7 +906,7 @@ class BuildContext(object): ...@@ -883,7 +906,7 @@ class BuildContext(object):
env['ENV'] = self.env_overrides env['ENV'] = self.env_overrides
def PostprocessOptions(options): def PostprocessOptions(options, os):
# Adjust architecture if the simulator option has been set # Adjust architecture if the simulator option has been set
if (options['simulator'] != 'none') and (options['arch'] != options['simulator']): if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
if 'arch' in ARGUMENTS: if 'arch' in ARGUMENTS:
...@@ -894,6 +917,10 @@ def PostprocessOptions(options): ...@@ -894,6 +917,10 @@ def PostprocessOptions(options):
# Print a warning if profiling is enabled without profiling support # Print a warning if profiling is enabled without profiling support
print "Warning: forcing profilingsupport on when prof is on" print "Warning: forcing profilingsupport on when prof is on"
options['profilingsupport'] = 'on' options['profilingsupport'] = 'on'
if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
if 'msvcltcg' in ARGUMENTS:
print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
options['msvcltcg'] = 'on'
if (options['armvariant'] == 'none' and options['arch'] == 'arm'): if (options['armvariant'] == 'none' and options['arch'] == 'arm'):
options['armvariant'] = 'arm' options['armvariant'] = 'arm'
if (options['armvariant'] != 'none' and options['arch'] != 'arm'): if (options['armvariant'] != 'none' and options['arch'] != 'arm'):
...@@ -924,7 +951,7 @@ def BuildSpecific(env, mode, env_overrides): ...@@ -924,7 +951,7 @@ def BuildSpecific(env, mode, env_overrides):
options = {'mode': mode} options = {'mode': mode}
for option in SIMPLE_OPTIONS: for option in SIMPLE_OPTIONS:
options[option] = env[option] options[option] = env[option]
PostprocessOptions(options) PostprocessOptions(options, env['os'])
context = BuildContext(options, env_overrides, samples=SplitList(env['sample'])) context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
......
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