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

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

Issue 39543003: Refactor loading a pointer and loading an integer64 into a register instructions for X64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make movq(Register, int64_t) an assembler instruction for 64-bit integer only" Created 7 years, 1 month 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 | « src/x64/assembler-x64.h ('k') | src/x64/code-stubs-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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 emit_rex_64(src, dst); 1449 emit_rex_64(src, dst);
1450 emit(0x89); 1450 emit(0x89);
1451 emit_operand(src, dst); 1451 emit_operand(src, dst);
1452 } 1452 }
1453 1453
1454 1454
1455 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { 1455 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) {
1456 // This method must not be used with heap object references. The stored 1456 // This method must not be used with heap object references. The stored
1457 // address is not GC safe. Use the handle version instead. 1457 // address is not GC safe. Use the handle version instead.
1458 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); 1458 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM);
1459 if (RelocInfo::IsNone(rmode)) {
1460 movq(dst, reinterpret_cast<int64_t>(value));
1461 } else {
1462 EnsureSpace ensure_space(this);
1463 emit_rex_64(dst);
1464 emit(0xB8 | dst.low_bits());
1465 emitp(value, rmode);
1466 }
1467 }
1468
1469
1470 void Assembler::movq(Register dst, int64_t value) {
haitao.feng 2013/10/25 06:19:11 Use MacroAssembler::Set instruction if the value c
1459 EnsureSpace ensure_space(this); 1471 EnsureSpace ensure_space(this);
1460 emit_rex_64(dst); 1472 emit_rex_64(dst);
1461 emit(0xB8 | dst.low_bits()); 1473 emit(0xB8 | dst.low_bits());
1462 emitp(value, rmode); 1474 emitq(value);
1463 }
1464
1465
1466 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) {
1467 // Non-relocatable values might not need a 64-bit representation.
1468 ASSERT(RelocInfo::IsNone(rmode));
1469 if (is_uint32(value)) {
1470 movl(dst, Immediate(static_cast<int32_t>(value)));
1471 } else if (is_int32(value)) {
1472 movq(dst, Immediate(static_cast<int32_t>(value)));
1473 } else {
1474 // Value cannot be represented by 32 bits, so do a full 64 bit immediate
1475 // value.
1476 EnsureSpace ensure_space(this);
1477 emit_rex_64(dst);
1478 emit(0xB8 | dst.low_bits());
1479 emitq(value);
1480 }
1481 } 1475 }
1482 1476
1483 1477
1484 void Assembler::movq(Register dst, ExternalReference ref) { 1478 void Assembler::movq(Register dst, ExternalReference ref) {
1485 Address value = reinterpret_cast<Address>(ref.address()); 1479 Address value = reinterpret_cast<Address>(ref.address());
1486 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); 1480 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE);
1487 } 1481 }
1488 1482
1489 1483
1490 void Assembler::movq(const Operand& dst, Immediate value) { 1484 void Assembler::movq(const Operand& dst, Immediate value) {
(...skipping 23 matching lines...) Expand all
1514 ASSERT(src->is_unused()); 1508 ASSERT(src->is_unused());
1515 int32_t current = pc_offset(); 1509 int32_t current = pc_offset();
1516 emitl(current); 1510 emitl(current);
1517 src->link_to(current); 1511 src->link_to(current);
1518 } 1512 }
1519 } 1513 }
1520 1514
1521 1515
1522 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { 1516 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) {
1523 AllowDeferredHandleDereference using_raw_address; 1517 AllowDeferredHandleDereference using_raw_address;
1524 // If there is no relocation info, emit the value of the handle efficiently 1518 ASSERT(!RelocInfo::IsNone(mode));
haitao.feng 2013/10/25 06:19:11 Currently SMI cases are all handled before calling
1525 // (possibly using less that 8 bytes for the value). 1519 EnsureSpace ensure_space(this);
1526 if (RelocInfo::IsNone(mode)) { 1520 ASSERT(value->IsHeapObject());
1527 // There is no possible reason to store a heap pointer without relocation 1521 ASSERT(!isolate()->heap()->InNewSpace(*value));
1528 // info, so it must be a smi. 1522 emit_rex_64(dst);
1529 ASSERT(value->IsSmi()); 1523 emit(0xB8 | dst.low_bits());
1530 movq(dst, reinterpret_cast<int64_t>(*value), RelocInfo::NONE64); 1524 emitp(value.location(), mode);
1531 } else {
1532 EnsureSpace ensure_space(this);
1533 ASSERT(value->IsHeapObject());
1534 ASSERT(!isolate()->heap()->InNewSpace(*value));
1535 emit_rex_64(dst);
1536 emit(0xB8 | dst.low_bits());
1537 emitp(value.location(), mode);
1538 }
1539 } 1525 }
1540 1526
1541 1527
1542 void Assembler::movsxbq(Register dst, const Operand& src) { 1528 void Assembler::movsxbq(Register dst, const Operand& src) {
1543 EnsureSpace ensure_space(this); 1529 EnsureSpace ensure_space(this);
1544 emit_rex_64(dst, src); 1530 emit_rex_64(dst, src);
1545 emit(0x0F); 1531 emit(0x0F);
1546 emit(0xBE); 1532 emit(0xBE);
1547 emit_operand(dst, src); 1533 emit_operand(dst, src);
1548 } 1534 }
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 bool RelocInfo::IsCodedSpecially() { 3064 bool RelocInfo::IsCodedSpecially() {
3079 // The deserializer needs to know whether a pointer is specially coded. Being 3065 // The deserializer needs to know whether a pointer is specially coded. Being
3080 // specially coded on x64 means that it is a relative 32 bit address, as used 3066 // specially coded on x64 means that it is a relative 32 bit address, as used
3081 // by branch instructions. 3067 // by branch instructions.
3082 return (1 << rmode_) & kApplyMask; 3068 return (1 << rmode_) & kApplyMask;
3083 } 3069 }
3084 3070
3085 } } // namespace v8::internal 3071 } } // namespace v8::internal
3086 3072
3087 #endif // V8_TARGET_ARCH_X64 3073 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698