Changeset 35245 in webkit for trunk/JavaScriptCore/VM/CodeBlock.h


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/CodeBlock.h

    r35231 r35245  
    3434#include "JSGlobalObject.h"
    3535#include "nodes.h"
     36#include "SourceRange.h"
    3637#include "ustring.h"
    3738#include <wtf/RefPtr.h>
     
    4546
    4647    struct HandlerInfo {
    47         unsigned start;
    48         unsigned end;
    49         unsigned target;
    50         unsigned scopeDepth;
     48        uint32_t start;
     49        uint32_t end;
     50        uint32_t target;
     51        uint32_t scopeDepth;
     52    };
     53
     54    struct ExpressionRangeInfo {
     55        enum { MaxOffset = (1 << 7) - 1,
     56               MaxDivot = (1 << 25) - 1
     57        };
     58        uint32_t instructionOffset : 25;
     59        uint32_t divotPoint : 25;
     60        uint32_t startOffset : 7;
     61        uint32_t endOffset : 7;
    5162    };
    5263
    5364    struct LineInfo {
    54         unsigned instructionOffset;
    55         int lineNumber;
     65        uint32_t instructionOffset;
     66        int32_t lineNumber;
    5667    };
    5768
    5869    struct CodeBlock {
    59         CodeBlock(ScopeNode* ownerNode_, CodeType codeType_)
     70        CodeBlock(ScopeNode* ownerNode_, CodeType codeType_, PassRefPtr<SourceProvider> source_, unsigned sourceOffset_)
    6071            : ownerNode(ownerNode_)
    6172            , numTemporaries(0)
     
    6677            , usesEval(ownerNode_->usesEval())
    6778            , codeType(codeType_)
     79            , source(source_)
     80            , sourceOffset(sourceOffset_)
    6881        {
    6982        }
    7083
    7184        void dump(ExecState*) const;
    72         int lineNumberForVPC(const Instruction*);
     85        int expressionRangeForVPC(const Instruction*, int& divot, int& startOffset, int& endOffset);
     86        int lineNumberForVPC(const Instruction* vPC);
    7387        bool getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth);
    7488        void mark();
     
    8498        bool usesEval;
    8599        CodeType codeType;
     100        RefPtr<SourceProvider> source;
     101        unsigned sourceOffset;
    86102
    87103        Vector<Instruction> instructions;
     
    94110        Vector<RefPtr<RegExp> > regexps;
    95111        Vector<HandlerInfo> exceptionHandlers;
     112        Vector<ExpressionRangeInfo> expressionInfo;
    96113        Vector<LineInfo> lineInfo;
    97114
     
    104121
    105122    struct ProgramCodeBlock : public CodeBlock {
    106         ProgramCodeBlock(ScopeNode* ownerNode_, CodeType codeType_, JSGlobalObject* globalObject_)
    107             : CodeBlock(ownerNode_, codeType_)
     123        ProgramCodeBlock(ScopeNode* ownerNode_, CodeType codeType_, JSGlobalObject* globalObject_, PassRefPtr<SourceProvider> source_)
     124            : CodeBlock(ownerNode_, codeType_, source_, 0)
    108125            , globalObject(globalObject_)
    109126        {
     
    121138
    122139    struct EvalCodeBlock : public ProgramCodeBlock {
    123         EvalCodeBlock(ScopeNode* ownerNode_, JSGlobalObject* globalObject_)
    124             : ProgramCodeBlock(ownerNode_, EvalCode, globalObject_)
     140        EvalCodeBlock(ScopeNode* ownerNode_, JSGlobalObject* globalObject_, PassRefPtr<SourceProvider> source_)
     141            : ProgramCodeBlock(ownerNode_, EvalCode, globalObject_, source_)
    125142        {
    126143        }
Note: See TracChangeset for help on using the changeset viewer.