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

Unified Diff: src/x64/macro-assembler-x64.cc

Issue 2685213004: [x64] Use smaller code sequence when pushing SMIs (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 37220c3d26e8d9ef95692a371baf971de0009b96..30ae159aff5568cfaf671bdea8f8082f74831345 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -2465,10 +2465,19 @@ void MacroAssembler::Push(Smi* source) {
intptr_t smi = reinterpret_cast<intptr_t>(source);
if (is_int32(smi)) {
Push(Immediate(static_cast<int32_t>(smi)));
- } else {
- Register constant = GetSmiConstant(source);
- Push(constant);
+ return;
+ }
+ int first_byte_set = base::bits::CountTrailingZeros64(smi) / 8;
+ int last_byte_set = (63 - base::bits::CountLeadingZeros64(smi)) / 8;
+ if (first_byte_set == last_byte_set && kPointerSize == kInt64Size) {
+ // This sequence has only 7 bytes, compared to the 12 bytes below.
+ Push(Immediate(0));
+ movb(Operand(rsp, first_byte_set),
+ Immediate(static_cast<int8_t>(smi >> (8 * first_byte_set))));
+ return;
}
+ Register constant = GetSmiConstant(source);
+ Push(constant);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698