Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/stubGenerator_x86_32.cpp @ 11127:980532a806a5
8016697: Use stubs to implement safefetch
Summary: Implement Safefetch as stub routines. This reduces compiler and os dependencies.
Reviewed-by: twisti, kvn
author | goetz |
---|---|
date | Thu, 20 Jun 2013 15:02:05 +0200 |
parents | b800986664f4 |
children | 6b0fd0964b87 740e263c80c6 |
comparison
equal
deleted
inserted
replaced
11088:ea4d24c1e0c6 | 11127:980532a806a5 |
---|---|
2764 __ ret(0); | 2764 __ ret(0); |
2765 | 2765 |
2766 return start; | 2766 return start; |
2767 } | 2767 } |
2768 | 2768 |
2769 // Safefetch stubs. | |
2770 void generate_safefetch(const char* name, int size, address* entry, | |
2771 address* fault_pc, address* continuation_pc) { | |
2772 // safefetch signatures: | |
2773 // int SafeFetch32(int* adr, int errValue); | |
2774 // intptr_t SafeFetchN (intptr_t* adr, intptr_t errValue); | |
2775 | |
2776 StubCodeMark mark(this, "StubRoutines", name); | |
2777 | |
2778 // Entry point, pc or function descriptor. | |
2779 *entry = __ pc(); | |
2780 | |
2781 __ movl(rax, Address(rsp, 0x8)); | |
2782 __ movl(rcx, Address(rsp, 0x4)); | |
2783 // Load *adr into eax, may fault. | |
2784 *fault_pc = __ pc(); | |
2785 switch (size) { | |
2786 case 4: | |
2787 // int32_t | |
2788 __ movl(rax, Address(rcx, 0)); | |
2789 break; | |
2790 case 8: | |
2791 // int64_t | |
2792 Unimplemented(); | |
2793 break; | |
2794 default: | |
2795 ShouldNotReachHere(); | |
2796 } | |
2797 | |
2798 // Return errValue or *adr. | |
2799 *continuation_pc = __ pc(); | |
2800 __ ret(0); | |
2801 } | |
2769 | 2802 |
2770 public: | 2803 public: |
2771 // Information about frame layout at time of blocking runtime call. | 2804 // Information about frame layout at time of blocking runtime call. |
2772 // Note that we only have to preserve callee-saved registers since | 2805 // Note that we only have to preserve callee-saved registers since |
2773 // the compilers are responsible for supplying a continuation point | 2806 // the compilers are responsible for supplying a continuation point |
2976 StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); | 3009 StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); |
2977 StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); | 3010 StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); |
2978 StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); | 3011 StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); |
2979 StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); | 3012 StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); |
2980 } | 3013 } |
3014 | |
3015 // Safefetch stubs. | |
3016 generate_safefetch("SafeFetch32", sizeof(int), &StubRoutines::_safefetch32_entry, | |
3017 &StubRoutines::_safefetch32_fault_pc, | |
3018 &StubRoutines::_safefetch32_continuation_pc); | |
3019 StubRoutines::_safefetchN_entry = StubRoutines::_safefetch32_entry; | |
3020 StubRoutines::_safefetchN_fault_pc = StubRoutines::_safefetch32_fault_pc; | |
3021 StubRoutines::_safefetchN_continuation_pc = StubRoutines::_safefetch32_continuation_pc; | |
2981 } | 3022 } |
2982 | 3023 |
2983 | 3024 |
2984 public: | 3025 public: |
2985 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { | 3026 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { |