寻找一个函数的GHC程序集(finding GHC assembly for a function)
我想确定GHC为给定函数生成的组件。
这里,例如,是一些代码(应该)在一个字中旋转位 - 它将位0移动到位12,位12到14,位14移回0,类似地位置1,18,13和6。
在
ghc -O2 -S ...
生成的.S
文件中查找为rot0cw
生成的汇编的最佳方法是什么?我读过这个答案 ,但是在程序集输出中没有看到...
..._rot0cw_closure
。import Data.Bits import Data.Int (Int64) import Text.Printf import System.Environment {-# INLINE maskbits #-} -- set in word v the bits of b corresponding to the mask m -- assume a bit in b is zero if not in the mask maskbits v m b = (v .&. (complement m) .|. b) {-# INLINE tb #-} -- transfer bit i of word v to bit j of word m; assume bit j of m is 0 tb v i j m = m .|. (rotate (v .&. (bit i)) (j-i)) rot0cw :: Int64 -> Int64 rot0cw v = maskbits (maskbits v m1 b1) m2 b2 where m1 = 0x0000005005 b1 = tb v 0 2 . tb v 2 14 . tb v 14 12 . tb v 12 0 $ 0 m2 = 0x0000002142 b2 = tb v 1 8 . tb v 8 13 . tb v 13 6 . tb v 6 1 $ 0 showBits v = let set = [ i | i <- [0..35], testBit v i ] in "bits set: " ++ (unwords $ map show set) main = do (arg0:_) <- getArgs let v = read arg0 -- let v = 0x0000000005 let v' = rot0cw v putStrLn $ printf "v = 0x%010x = %12d %s" v v (showBits v) putStrLn $ printf "v' = 0x%010x = %12d %s" v' v' (showBits v')
I'd like to identify what assembly GHC produces for a given function.
Here, for example, is some code which (should) rotate bits around in a word - it moves bit 0 to bit 12, bit 12 to 14, bit 14 back to 0 and similarly for the positions 1, 18, 13 and 6.
What's the best way to go about finding the assembly generated for
rot0cw
in the.S
file produced byghc -O2 -S ...
?I've read this answer, but I don't see any
..._rot0cw_closure
in the assembly output.import Data.Bits import Data.Int (Int64) import Text.Printf import System.Environment {-# INLINE maskbits #-} -- set in word v the bits of b corresponding to the mask m -- assume a bit in b is zero if not in the mask maskbits v m b = (v .&. (complement m) .|. b) {-# INLINE tb #-} -- transfer bit i of word v to bit j of word m; assume bit j of m is 0 tb v i j m = m .|. (rotate (v .&. (bit i)) (j-i)) rot0cw :: Int64 -> Int64 rot0cw v = maskbits (maskbits v m1 b1) m2 b2 where m1 = 0x0000005005 b1 = tb v 0 2 . tb v 2 14 . tb v 14 12 . tb v 12 0 $ 0 m2 = 0x0000002142 b2 = tb v 1 8 . tb v 8 13 . tb v 13 6 . tb v 6 1 $ 0 showBits v = let set = [ i | i <- [0..35], testBit v i ] in "bits set: " ++ (unwords $ map show set) main = do (arg0:_) <- getArgs let v = read arg0 -- let v = 0x0000000005 let v' = rot0cw v putStrLn $ printf "v = 0x%010x = %12d %s" v v (showBits v) putStrLn $ printf "v' = 0x%010x = %12d %s" v' v' (showBits v')
原文:https://stackoverflow.com/questions/27495041
最满意答案
你可以将第一行改为位置
~ \.cgi$
? 这将是我的第一个猜测Can you change the first line to be location
~ \.cgi$
? That would be my first guess
相关问答
更多-
为什么lnmp搭建后nginx解析不了php?[2023-04-02]
回复 chenyx 以上是php配置,selinux也已经用命令setenforce 0关了!!! 帮忙看下还有什么需要注意的 -
nginx php-fpm 无法解析cgi文件,但是PHP类型的没问题[2023-10-18]
访问PHP文件成下载,这是nginx配置问题,原因是你没有把访问PHP文件的请求转发给PHP:9000端口,nginx本身不能解析 .php 文件,所以变成下载。你检查一下配置 .我给示例,帮得到你希望给分: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fas ... -
nginx和php-cgi的进程多开效果好吗?[2022-06-26]
回复 1# 的帖子 nginx 开2个就行了,php-cgi 根据自己的访问量调整就可以了。 -
请问windows下如何管理php-cgi进程[2022-03-23]
NMP环境现在还是比较多人用的,下面介绍一个修改php-cgi进程数的方法: 一、修改php-cgi: vi /usr/local/nginx/conf/nginx.conf 二、其中worker_processes 1;可以修改成2或3个,nginx本身就很强大,不需要像apache那样,开启过多的进程来保证其稳定运行。 vi /usr/local/php/etc/php-fpm.conf 三、找到,按你的内存容量修改PHP进程的数量,一般128内存开启6个,256内存开启16个。这样能保证, ... -
安装php的时候没有php-cgi[2021-04-28]
什么问题啊 用nginx只要 ./configure --prefix=/usr/local/php (5.3以下版本加上这个--enable-fastcgi) --enable-fpm -
问题解决了。 诀窍是使用以下几行 FastCGIExternalServer /var/www/fast-cgi-fake-handler -host 127.0.0.1:9000 AddType application/x-httpd-fastphp5 .php Action application/x-httpd-fastphp5 /fast-cgi-fake-handler Action +中的相对路径+ FastCGIExternalServer中的完整路径做到了! Problem solved. ...
-
天儿真好, Web服务器(例如Apache)只发送回静态内容是对客户端内容请求的响应。 例如,对http://www.myserver.com/index.html的请求通常会导致服务器打开文件并返回使用相关http组件包装的文件的内容。 基本上CGI是一种技术,用于根据需要通过Web服务器运行的其他应用程序动态生成此类网页。 目录cgi-bin通常用于存放正在运行的脚本。 虽然它主要集中在Perl上。“ 使用Perl进行CGI编程 ”一书有关于CGI的很好介绍。 编辑:正如在下面的评论中提到的那样,“如果 ...
-
PHP-FPM是fastCGI协议的一种实现,因此它遵守所有fastCGI规范要求。 其中一个要求是在规范的第3.5节中 ,特别是关于Closing连接: Web服务器控制传输连接的生命周期。 没有请求处于活动状态时,Web服务器可以关闭连接。 或者Web服务器可以将关闭权限委派给应用程序(请参阅FCGI_BEGIN_REQUEST)。 在这种情况下,应用程序在指定请求结束时关闭连接。 这种灵活性适用于各种应用程序样式。 简单应用程序将一次处理一个请求,并为每个请求接受新的传输连接。 更复杂的应用程序将通过 ...
-
nginx:解析* .cgi as php(nginx: parse *.cgi as php)[2023-03-21]
你可以将第一行改为位置~ \.cgi$ ? 这将是我的第一个猜测 Can you change the first line to be location ~ \.cgi$? That would be my first guess -
PHP-CGI Nginx的缩略图(Thumbnail on PHP-CGI Nginx)[2022-04-20]
如果我是正确的,我看看PHP文件,我认为你只是命名一个参数错误,尝试使用file而不是src image_products_thumb.php? file =7c885388d2584a80dd4bd5e21e14afd6.jpeg&.... If I'm correct, I took a look on the PHP file and I think you just named a parameter wrong, try using file instead of src image_produc ...