Changeset bfc7811


Ignore:
Timestamp:
Apr 10, 2018, 2:43:50 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
9f2012f
Parents:
dbc2c2c
Message:

Fix some GC bugs

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Common/GC.cc

    rdbc2c2c rbfc7811  
    117117}
    118118
    119 bool stack_check( int* i, GC_Object* o ) {
    120         int j;
    121         return ( i < &j ) == ( (void*)o < (void*)&j );
    122 }
    123 
    124119GC_Object::GC_Object() {
    125120        GC::get().register_object( this );
    126 
    127         int i;
    128         assert(!stack_check(&i, this));
    129121}
    130122
  • src/Common/GC.h

    rdbc2c2c rbfc7811  
    7171inline void new_generation() { GC::get().new_generation(); }
    7272
    73 /// no-op default trace
    74 template<typename T>
    75 inline const GC& operator<< (const GC& gc, const T& x) { return gc; }
     73// /// no-op default trace
     74// template<typename T>
     75// inline const GC& operator<< (const GC& gc, const T& x) { return gc; }
    7676
    7777inline void traceAll(const GC&) {}
  • src/ControlStruct/ExceptTranslate.cc

    rdbc2c2c rbfc7811  
    104104                // Types used in translation, make sure to use clone.
    105105                // void (*function)();
    106                 FunctionType try_func_t;
     106                FunctionType * try_func_t;
    107107                // void (*function)(int, exception);
    108                 FunctionType catch_func_t;
     108                FunctionType * catch_func_t;
    109109                // int (*function)(exception);
    110                 FunctionType match_func_t;
     110                FunctionType * match_func_t;
    111111                // bool (*function)(exception);
    112                 FunctionType handle_func_t;
     112                FunctionType * handle_func_t;
    113113                // void (*function)(__attribute__((unused)) void *);
    114                 FunctionType finally_func_t;
     114                FunctionType * finally_func_t;
    115115
    116116                StructInstType * create_except_type() {
     
    125125                        handler_except_decl( nullptr ),
    126126                        except_decl( nullptr ), node_decl( nullptr ), hook_decl( nullptr ),
    127                         try_func_t( noQualifiers, false ),
    128                         catch_func_t( noQualifiers, false ),
    129                         match_func_t( noQualifiers, false ),
    130                         handle_func_t( noQualifiers, false ),
    131                         finally_func_t( noQualifiers, false )
     127                        try_func_t( new FunctionType(noQualifiers, false) ),
     128                        catch_func_t( new FunctionType(noQualifiers, false) ),
     129                        match_func_t( new FunctionType(noQualifiers, false) ),
     130                        handle_func_t( new FunctionType(noQualifiers, false) ),
     131                        finally_func_t( new FunctionType(noQualifiers, false) )
    132132                {}
    133133
     
    141141                assert( except_decl );
    142142
    143                 ObjectDecl index_obj(
     143                auto index_obj = new ObjectDecl(
    144144                        "__handler_index",
    145145                        Type::StorageClasses(),
     
    149149                        /*init*/ NULL
    150150                        );
    151                 ObjectDecl exception_obj(
     151                auto exception_obj = new ObjectDecl(
    152152                        "__exception_inst",
    153153                        Type::StorageClasses(),
     
    160160                        /*init*/ NULL
    161161                        );
    162                 ObjectDecl bool_obj(
     162                auto bool_obj = new ObjectDecl(
    163163                        "__ret_bool",
    164164                        Type::StorageClasses(),
     
    169169                        std::list<Attribute *>{ new Attribute( "unused" ) }
    170170                        );
    171                 ObjectDecl voidptr_obj(
     171                auto voidptr_obj = new ObjectDecl(
    172172                        "__hook",
    173173                        Type::StorageClasses(),
     
    184184                        );
    185185
    186                 ObjectDecl * unused_index_obj = index_obj.clone();
     186                ObjectDecl * unused_index_obj = index_obj->clone();
    187187                unused_index_obj->attributes.push_back( new Attribute( "unused" ) );
    188188
    189                 catch_func_t.get_parameters().push_back( index_obj.clone() );
    190                 catch_func_t.get_parameters().push_back( exception_obj.clone() );
    191                 match_func_t.get_returnVals().push_back( unused_index_obj );
    192                 match_func_t.get_parameters().push_back( exception_obj.clone() );
    193                 handle_func_t.get_returnVals().push_back( bool_obj.clone() );
    194                 handle_func_t.get_parameters().push_back( exception_obj.clone() );
    195                 finally_func_t.get_parameters().push_back( voidptr_obj.clone() );
     189                catch_func_t->get_parameters().push_back( index_obj );
     190                catch_func_t->get_parameters().push_back( exception_obj->clone() );
     191                match_func_t->get_returnVals().push_back( unused_index_obj );
     192                match_func_t->get_parameters().push_back( exception_obj->clone() );
     193                handle_func_t->get_returnVals().push_back( bool_obj );
     194                handle_func_t->get_parameters().push_back( exception_obj );
     195                finally_func_t->get_parameters().push_back( voidptr_obj );
    196196        }
    197197
     
    264264
    265265                return new FunctionDecl( "try", Type::StorageClasses(),
    266                         LinkageSpec::Cforall, try_func_t.clone(), body );
     266                        LinkageSpec::Cforall, try_func_t->clone(), body );
    267267        }
    268268
     
    271271                std::list<CaseStmt *> handler_wrappers;
    272272
    273                 FunctionType *func_type = catch_func_t.clone();
     273                FunctionType *func_type = catch_func_t->clone();
    274274                DeclarationWithType * index_obj = func_type->get_parameters().front();
    275275                DeclarationWithType * except_obj = func_type->get_parameters().back();
     
    392392                CompoundStmt * body = new CompoundStmt();
    393393
    394                 FunctionType * func_type = match_func_t.clone();
     394                FunctionType * func_type = match_func_t->clone();
    395395                DeclarationWithType * except_obj = func_type->get_parameters().back();
    396396
     
    446446                CompoundStmt * body = new CompoundStmt();
    447447
    448                 FunctionType * func_type = handle_func_t.clone();
     448                FunctionType * func_type = handle_func_t->clone();
    449449                DeclarationWithType * except_obj = func_type->get_parameters().back();
    450450
     
    529529
    530530                return new FunctionDecl("finally", Type::StorageClasses(),
    531                         LinkageSpec::Cforall, finally_func_t.clone(), body);
     531                        LinkageSpec::Cforall, finally_func_t->clone(), body);
    532532        }
    533533
  • src/GenPoly/Box.cc

    rdbc2c2c rbfc7811  
    279279        /// Adds parameters for otype layout to a function type
    280280        void addOtypeParams( FunctionType *layoutFnType, std::list< TypeDecl* > &otypeParams ) {
    281                 BasicType sizeAlignType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    282 
    283                 for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin(); param != otypeParams.end(); ++param ) {
     281                auto sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     282
     283                for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin();
     284                                param != otypeParams.end(); ++param ) {
    284285                        TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param );
    285286                        std::string paramName = mangleType( &paramType );
    286                         layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
    287                         layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
     287                        layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType->clone(), 0 ) );
     288                        layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType->clone(), 0 ) );
    288289                }
    289290        }
     
    740741                                Type * newType = param->clone();
    741742                                if ( env ) env->apply( newType );
    742                                 ObjectDecl *newObj = ObjectDecl::newObject( tempNamer.newName(), newType, nullptr );
     743                                ObjectDecl *newObj = ObjectDecl::newObject(
     744                                        tempNamer.newName(), newType, nullptr );
    743745                                newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right???
    744746                                stmtsToAddBefore.push_back( new DeclStmt( newObj ) );
     
    13251327                        std::list< DeclarationWithType *> inferredParams;
    13261328                        // size/align/offset parameters may not be used in body, pass along with unused attribute.
    1327                         ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
    1328                                            { new Attribute( "unused" ) } );
    1329                         ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
    1330                                            new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1331                         for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1329                        auto newObj = new ObjectDecl(
     1330                                "", Type::StorageClasses(), LinkageSpec::C, 0,
     1331                                new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
     1332                            { new Attribute( "unused" ) } );
     1333                        auto newPtr = new ObjectDecl(
     1334                                "", Type::StorageClasses(), LinkageSpec::C, 0,
     1335                            new PointerType( Type::Qualifiers(),
     1336                                        new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
     1337                        for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin();
     1338                                        tyParm != funcType->get_forall().end(); ++tyParm ) {
    13321339                                ObjectDecl *sizeParm, *alignParm;
    13331340                                // add all size and alignment parameters to parameter list
     
    13361343                                        std::string parmName = mangleType( &parmType );
    13371344
    1338                                         sizeParm = newObj.clone();
     1345                                        sizeParm = newObj->clone();
    13391346                                        sizeParm->set_name( sizeofName( parmName ) );
    13401347                                        last = funcType->get_parameters().insert( last, sizeParm );
    13411348                                        ++last;
    13421349
    1343                                         alignParm = newObj.clone();
     1350                                        alignParm = newObj->clone();
    13441351                                        alignParm->set_name( alignofName( parmName ) );
    13451352                                        last = funcType->get_parameters().insert( last, alignParm );
     
    13641371
    13651372                                        ObjectDecl *sizeParm, *alignParm, *offsetParm;
    1366                                         sizeParm = newObj.clone();
     1373                                        sizeParm = newObj->clone();
    13671374                                        sizeParm->set_name( sizeofName( typeName ) );
    13681375                                        last = funcType->get_parameters().insert( last, sizeParm );
    13691376                                        ++last;
    13701377
    1371                                         alignParm = newObj.clone();
     1378                                        alignParm = newObj->clone();
    13721379                                        alignParm->set_name( alignofName( typeName ) );
    13731380                                        last = funcType->get_parameters().insert( last, alignParm );
     
    13771384                                                // NOTE zero-length arrays are illegal in C, so empty structs have no offset array
    13781385                                                if ( ! polyBaseStruct->get_baseStruct()->get_members().empty() ) {
    1379                                                         offsetParm = newPtr.clone();
     1386                                                        offsetParm = newPtr->clone();
    13801387                                                        offsetParm->set_name( offsetofName( typeName ) );
    13811388                                                        last = funcType->get_parameters().insert( last, offsetParm );
     
    16141621
    16151622                ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) {
    1616                         ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init );
     1623                        ObjectDecl *newObj = new ObjectDecl(
     1624                                name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init );
    16171625                        stmtsToAddBefore.push_back( new DeclStmt( newObj ) );
    16181626                        return newObj;
  • src/SynTree/GcTracer.h

    rdbc2c2c rbfc7811  
    3636        void previsit( BaseSyntaxNode * node ) {
    3737                // skip tree if already seen
    38                 if ( node->mark == gc.mark ) {
    39                         visit_children = false;
    40                         return;
    41                 }
     38                // if ( node->mark == gc.mark ) {
     39                //      visit_children = false;
     40                //      return;
     41                // }
    4242
    4343                // mark node
Note: See TracChangeset for help on using the changeset viewer.