This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Ticket #3708: Bug_1227028_Mod.diff

File Bug_1227028_Mod.diff, 5.7 KB (added by Yves, 8 years ago)

Modified version of the patch in bug 1227028 (modified context lines in Ion.cpp)

  • js/src/jit/Ion.cpp

    # HG changeset patch
    # User Hannes Verschore <hv1989@gmail.com>
    # Date 1448912718 -3600
    # Node ID 7683aae0caff682c97e21bbe0e6e40c0c958f7eb
    # Parent  541a97a551cb7bdd2791e937b3cb2a087b0eab6f
    Bug 1227028: TraceLogger - Fix when to keep the payload of a TraceLogger event, r=bbouvier
    
    diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp
    a b IonScript::Trace(JSTracer* trc, IonScrip  
    12471247void
    12481248IonScript::Destroy(FreeOp* fop, IonScript* script)
    12491249{
    12501250    if (script->pendingBuilder())
    12511251        jit::FinishOffThreadBuilder(nullptr, script->pendingBuilder());
    12521252
    12531253    script->destroyCaches();
    12541254    script->unlinkFromRuntime(fop);
     1255    // Frees the potential event we have set.
     1256    script->traceLoggerScriptEvent_ = TraceLoggerEvent();
    12551257    fop->free_(script);
    12561258}
    12571259
    12581260void
    12591261IonScript::toggleBarriers(bool enabled)
    12601262{
    12611263    method()->togglePreBarriers(enabled);
    12621264}
  • js/src/vm/TraceLogging.cpp

    diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp
    a b TraceLoggerThread::extractScriptDetails(  
    344344    *lineno_len = *colno - *lineno - 1;
    345345    *colno_len = strlen(*colno);
    346346}
    347347
    348348TraceLoggerEventPayload*
    349349TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId textId)
    350350{
    351351    TextIdHashMap::AddPtr p = textIdPayloads.lookupForAdd(textId);
    352     if (p)
     352    if (p) {
     353        MOZ_ASSERT(p->value()->textId() == textId); // Sanity check.
    353354        return p->value();
     355    }
    354356
    355357    TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, (char*)nullptr);
    356358
    357359    if (!textIdPayloads.add(p, textId, payload))
    358360        return nullptr;
    359361
    360362    return payload;
    361363}
    362364
    363365TraceLoggerEventPayload*
    364366TraceLoggerThread::getOrCreateEventPayload(const char* text)
    365367{
    366368    PointerHashMap::AddPtr p = pointerMap.lookupForAdd((const void*)text);
    367     if (p)
     369    if (p) {
     370        MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check.
    368371        return p->value();
     372    }
    369373
    370374    size_t len = strlen(text);
    371375    char* str = js_pod_malloc<char>(len + 1);
    372376    if (!str)
    373377        return nullptr;
    374378
    375379    DebugOnly<size_t> ret = JS_snprintf(str, len + 1, "%s", text);
    376380    MOZ_ASSERT(ret == len);
    TraceLoggerThread::getOrCreateEventPaylo  
    412416
    413417    // Only log scripts when enabled otherwise return the global Scripts textId,
    414418    // which will get filtered out.
    415419    MOZ_ASSERT(traceLoggerState);
    416420    if (!traceLoggerState->isTextIdEnabled(type))
    417421        return getOrCreateEventPayload(type);
    418422
    419423    PointerHashMap::AddPtr p = pointerMap.lookupForAdd(ptr);
    420     if (p)
     424    if (p) {
     425        MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check.
    421426        return p->value();
     427    }
    422428
    423429    // Compute the length of the string to create.
    424430    size_t lenFilename = strlen(filename);
    425431    size_t lenLineno = 1;
    426432    for (size_t i = lineno; i /= 10; lenLineno++);
    427433    size_t lenColno = 1;
    428434    for (size_t i = colno; i /= 10; lenColno++);
    429435
    TraceLoggerThread::log(uint32_t id)  
    561567            entryStart.time = start;
    562568            entryStart.textId = TraceLogger_Internal;
    563569
    564570            EventEntry& entryStop = events.pushUninitialized();
    565571            entryStop.time = rdtsc() - traceLoggerState->startupTime;
    566572            entryStop.textId = TraceLogger_Stop;
    567573        }
    568574
    569         // Free all TextEvents that have no uses anymore.
     575        // Remove the item in the pointerMap for which the payloads
     576        // have no uses anymore
     577        for (PointerHashMap::Enum e(pointerMap); !e.empty(); e.popFront()) {
     578            if (e.front().value()->uses() != 0)
     579                continue;
     580
     581            TextIdHashMap::Ptr p = textIdPayloads.lookup(e.front().value()->textId());
     582            MOZ_ASSERT(p);
     583            textIdPayloads.remove(p);
     584
     585            e.removeFront();
     586        }
     587
     588        // Free all payloads that have no uses anymore.
    570589        for (TextIdHashMap::Enum e(textIdPayloads); !e.empty(); e.popFront()) {
    571590            if (e.front().value()->uses() == 0) {
    572591                js_delete(e.front().value());
    573592                e.removeFront();
    574593            }
    575594        }
    576595    }
    577596
    TraceLoggerEvent::TraceLoggerEvent(Trace  
    9921011    }
    9931012}
    9941013
    9951014TraceLoggerEvent::~TraceLoggerEvent()
    9961015{
    9971016    if (payload_)
    9981017        payload_->release();
    9991018}
     1019
     1020TraceLoggerEvent&
     1021TraceLoggerEvent::operator=(const TraceLoggerEvent& other)
     1022{
     1023    if (hasPayload())
     1024        payload()->release();
     1025    if (other.hasPayload())
     1026        other.payload()->use();
     1027
     1028    payload_ = other.payload_;
     1029
     1030    return *this;
     1031}
  • js/src/vm/TraceLogging.h

    diff --git a/js/src/vm/TraceLogging.h b/js/src/vm/TraceLogging.h
    a b class TraceLoggerEvent {  
    105105
    106106    TraceLoggerEventPayload* payload() const {
    107107        MOZ_ASSERT(hasPayload());
    108108        return payload_;
    109109    }
    110110    bool hasPayload() const {
    111111        return !!payload_;
    112112    }
     113
     114    TraceLoggerEvent& operator=(const TraceLoggerEvent& other);
     115    TraceLoggerEvent(const TraceLoggerEvent& event) = delete;
    113116};
    114117
    115118/**
    116119 * An internal class holding the to-report string information, together with an
    117120 * unique id and a useCount. Whenever this useCount reaches 0, this event
    118121 * cannot get started/stopped anymore. Though consumers might still request the
    119122 * to-report string information.
    120123 */
    class TraceLoggerEventPayload {  
    125128
    126129  public:
    127130    TraceLoggerEventPayload(uint32_t textId, char* string)
    128131      : textId_(textId),
    129132        string_(string),
    130133        uses_(0)
    131134    { }
    132135
     136    ~TraceLoggerEventPayload() {
     137        MOZ_ASSERT(uses_ == 0);
     138    }
     139
    133140    uint32_t textId() {
    134141        return textId_;
    135142    }
    136143    const char* string() {
    137144        return string_.get();
    138145    }
    139146    uint32_t uses() {
    140147        return uses_;