首页 \ 问答 \ 寻找一个函数的GHC程序集(finding GHC assembly for a function)

寻找一个函数的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 by ghc -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
更新时间:2023-08-29 11:08

最满意答案

你可以将第一行改为位置~ \.cgi$ ? 这将是我的第一个猜测


Can you change the first line to be location ~ \.cgi$? That would be my first guess

相关问答

更多
  • 回复 chenyx 以上是php配置,selinux也已经用命令setenforce 0关了!!! 帮忙看下还有什么需要注意的
  • 访问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 ...
  • 回复 1# 的帖子 nginx 开2个就行了,php-cgi 根据自己的访问量调整就可以了。
  • 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个。这样能保证, ...
  • 什么问题啊 用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)。 在这种情况下,应用程序在指定请求结束时关闭连接。 这种灵活性适用于各种应用程序样式。 简单应用程序将一次处理一个请求,并为每个请求接受新的传输连接。 更复杂的应用程序将通过 ...
  • 你可以将第一行改为位置~ \.cgi$ ? 这将是我的第一个猜测 Can you change the first line to be location ~ \.cgi$? That would be my first guess
  • 如果我是正确的,我看看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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)