OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } else { | 151 } else { |
152 __ push(backing.reg()); | 152 __ push(backing.reg()); |
153 } | 153 } |
154 break; | 154 break; |
155 } | 155 } |
156 } | 156 } |
157 elements_[index].set_sync(); | 157 elements_[index].set_sync(); |
158 } | 158 } |
159 | 159 |
160 | 160 |
| 161 // Clear the dirty bits for the range of elements in |
| 162 // [min(stack_pointer_ + 1,begin), end]. |
| 163 void VirtualFrame::SyncRange(int begin, int end) { |
| 164 ASSERT(begin >= 0); |
| 165 ASSERT(end < elements_.length()); |
| 166 // Sync elements below the range if they have not been materialized |
| 167 // on the stack. |
| 168 int start = Min(begin, stack_pointer_ + 1); |
| 169 |
| 170 // If positive we have to adjust the stack pointer. |
| 171 int delta = end - stack_pointer_; |
| 172 if (delta > 0) { |
| 173 stack_pointer_ = end; |
| 174 __ sub(Operand(esp), Immediate(delta * kPointerSize)); |
| 175 } |
| 176 |
| 177 for (int i = start; i <= end; i++) { |
| 178 if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i); |
| 179 } |
| 180 } |
| 181 |
| 182 |
161 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 183 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
162 Comment cmnt(masm_, "[ Merge frame"); | 184 Comment cmnt(masm_, "[ Merge frame"); |
163 // We should always be merging the code generator's current frame to an | 185 // We should always be merging the code generator's current frame to an |
164 // expected frame. | 186 // expected frame. |
165 ASSERT(cgen_->frame() == this); | 187 ASSERT(cgen_->frame() == this); |
166 | 188 |
167 // Adjust the stack pointer upward (toward the top of the virtual | 189 // Adjust the stack pointer upward (toward the top of the virtual |
168 // frame) if necessary. | 190 // frame) if necessary. |
169 if (stack_pointer_ < expected->stack_pointer_) { | 191 if (stack_pointer_ < expected->stack_pointer_) { |
170 int difference = expected->stack_pointer_ - stack_pointer_; | 192 int difference = expected->stack_pointer_ - stack_pointer_; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 void VirtualFrame::AllocateStackSlots(int count) { | 482 void VirtualFrame::AllocateStackSlots(int count) { |
461 ASSERT(height() == 0); | 483 ASSERT(height() == 0); |
462 local_count_ = count; | 484 local_count_ = count; |
463 | 485 |
464 if (count > 0) { | 486 if (count > 0) { |
465 Comment cmnt(masm_, "[ Allocate space for locals"); | 487 Comment cmnt(masm_, "[ Allocate space for locals"); |
466 // The locals are initialized to a constant (the undefined value), but | 488 // The locals are initialized to a constant (the undefined value), but |
467 // we sync them with the actual frame to allocate space for spilling | 489 // we sync them with the actual frame to allocate space for spilling |
468 // them later. First sync everything above the stack pointer so we can | 490 // them later. First sync everything above the stack pointer so we can |
469 // use pushes to allocate and initialize the locals. | 491 // use pushes to allocate and initialize the locals. |
470 SyncRange(stack_pointer_ + 1, elements_.length()); | 492 SyncRange(stack_pointer_ + 1, elements_.length() - 1); |
471 Handle<Object> undefined = Factory::undefined_value(); | 493 Handle<Object> undefined = Factory::undefined_value(); |
472 FrameElement initial_value = | 494 FrameElement initial_value = |
473 FrameElement::ConstantElement(undefined, FrameElement::SYNCED); | 495 FrameElement::ConstantElement(undefined, FrameElement::SYNCED); |
474 Result temp = cgen_->allocator()->Allocate(); | 496 Result temp = cgen_->allocator()->Allocate(); |
475 ASSERT(temp.is_valid()); | 497 ASSERT(temp.is_valid()); |
476 __ Set(temp.reg(), Immediate(undefined)); | 498 __ Set(temp.reg(), Immediate(undefined)); |
477 for (int i = 0; i < count; i++) { | 499 for (int i = 0; i < count; i++) { |
478 elements_.Add(initial_value); | 500 elements_.Add(initial_value); |
479 stack_pointer_++; | 501 stack_pointer_++; |
480 __ push(temp.reg()); | 502 __ push(temp.reg()); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 ASSERT(stack_pointer_ == elements_.length() - 1); | 1053 ASSERT(stack_pointer_ == elements_.length() - 1); |
1032 elements_.Add(FrameElement::MemoryElement()); | 1054 elements_.Add(FrameElement::MemoryElement()); |
1033 stack_pointer_++; | 1055 stack_pointer_++; |
1034 __ push(immediate); | 1056 __ push(immediate); |
1035 } | 1057 } |
1036 | 1058 |
1037 | 1059 |
1038 #undef __ | 1060 #undef __ |
1039 | 1061 |
1040 } } // namespace v8::internal | 1062 } } // namespace v8::internal |
OLD | NEW |