OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 delete memory; | 68 delete memory; |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 Assembler assm(NULL, memory->address(), kBufferSize); | 72 Assembler assm(NULL, memory->address(), kBufferSize); |
73 Label cpuid, done; | 73 Label cpuid, done; |
74 #define __ assm. | 74 #define __ assm. |
75 // Save old rsp, since we are going to modify the stack. | 75 // Save old rsp, since we are going to modify the stack. |
76 __ push(rbp); | 76 __ push(rbp); |
77 __ pushfq(); | 77 __ pushfq(); |
| 78 __ push(rsi); |
78 __ push(rcx); | 79 __ push(rcx); |
79 __ push(rbx); | 80 __ push(rbx); |
80 __ movq(rbp, rsp); | 81 __ movq(rbp, rsp); |
81 | 82 |
82 // If we can modify bit 21 of the EFLAGS register, then CPUID is supported. | 83 // If we can modify bit 21 of the EFLAGS register, then CPUID is supported. |
83 __ pushfq(); | 84 __ pushfq(); |
84 __ pop(rax); | 85 __ pop(rax); |
85 __ movq(rdx, rax); | 86 __ movq(rdx, rax); |
86 __ xor_(rax, Immediate(0x200000)); // Flip bit 21. | 87 __ xor_(rax, Immediate(0x200000)); // Flip bit 21. |
87 __ push(rax); | 88 __ push(rax); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 __ not_(rax); | 122 __ not_(rax); |
122 __ and_(rax, rdi); | 123 __ and_(rax, rdi); |
123 __ or_(rax, rcx); | 124 __ or_(rax, rcx); |
124 __ or_(rax, Immediate(1 << CPUID)); | 125 __ or_(rax, Immediate(1 << CPUID)); |
125 | 126 |
126 // Done. | 127 // Done. |
127 __ bind(&done); | 128 __ bind(&done); |
128 __ movq(rsp, rbp); | 129 __ movq(rsp, rbp); |
129 __ pop(rbx); | 130 __ pop(rbx); |
130 __ pop(rcx); | 131 __ pop(rcx); |
| 132 __ pop(rsi); |
131 __ popfq(); | 133 __ popfq(); |
132 __ pop(rbp); | 134 __ pop(rbp); |
133 __ ret(0); | 135 __ ret(0); |
134 #undef __ | 136 #undef __ |
135 | 137 |
136 typedef uint64_t (*F0)(); | 138 typedef uint64_t (*F0)(); |
137 F0 probe = FUNCTION_CAST<F0>(reinterpret_cast<Address>(memory->address())); | 139 F0 probe = FUNCTION_CAST<F0>(reinterpret_cast<Address>(memory->address())); |
138 supported_ = probe(); | 140 supported_ = probe(); |
139 found_by_runtime_probing_ = supported_; | 141 found_by_runtime_probing_ = supported_; |
140 found_by_runtime_probing_ &= ~kDefaultCpuFeatures; | 142 found_by_runtime_probing_ &= ~kDefaultCpuFeatures; |
(...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 bool RelocInfo::IsCodedSpecially() { | 3043 bool RelocInfo::IsCodedSpecially() { |
3042 // The deserializer needs to know whether a pointer is specially coded. Being | 3044 // The deserializer needs to know whether a pointer is specially coded. Being |
3043 // specially coded on x64 means that it is a relative 32 bit address, as used | 3045 // specially coded on x64 means that it is a relative 32 bit address, as used |
3044 // by branch instructions. | 3046 // by branch instructions. |
3045 return (1 << rmode_) & kApplyMask; | 3047 return (1 << rmode_) & kApplyMask; |
3046 } | 3048 } |
3047 | 3049 |
3048 } } // namespace v8::internal | 3050 } } // namespace v8::internal |
3049 | 3051 |
3050 #endif // V8_TARGET_ARCH_X64 | 3052 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |