From d42edecffba30584bcc8c1534932d3085319442c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 11 Aug 2008 23:30:18 -0500 Subject: [PATCH 1/3] Updating codegen for new optimizer --- unfinished/compiler/generator/authors.txt | 1 + .../compiler/generator/fixup/authors.txt | 1 + .../generator/fixup/fixup-docs.factor | 16 + .../compiler/generator/fixup/fixup.factor | 154 ++++ .../compiler/generator/fixup/summary.txt | 1 + .../compiler/generator/generator-docs.factor | 88 +++ .../compiler/generator/generator.factor | 269 +++++++ .../generator/iterator/iterator.factor | 41 ++ .../compiler/generator/registers/authors.txt | 1 + .../generator/registers/registers.factor | 660 ++++++++++++++++++ .../compiler/generator/registers/summary.txt | 1 + unfinished/compiler/generator/summary.txt | 1 + unfinished/compiler/generator/tags.txt | 1 + .../compiler/tree/debugger/debugger.factor | 12 +- unfinished/compiler/tree/tree.factor | 5 + .../stack-checker/inlining/inlining.factor | 4 +- 16 files changed, 1247 insertions(+), 9 deletions(-) create mode 100644 unfinished/compiler/generator/authors.txt create mode 100644 unfinished/compiler/generator/fixup/authors.txt create mode 100644 unfinished/compiler/generator/fixup/fixup-docs.factor create mode 100755 unfinished/compiler/generator/fixup/fixup.factor create mode 100644 unfinished/compiler/generator/fixup/summary.txt create mode 100755 unfinished/compiler/generator/generator-docs.factor create mode 100755 unfinished/compiler/generator/generator.factor create mode 100644 unfinished/compiler/generator/iterator/iterator.factor create mode 100644 unfinished/compiler/generator/registers/authors.txt create mode 100755 unfinished/compiler/generator/registers/registers.factor create mode 100644 unfinished/compiler/generator/registers/summary.txt create mode 100644 unfinished/compiler/generator/summary.txt create mode 100644 unfinished/compiler/generator/tags.txt diff --git a/unfinished/compiler/generator/authors.txt b/unfinished/compiler/generator/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/unfinished/compiler/generator/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/unfinished/compiler/generator/fixup/authors.txt b/unfinished/compiler/generator/fixup/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/unfinished/compiler/generator/fixup/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/unfinished/compiler/generator/fixup/fixup-docs.factor b/unfinished/compiler/generator/fixup/fixup-docs.factor new file mode 100644 index 0000000000..a4ff549e8e --- /dev/null +++ b/unfinished/compiler/generator/fixup/fixup-docs.factor @@ -0,0 +1,16 @@ +USING: help.syntax help.markup math kernel +words strings alien ; +IN: compiler.generator.fixup + +HELP: frame-required +{ $values { "n" "a non-negative integer" } } +{ $description "Notify the code generator that the currently compiling code block needs a stack frame with room for at least " { $snippet "n" } " parameters." } ; + +HELP: add-literal +{ $values { "obj" object } { "n" integer } } +{ $description "Adds a literal to the " { $link literal-table } ", if it is not already there, and outputs the index of the literal in the table. This literal can then be used as an argument for a " { $link rt-literal } " relocation with " { $link rel-fixup } "." } ; + +HELP: rel-dlsym +{ $values { "name" string } { "dll" "a " { $link dll } " or " { $link f } } { "class" "a relocation class" } } +{ $description "Records that the most recently assembled instruction contains a reference to the " { $snippet "name" } " symbol from " { $snippet "dll" } ". The correct " { $snippet "class" } " to use depends on instruction formats." +} ; diff --git a/unfinished/compiler/generator/fixup/fixup.factor b/unfinished/compiler/generator/fixup/fixup.factor new file mode 100755 index 0000000000..e1b4e42e67 --- /dev/null +++ b/unfinished/compiler/generator/fixup/fixup.factor @@ -0,0 +1,154 @@ +! Copyright (C) 2007, 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays byte-arrays generic assocs hashtables io.binary +kernel kernel.private math namespaces sequences words +quotations strings alien.accessors alien.strings layouts system +combinators math.bitfields words.private cpu.architecture +math.order accessors growable ; +IN: compiler.generator.fixup + +: no-stack-frame -1 ; inline + +TUPLE: frame-required n ; + +: frame-required ( n -- ) \ frame-required boa , ; + +: stack-frame-size ( code -- n ) + no-stack-frame [ + dup frame-required? [ frame-required-n max ] [ drop ] if + ] reduce ; + +GENERIC: fixup* ( frame-size obj -- frame-size ) + +: code-format 22 getenv ; + +: compiled-offset ( -- n ) building get length code-format * ; + +TUPLE: label offset ; + +: