Reviewers: Yang,
Message:
This fixes a shortcut I took with my OSR changes where I disabled dynamic
frame
alignment for OSR functions. The performance difference is extremely
slight--slight enough that Golem can't reliably detect it. However, local
experiments show that the fixing the dynamic alignment improves performance
ever-so-slightly.
Description:
Dynamically align OSR frames on ia32.
BUG=
Please review this at https://codereview.chromium.org/23619076/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+79, -5 lines):
M src/ia32/lithium-codegen-ia32.cc
A + test/mjsunit/compiler/osr-alignment.js
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc
b/src/ia32/lithium-codegen-ia32.cc
index
06628ffd81c334a85e992e72308fef4106825918..c37d4cca51edd3b17b28cd31488d8ac98332a00c
100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -340,12 +340,44 @@ void LCodeGen::GenerateOsrPrologue() {
osr_pc_offset_ = masm()->pc_offset();
+ // Move state of dynamic frame alignment into edx.
+ __ mov(edx, Immediate(kNoAlignmentPadding));
+
+ if (support_aligned_spilled_doubles_ && dynamic_frame_alignment_) {
+ __ mov(ebx, ebp);
+ __ add(Operand(ebx), Immediate(kPointerSize));
+
+ Label do_not_pad, align_loop;
+ // Align ebp + 4 to a multiple of 2 * kPointerSize.
+ __ test(ebx, Immediate(kPointerSize));
+ __ j(not_zero, &do_not_pad, Label::kNear);
+ __ push(Immediate(0));
+ __ mov(ebx, esp);
+ __ mov(edx, Immediate(kAlignmentPaddingPushed));
+
+ // Move all parts of the frame over one word. The frame consists of:
+ // unoptimized frame slots, alignment state, context, frame pointer,
return
+ // address, receiver, and the arguments.
+ __ mov(ecx, Immediate(scope()->num_parameters() +
+ 5 + graph()->osr()->UnoptimizedFrameSlots()));
+
+ __ bind(&align_loop);
+ __ mov(eax, Operand(ebx, 1 * kPointerSize));
+ __ mov(Operand(ebx, 0), eax);
+ __ add(Operand(ebx), Immediate(kPointerSize));
+ __ dec(ecx);
+ __ j(not_zero, &align_loop, Label::kNear);
+ __ mov(Operand(ebx, 0), Immediate(kAlignmentZapValue));
+ __ sub(Operand(ebp), Immediate(kPointerSize));
+ __ bind(&do_not_pad);
+ }
+
// Save the first local, which is overwritten by the alignment state.
Operand alignment_loc = MemOperand(ebp, -3 * kPointerSize);
__ push(alignment_loc);
- // Set the dynamic frame alignment state to "not aligned".
- __ mov(alignment_loc, Immediate(kNoAlignmentPadding));
+ // Set the dynamic frame alignment state.
+ __ mov(alignment_loc, edx);
// Adjust the frame size, subsuming the unoptimized frame into the
// optimized frame.
Index: test/mjsunit/compiler/osr-alignment.js
diff --git a/test/mjsunit/compiler/osr-simple.js
b/test/mjsunit/compiler/osr-alignment.js
similarity index 71%
copy from test/mjsunit/compiler/osr-simple.js
copy to test/mjsunit/compiler/osr-alignment.js
index
8ec1b2b9368c1670209cd4810968a20a2946b4b4..30d72d0614bd0de698029ca55848c39ae3125417
100644
--- a/test/mjsunit/compiler/osr-simple.js
+++ b/test/mjsunit/compiler/osr-alignment.js
@@ -27,7 +27,7 @@
// Flags: --use-osr
-function f() {
+function f1() {
var sum = 0;
for (var i = 0; i < 1000000; i++) {
var x = i + 2;
@@ -38,7 +38,49 @@ function f() {
return sum;
}
+function f2() {
+ var sum = 0;
+ for (var i = 0; i < 1000000; i++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ return sum;
+}
-for (var i = 0; i < 2; i++) {
- assertEquals(500009500000, f());
+function f3() {
+ var sum = 0;
+ for (var i = 0; i < 1000000; i++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ return sum;
}
+
+function test1() {
+ var j = 11;
+ for (var i = 0; i < 2; i++) {
+ assertEquals(500009500000, f1());
+ }
+}
+
+function test2() {
+ for (var i = 0; i < 2; i++) {
+ var j = 11, k = 12;
+ assertEquals(500009500000, f2());
+ }
+}
+
+function test3() {
+ for (var i = 0; i < 2; i++) {
+ var j = 11, k = 13, m = 14;
+ assertEquals(500009500000, f3());
+ }
+}
+
+test1();
+test2();
+test3();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.