Exemple #1
0
// Process a constant within the code.  This is a direct copy of ScanAddress::ScanConstant
// with the addition of the locking.
void MTGCProcessMarkPointers::ScanConstant(byte *addressOfConstant, ScanRelocationKind code)
{
    // If this code is in the local area there's the possibility that
    // ScanObjectAddress could return an updated address for a
    // constant within the code.  This could happen if the code is
    // in the allocation area or if it has been moved into the
    // mutable/immutable area by the last incomplete partial GC.
    // Constants can be aligned on any byte offset so another thread
    // scanning the same code could see an invalid address if it read
    // the constant while it was being updated.  We put a lock round
    // this just in case.
    LocalMemSpace *space = gMem.LocalSpaceForAddress(addressOfConstant);

    if (space != 0)
        space->spaceLock.Lock();
    PolyWord p = GetConstantValue(addressOfConstant, code);
    if (space != 0)
        space->spaceLock.Unlock();

    if (! IS_INT(p))
    {
        PolyWord oldValue = p;
        ScanAddress::ScanAddressAt(&p);
        if (p != oldValue) // Update it if it has changed.
        {
            if (space != 0)
                space->spaceLock.Lock();
            SetConstantValue(addressOfConstant, p, code);
            if (space != 0)
                space->spaceLock.Unlock();
        }
    }
}
Exemple #2
0
// The default action is to call the DEFAULT ScanAddressAt NOT the virtual which means that it calls
// ScanObjectAddress for the base address of the object referred to.
void ScanAddress::ScanConstant(byte *addressOfConstant, ScanRelocationKind code)
{
    PolyWord p = GetConstantValue(addressOfConstant, code);

    if (! IS_INT(p))
    {
        PolyWord oldValue = p;
        ScanAddress::ScanAddressAt(&p);
        if (p != oldValue) // Update it if it has changed.
            SetConstantValue(addressOfConstant, p, code);
    }
}
Exemple #3
0
// How a button loads itself from a file
int MyButton::LoadLayout(FILE *fp, int &line, std::string &errmsg) {
    char s[1024], arg[1024];
    int braces = 0;
    while ( fgets(s, sizeof(s)-1, fp) != 0 ) {
        line++;
        char *ss = skipwhite(s);
        if ( *ss == '\n' || *ss == '\r' || *ss == 0 || *ss == '#' ) {   // skip blank lines + comments
            continue;
        }
        if ( *ss == '{' ) {                                     // count open braces
            ++braces;
            continue;
        }
        if ( *ss == '}' ) {                             // count close braces
            if ( --braces <= 0 ) { break; }
            else { continue; }
        }
        if ( sscanf(ss, "dtype %79s", arg) == 1 ) {
            if ( SetDataTypeStr(arg) < 0 ) {
                errmsg = std::string("unknown data type '") +
                         std::string(arg) +
                         std::string("'") +
                         std::string("\n") + std::string(s);
                return(-1);
            }
            continue;
        }
        if ( sscanf(ss, "const %1023[^\n]\n", arg) == 1 ) {
            SetConstantValue(arg);
            continue;
        }
        // Got this far? Unknown command
        errmsg = std::string("unknown button command") +
                 std::string("\n") + std::string(s);
        return(-1);
    }
    return(0);
}