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

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

Issue 2815028: X64: Remove more fpu code. Unroll more local initialization loops. (Closed)
Patch Set: Addressed review comments. Created 10 years, 6 months 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
« no previous file with comments | « src/x64/virtual-frame-x64.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/virtual-frame-x64.cc
diff --git a/src/x64/virtual-frame-x64.cc b/src/x64/virtual-frame-x64.cc
index e65378dc074e8ed554e7a04d9a7cf6ee2c5fd187..f5e17fd18f5d312dbf7bc80e8c963426987bff43 100644
--- a/src/x64/virtual-frame-x64.cc
+++ b/src/x64/virtual-frame-x64.cc
@@ -115,25 +115,45 @@ void VirtualFrame::AllocateStackSlots() {
Handle<Object> undefined = Factory::undefined_value();
FrameElement initial_value =
FrameElement::ConstantElement(undefined, FrameElement::SYNCED);
- if (count == 1) {
- __ Push(undefined);
- } else if (count < kLocalVarBound) {
- // For less locals the unrolled loop is more compact.
- __ movq(kScratchRegister, undefined, RelocInfo::EMBEDDED_OBJECT);
+ if (count < kLocalVarBound) {
+ // For fewer locals the unrolled loop is more compact.
+
+ // Hope for one of the first eight registers, where the push operation
+ // takes only one byte (kScratchRegister needs the REX.W bit).
+ Result tmp = cgen()->allocator()->Allocate();
+ ASSERT(tmp.is_valid());
+ __ movq(tmp.reg(), undefined, RelocInfo::EMBEDDED_OBJECT);
for (int i = 0; i < count; i++) {
- __ push(kScratchRegister);
+ __ push(tmp.reg());
}
} else {
// For more locals a loop in generated code is more compact.
Label alloc_locals_loop;
Result cnt = cgen()->allocator()->Allocate();
ASSERT(cnt.is_valid());
- __ movq(cnt.reg(), Immediate(count));
__ movq(kScratchRegister, undefined, RelocInfo::EMBEDDED_OBJECT);
+#ifdef DEBUG
+ Label loop_size;
+ __ bind(&loop_size);
+#endif
+ if (is_uint8(count)) {
+ // Loading imm8 is shorter than loading imm32.
+ // Loading only partial byte register, and using decb below.
+ __ movb(cnt.reg(), Immediate(count));
+ } else {
+ __ movl(cnt.reg(), Immediate(count));
+ }
__ bind(&alloc_locals_loop);
__ push(kScratchRegister);
- __ decl(cnt.reg());
+ if (is_uint8(count)) {
+ __ decb(cnt.reg());
+ } else {
+ __ decl(cnt.reg());
+ }
__ j(not_zero, &alloc_locals_loop);
+#ifdef DEBUG
+ CHECK(masm()->SizeOfCodeGeneratedSince(&loop_size) < kLocalVarBound);
+#endif
}
for (int i = 0; i < count; i++) {
elements_.Add(initial_value);
« no previous file with comments | « src/x64/virtual-frame-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698