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

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

Issue 64453002: Refactor loading a pointer into a register instruction for X64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased with bleeding_edge Created 7 years 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Create a code patcher. 103 // Create a code patcher.
104 CodePatcher patcher(pc_, code_size); 104 CodePatcher patcher(pc_, code_size);
105 105
106 // Add a label for checking the size of the code used for returning. 106 // Add a label for checking the size of the code used for returning.
107 #ifdef DEBUG 107 #ifdef DEBUG
108 Label check_codesize; 108 Label check_codesize;
109 patcher.masm()->bind(&check_codesize); 109 patcher.masm()->bind(&check_codesize);
110 #endif 110 #endif
111 111
112 // Patch the code. 112 // Patch the code.
113 patcher.masm()->movq(kScratchRegister, target, RelocInfo::NONE64); 113 patcher.masm()->movp(kScratchRegister, target, RelocInfo::NONE64);
114 patcher.masm()->call(kScratchRegister); 114 patcher.masm()->call(kScratchRegister);
115 115
116 // Check that the size of the code generated is as expected. 116 // Check that the size of the code generated is as expected.
117 ASSERT_EQ(Assembler::kCallSequenceLength, 117 ASSERT_EQ(Assembler::kCallSequenceLength,
118 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); 118 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
119 119
120 // Add the requested number of int3 instructions after the call. 120 // Add the requested number of int3 instructions after the call.
121 for (int i = 0; i < guard_bytes; i++) { 121 for (int i = 0; i < guard_bytes; i++) {
122 patcher.masm()->int3(); 122 patcher.masm()->int3();
123 } 123 }
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1441
1442 void Assembler::emit_mov(const Operand& dst, Immediate value, int size) { 1442 void Assembler::emit_mov(const Operand& dst, Immediate value, int size) {
1443 EnsureSpace ensure_space(this); 1443 EnsureSpace ensure_space(this);
1444 emit_rex(dst, size); 1444 emit_rex(dst, size);
1445 emit(0xC7); 1445 emit(0xC7);
1446 emit_operand(0x0, dst); 1446 emit_operand(0x0, dst);
1447 emit(value); 1447 emit(value);
1448 } 1448 }
1449 1449
1450 1450
1451 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { 1451 void Assembler::movp(Register dst, void* value, RelocInfo::Mode rmode) {
1452 // This method must not be used with heap object references. The stored 1452 EnsureSpace ensure_space(this);
1453 // address is not GC safe. Use the handle version instead. 1453 emit_rex(dst, kPointerSize);
1454 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); 1454 emit(0xB8 | dst.low_bits());
1455 if (RelocInfo::IsNone(rmode)) { 1455 emitp(value, rmode);
1456 movq(dst, reinterpret_cast<int64_t>(value));
1457 } else {
1458 EnsureSpace ensure_space(this);
1459 emit_rex_64(dst);
1460 emit(0xB8 | dst.low_bits());
1461 emitp(value, rmode);
1462 }
1463 } 1456 }
1464 1457
1465 1458
1466 void Assembler::movq(Register dst, int64_t value) { 1459 void Assembler::movq(Register dst, int64_t value) {
1467 EnsureSpace ensure_space(this); 1460 EnsureSpace ensure_space(this);
1468 emit_rex_64(dst); 1461 emit_rex_64(dst);
1469 emit(0xB8 | dst.low_bits()); 1462 emit(0xB8 | dst.low_bits());
1470 emitq(value); 1463 emitq(value);
1471 } 1464 }
1472 1465
(...skipping 19 matching lines...) Expand all
1492 src->link_to(pc_offset() - sizeof(int32_t)); 1485 src->link_to(pc_offset() - sizeof(int32_t));
1493 } else { 1486 } else {
1494 ASSERT(src->is_unused()); 1487 ASSERT(src->is_unused());
1495 int32_t current = pc_offset(); 1488 int32_t current = pc_offset();
1496 emitl(current); 1489 emitl(current);
1497 src->link_to(current); 1490 src->link_to(current);
1498 } 1491 }
1499 } 1492 }
1500 1493
1501 1494
1502 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) {
1503 AllowDeferredHandleDereference using_raw_address;
1504 ASSERT(!RelocInfo::IsNone(mode));
1505 EnsureSpace ensure_space(this);
1506 ASSERT(value->IsHeapObject());
1507 ASSERT(!isolate()->heap()->InNewSpace(*value));
1508 emit_rex_64(dst);
1509 emit(0xB8 | dst.low_bits());
1510 emitp(value.location(), mode);
1511 }
1512
1513
1514 void Assembler::movsxbq(Register dst, const Operand& src) { 1495 void Assembler::movsxbq(Register dst, const Operand& src) {
1515 EnsureSpace ensure_space(this); 1496 EnsureSpace ensure_space(this);
1516 emit_rex_64(dst, src); 1497 emit_rex_64(dst, src);
1517 emit(0x0F); 1498 emit(0x0F);
1518 emit(0xBE); 1499 emit(0xBE);
1519 emit_operand(dst, src); 1500 emit_operand(dst, src);
1520 } 1501 }
1521 1502
1522 1503
1523 void Assembler::movsxwq(Register dst, const Operand& src) { 1504 void Assembler::movsxwq(Register dst, const Operand& src) {
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 bool RelocInfo::IsCodedSpecially() { 3161 bool RelocInfo::IsCodedSpecially() {
3181 // The deserializer needs to know whether a pointer is specially coded. Being 3162 // The deserializer needs to know whether a pointer is specially coded. Being
3182 // specially coded on x64 means that it is a relative 32 bit address, as used 3163 // specially coded on x64 means that it is a relative 32 bit address, as used
3183 // by branch instructions. 3164 // by branch instructions.
3184 return (1 << rmode_) & kApplyMask; 3165 return (1 << rmode_) & kApplyMask;
3185 } 3166 }
3186 3167
3187 } } // namespace v8::internal 3168 } } // namespace v8::internal
3188 3169
3189 #endif // V8_TARGET_ARCH_X64 3170 #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