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(rdi); |
79 __ push(rcx); | 79 __ push(rcx); |
80 __ push(rbx); | 80 __ push(rbx); |
81 __ movq(rbp, rsp); | 81 __ movq(rbp, rsp); |
82 | 82 |
83 // 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. |
84 __ pushfq(); | 84 __ pushfq(); |
85 __ pop(rax); | 85 __ pop(rax); |
86 __ movq(rdx, rax); | 86 __ movq(rdx, rax); |
87 __ xor_(rax, Immediate(0x200000)); // Flip bit 21. | 87 __ xor_(rax, Immediate(0x200000)); // Flip bit 21. |
88 __ push(rax); | 88 __ push(rax); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 __ not_(rax); | 122 __ not_(rax); |
123 __ and_(rax, rdi); | 123 __ and_(rax, rdi); |
124 __ or_(rax, rcx); | 124 __ or_(rax, rcx); |
125 __ or_(rax, Immediate(1 << CPUID)); | 125 __ or_(rax, Immediate(1 << CPUID)); |
126 | 126 |
127 // Done. | 127 // Done. |
128 __ bind(&done); | 128 __ bind(&done); |
129 __ movq(rsp, rbp); | 129 __ movq(rsp, rbp); |
130 __ pop(rbx); | 130 __ pop(rbx); |
131 __ pop(rcx); | 131 __ pop(rcx); |
132 __ pop(rsi); | 132 __ pop(rdi); |
133 __ popfq(); | 133 __ popfq(); |
134 __ pop(rbp); | 134 __ pop(rbp); |
135 __ ret(0); | 135 __ ret(0); |
136 #undef __ | 136 #undef __ |
137 | 137 |
138 typedef uint64_t (*F0)(); | 138 typedef uint64_t (*F0)(); |
139 F0 probe = FUNCTION_CAST<F0>(reinterpret_cast<Address>(memory->address())); | 139 F0 probe = FUNCTION_CAST<F0>(reinterpret_cast<Address>(memory->address())); |
140 supported_ = probe(); | 140 supported_ = probe(); |
141 found_by_runtime_probing_ = supported_; | 141 found_by_runtime_probing_ = supported_; |
142 found_by_runtime_probing_ &= ~kDefaultCpuFeatures; | 142 found_by_runtime_probing_ &= ~kDefaultCpuFeatures; |
(...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 bool RelocInfo::IsCodedSpecially() { | 3043 bool RelocInfo::IsCodedSpecially() { |
3044 // 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 |
3045 // 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 |
3046 // by branch instructions. | 3046 // by branch instructions. |
3047 return (1 << rmode_) & kApplyMask; | 3047 return (1 << rmode_) & kApplyMask; |
3048 } | 3048 } |
3049 | 3049 |
3050 } } // namespace v8::internal | 3050 } } // namespace v8::internal |
3051 | 3051 |
3052 #endif // V8_TARGET_ARCH_X64 | 3052 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |