Set SAHF flag correctly for ia32

sahf flag will not be set for ia32 on some old platform because some old processors does not support CPUID's extended features.
This also avoids redundant cpuid check in ia32 for sahf.

BUG=
R=danno@chromium.org

Review URL: https://codereview.chromium.org/298823008

Patch from Weiliang Lin <weiliang.lin@intel.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ce947a43
...@@ -300,6 +300,10 @@ CPU::CPU() : stepping_(0), ...@@ -300,6 +300,10 @@ CPU::CPU() : stepping_(0),
has_sse42_ = (cpu_info[2] & 0x00100000) != 0; has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
} }
#if V8_HOST_ARCH_IA32
// SAHF is always available in compat/legacy mode,
has_sahf_ = true;
#else
// Query extended IDs. // Query extended IDs.
__cpuid(cpu_info, 0x80000000); __cpuid(cpu_info, 0x80000000);
unsigned num_ext_ids = cpu_info[0]; unsigned num_ext_ids = cpu_info[0];
...@@ -307,14 +311,10 @@ CPU::CPU() : stepping_(0), ...@@ -307,14 +311,10 @@ CPU::CPU() : stepping_(0),
// Interpret extended CPU feature information. // Interpret extended CPU feature information.
if (num_ext_ids > 0x80000000) { if (num_ext_ids > 0x80000000) {
__cpuid(cpu_info, 0x80000001); __cpuid(cpu_info, 0x80000001);
// SAHF is always available in compat/legacy mode, // SAHF must be probed in long mode.
// but must be probed in long mode.
#if V8_HOST_ARCH_IA32
has_sahf_ = true;
#else
has_sahf_ = (cpu_info[2] & 0x00000001) != 0; has_sahf_ = (cpu_info[2] & 0x00000001) != 0;
#endif
} }
#endif
#elif V8_HOST_ARCH_ARM #elif V8_HOST_ARCH_ARM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment