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

Side by Side Diff: src/x64/assembler-x64.cc

Issue 6824074: X64: Tweak code generation slightly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments. Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 __ j(not_zero, &cpuid); 92 __ j(not_zero, &cpuid);
93 93
94 // CPUID not supported. Clear the supported features in rax. 94 // CPUID not supported. Clear the supported features in rax.
95 __ xor_(rax, rax); 95 __ xor_(rax, rax);
96 __ jmp(&done); 96 __ jmp(&done);
97 97
98 // Invoke CPUID with 1 in eax to get feature information in 98 // Invoke CPUID with 1 in eax to get feature information in
99 // ecx:edx. Temporarily enable CPUID support because we know it's 99 // ecx:edx. Temporarily enable CPUID support because we know it's
100 // safe here. 100 // safe here.
101 __ bind(&cpuid); 101 __ bind(&cpuid);
102 __ movq(rax, Immediate(1)); 102 __ movl(rax, Immediate(1));
103 supported_ = kDefaultCpuFeatures | (1 << CPUID); 103 supported_ = kDefaultCpuFeatures | (1 << CPUID);
104 { Scope fscope(CPUID); 104 { Scope fscope(CPUID);
105 __ cpuid(); 105 __ cpuid();
106 // Move the result from ecx:edx to rdi. 106 // Move the result from ecx:edx to rdi.
107 __ movl(rdi, rdx); // Zero-extended to 64 bits. 107 __ movl(rdi, rdx); // Zero-extended to 64 bits.
108 __ shl(rcx, Immediate(32)); 108 __ shl(rcx, Immediate(32));
109 __ or_(rdi, rcx); 109 __ or_(rdi, rcx);
110 110
111 // Get the sahf supported flag, from CPUID(0x80000001) 111 // Get the sahf supported flag, from CPUID(0x80000001)
112 __ movq(rax, 0x80000001, RelocInfo::NONE); 112 __ movq(rax, 0x80000001, RelocInfo::NONE);
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1391
1392 1392
1393 void Assembler::leave() { 1393 void Assembler::leave() {
1394 EnsureSpace ensure_space(this); 1394 EnsureSpace ensure_space(this);
1395 emit(0xC9); 1395 emit(0xC9);
1396 } 1396 }
1397 1397
1398 1398
1399 void Assembler::movb(Register dst, const Operand& src) { 1399 void Assembler::movb(Register dst, const Operand& src) {
1400 EnsureSpace ensure_space(this); 1400 EnsureSpace ensure_space(this);
1401 emit_rex_32(dst, src); 1401 if (dst.code() > 3) {
1402 // Register is not one of al, bl, cl, dl. Its encoding needs REX.
1403 emit_rex_32(dst, src);
1404 } else {
1405 emit_optional_rex_32(dst, src);
1406 }
1402 emit(0x8A); 1407 emit(0x8A);
1403 emit_operand(dst, src); 1408 emit_operand(dst, src);
1404 } 1409 }
1405 1410
1406 1411
1407 void Assembler::movb(Register dst, Immediate imm) { 1412 void Assembler::movb(Register dst, Immediate imm) {
1408 EnsureSpace ensure_space(this); 1413 EnsureSpace ensure_space(this);
1409 emit_rex_32(dst); 1414 if (dst.code() > 3) {
1410 emit(0xC6); 1415 emit_rex_32(dst);
1411 emit_modrm(0x0, dst); 1416 }
1417 emit(0xB0 + dst.low_bits());
1412 emit(imm.value_); 1418 emit(imm.value_);
1413 } 1419 }
1414 1420
1415 1421
1416 void Assembler::movb(const Operand& dst, Register src) { 1422 void Assembler::movb(const Operand& dst, Register src) {
1417 EnsureSpace ensure_space(this); 1423 EnsureSpace ensure_space(this);
1418 emit_rex_32(src, dst); 1424 if (src.code() > 3) {
1425 emit_rex_32(src, dst);
1426 } else {
1427 emit_optional_rex_32(src, dst);
1428 }
1419 emit(0x88); 1429 emit(0x88);
1420 emit_operand(src, dst); 1430 emit_operand(src, dst);
1421 } 1431 }
1422 1432
1423 1433
1424 void Assembler::movw(const Operand& dst, Register src) { 1434 void Assembler::movw(const Operand& dst, Register src) {
1425 EnsureSpace ensure_space(this); 1435 EnsureSpace ensure_space(this);
1426 emit(0x66); 1436 emit(0x66);
1427 emit_optional_rex_32(src, dst); 1437 emit_optional_rex_32(src, dst);
1428 emit(0x89); 1438 emit(0x89);
(...skipping 29 matching lines...) Expand all
1458 emit(0x89); 1468 emit(0x89);
1459 emit_operand(src, dst); 1469 emit_operand(src, dst);
1460 } 1470 }
1461 1471
1462 1472
1463 void Assembler::movl(const Operand& dst, Immediate value) { 1473 void Assembler::movl(const Operand& dst, Immediate value) {
1464 EnsureSpace ensure_space(this); 1474 EnsureSpace ensure_space(this);
1465 emit_optional_rex_32(dst); 1475 emit_optional_rex_32(dst);
1466 emit(0xC7); 1476 emit(0xC7);
1467 emit_operand(0x0, dst); 1477 emit_operand(0x0, dst);
1468 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. 1478 emit(value);
1469 } 1479 }
1470 1480
1471 1481
1472 void Assembler::movl(Register dst, Immediate value) { 1482 void Assembler::movl(Register dst, Immediate value) {
1473 EnsureSpace ensure_space(this); 1483 EnsureSpace ensure_space(this);
1474 emit_optional_rex_32(dst); 1484 emit_optional_rex_32(dst);
1475 emit(0xC7); 1485 emit(0xB8 + dst.low_bits());
1476 emit_modrm(0x0, dst); 1486 emit(value);
1477 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates.
1478 } 1487 }
1479 1488
1480 1489
1481 void Assembler::movq(Register dst, const Operand& src) { 1490 void Assembler::movq(Register dst, const Operand& src) {
1482 EnsureSpace ensure_space(this); 1491 EnsureSpace ensure_space(this);
1483 emit_rex_64(dst, src); 1492 emit_rex_64(dst, src);
1484 emit(0x8B); 1493 emit(0x8B);
1485 emit_operand(dst, src); 1494 emit_operand(dst, src);
1486 } 1495 }
1487 1496
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 // specially coded on x64 means that it is a relative 32 bit address, as used 2954 // specially coded on x64 means that it is a relative 32 bit address, as used
2946 // by branch instructions. 2955 // by branch instructions.
2947 return (1 << rmode_) & kApplyMask; 2956 return (1 << rmode_) & kApplyMask;
2948 } 2957 }
2949 2958
2950 2959
2951 2960
2952 } } // namespace v8::internal 2961 } } // namespace v8::internal
2953 2962
2954 #endif // V8_TARGET_ARCH_X64 2963 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698