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_IA32_MACRO_ASSEMBLER_IA32_H_ | 5 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
6 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 6 #define V8_IA32_MACRO_ASSEMBLER_IA32_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" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 public: | 64 public: |
65 // The isolate parameter can be NULL if the macro assembler should | 65 // The isolate parameter can be NULL if the macro assembler should |
66 // not use isolate-dependent functionality. In this case, it's the | 66 // not use isolate-dependent functionality. In this case, it's the |
67 // responsibility of the caller to never invoke such function on the | 67 // responsibility of the caller to never invoke such function on the |
68 // macro assembler. | 68 // macro assembler. |
69 MacroAssembler(Isolate* isolate, void* buffer, int size); | 69 MacroAssembler(Isolate* isolate, void* buffer, int size); |
70 | 70 |
71 void Load(Register dst, const Operand& src, Representation r); | 71 void Load(Register dst, const Operand& src, Representation r); |
72 void Store(Register src, const Operand& dst, Representation r); | 72 void Store(Register src, const Operand& dst, Representation r); |
73 | 73 |
| 74 // Load a register with a long value as efficiently as possible. |
| 75 void Set(Register dst, int32_t x) { |
| 76 if (x == 0) { |
| 77 xor_(dst, dst); |
| 78 } else { |
| 79 mov(dst, Immediate(x)); |
| 80 } |
| 81 } |
| 82 void Set(const Operand& dst, int32_t x) { mov(dst, Immediate(x)); } |
| 83 |
74 // Operations on roots in the root-array. | 84 // Operations on roots in the root-array. |
75 void LoadRoot(Register destination, Heap::RootListIndex index); | 85 void LoadRoot(Register destination, Heap::RootListIndex index); |
76 void StoreRoot(Register source, Register scratch, Heap::RootListIndex index); | 86 void StoreRoot(Register source, Register scratch, Heap::RootListIndex index); |
77 void CompareRoot(Register with, Register scratch, Heap::RootListIndex index); | 87 void CompareRoot(Register with, Register scratch, Heap::RootListIndex index); |
78 // These methods can only be used with constant roots (i.e. non-writable | 88 // These methods can only be used with constant roots (i.e. non-writable |
79 // and not in new space). | 89 // and not in new space). |
80 void CompareRoot(Register with, Heap::RootListIndex index); | 90 void CompareRoot(Register with, Heap::RootListIndex index); |
81 void CompareRoot(const Operand& with, Heap::RootListIndex index); | 91 void CompareRoot(const Operand& with, Heap::RootListIndex index); |
| 92 void PushRoot(Heap::RootListIndex index); |
| 93 |
| 94 // Compare the object in a register to a value and jump if they are equal. |
| 95 void JumpIfRoot(Register with, Heap::RootListIndex index, Label* if_equal, |
| 96 Label::Distance if_equal_distance = Label::kNear) { |
| 97 CompareRoot(with, index); |
| 98 j(equal, if_equal, if_equal_distance); |
| 99 } |
| 100 |
| 101 // Compare the object in a register to a value and jump if they are not equal. |
| 102 void JumpIfNotRoot(Register with, Heap::RootListIndex index, |
| 103 Label* if_not_equal, |
| 104 Label::Distance if_not_equal_distance = Label::kNear) { |
| 105 CompareRoot(with, index); |
| 106 j(not_equal, if_not_equal, if_not_equal_distance); |
| 107 } |
82 | 108 |
83 // --------------------------------------------------------------------------- | 109 // --------------------------------------------------------------------------- |
84 // GC Support | 110 // GC Support |
85 enum RememberedSetFinalAction { | 111 enum RememberedSetFinalAction { |
86 kReturnAtEnd, | 112 kReturnAtEnd, |
87 kFallThroughAtEnd | 113 kFallThroughAtEnd |
88 }; | 114 }; |
89 | 115 |
90 // Record in the remembered set the fact that we have a pointer to new space | 116 // Record in the remembered set the fact that we have a pointer to new space |
91 // at the address pointed to by the addr register. Only works if addr is not | 117 // at the address pointed to by the addr register. Only works if addr is not |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // argument in register esi. | 281 // argument in register esi. |
256 void LeaveExitFrame(bool save_doubles); | 282 void LeaveExitFrame(bool save_doubles); |
257 | 283 |
258 // Leave the current exit frame. Expects the return value in | 284 // Leave the current exit frame. Expects the return value in |
259 // register eax (untouched). | 285 // register eax (untouched). |
260 void LeaveApiExitFrame(bool restore_context); | 286 void LeaveApiExitFrame(bool restore_context); |
261 | 287 |
262 // Find the function context up the context chain. | 288 // Find the function context up the context chain. |
263 void LoadContext(Register dst, int context_chain_length); | 289 void LoadContext(Register dst, int context_chain_length); |
264 | 290 |
| 291 // Load the global proxy from the current context. |
| 292 void LoadGlobalProxy(Register dst); |
| 293 |
265 // Conditionally load the cached Array transitioned map of type | 294 // Conditionally load the cached Array transitioned map of type |
266 // transitioned_kind from the native context if the map in register | 295 // transitioned_kind from the native context if the map in register |
267 // map_in_out is the cached Array map in the native context of | 296 // map_in_out is the cached Array map in the native context of |
268 // expected_kind. | 297 // expected_kind. |
269 void LoadTransitionedArrayMapConditional( | 298 void LoadTransitionedArrayMapConditional( |
270 ElementsKind expected_kind, | 299 ElementsKind expected_kind, |
271 ElementsKind transitioned_kind, | 300 ElementsKind transitioned_kind, |
272 Register map_in_out, | 301 Register map_in_out, |
273 Register scratch, | 302 Register scratch, |
274 Label* no_map_match); | 303 Label* no_map_match); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 587 |
559 // Abort execution if argument is a smi, enabled via --debug-code. | 588 // Abort execution if argument is a smi, enabled via --debug-code. |
560 void AssertNotSmi(Register object); | 589 void AssertNotSmi(Register object); |
561 | 590 |
562 // Abort execution if argument is not a string, enabled via --debug-code. | 591 // Abort execution if argument is not a string, enabled via --debug-code. |
563 void AssertString(Register object); | 592 void AssertString(Register object); |
564 | 593 |
565 // Abort execution if argument is not a name, enabled via --debug-code. | 594 // Abort execution if argument is not a name, enabled via --debug-code. |
566 void AssertName(Register object); | 595 void AssertName(Register object); |
567 | 596 |
| 597 // Abort execution if argument is not a JSFunction, enabled via --debug-code. |
| 598 void AssertFunction(Register object); |
| 599 |
568 // Abort execution if argument is not undefined or an AllocationSite, enabled | 600 // Abort execution if argument is not undefined or an AllocationSite, enabled |
569 // via --debug-code. | 601 // via --debug-code. |
570 void AssertUndefinedOrAllocationSite(Register object); | 602 void AssertUndefinedOrAllocationSite(Register object); |
571 | 603 |
572 // --------------------------------------------------------------------------- | 604 // --------------------------------------------------------------------------- |
573 // Exception handling | 605 // Exception handling |
574 | 606 |
575 // Push a new stack handler and link it into stack handler chain. | 607 // Push a new stack handler and link it into stack handler chain. |
576 void PushStackHandler(); | 608 void PushStackHandler(); |
577 | 609 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 828 |
797 // Return and drop arguments from stack, where the number of arguments | 829 // Return and drop arguments from stack, where the number of arguments |
798 // may be bigger than 2^16 - 1. Requires a scratch register. | 830 // may be bigger than 2^16 - 1. Requires a scratch register. |
799 void Ret(int bytes_dropped, Register scratch); | 831 void Ret(int bytes_dropped, Register scratch); |
800 | 832 |
801 // Emit code to discard a non-negative number of pointer-sized elements | 833 // Emit code to discard a non-negative number of pointer-sized elements |
802 // from the stack, clobbering only the esp register. | 834 // from the stack, clobbering only the esp register. |
803 void Drop(int element_count); | 835 void Drop(int element_count); |
804 | 836 |
805 void Call(Label* target) { call(target); } | 837 void Call(Label* target) { call(target); } |
| 838 void Call(Handle<Code> target, RelocInfo::Mode rmode) { call(target, rmode); } |
| 839 void Jump(Handle<Code> target, RelocInfo::Mode rmode) { jmp(target, rmode); } |
806 void Push(Register src) { push(src); } | 840 void Push(Register src) { push(src); } |
| 841 void Push(const Operand& src) { push(src); } |
| 842 void Push(Immediate value) { push(value); } |
807 void Pop(Register dst) { pop(dst); } | 843 void Pop(Register dst) { pop(dst); } |
| 844 void PushReturnAddressFrom(Register src) { push(src); } |
| 845 void PopReturnAddressTo(Register dst) { pop(dst); } |
808 | 846 |
809 // Non-SSE2 instructions. | 847 // Non-SSE2 instructions. |
810 void Pextrd(Register dst, XMMRegister src, int8_t imm8); | 848 void Pextrd(Register dst, XMMRegister src, int8_t imm8); |
811 void Pinsrd(XMMRegister dst, Register src, int8_t imm8) { | 849 void Pinsrd(XMMRegister dst, Register src, int8_t imm8) { |
812 Pinsrd(dst, Operand(src), imm8); | 850 Pinsrd(dst, Operand(src), imm8); |
813 } | 851 } |
814 void Pinsrd(XMMRegister dst, const Operand& src, int8_t imm8); | 852 void Pinsrd(XMMRegister dst, const Operand& src, int8_t imm8); |
815 | 853 |
816 void Lzcnt(Register dst, Register src) { Lzcnt(dst, Operand(src)); } | 854 void Lzcnt(Register dst, Register src) { Lzcnt(dst, Operand(src)); } |
817 void Lzcnt(Register dst, const Operand& src); | 855 void Lzcnt(Register dst, const Operand& src); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } \ | 1133 } \ |
1096 masm-> | 1134 masm-> |
1097 #else | 1135 #else |
1098 #define ACCESS_MASM(masm) masm-> | 1136 #define ACCESS_MASM(masm) masm-> |
1099 #endif | 1137 #endif |
1100 | 1138 |
1101 | 1139 |
1102 } } // namespace v8::internal | 1140 } } // namespace v8::internal |
1103 | 1141 |
1104 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 1142 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
OLD | NEW |