| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
| 32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
| 33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. |
| 34 | 34 |
| 35 // A lightweight X64 Assembler. | 35 // A lightweight X64 Assembler. |
| 36 | 36 |
| 37 #ifndef V8_X64_ASSEMBLER_X64_H_ | 37 #ifndef V8_X64_ASSEMBLER_X64_H_ |
| 38 #define V8_X64_ASSEMBLER_X64_H_ | 38 #define V8_X64_ASSEMBLER_X64_H_ |
| 39 | 39 |
| 40 #include <deque> | 40 #include <deque> |
| 41 #include <forward_list> |
| 41 | 42 |
| 42 #include "src/assembler.h" | 43 #include "src/assembler.h" |
| 43 #include "src/x64/sse-instr.h" | 44 #include "src/x64/sse-instr.h" |
| 44 | 45 |
| 45 namespace v8 { | 46 namespace v8 { |
| 46 namespace internal { | 47 namespace internal { |
| 47 | 48 |
| 48 // Utility functions | 49 // Utility functions |
| 49 | 50 |
| 50 #define GENERAL_REGISTERS(V) \ | 51 #define GENERAL_REGISTERS(V) \ |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // buffer, and buffer_size determines the initial buffer size. The buffer is | 482 // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 482 // owned by the assembler and deallocated upon destruction of the assembler. | 483 // owned by the assembler and deallocated upon destruction of the assembler. |
| 483 // | 484 // |
| 484 // If the provided buffer is not NULL, the assembler uses the provided buffer | 485 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 485 // for code generation and assumes its size to be buffer_size. If the buffer | 486 // for code generation and assumes its size to be buffer_size. If the buffer |
| 486 // is too small, a fatal error occurs. No deallocation of the buffer is done | 487 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 487 // upon destruction of the assembler. | 488 // upon destruction of the assembler. |
| 488 Assembler(Isolate* isolate, void* buffer, int buffer_size) | 489 Assembler(Isolate* isolate, void* buffer, int buffer_size) |
| 489 : Assembler(IsolateData(isolate), buffer, buffer_size) {} | 490 : Assembler(IsolateData(isolate), buffer, buffer_size) {} |
| 490 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); | 491 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); |
| 491 virtual ~Assembler() { } | 492 virtual ~Assembler() {} |
| 492 | 493 |
| 493 // GetCode emits any pending (non-emitted) code and fills the descriptor | 494 // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 494 // desc. GetCode() is idempotent; it returns the same result if no other | 495 // desc. GetCode() is idempotent; it returns the same result if no other |
| 495 // Assembler functions are invoked in between GetCode() calls. | 496 // Assembler functions are invoked in between GetCode() calls. |
| 496 void GetCode(CodeDesc* desc); | 497 void GetCode(Isolate* isolate, CodeDesc* desc); |
| 497 | 498 |
| 498 // Read/Modify the code target in the relative branch/call instruction at pc. | 499 // Read/Modify the code target in the relative branch/call instruction at pc. |
| 499 // On the x64 architecture, we use relative jumps with a 32-bit displacement | 500 // On the x64 architecture, we use relative jumps with a 32-bit displacement |
| 500 // to jump to other Code objects in the Code space in the heap. | 501 // to jump to other Code objects in the Code space in the heap. |
| 501 // Jumps to C functions are done indirectly through a 64-bit register holding | 502 // Jumps to C functions are done indirectly through a 64-bit register holding |
| 502 // the absolute address of the target. | 503 // the absolute address of the target. |
| 503 // These functions convert between absolute Addresses of Code objects and | 504 // These functions convert between absolute Addresses of Code objects and |
| 504 // the relative displacements stored in the code. | 505 // the relative displacements stored in the code. |
| 505 // The isolate argument is unused (and may be nullptr) when skipping flushing. | 506 // The isolate argument is unused (and may be nullptr) when skipping flushing. |
| 506 static inline Address target_address_at(Address pc, Address constant_pool); | 507 static inline Address target_address_at(Address pc, Address constant_pool); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 void movw(const Operand& dst, Register src); | 690 void movw(const Operand& dst, Register src); |
| 690 void movw(const Operand& dst, Immediate imm); | 691 void movw(const Operand& dst, Immediate imm); |
| 691 | 692 |
| 692 // Move the offset of the label location relative to the current | 693 // Move the offset of the label location relative to the current |
| 693 // position (after the move) to the destination. | 694 // position (after the move) to the destination. |
| 694 void movl(const Operand& dst, Label* src); | 695 void movl(const Operand& dst, Label* src); |
| 695 | 696 |
| 696 // Loads a pointer into a register with a relocation mode. | 697 // Loads a pointer into a register with a relocation mode. |
| 697 void movp(Register dst, void* ptr, RelocInfo::Mode rmode); | 698 void movp(Register dst, void* ptr, RelocInfo::Mode rmode); |
| 698 | 699 |
| 700 // Load a heap number into a register. |
| 701 // The heap number will not be allocated and embedded into the code right |
| 702 // away. Instead, we emit the load of a dummy object. Later, when calling |
| 703 // Assembler::GetCode, the heap number will be allocated and the code will be |
| 704 // patched by replacing the dummy with the actual object. The RelocInfo for |
| 705 // the embedded object gets already recorded correctly when emitting the dummy |
| 706 // move. |
| 707 void movp_heap_number(Register dst, double value); |
| 708 |
| 709 // Patch the dummy heap number that we emitted at {pc} during code assembly |
| 710 // with the actual heap object (handle). |
| 711 static void set_heap_number(Handle<HeapObject> number, Address pc) { |
| 712 Memory::Object_Handle_at(pc) = number; |
| 713 } |
| 714 |
| 699 // Loads a 64-bit immediate into a register. | 715 // Loads a 64-bit immediate into a register. |
| 700 void movq(Register dst, int64_t value, | 716 void movq(Register dst, int64_t value, |
| 701 RelocInfo::Mode rmode = RelocInfo::NONE64); | 717 RelocInfo::Mode rmode = RelocInfo::NONE64); |
| 702 void movq(Register dst, uint64_t value, | 718 void movq(Register dst, uint64_t value, |
| 703 RelocInfo::Mode rmode = RelocInfo::NONE64); | 719 RelocInfo::Mode rmode = RelocInfo::NONE64); |
| 704 | 720 |
| 705 void movsxbl(Register dst, Register src); | 721 void movsxbl(Register dst, Register src); |
| 706 void movsxbl(Register dst, const Operand& src); | 722 void movsxbl(Register dst, const Operand& src); |
| 707 void movsxbq(Register dst, Register src); | 723 void movsxbq(Register dst, Register src); |
| 708 void movsxbq(Register dst, const Operand& src); | 724 void movsxbq(Register dst, const Operand& src); |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 Assembler* assembler_; | 2540 Assembler* assembler_; |
| 2525 #ifdef DEBUG | 2541 #ifdef DEBUG |
| 2526 int space_before_; | 2542 int space_before_; |
| 2527 #endif | 2543 #endif |
| 2528 }; | 2544 }; |
| 2529 | 2545 |
| 2530 } // namespace internal | 2546 } // namespace internal |
| 2531 } // namespace v8 | 2547 } // namespace v8 |
| 2532 | 2548 |
| 2533 #endif // V8_X64_ASSEMBLER_X64_H_ | 2549 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |