Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: src/virtual-frame-ia32.cc

Issue 10993: Begin using the virtual frame for assignment statements of the form:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/virtual-frame-ia32.h ('K') | « src/virtual-frame-ia32.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/virtual-frame-ia32.cc
===================================================================
--- src/virtual-frame-ia32.cc (revision 861)
+++ src/virtual-frame-ia32.cc (working copy)
@@ -160,7 +160,7 @@
// its external reference count (so that spilling it from the frame frees
// it for use).
int min_count = kMaxInt;
- int best_register_code = no_reg.code();
+ int best_register_code = no_reg.code_;
for (int i = 0; i < RegisterFile::kNumRegisters; i++) {
int count = frame_registers_.count(i);
@@ -170,7 +170,7 @@
}
}
- if (best_register_code != no_reg.code()) {
+ if (best_register_code != no_reg.code_) {
// Spill all occurrences of the register. There are min_count
// occurrences, stop when we've spilled them all to avoid syncing
// elements unnecessarily.
@@ -347,6 +347,35 @@
}
+void VirtualFrame::StoreToFrameSlotAt(int index) {
William Hesse 2008/11/28 10:32:45 So this changelist enables the register and memory
Kevin Millikin (Chromium) 2008/11/28 12:19:08 It is expected to correctly handle constants.
+ // Store the value on top of the frame to the virtual frame slot at a
+ // given index. The value on top of the frame is left in place.
+ ASSERT(index < elements_.length());
+ FrameElement top = elements_[elements_.length() - 1];
+
+ // The virtual frame slot is now of the same type and has the same value
+ // as the frame top.
+ elements_[index] = top;
William Hesse 2008/11/28 10:32:45 Don't we need to unuse elements_[index] if it is a
Kevin Millikin (Chromium) 2008/11/28 12:19:08 Yes. Good catch.
+
+ if (top.is_memory()) {
+ // Emit code to store memory values into the required frame slot.
+ Register tmp = cgen_->allocator()->Allocate();
+ ASSERT(!tmp.is(no_reg));
William Hesse 2008/11/28 10:32:45 Will we actually need error handling code in the f
Kevin Millikin (Chromium) 2008/11/28 12:19:08 We don't have a good way to handle that yet. I'm
+ __ mov(tmp, Top());
+ __ mov(Operand(ebp, fp_relative(index)), tmp);
+ cgen_->allocator()->Unuse(tmp);
+ } else {
+ // We haven't actually written the value to memory.
+ elements_[index].clear_sync();
+
+ if (top.is_register()) {
+ // Establish another frame-internal reference to the register.
+ Use(top.reg());
+ }
+ }
+}
+
+
void VirtualFrame::PushTryHandler(HandlerType type) {
// Grow the expression stack by handler size less two (the return address
// is already pushed by a call instruction, and PushTryHandler from the
@@ -395,19 +424,21 @@
void VirtualFrame::Drop(int count) {
ASSERT(height() >= count);
+ int num_virtual_elements = (elements_.length() - 1) - stack_pointer_;
- // Discard elements above the stack pointer.
- while (count > 0 && stack_pointer_ < elements_.length() - 1) {
- FrameElement last = elements_.RemoveLast();
- if (last.is_register()) {
- Unuse(last.reg());
- }
+ // Emit code to lower the stack pointer if necessary.
+ if (num_virtual_elements < count) {
+ int num_dropped = count - num_virtual_elements;
+ stack_pointer_ -= num_dropped;
+ __ add(Operand(esp), Immediate(num_dropped * kPointerSize));
}
- // Discard the rest of the elements and lower the stack pointer.
- Forget(count);
- if (count > 0) {
- __ add(Operand(esp), Immediate(count * kPointerSize));
+ // Discard elements from the virtual frame and free any registers.
+ for (int i = 0; i < count; i++) {
+ FrameElement dropped = elements_.RemoveLast();
+ if (dropped.is_register()) {
+ Unuse(dropped.reg());
+ }
}
}
@@ -469,6 +500,17 @@
}
+#ifdef DEBUG
+bool VirtualFrame::IsSpilled() {
+ for (int i = 0; i < elements_.length(); i++) {
+ if (!elements_[i].is_memory()) {
+ return false;
+ }
+ }
+ return true;
+}
+#endif
+
#undef __
} } // namespace v8::internal
« src/virtual-frame-ia32.h ('K') | « src/virtual-frame-ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698