Merge branch 'master' of git://factorcode.org/git/factor
commit
2d21e94fa2
|
@ -305,10 +305,7 @@ os windows? [
|
|||
4 "double" c-type (>>align)
|
||||
] unless
|
||||
|
||||
FUNCTION: bool check_sse2 ( ) ;
|
||||
|
||||
: sse2? ( -- ? )
|
||||
check_sse2 ;
|
||||
USING: cpu.x86.features cpu.x86.features.private ;
|
||||
|
||||
"-no-sse2" (command-line) member? [
|
||||
[ { check_sse2 } compile ] with-optimizer
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
|
@ -0,0 +1,7 @@
|
|||
IN: cpu.x86.features.tests
|
||||
USING: cpu.x86.features tools.test kernel sequences math system ;
|
||||
|
||||
cpu x86? [
|
||||
[ t ] [ sse2? { t f } member? ] unit-test
|
||||
[ t ] [ [ 10000 [ ] times ] count-instructions integer? ] unit-test
|
||||
] when
|
|
@ -0,0 +1,25 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: system kernel math alien.syntax ;
|
||||
IN: cpu.x86.features
|
||||
|
||||
<PRIVATE
|
||||
|
||||
FUNCTION: bool check_sse2 ( ) ;
|
||||
|
||||
FUNCTION: longlong read_timestamp_counter ( ) ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
HOOK: sse2? cpu ( -- ? )
|
||||
|
||||
M: x86.32 sse2? check_sse2 ;
|
||||
|
||||
M: x86.64 sse2? t ;
|
||||
|
||||
HOOK: instruction-count cpu ( -- n )
|
||||
|
||||
M: x86 instruction-count read_timestamp_counter ;
|
||||
|
||||
: count-instructions ( quot -- n )
|
||||
instruction-count [ call ] dip instruction-count swap - ; inline
|
|
@ -55,6 +55,10 @@ DEF(bool,check_sse2,(void)):
|
|||
mov %edx,%eax
|
||||
ret
|
||||
|
||||
DEF(long long,read_timestamp_counter,(void)):
|
||||
rdtsc
|
||||
ret
|
||||
|
||||
DEF(void,primitive_inline_cache_miss,(void)):
|
||||
mov (%esp),%ebx
|
||||
DEF(void,primitive_inline_cache_miss_tail,(void)):
|
||||
|
@ -69,4 +73,5 @@ DEF(void,primitive_inline_cache_miss_tail,(void)):
|
|||
#ifdef WINDOWS
|
||||
.section .drectve
|
||||
.ascii " -export:check_sse2"
|
||||
.ascii " -export:read_timestamp_counter"
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,13 @@ DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, voi
|
|||
call *ARG3 /* call memcpy */
|
||||
ret /* return _with new stack_ */
|
||||
|
||||
DEF(long long,read_timestamp_counter,(void)):
|
||||
mov $0,%rax
|
||||
rdtsc
|
||||
shl $32,%rdx
|
||||
or %rdx,%rax
|
||||
ret
|
||||
|
||||
DEF(void,primitive_inline_cache_miss,(void)):
|
||||
mov (%rsp),%rbx
|
||||
DEF(void,primitive_inline_cache_miss_tail,(void)):
|
||||
|
|
Loading…
Reference in New Issue