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
parent f706cfa3
...@@ -149,7 +149,7 @@ void JumpTarget::Call() { ...@@ -149,7 +149,7 @@ void JumpTarget::Call() {
} }
void JumpTarget::DoBind(int mergable_elements) { void JumpTarget::DoBind() {
ASSERT(!is_bound()); ASSERT(!is_bound());
// Live non-frame registers are not allowed at the start of a basic // Live non-frame registers are not allowed at the start of a basic
...@@ -207,7 +207,7 @@ void JumpTarget::DoBind(int mergable_elements) { ...@@ -207,7 +207,7 @@ void JumpTarget::DoBind(int mergable_elements) {
// Compute the frame to use for entry to the block. // Compute the frame to use for entry to the block.
if (entry_frame_ == NULL) { if (entry_frame_ == NULL) {
ComputeEntryFrame(mergable_elements); ComputeEntryFrame();
} }
// Some moves required to merge to an expected frame require purely // Some moves required to merge to an expected frame require purely
......
...@@ -317,9 +317,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) { ...@@ -317,9 +317,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
if (function_return_.is_bound()) { if (function_return_.is_bound()) {
function_return_.Jump(&undefined); function_return_.Jump(&undefined);
} else { } else {
// Though this is a (possibly) backward block, the frames function_return_.Bind(&undefined);
// can only differ on their top element.
function_return_.Bind(&undefined, 1);
GenerateReturnSequence(&undefined); GenerateReturnSequence(&undefined);
} }
} else if (function_return_.is_linked()) { } else if (function_return_.is_linked()) {
...@@ -329,9 +327,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) { ...@@ -329,9 +327,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
// compile an artificial return statement just above, and (b) there // compile an artificial return statement just above, and (b) there
// are return statements in the body but (c) they are all shadowed. // are return statements in the body but (c) they are all shadowed.
Result return_value; Result return_value;
// Though this is a (possibly) backward block, the frames can function_return_.Bind(&return_value);
// only differ on their top element.
function_return_.Bind(&return_value, 1);
GenerateReturnSequence(&return_value); GenerateReturnSequence(&return_value);
} }
} }
...@@ -2328,9 +2324,7 @@ void CodeGenerator::VisitReturnStatement(ReturnStatement* node) { ...@@ -2328,9 +2324,7 @@ void CodeGenerator::VisitReturnStatement(ReturnStatement* node) {
// code by jumping to the return site. // code by jumping to the return site.
function_return_.Jump(&return_value); function_return_.Jump(&return_value);
} else { } else {
// Though this is a (possibly) backward block, the frames can function_return_.Bind(&return_value);
// only differ on their top element.
function_return_.Bind(&return_value, 1);
GenerateReturnSequence(&return_value); GenerateReturnSequence(&return_value);
} }
} }
......
...@@ -164,7 +164,7 @@ void JumpTarget::Call() { ...@@ -164,7 +164,7 @@ void JumpTarget::Call() {
} }
void JumpTarget::DoBind(int mergable_elements) { void JumpTarget::DoBind() {
ASSERT(cgen() != NULL); ASSERT(cgen() != NULL);
ASSERT(!is_bound()); ASSERT(!is_bound());
...@@ -210,7 +210,7 @@ void JumpTarget::DoBind(int mergable_elements) { ...@@ -210,7 +210,7 @@ void JumpTarget::DoBind(int mergable_elements) {
// Fast case: no forward jumps, possible backward ones. Remove // Fast case: no forward jumps, possible backward ones. Remove
// constants and copies above the watermark on the fall-through // constants and copies above the watermark on the fall-through
// frame and use it as the entry frame. // frame and use it as the entry frame.
cgen()->frame()->MakeMergable(mergable_elements); cgen()->frame()->MakeMergable();
entry_frame_ = new VirtualFrame(cgen()->frame()); entry_frame_ = new VirtualFrame(cgen()->frame());
} }
__ bind(&entry_label_); __ bind(&entry_label_);
...@@ -252,7 +252,7 @@ void JumpTarget::DoBind(int mergable_elements) { ...@@ -252,7 +252,7 @@ void JumpTarget::DoBind(int mergable_elements) {
} }
// Compute the frame to use for entry to the block. // 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 // Some moves required to merge to an expected frame require purely
// frame state changes, and do not require any code generation. // frame state changes, and do not require any code generation.
......
...@@ -174,14 +174,8 @@ void VirtualFrame::SyncRange(int begin, int end) { ...@@ -174,14 +174,8 @@ void VirtualFrame::SyncRange(int begin, int end) {
} }
void VirtualFrame::MakeMergable(int mergable_elements) { void VirtualFrame::MakeMergable() {
if (mergable_elements == JumpTarget::kAllElements) { for (int i = 0; i < element_count(); i++) {
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++) {
FrameElement element = elements_[i]; FrameElement element = elements_[i];
if (element.is_constant() || element.is_copy()) { if (element.is_constant() || element.is_copy()) {
......
...@@ -153,11 +153,8 @@ class VirtualFrame : public ZoneObject { ...@@ -153,11 +153,8 @@ class VirtualFrame : public ZoneObject {
void SyncRange(int begin, int end); void SyncRange(int begin, int end);
// Make this frame so that an arbitrary frame of the same height can // Make this frame so that an arbitrary frame of the same height can
// be merged to it. Copies and constants are removed from the // be merged to it. Copies and constants are removed from the frame.
// topmost mergable_elements elements of the frame. A void MakeMergable();
// mergable_elements of JumpTarget::kAllElements indicates constants
// and copies are should be removed from the entire frame.
void MakeMergable(int mergable_elements);
// Prepare this virtual frame for merging to an expected frame by // Prepare this virtual frame for merging to an expected frame by
// performing some state changes that do not require generating // performing some state changes that do not require generating
......
...@@ -48,7 +48,7 @@ void JumpTarget::Unuse() { ...@@ -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 // Given: a collection of frames reaching by forward CFG edges and
// the directionality of the block. Compute: an entry frame for the // the directionality of the block. Compute: an entry frame for the
// block. // block.
...@@ -77,14 +77,6 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) { ...@@ -77,14 +77,6 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
int length = initial_frame->element_count(); int length = initial_frame->element_count();
ZoneList<FrameElement*> elements(length); 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 // Initially populate the list of elements based on the initial
// frame. // frame.
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
...@@ -92,7 +84,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) { ...@@ -92,7 +84,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
// We do not allow copies or constants in bidirectional frames. All // We do not allow copies or constants in bidirectional frames. All
// elements above the water mark on bidirectional frames have // elements above the water mark on bidirectional frames have
// unknown static types. // unknown static types.
if (direction_ == BIDIRECTIONAL && i > high_water_mark) { if (direction_ == BIDIRECTIONAL) {
if (element.is_constant() || element.is_copy()) { if (element.is_constant() || element.is_copy()) {
elements.Add(NULL); elements.Add(NULL);
continue; continue;
...@@ -158,7 +150,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) { ...@@ -158,7 +150,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) {
int best_reg_num = RegisterAllocator::kInvalidRegister; int best_reg_num = RegisterAllocator::kInvalidRegister;
StaticType type; // Initially invalid. StaticType type; // Initially invalid.
if (direction_ != BIDIRECTIONAL || i < high_water_mark) { if (direction_ != BIDIRECTIONAL) {
type = reaching_frames_[0]->elements_[i].static_type(); type = reaching_frames_[0]->elements_[i].static_type();
} }
...@@ -241,25 +233,6 @@ void JumpTarget::Jump(Result* arg) { ...@@ -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) { void JumpTarget::Branch(Condition cc, Hint hint) {
DoBranch(cc, hint); DoBranch(cc, hint);
} }
...@@ -314,65 +287,6 @@ void JumpTarget::Branch(Condition cc, Result* arg0, Result* arg1, Hint 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) { void BreakTarget::Branch(Condition cc, Result* arg, Hint hint) {
ASSERT(cgen()->has_valid_frame()); ASSERT(cgen()->has_valid_frame());
...@@ -400,61 +314,26 @@ void BreakTarget::Branch(Condition cc, Result* arg, Hint hint) { ...@@ -400,61 +314,26 @@ void BreakTarget::Branch(Condition cc, Result* arg, Hint hint) {
#undef ASSERT_ARGCHECK #undef ASSERT_ARGCHECK
void JumpTarget::Bind(int mergable_elements) { void JumpTarget::Bind() {
DoBind(mergable_elements); DoBind();
} }
void JumpTarget::Bind(Result* arg, int mergable_elements) { void JumpTarget::Bind(Result* arg) {
if (cgen()->has_valid_frame()) { if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg); cgen()->frame()->Push(arg);
} }
DoBind(mergable_elements); DoBind();
*arg = cgen()->frame()->Pop(); *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()) { if (cgen()->has_valid_frame()) {
cgen()->frame()->Push(arg0); cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1); cgen()->frame()->Push(arg1);
cgen()->frame()->Push(arg2);
cgen()->frame()->Push(arg3);
} }
DoBind(mergable_elements); DoBind();
*arg3 = cgen()->frame()->Pop();
*arg2 = cgen()->frame()->Pop();
*arg1 = cgen()->frame()->Pop(); *arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop(); *arg0 = cgen()->frame()->Pop();
} }
...@@ -531,7 +410,7 @@ void BreakTarget::Branch(Condition cc, Hint hint) { ...@@ -531,7 +410,7 @@ void BreakTarget::Branch(Condition cc, Hint hint) {
} }
void BreakTarget::Bind(int mergable_elements) { void BreakTarget::Bind() {
#ifdef DEBUG #ifdef DEBUG
// All the forward-reaching frames should have been adjusted at the // All the forward-reaching frames should have been adjusted at the
// jumps to this target. // jumps to this target.
...@@ -547,11 +426,11 @@ void BreakTarget::Bind(int mergable_elements) { ...@@ -547,11 +426,11 @@ void BreakTarget::Bind(int mergable_elements) {
int count = cgen()->frame()->height() - expected_height_; int count = cgen()->frame()->height() - expected_height_;
cgen()->frame()->ForgetElements(count); cgen()->frame()->ForgetElements(count);
} }
DoBind(mergable_elements); DoBind();
} }
void BreakTarget::Bind(Result* arg, int mergable_elements) { void BreakTarget::Bind(Result* arg) {
#ifdef DEBUG #ifdef DEBUG
// All the forward-reaching frames should have been adjusted at the // All the forward-reaching frames should have been adjusted at the
// jumps to this target. // jumps to this target.
...@@ -568,7 +447,7 @@ void BreakTarget::Bind(Result* arg, int mergable_elements) { ...@@ -568,7 +447,7 @@ void BreakTarget::Bind(Result* arg, int mergable_elements) {
cgen()->frame()->ForgetElements(count); cgen()->frame()->ForgetElements(count);
cgen()->frame()->Push(arg); cgen()->frame()->Push(arg);
} }
DoBind(mergable_elements); DoBind();
*arg = cgen()->frame()->Pop(); *arg = cgen()->frame()->Pop();
} }
......
...@@ -107,8 +107,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -107,8 +107,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// jump and there will be no current frame after the jump. // jump and there will be no current frame after the jump.
virtual void Jump(); virtual void Jump();
virtual void Jump(Result* arg); 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 // Emit a conditional branch to the target. There must be a current
// frame at the branch. The current frame will fall through to the // frame at the branch. The current frame will fall through to the
...@@ -116,43 +114,13 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -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, Hint hint = no_hint);
virtual void Branch(Condition cc, Result* arg, 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, 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 // 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 // site, there must be at least one frame reaching via a forward
// jump. // jump.
// virtual void Bind();
// The number of mergable elements is a number of frame elements virtual void Bind(Result* arg);
// counting from the top down which must be "mergable" (not void Bind(Result* arg0, Result* arg1);
// 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);
// Emit a call to a jump target. There must be a current frame at // 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 // 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. ...@@ -160,8 +128,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// after the call is the same as the frame before the call. // after the call is the same as the frame before the call.
void Call(); void Call();
static const int kAllElements = -1; // Not a valid number of elements.
static void set_compiling_deferred_code(bool flag) { static void set_compiling_deferred_code(bool flag) {
compiling_deferred_code_ = flag; compiling_deferred_code_ = flag;
} }
...@@ -188,7 +154,7 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -188,7 +154,7 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// return values using the virtual frame. // return values using the virtual frame.
void DoJump(); void DoJump();
void DoBranch(Condition cc, Hint hint); void DoBranch(Condition cc, Hint hint);
void DoBind(int mergable_elements); void DoBind();
private: private:
static bool compiling_deferred_code_; static bool compiling_deferred_code_;
...@@ -202,9 +168,8 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -202,9 +168,8 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// target. // target.
inline void InitializeEntryElement(int index, FrameElement* target); inline void InitializeEntryElement(int index, FrameElement* target);
// Compute a frame to use for entry to this block. Mergable // Compute a frame to use for entry to this block.
// elements is as described for the Bind function. void ComputeEntryFrame();
void ComputeEntryFrame(int mergable_elements);
DISALLOW_COPY_AND_ASSIGN(JumpTarget); DISALLOW_COPY_AND_ASSIGN(JumpTarget);
}; };
...@@ -251,8 +216,8 @@ class BreakTarget : public JumpTarget { ...@@ -251,8 +216,8 @@ class BreakTarget : public JumpTarget {
// Bind a break target. If there is no current frame at the binding // 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 // site, there must be at least one frame reaching via a forward
// jump. // jump.
virtual void Bind(int mergable_elements = kAllElements); virtual void Bind();
virtual void Bind(Result* arg, int mergable_elements = kAllElements); virtual void Bind(Result* arg);
// Setter for expected height. // Setter for expected height.
void set_expected_height(int expected) { expected_height_ = expected; } void set_expected_height(int expected) { expected_height_ = expected; }
......
...@@ -1526,7 +1526,7 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* a, ...@@ -1526,7 +1526,7 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* a,
return NULL; return NULL;
} }
void JumpTarget::DoBind(int a) { void JumpTarget::DoBind() {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
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