}
-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
// 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
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()) {
// 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);
}
}
// 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);
}
}
}
-void JumpTarget::DoBind(int mergable_elements) {
+void JumpTarget::DoBind() {
ASSERT(cgen() != NULL);
ASSERT(!is_bound());
// 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_);
}
// 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.
}
-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()) {
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
}
-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.
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++) {
// 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;
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();
}
}
-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);
}
}
-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());
#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) {
- 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) {
+void JumpTarget::Bind(Result* arg0, Result* arg1) {
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();
}
}
-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.
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.
cgen()->frame()->ForgetElements(count);
cgen()->frame()->Push(arg);
}
- DoBind(mergable_elements);
+ DoBind();
*arg = cgen()->frame()->Pop();
}
// 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
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
// 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;
}
// 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_;
// 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);
};
// 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; }
return NULL;
}
-void JumpTarget::DoBind(int a) {
+void JumpTarget::DoBind() {
UNIMPLEMENTED();
}