First round of JumpTarget simplification. Remove dead functions (jumps,

branches, and bind with more than two arguments).  Remove unneeded
variable (the "watermark" on virtual frames).

Review URL: http://codereview.chromium.org/125045

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2153 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kmillikin@chromium.org 2009-06-12 11:25:13 +00:00
parent f706cfa30c
commit b318835cdc
8 changed files with 34 additions and 205 deletions

View File

@ -149,7 +149,7 @@ void JumpTarget::Call() {
}
void JumpTarget::DoBind(int mergable_elements) {
void JumpTarget::DoBind() {
ASSERT(!is_bound());
// Live non-frame registers are not allowed at the start of a basic
@ -207,7 +207,7 @@ void JumpTarget::DoBind(int mergable_elements) {
// Compute the frame to use for entry to the block.
if (entry_frame_ == NULL) {
ComputeEntryFrame(mergable_elements);
ComputeEntryFrame();
}
// Some moves required to merge to an expected frame require purely

View File

@ -317,9 +317,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
if (function_return_.is_bound()) {
function_return_.Jump(&undefined);
} else {
// Though this is a (possibly) backward block, the frames
// can only differ on their top element.
function_return_.Bind(&undefined, 1);
function_return_.Bind(&undefined);
GenerateReturnSequence(&undefined);
}
} else if (function_return_.is_linked()) {
@ -329,9 +327,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
// compile an artificial return statement just above, and (b) there
// are return statements in the body but (c) they are all shadowed.
Result return_value;
// Though this is a (possibly) backward block, the frames can
// only differ on their top element.
function_return_.Bind(&return_value, 1);
function_return_.Bind(&return_value);
GenerateReturnSequence(&return_value);
}
}
@ -2328,9 +2324,7 @@ void CodeGenerator::VisitReturnStatement(ReturnStatement* node) {
// code by jumping to the return site.
function_return_.Jump(&return_value);
} else {
// Though this is a (possibly) backward block, the frames can
// only differ on their top element.
function_return_.Bind(&return_value, 1);
function_return_.Bind(&return_value);
GenerateReturnSequence(&return_value);
}
}

View File

