Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,41 +1,33 @@
|
|||
(notonline)-->
|
||||
<span style="color: #000080;font-style:italic;">--
|
||||
-- demo\rosetta\Compiler\vm.exw
|
||||
-- ============================
|
||||
--
|
||||
-- Since we have generated executable machine code, the virtual machine, such as it is, is just
|
||||
-- the higher level implementations of printc/i/s, see setbuiltins() in cgen.e
|
||||
-- Otherwise the only difference between this and cgen.exw is call(code_mem) instead of decode().
|
||||
--
|
||||
-- A quick test (calculating fib(44) 10^6 times) suggests ~500 times faster than interp.exw -
|
||||
-- which is to be expected given that a single add instruction (1 clock) here is implemented as
|
||||
-- at least three (and quite possibly five!) resursive calls to interp() in the other.</span>
|
||||
-- demo\rosetta\Compiler\vm.exw
|
||||
-- Since we have generated executable machine code, the virtual machine, such as it is, is just
|
||||
-- the higher level implementations of printc/i/s, see setbuiltins() in cgen.e
|
||||
-- Otherwise the only difference between this and cgen.exw is call(code_mem) instead of decode().
|
||||
-- A quick test (calculating fib(44) 10^6 times) suggests ~500 times faster than interp.exw -
|
||||
-- which is to be expected given that a single add instruction (1 clock) here is implemented as
|
||||
-- at least three (and quite possibly five!) resursive calls to interp() in the other.
|
||||
format PE32
|
||||
--format ELF32
|
||||
-- Note: cgen generates 32-bit machine code, which cannot be executed directly from a 64-bit interpreter.
|
||||
-- You can however, via the magic of either the above format directives, use a 64-bit version of
|
||||
-- Phix to compile this (just add a -c command line option) to a 32-bit executable, which can.
|
||||
-- It would not be particularly difficult to emit 32 or 64 bit code, but some source code files
|
||||
-- would, fairly obviously, then be very nearly twice as long, and a fair bit harder to read.
|
||||
without js -- (machine code!)
|
||||
include cgen.e
|
||||
|
||||
<span style="color: #000000;">format</span> <span style="color: #000000;">PE32</span>
|
||||
<span style="color: #000080;font-style:italic;">--format ELF32
|
||||
-- Note: cgen generates 32-bit machine code, which cannot be executed directly from a 64-bit interpreter.
|
||||
-- You can however, via the magic of either the above format directives, use a 64-bit version of
|
||||
-- Phix to compile this (just add a -c command line option) to a 32-bit executable, which can.
|
||||
-- It would not be particularly difficult to emit 32 or 64 bit code, but some source code files
|
||||
-- would, fairly obviously, then be very nearly twice as long, and a fair bit harder to read.</span>
|
||||
procedure main(sequence cl)
|
||||
open_files(cl)
|
||||
toks = lex()
|
||||
object t = parse()
|
||||
code_gen(t)
|
||||
fixup()
|
||||
if machine_bits()=32 then
|
||||
-- ^ as per note above
|
||||
call(code_mem)
|
||||
end if
|
||||
free({var_mem,code_mem})
|
||||
close_files()
|
||||
end procedure
|
||||
|
||||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (machine code!)</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #000000;">cgen</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
|
||||
<span style="color: #008080;">procedure</span> <span style="color: #000000;">main</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">cl</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">open_files</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cl</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">toks</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">lex</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #004080;">object</span> <span style="color: #000000;">t</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">parse</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #000000;">code_gen</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">fixup</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">machine_bits</span><span style="color: #0000FF;">()=</span><span style="color: #000000;">32</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #000080;font-style:italic;">-- ^ as per note above</span>
|
||||
<span style="color: #000000;">call</span><span style="color: #0000FF;">(</span><span style="color: #000000;">code_mem</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #7060A8;">free</span><span style="color: #0000FF;">({</span><span style="color: #000000;">var_mem</span><span style="color: #0000FF;">,</span><span style="color: #000000;">code_mem</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #000000;">close_files</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
|
||||
|
||||
<span style="color: #000080;font-style:italic;">--main(command_line())</span>
|
||||
<span style="color: #000000;">main</span><span style="color: #0000FF;">({</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"count.c"</span><span style="color: #0000FF;">})</span>
|
||||
<!--
|
||||
--main(command_line())
|
||||
main({0,0,"count.c"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue