Author: [email protected]
Date: Thu Feb 19 06:53:40 2009
New Revision: 1320
Modified:
branches/experimental/toiger/src/jump-target-arm.cc
branches/experimental/toiger/src/jump-target-ia32.cc
branches/experimental/toiger/src/virtual-frame-arm.h
branches/experimental/toiger/src/virtual-frame-ia32.h
branches/experimental/toiger/src/virtual-frame.cc
Log:
Experimental: add a pre-merge step to perform some frame moves that do
not require code generation (X-to-memory where X is synced and
X-to-invalid).
This allows us to catch more empty merge-code blocks and combine more
non-empty blocks.
Review URL: http://codereview.chromium.org/20492
Modified: branches/experimental/toiger/src/jump-target-arm.cc
==============================================================================
--- branches/experimental/toiger/src/jump-target-arm.cc (original)
+++ branches/experimental/toiger/src/jump-target-arm.cc Thu Feb 19 06:53:40
2009
@@ -145,6 +145,17 @@
// There were forward jumps. Handle merging the reaching frames
// and possible fall through to the entry frame.
+ // Some moves required to merge to an expected frame require
+ // purely frame state changes, and do not require any code
+ // generation. Perform those first to increase the possibility of
+ // finding equal frames below.
+ if (cgen_->has_valid_frame()) {
+ cgen_->frame()->PrepareMergeTo(entry_frame_);
+ }
+ for (int i = 0; i < reaching_frames_.length(); i++) {
+ reaching_frames_[i]->PrepareMergeTo(entry_frame_);
+ }
+
// If there is a fall through to the jump target and it needs
// merge code, process it first.
if (cgen_->has_valid_frame() && !cgen_->frame()->Equals(entry_frame_))
{
Modified: branches/experimental/toiger/src/jump-target-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/jump-target-ia32.cc (original)
+++ branches/experimental/toiger/src/jump-target-ia32.cc Thu Feb 19
06:53:40 2009
@@ -145,6 +145,17 @@
// There were forward jumps. Handle merging the reaching frames
// and possible fall through to the entry frame.
+ // Some moves required to merge to an expected frame require
+ // purely frame state changes, and do not require any code
+ // generation. Perform those first to increase the possibility of
+ // finding equal frames below.
+ if (cgen_->has_valid_frame()) {
+ cgen_->frame()->PrepareMergeTo(entry_frame_);
+ }
+ for (int i = 0; i < reaching_frames_.length(); i++) {
+ reaching_frames_[i]->PrepareMergeTo(entry_frame_);
+ }
+
// If there is a fall through to the jump target and it needs
// merge code, process it first.
if (cgen_->has_valid_frame() && !cgen_->frame()->Equals(entry_frame_))
{
Modified: branches/experimental/toiger/src/virtual-frame-arm.h
==============================================================================
--- branches/experimental/toiger/src/virtual-frame-arm.h (original)
+++ branches/experimental/toiger/src/virtual-frame-arm.h Thu Feb 19
06:53:40 2009
@@ -95,6 +95,11 @@
// (ie, they all have frame-external references).
Register SpillAnyRegister();
+ // Prepare this virtual frame for merging to an expected frame by
+ // performing some state changes that do not require generating
+ // code. It is guaranteed that no code will be generated.
+ void PrepareMergeTo(VirtualFrame* expected);
+
// Make this virtual frame have a state identical to an expected virtual
// frame. As a side effect, code may be emitted to make this frame match
// the expected one.
Modified: branches/experimental/toiger/src/virtual-frame-ia32.h
==============================================================================
--- branches/experimental/toiger/src/virtual-frame-ia32.h (original)
+++ branches/experimental/toiger/src/virtual-frame-ia32.h Thu Feb 19
06:53:40 2009
@@ -95,6 +95,11 @@
// (ie, they all have frame-external references).
Register SpillAnyRegister();
+ // Prepare this virtual frame for merging to an expected frame by
+ // performing some state changes that do not require generating
+ // code. It is guaranteed that no code will be generated.
+ void PrepareMergeTo(VirtualFrame* expected);
+
// Make this virtual frame have a state identical to an expected virtual
// frame. As a side effect, code may be emitted to make this frame match
// the expected one.
Modified: branches/experimental/toiger/src/virtual-frame.cc
==============================================================================
--- branches/experimental/toiger/src/virtual-frame.cc (original)
+++ branches/experimental/toiger/src/virtual-frame.cc Thu Feb 19 06:53:40
2009
@@ -229,6 +229,31 @@
}
+void VirtualFrame::PrepareMergeTo(VirtualFrame* expected) {
+ // No code needs to be generated to invalidate valid elements. No
+ // code needs to be generated to move values to memory if they are
+ // already synced.
+ for (int i = 0; i < elements_.length(); i++) {
+ FrameElement source = elements_[i];
+ FrameElement target = expected->elements_[i];
+ if (!target.is_valid() ||
+ (target.is_memory() && !source.is_memory() && source.is_synced()))
{
+ if (source.is_register()) {
+ // If the frame is the code generator's current frame, we have
+ // to decrement both the frame-internal and global register
+ // counts.
+ if (cgen_->frame() == this) {
+ Unuse(source.reg());
+ } else {
+ frame_registers_.Unuse(source.reg());
+ }
+ }
+ elements_[i] = target;
+ }
+ }
+}
+
+
void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) {
ASSERT(height() >= dropped_args);
ASSERT(height() >= spilled_args);
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---