@ -164,7 +164,7 @@ void JumpTarget::Call() {
}
void JumpTarget::DoBind(int mergable_elements) {
void JumpTarget::DoBind() {
ASSERT(cgen() != NULL);
ASSERT(!is_bound());
@ -210,7 +210,7 @@ void JumpTarget::DoBind(int mergable_elements) {
// Fast case: no forward jumps, possible backward ones. Remove
// constants and copies above the watermark on the fall-through
// frame and use it as the entry frame.
cgen()->frame()->MakeMergable(mergable_elements);
cgen()->frame()->MakeMergable();
entry_frame_ = new VirtualFrame(cgen()->frame());
}
__ bind(&entry_label_);
@ -252,7 +252,7 @@ void JumpTarget::DoBind(int mergable_elements) {
}
// Compute the frame to use for entry to the block.
ComputeEntryFrame(mergable_elements);
ComputeEntryFrame();
// Some moves required to merge to an expected frame require purely
// frame state changes, and do not require any code generation.

View File

@ -174,14 +174,8 @@ void VirtualFrame::SyncRange(int begin, int end) {
}
void VirtualFrame::MakeMergable(int mergable_elements) {
if (mergable_elements == JumpTarget::kAllElements) {
mergable_elements = element_count();
}
ASSERT(mergable_elements <= element_count());
int start_index = element_count() - mergable_elements;
for (int i = start_index; i < element_count(); i++) {
void VirtualFrame::MakeMergable() {
for (int i = 0; i < element_count(); i++) {
FrameElement element = elements_[i];
if (element.is_constant() || element.is_copy()) {

View File

@ -153,11 +153,8 @@ class VirtualFrame : public ZoneObject {
void SyncRange(int begin, int end);
// Make this frame so that an arbitrary frame of the same height can
// be merged to it. Copies and constants are removed from the
// topmost mergable_elements elements of the frame. A
// mergable_elements of JumpTarget::kAllElements indicates constants
// and copies are should be removed from the entire frame.
void MakeMergable(int mergable_elements);
// be merged to it. Copies and constants are removed from the frame.
void MakeMergable();
// Prepare this virtual frame for merging to an expected frame by
// performing some state changes that do not require generating

View File

@ -48,7 +48,7 @@ void JumpTarget::Unuse() {
}
void JumpTarget::ComputeEntryFrame(int mergable_elements) {
void JumpTarget::ComputeEntryFrame() {
// Given: a collection of frames reaching by forward CFG edges and
// the directionality of the block. Compute: an entry frame for the
// block.
@ -77,14 +77,6 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
int length = initial_frame->element_count();
ZoneList<FrameElement*> elements(length);
// Convert the number of mergable elements (counted from the top
// down) to a frame high-water mark (counted from the bottom up).
// Elements strictly above the high-water index will be mergable in
// entry frames for bidirectional jump targets.
int high_water_mark = (mergable_elements == kAllElements)
? VirtualFrame::kIllegalIndex // All frame indices are above this.
: length - mergable_elements - 1; // Top index if m_e == 0.
// Initially populate the list of elements based on the initial
// frame.
for (int i = 0; i < length; i++) {
@ -92,7 +84,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
// We do not allow copies or constants in bidirectional frames. All
// elements above the water mark on bidirectional frames have
// unknown static types.
if (direction_ == BIDIRECTIONAL && i > high_water_mark) {
if (direction_ == BIDIRECTIONAL) {
if (element.is_constant() || element.is_copy()) {
elements.Add(NULL);
continue;
@ -158,7 +150,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
int best_reg_num = RegisterAllocator::kInvalidRegister;
StaticType type; // Initially invalid.
if (direction_ != BIDIRECTIONAL || i < high_water_mark) {
if (direction_ != BIDIRECTIONAL) {
type = reaching_frames_[0]->elements_[i].static_type();
}
@ -241,25 +233,6 @@ void JumpTarget::Jump(Result* arg) {
}
void JumpTarget::Jump(Result* arg0, Result* arg1) {
ASSERT(cgen()->has_valid_frame());
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
DoJump();
}
void JumpTarget::Jump(Result* arg0, Result* arg1, Result* arg2) {
ASSERT(cgen()->has_valid_frame());
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
DoJump();
}
void JumpTarget::Branch(Condition cc, Hint hint) {
DoBranch(cc, hint);
}
@ -314,65 +287,6 @@ void JumpTarget::Branch(Condition cc, Result* arg0, Result* arg1, Hint hint) {
}
void JumpTarget::Branch(Condition cc,
Result* arg0,
Result* arg1,
Result* arg2,
Hint hint) {
ASSERT(cgen()->frame() != NULL);
// We want to check that non-frame registers at the call site stay in
// the same registers on the fall-through branch.
DECLARE_ARGCHECK_VARS(arg0);
DECLARE_ARGCHECK_VARS(arg1);
DECLARE_ARGCHECK_VARS(arg2);
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
DoBranch(cc, hint);
*arg2 = cgen()->frame()->Pop();
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
ASSERT_ARGCHECK(arg0);
ASSERT_ARGCHECK(arg1);
ASSERT_ARGCHECK(arg2);
}
void JumpTarget::Branch(Condition cc,
Result* arg0,
Result* arg1,
Result* arg2,
Result* arg3,
Hint hint) {
ASSERT(cgen()->frame() != NULL);
// We want to check that non-frame registers at the call site stay in
// the same registers on the fall-through branch.
DECLARE_ARGCHECK_VARS(arg0);
DECLARE_ARGCHECK_VARS(arg1);
DECLARE_ARGCHECK_VARS(arg2);
DECLARE_ARGCHECK_VARS(arg3);
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
cgen()->frame()->Push(arg3);
DoBranch(cc, hint);
*arg3 = cgen()->frame()->Pop();
*arg2 = cgen()->frame()->Pop();
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
ASSERT_ARGCHECK(arg0);
ASSERT_ARGCHECK(arg1);
ASSERT_ARGCHECK(arg2);
ASSERT_ARGCHECK(arg3);
}
void BreakTarget::Branch(Condition cc, Result* arg, Hint hint) {
ASSERT(cgen()->has_valid_frame());
@ -400,61 +314,26 @@ void BreakTarget::Branch(Condition cc, Result* arg, Hint hint) {
#undef ASSERT_ARGCHECK
void JumpTarget::Bind(int mergable_elements) {
DoBind(mergable_elements);
void JumpTarget::Bind() {
DoBind();
}
void JumpTarget::Bind(Result* arg, int mergable_elements) {
void JumpTarget::Bind(Result* arg) {
if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg);
}
DoBind(mergable_elements);
DoBind();
*arg = cgen()->frame()->Pop();
}
void JumpTarget::Bind(Result* arg0, Result* arg1, int mergable_elements) {
void JumpTarget::Bind(Result* arg0, Result* arg1) {
if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
}
DoBind(mergable_elements);
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
}
void JumpTarget::Bind(Result* arg0,
Result* arg1,
Result* arg2,
int mergable_elements) {
if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
}
DoBind(mergable_elements);
*arg2 = cgen()->frame()->Pop();
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
}
void JumpTarget::Bind(Result* arg0,
Result* arg1,
Result* arg2,
Result* arg3,
int mergable_elements) {
if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
cgen()->frame()->Push(arg3);
}
DoBind(mergable_elements);
*arg3 = cgen()->frame()->Pop();
*arg2 = cgen()->frame()->Pop();
DoBind();
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
}
@ -531,7 +410,7 @@ void BreakTarget::Branch(Condition cc, Hint hint) {
}
void BreakTarget::Bind(int mergable_elements) {
void BreakTarget::Bind() {
#ifdef DEBUG
// All the forward-reaching frames should have been adjusted at the
// jumps to this target.
@ -547,11 +426,11 @@ void BreakTarget::Bind(int mergable_elements) {
int count = cgen()->frame()->height() - expected_height_;
cgen()->frame()->ForgetElements(count);
}
DoBind(mergable_elements);
DoBind();
}
void BreakTarget::Bind(Result* arg, int mergable_elements) {
void BreakTarget::Bind(Result* arg) {
#ifdef DEBUG
// All the forward-reaching frames should have been adjusted at the
// jumps to this target.
@ -568,7 +447,7 @@ void BreakTarget::Bind(Result* arg, int mergable_elements) {
cgen()->frame()->ForgetElements(count);
cgen()->frame()->Push(arg);
}
DoBind(mergable_elements);
DoBind();
*arg = cgen()->frame()->Pop();
}

View File

@ -107,8 +107,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// jump and there will be no current frame after the jump.
virtual void Jump();
virtual void Jump(Result* arg);
void Jump(Result* arg0, Result* arg1);
void Jump(Result* arg0, Result* arg1, Result* arg2);
// Emit a conditional branch to the target. There must be a current
// frame at the branch. The current frame will fall through to the
@ -116,43 +114,13 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
virtual void Branch(Condition cc, Hint hint = no_hint);
virtual void Branch(Condition cc, Result* arg, Hint hint = no_hint);
void Branch(Condition cc, Result* arg0, Result* arg1, Hint hint = no_hint);
void Branch(Condition cc,
Result* arg0,
Result* arg1,
Result* arg2,
Hint hint = no_hint);
void Branch(Condition cc,
Result* arg0,
Result* arg1,
Result* arg2,
Result* arg3,
Hint hint = no_hint);
// Bind a jump target. If there is no current frame at the binding
// site, there must be at least one frame reaching via a forward
// jump.
//
// The number of mergable elements is a number of frame elements
// counting from the top down which must be "mergable" (not
// constants or copies) in the entry frame at the jump target.
// Backward jumps to the target must contain the same constants and
// sharing as the entry frame, except for the mergable elements.
//
// A mergable elements argument of kAllElements indicates that all
// frame elements must be mergable. Mergable elements are ignored
// completely for forward-only jump targets.
virtual void Bind(int mergable_elements = kAllElements);
virtual void Bind(Result* arg, int mergable_elements = kAllElements);
void Bind(Result* arg0, Result* arg1, int mergable_elements = kAllElements);
void Bind(Result* arg0,
Result* arg1,
Result* arg2,
int mergable_elements = kAllElements);
void Bind(Result* arg0,
Result* arg1,
Result* arg2,
Result* arg3,
int mergable_elements = kAllElements);
virtual void Bind();
virtual void Bind(Result* arg);
void Bind(Result* arg0, Result* arg1);
// Emit a call to a jump target. There must be a current frame at
// the call. The frame at the target is the same as the current
@ -160,8 +128,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// after the call is the same as the frame before the call.
void Call();
static const int kAllElements = -1; // Not a valid number of elements.
static void set_compiling_deferred_code(bool flag) {
compiling_deferred_code_ = flag;
}
@ -188,7 +154,7 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// return values using the virtual frame.
void DoJump();
void DoBranch(Condition cc, Hint hint);
void DoBind(int mergable_elements);
void DoBind();
private:
static bool compiling_deferred_code_;
@ -202,9 +168,8 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// target.
inline void InitializeEntryElement(int index, FrameElement* target);
// Compute a frame to use for entry to this block. Mergable
// elements is as described for the Bind function.
void ComputeEntryFrame(int mergable_elements);
// Compute a frame to use for entry to this block.
void ComputeEntryFrame();
DISALLOW_COPY_AND_ASSIGN(JumpTarget);
};
@ -251,8 +216,8 @@ class BreakTarget : public JumpTarget {
// Bind a break target. If there is no current frame at the binding
// site, there must be at least one frame reaching via a forward
// jump.
virtual void Bind(int mergable_elements = kAllElements);
virtual void Bind(Result* arg, int mergable_elements = kAllElements);
virtual void Bind();
virtual void Bind(Result* arg);
// Setter for expected height.
void set_expected_height(int expected) { expected_height_ = expected; }

View File

@ -1526,7 +1526,7 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* a,
return NULL;
}
void JumpTarget::DoBind(int a) {
void JumpTarget::DoBind() {
UNIMPLEMENTED();
}