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_X87_MACRO_ASSEMBLER_X87_H_ | 5 #ifndef V8_X87_MACRO_ASSEMBLER_X87_H_ |
6 #define V8_X87_MACRO_ASSEMBLER_X87_H_ | 6 #define V8_X87_MACRO_ASSEMBLER_X87_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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // argument in register esi. | 259 // argument in register esi. |
234 void LeaveExitFrame(bool save_doubles); | 260 void LeaveExitFrame(bool save_doubles); |
235 | 261 |
236 // Leave the current exit frame. Expects the return value in | 262 // Leave the current exit frame. Expects the return value in |
237 // register eax (untouched). | 263 // register eax (untouched). |
238 void LeaveApiExitFrame(bool restore_context); | 264 void LeaveApiExitFrame(bool restore_context); |
239 | 265 |
240 // Find the function context up the context chain. | 266 // Find the function context up the context chain. |
241 void LoadContext(Register dst, int context_chain_length); | 267 void LoadContext(Register dst, int context_chain_length); |
242 | 268 |
| 269 // Load the global proxy from the current context. |
| 270 void LoadGlobalProxy(Register dst); |
| 271 |
243 // Conditionally load the cached Array transitioned map of type | 272 // Conditionally load the cached Array transitioned map of type |
244 // transitioned_kind from the native context if the map in register | 273 // transitioned_kind from the native context if the map in register |
245 // map_in_out is the cached Array map in the native context of | 274 // map_in_out is the cached Array map in the native context of |
246 // expected_kind. | 275 // expected_kind. |
247 void LoadTransitionedArrayMapConditional( | 276 void LoadTransitionedArrayMapConditional( |
248 ElementsKind expected_kind, | 277 ElementsKind expected_kind, |
249 ElementsKind transitioned_kind, | 278 ElementsKind transitioned_kind, |
250 Register map_in_out, | 279 Register map_in_out, |
251 Register scratch, | 280 Register scratch, |
252 Label* no_map_match); | 281 Label* no_map_match); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 552 |
524 // Abort execution if argument is a smi, enabled via --debug-code. | 553 // Abort execution if argument is a smi, enabled via --debug-code. |
525 void AssertNotSmi(Register object); | 554 void AssertNotSmi(Register object); |
526 | 555 |
527 // Abort execution if argument is not a string, enabled via --debug-code. | 556 // Abort execution if argument is not a string, enabled via --debug-code. |
528 void AssertString(Register object); | 557 void AssertString(Register object); |
529 | 558 |
530 // Abort execution if argument is not a name, enabled via --debug-code. | 559 // Abort execution if argument is not a name, enabled via --debug-code. |
531 void AssertName(Register object); | 560 void AssertName(Register object); |
532 | 561 |
| 562 // Abort execution if argument is not a JSFunction, enabled via --debug-code. |
| 563 void AssertFunction(Register object); |
| 564 |
533 // Abort execution if argument is not undefined or an AllocationSite, enabled | 565 // Abort execution if argument is not undefined or an AllocationSite, enabled |
534 // via --debug-code. | 566 // via --debug-code. |
535 void AssertUndefinedOrAllocationSite(Register object); | 567 void AssertUndefinedOrAllocationSite(Register object); |
536 | 568 |
537 // --------------------------------------------------------------------------- | 569 // --------------------------------------------------------------------------- |
538 // Exception handling | 570 // Exception handling |
539 | 571 |
540 // Push a new stack handler and link it into stack handler chain. | 572 // Push a new stack handler and link it into stack handler chain. |
541 void PushStackHandler(); | 573 void PushStackHandler(); |
542 | 574 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 791 |
760 // Return and drop arguments from stack, where the number of arguments | 792 // Return and drop arguments from stack, where the number of arguments |
761 // may be bigger than 2^16 - 1. Requires a scratch register. | 793 // may be bigger than 2^16 - 1. Requires a scratch register. |
762 void Ret(int bytes_dropped, Register scratch); | 794 void Ret(int bytes_dropped, Register scratch); |
763 | 795 |
764 // Emit code to discard a non-negative number of pointer-sized elements | 796 // Emit code to discard a non-negative number of pointer-sized elements |
765 // from the stack, clobbering only the esp register. | 797 // from the stack, clobbering only the esp register. |
766 void Drop(int element_count); | 798 void Drop(int element_count); |
767 | 799 |
768 void Call(Label* target) { call(target); } | 800 void Call(Label* target) { call(target); } |
| 801 void Call(Handle<Code> target, RelocInfo::Mode rmode) { call(target, rmode); } |
| 802 void Jump(Handle<Code> target, RelocInfo::Mode rmode) { jmp(target, rmode); } |
769 void Push(Register src) { push(src); } | 803 void Push(Register src) { push(src); } |
| 804 void Push(const Operand& src) { push(src); } |
| 805 void Push(Immediate value) { push(value); } |
770 void Pop(Register dst) { pop(dst); } | 806 void Pop(Register dst) { pop(dst); } |
| 807 void PushReturnAddressFrom(Register src) { push(src); } |
| 808 void PopReturnAddressTo(Register dst) { pop(dst); } |
771 | 809 |
772 void Lzcnt(Register dst, Register src) { Lzcnt(dst, Operand(src)); } | 810 void Lzcnt(Register dst, Register src) { Lzcnt(dst, Operand(src)); } |
773 void Lzcnt(Register dst, const Operand& src); | 811 void Lzcnt(Register dst, const Operand& src); |
774 | 812 |
775 // Emit call to the code we are currently generating. | 813 // Emit call to the code we are currently generating. |
776 void CallSelf() { | 814 void CallSelf() { |
777 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); | 815 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); |
778 call(self, RelocInfo::CODE_TARGET); | 816 call(self, RelocInfo::CODE_TARGET); |
779 } | 817 } |
780 | 818 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 } \ | 1087 } \ |
1050 masm-> | 1088 masm-> |
1051 #else | 1089 #else |
1052 #define ACCESS_MASM(masm) masm-> | 1090 #define ACCESS_MASM(masm) masm-> |
1053 #endif | 1091 #endif |
1054 | 1092 |
1055 | 1093 |
1056 } } // namespace v8::internal | 1094 } } // namespace v8::internal |
1057 | 1095 |
1058 #endif // V8_X87_MACRO_ASSEMBLER_X87_H_ | 1096 #endif // V8_X87_MACRO_ASSEMBLER_X87_H_ |
OLD | NEW |