Changeset 4272


Ignore:
Timestamp:
Oct 28, 2014, 12:17:38 PM (4 years ago)
Author:
nmedfort
Message:

Implemented slab allocator based on the original Parabix StringPool?; intergrated it with RE and Pablo AST nodes.

Location:
icGREP/icgrep-devel/icgrep
Files:
2 added
29 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4251 r4272  
    5151set(Boost_USE_MULTITHREADED OFF)
    5252set(Boost_USE_STATIC_RUNTIME OFF)
    53 #find_package(Boost 1.21 COMPONENTS system)
     53# find_package(Boost COMPONENTS system filesystem REQUIRED)
    5454
    5555add_library(PabloADT pablo/pe_and.cpp pablo/pe_not.cpp pablo/pe_or.cpp  pablo/pabloAST.cpp  pablo/pe_sel.cpp  pablo/pe_xor.cpp pablo/codegenstate.cpp  pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp)
    56 add_library(RegExpADT re/re_cc.cpp re/re_parser.cpp re/re_rep.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/printer_re.cpp)
     56add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_parser.cpp re/re_rep.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/printer_re.cpp)
    5757add_library(CCADT cc/cc_namemap.cpp cc/cc_compiler.cpp utf_encoding.cpp utf8_encoder.cpp unicode_categories.h)
    5858
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r4268 r4272  
    224224pablo/analysis/useanalysis.cpp
    225225pablo/analysis/useanalysis.h
     226slab_allocator.h
     227re/re_re.cpp
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r4252 r4272  
    2121
    2222namespace pablo {
     23
     24PabloAST::Allocator PabloAST::mAllocator;
    2325
    2426/*
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4270 r4272  
    99
    1010#include <llvm/Support/Casting.h>
     11#include <slab_allocator.h>
    1112#include <vector>
    1213
     
    1920class PabloAST {
    2021public:
     22    typedef SlabAllocator<1024> Allocator;
    2123    enum class ClassTypeId : unsigned {
    2224        Advance
     
    4143        return mClassTypeId;
    4244    }
     45    inline static void release_memory() {
     46        mAllocator.release_memory();
     47    }
    4348protected:
    4449    inline PabloAST(const ClassTypeId id)
     
    4752
    4853    }
     54    static Allocator mAllocator;
    4955private:
    5056    const ClassTypeId   mClassTypeId;
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r4260 r4272  
    3030    }
    3131protected:
     32    void* operator new (std::size_t size) noexcept {
     33        return mAllocator.allocate(size);
     34    }
    3235    Advance(PabloAST * expr, int shiftAmount)
    3336    : PabloAST(ClassTypeId::Advance)
  • icGREP/icgrep-devel/icgrep/pablo/pe_and.h

    r4244 r4272  
    3333    }
    3434protected:
     35    void* operator new (std::size_t size) noexcept {
     36        return mAllocator.allocate(size);
     37    }
    3538    And(PabloAST * expr1, PabloAST * expr2)
    3639    : PabloAST(ClassTypeId::And)
  • icGREP/icgrep-devel/icgrep/pablo/pe_call.h

    r4257 r4272  
    2222        return mCallee;
    2323    }
    24 protected:   
     24protected:
     25    void* operator new (std::size_t size) noexcept {
     26        return mAllocator.allocate(size);
     27    }
    2528    Call(const PabloAST * callee)
    2629    : PabloAST(ClassTypeId::Call)
  • icGREP/icgrep-devel/icgrep/pablo/pe_next.h

    r4257 r4272  
    2828    }
    2929protected:
     30    void* operator new (std::size_t size) noexcept {
     31        return mAllocator.allocate(size);
     32    }
    3033    Next(const PabloAST * initial, PabloAST * expr)
    3134    : PabloAST(ClassTypeId::Next)
  • icGREP/icgrep-devel/icgrep/pablo/pe_not.h

    r4244 r4272  
    3030    }
    3131protected:
     32    void* operator new (std::size_t size) noexcept {
     33        return mAllocator.allocate(size);
     34    }
    3235    Not(PabloAST * expr)
    3336    : PabloAST(ClassTypeId::Not)
  • icGREP/icgrep-devel/icgrep/pablo/pe_ones.h

    r4248 r4272  
    3131    }
    3232protected:
    33     Ones()
    34     : PabloAST(ClassTypeId::Ones)
    35     {
    36 
     33    void* operator new (std::size_t size) noexcept {
     34        return mAllocator.allocate(size);
    3735    }
     36    Ones() : PabloAST(ClassTypeId::Ones) { }
    3837};
    3938
  • icGREP/icgrep-devel/icgrep/pablo/pe_or.h

    r4244 r4272  
    3333    }
    3434protected:
     35    void* operator new (std::size_t size) noexcept {
     36        return mAllocator.allocate(size);
     37    }
    3538    Or(PabloAST * expr1, PabloAST * expr2)
    3639    : PabloAST(ClassTypeId::Or)
  • icGREP/icgrep-devel/icgrep/pablo/pe_sel.h

    r4244 r4272  
    3636    }
    3737protected:
     38    void* operator new (std::size_t size) noexcept {
     39        return mAllocator.allocate(size);
     40    }
    3841    Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr)
    3942    : PabloAST(ClassTypeId::Sel)
  • icGREP/icgrep-devel/icgrep/pablo/pe_string.h

    r4257 r4272  
    2626    }
    2727protected:
     28    void* operator new (std::size_t size) noexcept {
     29        return mAllocator.allocate(size);
     30    }
    2831    String(const std::string && value) noexcept
    2932    : PabloAST(ClassTypeId::String)
  • icGREP/icgrep-devel/icgrep/pablo/pe_var.h

    r4264 r4272  
    4545    }
    4646protected:
     47    void* operator new (std::size_t size) noexcept {
     48        return mAllocator.allocate(size);
     49    }
    4750    Var(const PabloAST * var)
    4851    : PabloAST(ClassTypeId::Var)
  • icGREP/icgrep-devel/icgrep/pablo/pe_xor.h

    r4244 r4272  
    3333    }
    3434protected:
     35    void* operator new (std::size_t size) noexcept {
     36        return mAllocator.allocate(size);
     37    }
    3538    Xor(PabloAST * expr1, PabloAST * expr2)
    3639    : PabloAST(ClassTypeId::Xor)
  • icGREP/icgrep-devel/icgrep/pablo/pe_zeroes.h

    r4248 r4272  
    3131    }
    3232protected:
    33     Zeroes()
    34     : PabloAST(ClassTypeId::Zeroes)
    35     {
    36 
     33    void* operator new (std::size_t size) noexcept {
     34        return mAllocator.allocate(size);
    3735    }
     36    Zeroes() : PabloAST(ClassTypeId::Zeroes) { }
    3837};
    3938
  • icGREP/icgrep-devel/icgrep/pablo/ps_assign.h

    r4268 r4272  
    3737    }
    3838protected:
     39    void* operator new (std::size_t size) noexcept {
     40        return mAllocator.allocate(size);
     41    }
    3942    Assign(PabloAST * name, PabloAST * expr, const int outputIndex)
    4043    : PabloAST(ClassTypeId::Assign)
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.h

    r4264 r4272  
    3636    }
    3737protected:
     38    void* operator new (std::size_t size) noexcept {
     39        return mAllocator.allocate(size);
     40    }
    3841    If(PabloAST * expr, StatementList && body)
    3942    : PabloAST(ClassTypeId::If)
     
    4649private:
    4750    PabloAST * const    mExpr;
    48     StatementList      mBody;
     51    StatementList       mBody;
    4952    unsigned            mCarryCount;
    5053};
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4264 r4272  
    3636    }
    3737protected:
     38    void* operator new (std::size_t size) noexcept {
     39        return mAllocator.allocate(size);
     40    }
    3841    While(PabloAST * expr, StatementList && body)
    3942    : PabloAST(ClassTypeId::While)
     
    4649private:
    4750    PabloAST * const    mExpr;
    48     StatementList      mBody;
     51    StatementList       mBody;
    4952    unsigned            mCarryCount;
    5053};
  • icGREP/icgrep-devel/icgrep/re/re_alt.h

    r4249 r4272  
    1111#include "re_cc.h"
    1212#include <queue>
     13#include <iostream>
    1314
    1415namespace re {
     
    3233    : Vector(ClassTypeId::Alt, begin, end) {
    3334
    34     }   
     35    }
     36    void* operator new (std::size_t size) noexcept {
     37        return mAllocator.allocate(size);
     38    }
    3539private:
    3640    template<typename iterator>
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r4255 r4272  
    109109
    110110protected:
    111 
     111    friend CC * makeCC();
     112    friend CC * makeCC(const CodePointType codepoint);
     113    friend CC * makeCC(const CodePointType lo, const CodePointType hi);
     114    friend CC * makeCC(const CC * cc1, const CC * cc2);
     115    void* operator new (std::size_t size) noexcept {
     116        return mAllocator.allocate(size);
     117    }
    112118    inline CC()
    113119    : RE(ClassTypeId::CC) {
     
    123129        insert_range(lo_codepoint, hi_codepoint);
    124130    }
    125 
    126131    CC(const CC * cc1, const CC * cc2);
    127 
    128     friend CC * makeCC();
    129     friend CC * makeCC(const CodePointType codepoint);
    130     friend CC * makeCC(const CodePointType lo, const CodePointType hi);
    131     friend CC * makeCC(const CC * cc1, const CC * cc2);
    132 
    133132private:   
    134133    CharSetVector mSparseCharSet;
  • icGREP/icgrep-devel/icgrep/re/re_diff.h

    r4255 r4272  
    2828protected:
    2929    friend Diff * makeDiff(RE*, RE*);
     30    void* operator new (std::size_t size) noexcept {
     31        return mAllocator.allocate(size);
     32    }
    3033    Diff(RE * lh, RE * rh)
    3134    : RE(ClassTypeId::Diff)
  • icGREP/icgrep-devel/icgrep/re/re_end.h

    r4206 r4272  
    2323protected:
    2424    friend End * makeEnd();
     25    void* operator new (std::size_t size) noexcept {
     26        return mAllocator.allocate(size);
     27    }
    2528    End() : RE(ClassTypeId::End) {}
    2629};
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4256 r4272  
    4343    friend Name * makeName(const std::string, RE *);
    4444    friend Name * makeName(const std::string, const Type);
    45 
     45    void* operator new (std::size_t size) noexcept {
     46        return mAllocator.allocate(size);
     47    }
    4648    Name(const std::string && name, const Type type, RE * cc)
    4749    : RE(ClassTypeId::Name)
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4271 r4272  
    266266
    267267RE * RE_Parser::parse_charset() {
    268     std::unique_ptr<CC> cc(makeCC());
     268    CC * cc = makeCC();
    269269    bool negated = false;
    270270    cursor_t start = ++_cursor;
     
    291291                ++_cursor;
    292292                if (negated) {
    293                     return makeDiff(makeAny(), cc.release());
    294                 }
    295                 return cc.release();
     293                    return makeDiff(makeAny(), cc);
     294                }
     295                return cc;
    296296            // The hyphen (-) is not treated as a range separator if it appears first or last, or as the
    297297            // endpoint of a range.
  • icGREP/icgrep-devel/icgrep/re/re_re.h

    r4251 r4272  
    1111#include <assert.h>
    1212#include <llvm/Support/Casting.h>
     13#include <slab_allocator.h>
    1314
    1415using namespace llvm;
     
    3536class RE {
    3637public:
     38    typedef SlabAllocator<1024> Allocator;
    3739    enum class ClassTypeId : unsigned {
    3840        Alt
     
    5355        return mClassTypeId;
    5456    }
     57    inline static void release_memory() {
     58        mAllocator.release_memory();
     59    }
    5560    typedef std::initializer_list<RE *> InitializerList;
    5661protected:
     
    6065    }
    6166    const ClassTypeId mClassTypeId;
     67
     68    static Allocator mAllocator;
    6269};
    6370
  • icGREP/icgrep-devel/icgrep/re/re_rep.h

    r4206 r4272  
    3030protected:
    3131    friend RE * makeRep(RE *, const int, const int);
     32    void* operator new (std::size_t size) noexcept {
     33        return mAllocator.allocate(size);
     34    }
    3235    Rep(RE * re, const int lb, const int ub);
    3336private:
  • icGREP/icgrep-devel/icgrep/re/re_seq.h

    r4249 r4272  
    2525protected:
    2626    friend Seq * makeSeq();
     27    void* operator new (std::size_t size) noexcept {
     28        return mAllocator.allocate(size);
     29    }
    2730    template<typename iterator> friend RE * makeSeq(iterator, iterator);
    2831    Seq()
  • icGREP/icgrep-devel/icgrep/re/re_start.h

    r4255 r4272  
    2222protected:
    2323    friend Start * makeStart();
     24    void* operator new (std::size_t size) noexcept {
     25        return mAllocator.allocate(size);
     26    }
    2427    Start() : RE(ClassTypeId::Start) {}
    2528    virtual ~Start() {}
Note: See TracChangeset for help on using the changeset viewer.