Reviewers: William Hesse,

Description:
Added command line flag --sync_with_push (default: true) to
emit 'push' instead of 'sub esp, xxx' followed by 'mov' instructions
Reduces generated code size by 10-15% on several benchmarks.
Done on ia32 and x64 (no sync operation in the virtual frame on ARM
architecture)


Please review this at http://codereview.chromium.org/259058

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/flag-definitions.h
   M     src/ia32/virtual-frame-ia32.cc
   M     src/x64/virtual-frame-x64.cc


Index: src/ia32/virtual-frame-ia32.cc
===================================================================
--- src/ia32/virtual-frame-ia32.cc      (revision 3020)
+++ src/ia32/virtual-frame-ia32.cc      (working copy)
@@ -161,15 +161,29 @@
    // on the stack.
    int start = Min(begin, stack_pointer_ + 1);

-  // If positive we have to adjust the stack pointer.
-  int delta = end - stack_pointer_;
-  if (delta > 0) {
-    stack_pointer_ = end;
-    __ sub(Operand(esp), Immediate(delta * kPointerSize));
-  }
+  if (FLAG_sync_with_push) {
+    // emit normal 'push' insts
+    for (int i = start; i <= end; i++) {
+      if (!elements_[i].is_synced()) {
+        if (i <= stack_pointer_) {
+          SyncElementBelowStackPointer(i);
+        } else {
+          SyncElementByPushing(i);
+        }
+      }
+    }
+  } else {
+    // Emit 'sub' followed by 'mov' insts
+    // If positive we have to adjust the stack pointer.
+    int delta = end - stack_pointer_;
+    if (delta > 0) {
+      stack_pointer_ = end;
+      __ sub(Operand(esp), Immediate(delta * kPointerSize));
+    }

-  for (int i = start; i <= end; i++) {
-    if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i);
+    for (int i = start; i <= end; i++) {
+      if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i);
+    }
    }
  }

Index: src/flag-definitions.h
===================================================================
--- src/flag-definitions.h      (revision 3020)
+++ src/flag-definitions.h      (working copy)
@@ -208,6 +208,9 @@
  DEFINE_bool(preemption, false,
              "activate a 100ms timer that switches between V8 threads")

+// virtual-frame-ia32.cc
+DEFINE_bool(sync_with_push, true, "do SyncRange with push instead of  
sub+mov")
+
  // Regexp
  DEFINE_bool(trace_regexps, false, "trace regexp execution")
  DEFINE_bool(regexp_optimization, true, "generate optimized regexp code")
Index: src/x64/virtual-frame-x64.cc
===================================================================
--- src/x64/virtual-frame-x64.cc        (revision 3020)
+++ src/x64/virtual-frame-x64.cc        (working copy)
@@ -883,15 +883,29 @@
    // on the stack.
    int start = Min(begin, stack_pointer_ + 1);

-  // If positive we have to adjust the stack pointer.
-  int delta = end - stack_pointer_;
-  if (delta > 0) {
-    stack_pointer_ = end;
-    __ subq(rsp, Immediate(delta * kPointerSize));
-  }
+  if (FLAG_sync_with_push) {
+    // emit normal 'push' insts
+    for (int i = start; i <= end; i++) {
+      if (!elements_[i].is_synced()) {
+        if (i <= stack_pointer_) {
+          SyncElementBelowStackPointer(i);
+        } else {
+          SyncElementByPushing(i);
+        }
+      }
+    }
+  } else {
+    // Emit 'sub' followed by 'mov' insts
+    // If positive we have to adjust the stack pointer.
+    int delta = end - stack_pointer_;
+    if (delta > 0) {
+      stack_pointer_ = end;
+      __ subq(rsp, Immediate(delta * kPointerSize));
+    }

-  for (int i = start; i <= end; i++) {
-    if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i);
+    for (int i = start; i <= end; i++) {
+      if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i);
+    }
    }
  }




--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to