[turbofan]: Add a context relaxation Reducer
authordanno <danno@chromium.org>
Mon, 20 Jul 2015 17:15:59 +0000 (10:15 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 20 Jul 2015 17:16:14 +0000 (17:16 +0000)
commitcca5e74a5814543e7446167ba47bfa498ae10c16
tree9c651101d48906ed40c0e83dc84f227eef852896
parentd67e07f3971b3fe6ecff612b5b73e9191b0e32c4
[turbofan]: Add a context relaxation Reducer

In many cases, the context that TurboFan's ASTGraphBuilder or subsequent
reduction operations attaches to nodes does not need to be that exact
context, but rather only needs to be one with the same native context,
because it is used internally only to fetch the native context, e.g. for
creating and throwing exceptions.

This reducer recognizes common cases where the context that is specified
for a node can be relaxed to a canonical, less specific one. This
relaxed context can either be the enclosing function's context or a specific
Module or Script context that is explicitly created within the function.

This optimization is especially important for TurboFan-generated code stubs
which use context specialization and inlining to generate optimal code.
Without context relaxation, many extraneous moves are generated to pass
exactly the right context to internal functions like ToNumber and
AllocateHeapNumber, which only need the native context. By turning context
relaxation on, these moves disappear because all these common internal
context uses are unified to the context passed into the stub function, which
is typically already in the correct context register and remains there for
short stubs. It also eliminates the explicit use of a specialized context
constant in the code stub in these cases, which could cause memory leaks.

Review URL: https://codereview.chromium.org/1244583003

Cr-Commit-Position: refs/heads/master@{#29763}
15 files changed:
BUILD.gn
src/code-stubs.cc
src/compiler/ast-graph-builder.cc
src/compiler/common-operator.cc
src/compiler/common-operator.h
src/compiler/frame-states.h
src/compiler/js-context-relaxation.cc [new file with mode: 0644]
src/compiler/js-context-relaxation.h [new file with mode: 0644]
src/compiler/js-inlining.cc
src/compiler/pipeline.cc
test/unittests/compiler/instruction-selector-unittest.cc
test/unittests/compiler/js-context-relaxation-unittest.cc [new file with mode: 0644]
test/unittests/compiler/liveness-analyzer-unittest.cc
test/unittests/unittests.gyp
tools/gyp/v8.gyp