42
42
VirtualFrame::VirtualFrame(InvalidVirtualFrameInitializer* dummy)
43
43
: element_count_(0),
44
44
top_of_stack_state_(NO_TOS_REGISTERS),
45
register_allocation_map_(0) { }
45
register_allocation_map_(0),
46
tos_known_smi_map_(0) { }
48
49
// On entry to a function, the virtual frame already contains the receiver,
50
51
VirtualFrame::VirtualFrame()
51
52
: element_count_(parameter_count() + 2),
52
53
top_of_stack_state_(NO_TOS_REGISTERS),
53
register_allocation_map_(0) { }
54
register_allocation_map_(0),
55
tos_known_smi_map_(0) { }
56
58
// When cloned, a frame is a deep copy of the original.
57
59
VirtualFrame::VirtualFrame(VirtualFrame* original)
58
60
: element_count_(original->element_count()),
59
61
top_of_stack_state_(original->top_of_stack_state_),
60
register_allocation_map_(original->register_allocation_map_) { }
63
bool VirtualFrame::Equals(VirtualFrame* other) {
62
register_allocation_map_(original->register_allocation_map_),
63
tos_known_smi_map_(0) { }
66
bool VirtualFrame::Equals(const VirtualFrame* other) {
64
67
ASSERT(element_count() == other->element_count());
65
68
if (top_of_stack_state_ != other->top_of_stack_state_) return false;
66
69
if (register_allocation_map_ != other->register_allocation_map_) return false;
70
if (tos_known_smi_map_ != other->tos_known_smi_map_) return false;
72
76
void VirtualFrame::PrepareForReturn() {
77
// Don't bother flushing tos registers as returning does not require more
78
// access to the expression stack.
79
top_of_stack_state_ = NO_TOS_REGISTERS;
102
CodeGenerator* VirtualFrame::cgen() { return CodeGeneratorScope::Current(); }
108
CodeGenerator* VirtualFrame::cgen() const {
109
return CodeGeneratorScope::Current();
105
113
MacroAssembler* VirtualFrame::masm() { return cgen()->masm(); }
115
int VirtualFrame::parameter_count() {
123
int VirtualFrame::parameter_count() const {
116
124
return cgen()->scope()->num_parameters();
120
int VirtualFrame::local_count() { return cgen()->scope()->num_stack_slots(); }
123
int VirtualFrame::frame_pointer() { return parameter_count() + 3; }
128
int VirtualFrame::local_count() const {
129
return cgen()->scope()->num_stack_slots();
133
int VirtualFrame::frame_pointer() const { return parameter_count() + 3; }
126
136
int VirtualFrame::context_index() { return frame_pointer() - 1; }
129
139
int VirtualFrame::function_index() { return frame_pointer() - 2; }
132
int VirtualFrame::local0_index() { return frame_pointer() + 2; }
142
int VirtualFrame::local0_index() const { return frame_pointer() + 2; }
135
145
int VirtualFrame::fp_relative(int index) {
142
int VirtualFrame::expression_base_index() {
152
int VirtualFrame::expression_base_index() const {
143
153
return local0_index() + local_count();
147
int VirtualFrame::height() {
157
int VirtualFrame::height() const {
148
158
return element_count() - expression_base_index();