Ignore:
Timestamp:
Jul 18, 2008, 6:44:24 PM (17 years ago)
Author:
[email protected]
Message:

Bug 18774: SQUIRRELFISH: print meaningful error messages <https://bugs.webkit.org/show_bug.cgi?id=18774>
<rdar://problem/5769353> SQUIRRELFISH: JavaScript error messages are missing informative text

Reviewed by Cameron Zwarich

Add support for decent error messages in JavaScript. This patch achieves this by providing
ensuring the common errors and exceptions have messages that provide the text of expression
that trigger the exception. In addition it attaches a number of properties to the exception
object detailing where in the source the expression came from.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.h

    r35037 r35245  
    183183        }
    184184
     185        void emitExpressionInfo(unsigned divot, unsigned startOffset, unsigned endOffset)
     186        {
     187            divot -= m_codeBlock->sourceOffset;
     188            if (divot > ExpressionRangeInfo::MaxDivot) {
     189                // Overflow has occurred, we can only give line number info for errors for this region
     190                divot = 0;
     191                startOffset = 0;
     192                endOffset = 0;
     193            } else if (startOffset > ExpressionRangeInfo::MaxOffset) {
     194                // If the start offset is out of bounds we clear both offsets
     195                // so we only get the divot marker.  Error message will have to be reduced
     196                // to line and column number.
     197                startOffset = 0;
     198                endOffset = 0;
     199            } else if (endOffset > ExpressionRangeInfo::MaxOffset) {
     200                // The end offset is only used for additional context, and is much more likely
     201                // to overflow (eg. function call arguments) so we are willing to drop it without
     202                // dropping the rest of the range.
     203                endOffset = 0;
     204            }
     205           
     206            ExpressionRangeInfo info;
     207            info.instructionOffset = instructions().size();
     208            info.divotPoint = divot;
     209            info.startOffset = startOffset;
     210            info.endOffset = endOffset;
     211            m_codeBlock->expressionInfo.append(info);
     212        }
     213       
    185214        ALWAYS_INLINE bool leftHandSideNeedsCopy(bool rightHasAssignments, bool rightIsPure)
    186215        {
     
    245274        RegisterID* emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value);
    246275
    247         RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*);
    248         RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*);
     276        RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
     277        RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    249278
    250279        RegisterID* emitReturn(RegisterID* src) { return emitUnaryNoDstOp(op_ret, src); }
     
    313342        typedef HashMap<RefPtr<UString::Rep>, int, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, IdentifierMapIndexHashTraits> IdentifierMap;
    314343
    315         RegisterID* emitCall(OpcodeID, RegisterID*, RegisterID*, RegisterID*, ArgumentsNode*);
     344        RegisterID* emitCall(OpcodeID, RegisterID*, RegisterID*, RegisterID*, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    316345
    317346        // Maps a register index in the symbol table to a RegisterID index in m_locals.
Note: See TracChangeset for help on using the changeset viewer.