A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20130703/9dd7b5fb/attachment.html below:

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 3 July 2013 20:06, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
For my registervm project (fork of CPython using register-based<br>
bytecode, instead of stack-based bytecode), I implemented a<br>
Instruction.use_stack() method which just checks if the stack is<br>
"used": read the stack, exchange values in the stack (like "ROT"<br>
instruction), push or pop a value.<br>
<br>
Instruction.use_stack():<br>
<a href="http://hg.python.org/sandbox/registervm/file/ff24dfecc27d/Lib/registervm.py#l546" target="_blank">http://hg.python.org/sandbox/registervm/file/ff24dfecc27d/Lib/registervm.py#l546</a><br>
<br>
The method uses a dummy heuristic, just because it was quick to<br>
implement it, and it's enough for my use case.<br>
<br>
To answer your question: yes, I would like a opcode_stack_effect() function.<br>
<br>
registervm has its own disassembler which creates objects, rather than<br>
just generating a text representation of the bytecode. I'm using<br>
objects because I rewrite most instructions and I need more<br>
information and functions:<br>
<br>
* disassembler (raw bytes => list of instructions)<br>
* assembler (list of instructions => raw bytes)<br>
* format an instruction (human readable assembler)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
* is_terminal(): last instruction of a block<br>
* is_cond_jump(): the instruction is a conditional jump? hesitate to<br>
move this disassembler to CPython directly. I'm not sure that it would<br>
be useful, its API is maybe too specific to my registervm project.<br>
* is_reg_used(), is_reg_replaced(), is_reg_modified(), etc.: checks on registers<br>
* etc.<br>
<br>
Would it be useful to have such high-level API in Python?<br></blockquote><div><br>I finally committed a longstanding patch to add something like that a while ago for 3.4: <a href="http://docs.python.org/dev/library/dis#bytecode-analysis">http://docs.python.org/dev/library/dis#bytecode-analysis</a></div>
<br></div><div class="gmail_quote">It's still fairly low level, but already far more programmatically useful than the old disassembler text.<br><br></div><div class="gmail_quote">I'm still inclined to push higher level stuff out to external libraries - this patch was mostly about making some of our compiler tests a bit more maintainable, as well as giving third party libraries better building blocks without changing the dis module too much.<br>
<br></div><div class="gmail_quote">To get back to Larry's question, though, I think exposing the stack effects through dis.Instruction would be a good idea (since that will have access to the oparg to calculate the variable effects).<br>
<br></div><div class="gmail_quote">As far as how to expose the data to Python goes, I suggest adding an _opcode C module to back opcode.py and eliminate the manual duplication of the opcode values while you're at it.<br>
</div><div class="gmail_quote"><br><div>Cheers,<br></div><div>Nick.<br></div></div><br>-- <br>Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>   |   Brisbane, Australia
</div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4