OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_X64_MACRO_ASSEMBLER_X64_H_ | 5 #ifndef V8_X64_MACRO_ASSEMBLER_X64_H_ |
6 #define V8_X64_MACRO_ASSEMBLER_X64_H_ | 6 #define V8_X64_MACRO_ASSEMBLER_X64_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/frames.h" | 10 #include "src/frames.h" |
11 #include "src/globals.h" | 11 #include "src/globals.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 // Default scratch register used by MacroAssembler (and other code that needs | 16 // Default scratch register used by MacroAssembler (and other code that needs |
17 // a spare register). The register isn't callee save, and not used by the | 17 // a spare register). The register isn't callee save, and not used by the |
18 // function calling convention. | 18 // function calling convention. |
19 const Register kScratchRegister = { 10 }; // r10. | 19 const Register kScratchRegister = { 10 }; // r10. |
20 const Register kSmiConstantRegister = { 12 }; // r12 (callee save). | |
21 const Register kRootRegister = { 13 }; // r13 (callee save). | 20 const Register kRootRegister = { 13 }; // r13 (callee save). |
22 // Value of smi in kSmiConstantRegister. | |
23 const int kSmiConstantRegisterValue = 1; | |
24 // Actual value of root register is offset from the root array's start | 21 // Actual value of root register is offset from the root array's start |
25 // to take advantage of negitive 8-bit displacement values. | 22 // to take advantage of negitive 8-bit displacement values. |
26 const int kRootRegisterBias = 128; | 23 const int kRootRegisterBias = 128; |
27 | 24 |
28 // Convenience for platform-independent signatures. | 25 // Convenience for platform-independent signatures. |
29 typedef Operand MemOperand; | 26 typedef Operand MemOperand; |
30 | 27 |
31 enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; | 28 enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; |
32 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; | 29 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; |
33 enum PointersToHereCheck { | 30 enum PointersToHereCheck { |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 380 |
384 | 381 |
385 // --------------------------------------------------------------------------- | 382 // --------------------------------------------------------------------------- |
386 // Smi tagging, untagging and operations on tagged smis. | 383 // Smi tagging, untagging and operations on tagged smis. |
387 | 384 |
388 // Support for constant splitting. | 385 // Support for constant splitting. |
389 bool IsUnsafeInt(const int32_t x); | 386 bool IsUnsafeInt(const int32_t x); |
390 void SafeMove(Register dst, Smi* src); | 387 void SafeMove(Register dst, Smi* src); |
391 void SafePush(Smi* src); | 388 void SafePush(Smi* src); |
392 | 389 |
393 void InitializeSmiConstantRegister() { | |
394 Move(kSmiConstantRegister, Smi::FromInt(kSmiConstantRegisterValue), | |
395 Assembler::RelocInfoNone()); | |
396 } | |
397 | |
398 // Conversions between tagged smi values and non-tagged integer values. | 390 // Conversions between tagged smi values and non-tagged integer values. |
399 | 391 |
400 // Tag an integer value. The result must be known to be a valid smi value. | 392 // Tag an integer value. The result must be known to be a valid smi value. |
401 // Only uses the low 32 bits of the src register. Sets the N and Z flags | 393 // Only uses the low 32 bits of the src register. Sets the N and Z flags |
402 // based on the value of the resulting smi. | 394 // based on the value of the resulting smi. |
403 void Integer32ToSmi(Register dst, Register src); | 395 void Integer32ToSmi(Register dst, Register src); |
404 | 396 |
405 // Stores an integer32 value into a memory field that already holds a smi. | 397 // Stores an integer32 value into a memory field that already holds a smi. |
406 void Integer32ToSmiField(const Operand& dst, Register src); | 398 void Integer32ToSmiField(const Operand& dst, Register src); |
407 | 399 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 Condition CheckBothSmi(Register first, Register second); | 459 Condition CheckBothSmi(Register first, Register second); |
468 | 460 |
469 // Are both values non-negative tagged smis. | 461 // Are both values non-negative tagged smis. |
470 Condition CheckBothNonNegativeSmi(Register first, Register second); | 462 Condition CheckBothNonNegativeSmi(Register first, Register second); |
471 | 463 |
472 // Are either value a tagged smi. | 464 // Are either value a tagged smi. |
473 Condition CheckEitherSmi(Register first, | 465 Condition CheckEitherSmi(Register first, |
474 Register second, | 466 Register second, |
475 Register scratch = kScratchRegister); | 467 Register scratch = kScratchRegister); |
476 | 468 |
477 // Is the value the minimum smi value (since we are using | |
478 // two's complement numbers, negating the value is known to yield | |
479 // a non-smi value). | |
480 Condition CheckIsMinSmi(Register src); | |
481 | |
482 // Checks whether an 32-bit integer value is a valid for conversion | 469 // Checks whether an 32-bit integer value is a valid for conversion |
483 // to a smi. | 470 // to a smi. |
484 Condition CheckInteger32ValidSmiValue(Register src); | 471 Condition CheckInteger32ValidSmiValue(Register src); |
485 | 472 |
486 // Checks whether an 32-bit unsigned integer value is a valid for | 473 // Checks whether an 32-bit unsigned integer value is a valid for |
487 // conversion to a smi. | 474 // conversion to a smi. |
488 Condition CheckUInteger32ValidSmiValue(Register src); | 475 Condition CheckUInteger32ValidSmiValue(Register src); |
489 | 476 |
490 // Check whether src is a Smi, and set dst to zero if it is a smi, | 477 // Check whether src is a Smi, and set dst to zero if it is a smi, |
491 // and to one if it isn't. | 478 // and to one if it isn't. |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 918 |
932 // Emit call to the code we are currently generating. | 919 // Emit call to the code we are currently generating. |
933 void CallSelf() { | 920 void CallSelf() { |
934 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); | 921 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); |
935 Call(self, RelocInfo::CODE_TARGET); | 922 Call(self, RelocInfo::CODE_TARGET); |
936 } | 923 } |
937 | 924 |
938 // Non-x64 instructions. | 925 // Non-x64 instructions. |
939 // Push/pop all general purpose registers. | 926 // Push/pop all general purpose registers. |
940 // Does not push rsp/rbp nor any of the assembler's special purpose registers | 927 // Does not push rsp/rbp nor any of the assembler's special purpose registers |
941 // (kScratchRegister, kSmiConstantRegister, kRootRegister). | 928 // (kScratchRegister, kRootRegister). |
942 void Pushad(); | 929 void Pushad(); |
943 void Popad(); | 930 void Popad(); |
944 // Sets the stack as after performing Popad, without actually loading the | 931 // Sets the stack as after performing Popad, without actually loading the |
945 // registers. | 932 // registers. |
946 void Dropad(); | 933 void Dropad(); |
947 | 934 |
948 // Compare object type for heap object. | 935 // Compare object type for heap object. |
949 // Always use unsigned comparisons: above and below, not less and greater. | 936 // Always use unsigned comparisons: above and below, not less and greater. |
950 // Incoming register is heap_object and outgoing register is map. | 937 // Incoming register is heap_object and outgoing register is map. |
951 // They may be the same register, and may be kScratchRegister. | 938 // They may be the same register, and may be kScratchRegister. |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 j(equal, memento_found); | 1444 j(equal, memento_found); |
1458 bind(&no_memento_found); | 1445 bind(&no_memento_found); |
1459 } | 1446 } |
1460 | 1447 |
1461 // Jumps to found label if a prototype map has dictionary elements. | 1448 // Jumps to found label if a prototype map has dictionary elements. |
1462 void JumpIfDictionaryInPrototypeChain(Register object, Register scratch0, | 1449 void JumpIfDictionaryInPrototypeChain(Register object, Register scratch0, |
1463 Register scratch1, Label* found); | 1450 Register scratch1, Label* found); |
1464 | 1451 |
1465 private: | 1452 private: |
1466 // Order general registers are pushed by Pushad. | 1453 // Order general registers are pushed by Pushad. |
1467 // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. | 1454 // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r12, r14, r15. |
1468 static const int kSafepointPushRegisterIndices[Register::kNumRegisters]; | 1455 static const int kSafepointPushRegisterIndices[Register::kNumRegisters]; |
1469 static const int kNumSafepointSavedRegisters = 11; | 1456 static const int kNumSafepointSavedRegisters = 12; |
1470 static const int kSmiShift = kSmiTagSize + kSmiShiftSize; | 1457 static const int kSmiShift = kSmiTagSize + kSmiShiftSize; |
1471 | 1458 |
1472 bool generating_stub_; | 1459 bool generating_stub_; |
1473 bool has_frame_; | 1460 bool has_frame_; |
1474 bool root_array_available_; | 1461 bool root_array_available_; |
1475 | 1462 |
1476 // Returns a register holding the smi value. The register MUST NOT be | 1463 // Returns a register holding the smi value. The register MUST NOT be |
1477 // modified. It may be the "smi 1 constant" register. | 1464 // modified. It may be the "smi 1 constant" register. |
1478 Register GetSmiConstant(Smi* value); | 1465 Register GetSmiConstant(Smi* value); |
1479 | 1466 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 masm->popfq(); \ | 1621 masm->popfq(); \ |
1635 } \ | 1622 } \ |
1636 masm-> | 1623 masm-> |
1637 #else | 1624 #else |
1638 #define ACCESS_MASM(masm) masm-> | 1625 #define ACCESS_MASM(masm) masm-> |
1639 #endif | 1626 #endif |
1640 | 1627 |
1641 } } // namespace v8::internal | 1628 } } // namespace v8::internal |
1642 | 1629 |
1643 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1630 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |