By Yoshinori TAKESAKO (takesako) from Shibuya.pm
Date: Thursday, 10 September 2009 11:40
Duration: 20 minutes
Language: 日本語
How to make Perl-regex-based JIT x86 Compiler, only use DynaLoader.
package Acme::x86::CPUID;
use DynaLoader;
sub ProcessorBrandString {
my $cpu = "\0" x 48;
my $x86 = ""
. "S\xbf" . pack("P", $cpu)
. "\xb8\x02\x00\x00\x80"
. ("P\x0f\xa2\x89\x07\x89_\x04\x89O\x08\x89W\x0c\x8d\x7f\x10X\x8d\@\x01" x 3)
. "[\xc3"
;
DynaLoader::dl_install_xsub("X",unpack"L",pack"P",$x86);&X;
$cpu =~ s/\0+//g;
$cpu =~ s/^ +//;
$cpu;
}
print Acme::x86::CPUID::ProcessorBrandString, "\n";