Changeset 34372 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jun 4, 2008, 10:36:55 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-04 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak.

Big cleanup of formatting and whitespace.

Location:
trunk/JavaScriptCore
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r34371 r34372  
     12008-06-04  Sam Weinig  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Big cleanup of formatting and whitespace.
     6
    172008-06-04  Cameron Zwarich  <[email protected]>
    28
  • trunk/JavaScriptCore/VM/CodeBlock.cpp

    r34351 r34372  
    9898NEVER_INLINE static const char* debugHookName(int debugHookID)
    9999{
    100     switch((DebugHookID)debugHookID) {
    101     case DidEnterCallFrame:
    102         return "didEnterCallFrame";
    103     case WillLeaveCallFrame:
    104         return "willLeaveCallFrame";
    105     case WillExecuteStatement:
    106         return "willExecuteStatement";
    107     case WillExecuteProgram:
    108         return "willExecuteProgram";
    109     case DidExecuteProgram:
    110         return "didExecuteProgram";
    111     case DidReachBreakpoint:
    112         return "didReachBreakpoint";
    113     }
    114    
     100    switch (static_cast<DebugHookID>(debugHookID)) {
     101        case DidEnterCallFrame:
     102            return "didEnterCallFrame";
     103        case WillLeaveCallFrame:
     104            return "willLeaveCallFrame";
     105        case WillExecuteStatement:
     106            return "willExecuteStatement";
     107        case WillExecuteProgram:
     108            return "willExecuteProgram";
     109        case DidExecuteProgram:
     110            return "didExecuteProgram";
     111        case DidReachBreakpoint:
     112            return "didReachBreakpoint";
     113    }
     114
    115115    ASSERT_NOT_REACHED();
    116116    return "";
  • trunk/JavaScriptCore/VM/CodeBlock.h

    r34319 r34372  
    2727 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828 */
    29  
     29
    3030#ifndef CodeBlock_h
    3131#define CodeBlock_h
     
    9090        Vector<RefPtr<FuncExprNode> > functionExpressions;
    9191        Vector<JSValue*> jsValues;
    92         Vector<RefPtr<RegExp> > regexps;       
     92        Vector<RefPtr<RegExp> > regexps;
    9393        Vector<HandlerInfo> exceptionHandlers;
    9494        Vector<LineInfo> lineInfo;
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r34319 r34372  
    4040/*
    4141    The layout of a register frame looks like this:
    42    
    43     For 
    44    
     42
     43    For
     44
    4545    function f(x, y) {
    4646        var v1;
     
    4949        return (x) * (y);
    5050    }
    51    
     51
    5252    assuming (x) and (y) generated temporaries t1 and t2, you would have
    5353
     
    5858    ------------------------------------
    5959    | params->|<-locals      | temps->
    60    
     60
    6161    Because temporary registers are allocated in a stack-like fashion, we
    6262    can reclaim them with a simple popping algorithm. The same goes for labels.
    6363    (We never reclaim parameter or local registers, because parameters and
    6464    locals are DontDelete.)
    65    
     65
    6666    The register layout before a function call looks like this:
    67    
     67
    6868    For
    69    
     69
    7070    function f(x, y)
    7171    {
    7272    }
    73    
     73
    7474    f(1);
    75    
     75
    7676    >                        <------------------------------
    7777    <                        >  reserved: call frame  |  1 | <-- value held
     
    7979    <                        > +0 | +1 | +2 | +3 | +4 | +5 | <-- register index
    8080    >                        <------------------------------
    81     | params->|<-locals      | temps->   
    82    
     81    | params->|<-locals      | temps->
     82
    8383    The call instruction fills in the "call frame" registers. It also pads
    8484    missing arguments at the end of the call:
    85    
     85
    8686    >                        <-----------------------------------
    8787    <                        >  reserved: call frame  |  1 |  ? | <-- value held ("?" stands for "undefined")
     
    9090    >                        <-----------------------------------
    9191    | params->|<-locals      | temps->
    92    
     92
    9393    After filling in missing arguments, the call instruction sets up the new
    9494    stack frame to overlap the end of the old stack frame:
     
    100100                             |---------------------------------->                        <
    101101                             |                        | params->|<-locals       | temps->
    102    
     102
    103103    That way, arguments are "copied" into the callee's stack frame for free.
    104    
     104
    105105    If the caller supplies too many arguments, this trick doesn't work. The
    106106    extra arguments protrude into space reserved for locals and temporaries.
     
    111111    This copying strategy ensures that all named values will be at the indices
    112112    expected by the callee.
    113 
    114113*/
    115114
     
    133132    if (m_shouldEmitDebugHooks)
    134133        m_codeBlock->needsFullScopeChain = true;
    135    
     134
    136135    m_scopeNode->emitCode(*this);
    137136
     
    196195
    197196    JSGlobalObject* globalObject = scopeChain.globalObject();
    198    
     197
    199198    ExecState* exec = globalObject->globalExec();
    200199   
     
    207206            emitNewFunction(addVar(funcDecl->m_ident, false), funcDecl);
    208207        }
    209        
     208
    210209        for (size_t i = 0; i < varStack.size(); ++i) {
    211210            if (!globalObject->hasProperty(exec, varStack[i].first))
     
    245244        FuncDeclNode* funcDecl = functionStack[i].get();
    246245        const Identifier& ident = funcDecl->m_ident;
    247        
     246
    248247        m_functions.add(ident.ustring().rep());
    249248        emitNewFunction(addVar(ident, false), funcDecl);
     
    255254        if (ident == m_propertyNames->arguments)
    256255            continue;
    257        
     256
    258257        RegisterID* r0;
    259258        if (addVar(ident, r0, varStack[i].second & DeclarationStacks::IsConstant))
     
    306305        result = &(m_locals[localsIndex(m_nextParameter)]);
    307306    }
    308    
     307
    309308    // To maintain the calling convention, we have to allocate unique space for
    310309    // each parameter, even if the parameter doesn't make it into the symbol table.
     
    336335    if (m_codeType == EvalCode)
    337336        return 0;
    338    
     337
    339338    SymbolTableEntry entry = symbolTable().get(ident.ustring().rep());
    340339    ASSERT(!entry.isEmpty());
    341    
     340
    342341    return &m_locals[localsIndex(entry.getIndex())];
    343342}
     
    430429    if (result.second) // new entry
    431430        m_codeBlock->identifiers.append(rep);
    432    
     431
    433432    return result.first->second;
    434433}
     
    439438    if (result.second) // new entry
    440439        m_codeBlock->jsValues.append(v);
    441    
     440
    442441    return result.first->second;
    443442}
     
    752751    for (; iter != end; ++iter, ++depth) {
    753752        JSObject* currentScope = *iter;
    754         if (!currentScope->isVariableObject()) 
     753        if (!currentScope->isVariableObject())
    755754            break;
    756755        JSVariableObject* currentVariableObject = static_cast<JSVariableObject*>(currentScope);
     
    798797    return emitGetScopedVar(dst, depth, index);
    799798}
    800    
     799
    801800RegisterID* CodeGenerator::emitGetScopedVar(RegisterID* dst, size_t depth, int index)
    802801{
     
    807806    return dst;
    808807}
    809    
     808
    810809RegisterID* CodeGenerator::emitPutScopedVar(size_t depth, int index, RegisterID* value)
    811810{
     
    824823    return dst;
    825824}
    826    
     825
    827826RegisterID* CodeGenerator::emitResolveWithBase(RegisterID* baseDst, RegisterID* propDst, const Identifier& property)
    828827{
     
    965964    RefPtr<RegisterID> refFunc = func;
    966965    RefPtr<RegisterID> refBase = base;
    967    
     966
    968967    // Reserve space for call frame.
    969968    Vector<RefPtr<RegisterID>, Machine::CallFrameHeaderSize> callFrame;
     
    11071106        return 0;
    11081107    }
    1109    
     1108
    11101109    for (int i = m_jumpContextStack.size() - 1; i >= 0; i--) {
    11111110        JumpContext* scope = &m_jumpContextStack[i];
     
    11291128        return 0;
    11301129    }
    1131    
     1130
    11321131    for (int i = m_jumpContextStack.size() - 1; i >= 0; i--) {
    11331132        JumpContext* scope = &m_jumpContextStack[i];
     
    11521151
    11531152        if (nNormalScopes) {
    1154             // We need to remove a number of dynamic scopes to get to the next 
     1153            // We need to remove a number of dynamic scopes to get to the next
    11551154            // finally block
    11561155            instructions().append(machine().getOpcode(op_jmp_scopes));
    11571156            instructions().append(nNormalScopes);
    1158            
     1157
    11591158            // If topScope == bottomScope then there isn't actually a finally block
    11601159            // left to emit, so make the jmp_scopes jump directly to the target label
     
    11641163            }
    11651164
    1166             // Otherwise we just use jmp_scopes to pop a group of scopes and go 
     1165            // Otherwise we just use jmp_scopes to pop a group of scopes and go
    11671166            // to the next instruction
    11681167            RefPtr<LabelID> nextInsn = newLabel();
     
    12261225    return targetRegister;
    12271226}
    1228    
     1227
    12291228void CodeGenerator::emitThrow(RegisterID* exception)
    12301229{
  • trunk/JavaScriptCore/VM/CodeGenerator.h

    r34319 r34372  
    3838#include "Machine.h"
    3939#include "RegisterID.h"
     40#include "SegmentedVector.h"
    4041#include "SymbolTable.h"
    41 #include "SegmentedVector.h"
    4242#include "debugger.h"
    4343#include "nodes.h"
     
    6464        RegisterID* retAddrDst;
    6565    };
    66    
     66
    6767    struct ControlFlowContext {
    6868        bool isFinallyBlock;
    6969        FinallyContext finallyContext;
    7070    };
    71    
     71
    7272    class CodeGenerator {
    7373    public:
    7474        typedef DeclarationStacks::VarStack VarStack;
    7575        typedef DeclarationStacks::FunctionStack FunctionStack;
    76        
     76
    7777        static void setDumpsGeneratedCode(bool dumpsGeneratedCode);
    78        
     78
    7979        CodeGenerator(ProgramNode*, const Debugger*, const ScopeChain&, SymbolTable*, CodeBlock*, VarStack&, FunctionStack&, bool canCreateGlobals);
    8080        CodeGenerator(FunctionBodyNode*, const Debugger*, const ScopeChain&, SymbolTable*, CodeBlock*);
     
    9696
    9797        // Searches the scope chain in an attempt to  statically locate the requested
    98         // property.  Returns false if for any reason the property cannot be safely 
     98        // property.  Returns false if for any reason the property cannot be safely
    9999        // optimised at all.  Otherwise it will return the index and depth of the
    100         // VariableObject that defines the property.  If the property cannot be found 
     100        // VariableObject that defines the property.  If the property cannot be found
    101101        // statically, depth will contain the depth of the scope chain where dynamic
    102102        // lookup must begin.
     
    133133
    134134        // Returns the place to write the final output of an operation.
    135         RegisterID* finalDestination(RegisterID* originalDst, RegisterID* tempDst = 0) 
    136         { 
     135        RegisterID* finalDestination(RegisterID* originalDst, RegisterID* tempDst = 0)
     136        {
    137137            if (originalDst)
    138138                return originalDst;
    139139            if (tempDst && tempDst->isTemporary())
    140140                return tempDst;
    141             return newTemporary();
    142         }
    143        
    144         RegisterID* destinationForAssignResult(RegisterID* dst) {
    145             if (dst && m_codeBlock->needsFullScopeChain)
     141            return newTemporary();
     142        }
     143
     144        RegisterID* destinationForAssignResult(RegisterID* dst)
     145        {
     146            if (dst && m_codeBlock->needsFullScopeChain)
    146147                return dst->isTemporary() ? dst : newTemporary();
    147148            return 0;
     
    151152        RegisterID* moveToDestinationIfNeeded(RegisterID* dst, RegisterID* src) { return (dst && dst != src) ? emitMove(dst, src) : src; }
    152153
    153 
    154154        PassRefPtr<LabelID> newLabel();
    155        
     155
    156156        // The emitNode functions are just syntactic sugar for calling
    157157        // Node::emitCode. They're the only functions that accept a NULL register.
    158         RegisterID* emitNode(RegisterID* dst, Node* n) {
     158        RegisterID* emitNode(RegisterID* dst, Node* n)
     159        {
    159160            // Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
    160161            ASSERT(!dst || !dst->isTemporary() || dst->refCount());
     
    183184                return dst;
    184185            }
    185            
     186
    186187            return PassRefPtr<RegisterID>(emitNode(n));
    187188        }
     
    190191        RegisterID* emitLoad(RegisterID* dst, double);
    191192        RegisterID* emitLoad(RegisterID* dst, JSValue*);
    192        
     193
    193194        RegisterID* emitNewObject(RegisterID* dst);
    194195        RegisterID* emitNewArray(RegisterID* dst);
     
    266267        PassRefPtr<LabelID> emitJumpSubroutine(RegisterID* retAddrDst, LabelID*);
    267268        void emitSubroutineReturn(RegisterID* retAddrSrc);
    268        
     269
    269270        RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base);
    270271        RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target);
     
    273274        void emitThrow(RegisterID*);
    274275        RegisterID* emitNewError(RegisterID* dst, ErrorType type, JSValue* message);
    275        
     276
    276277        RegisterID* emitPushScope(RegisterID* scope);
    277278        void emitPopScope();
    278        
     279
    279280        void emitDebugHook(DebugHookID, int firstLine, int lastLine);
    280281
    281282        int scopeDepth() { return m_dynamicScopeDepth + m_finallyDepth; }
    282        
     283
    283284        void pushFinallyContext(LabelID* target, RegisterID* returnAddrDst);
    284285        void popFinallyContext();
     
    290291        JumpContext* jumpContextForBreak(const Identifier&);
    291292
    292 
    293293        CodeType codeType() const { return m_codeType; }
     294
    294295    private:
    295296        PassRefPtr<LabelID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
     
    300301
    301302        typedef HashMap<JSValue*, unsigned, DefaultHash<JSValue*>::Hash, JSValueHashTraits> JSValueMap;
    302        
     303
    303304        struct IdentifierMapIndexHashTraits {
    304305            typedef int TraitType;
     
    316317        // Maps a register index in the symbol table to a RegisterID index in m_locals.
    317318        int localsIndex(int registerIndex) { return -registerIndex - 1; }
    318        
     319
    319320        // Returns the RegisterID corresponding to ident.
    320321        RegisterID* addVar(const Identifier& ident, bool isConstant)
     
    335336        unsigned addConstant(JSValue*);
    336337        unsigned addRegExp(RegExp* r);
    337        
     338
    338339        Vector<Instruction>& instructions() { return m_codeBlock->instructions; }
    339340        SymbolTable& symbolTable() { return *m_symbolTable; }
    340341        Vector<HandlerInfo>& exceptionHandlers() { return m_codeBlock->exceptionHandlers; }
    341        
     342
    342343        bool shouldOptimizeLocals() { return (m_codeType != EvalCode) && !m_dynamicScopeDepth; }
    343344        bool canOptimizeNonLocals() { return (m_codeType == FunctionCode) && !m_dynamicScopeDepth && !m_codeBlock->usesEval; }
    344345
    345346        bool m_shouldEmitDebugHooks;
    346        
     347
    347348        const ScopeChain* m_scopeChain;
    348349        SymbolTable* m_symbolTable;
    349        
     350
    350351        ScopeNode* m_scopeNode;
    351352        CodeBlock* m_codeBlock;
    352        
     353
    353354        HashSet<RefPtr<UString::Rep>, IdentifierRepHash> m_functions;
    354355        RegisterID m_thisRegister;
     
    359360        int m_dynamicScopeDepth;
    360361        CodeType m_codeType;
    361        
     362
    362363        Vector<JumpContext> m_jumpContextStack;
    363364        int m_continueDepth;
     
    373374        CommonIdentifiers* m_propertyNames;
    374375
    375 #ifndef NDEBUG       
     376#ifndef NDEBUG
    376377        static bool s_dumpsGeneratedCode;
    377378#endif
  • trunk/JavaScriptCore/VM/ExceptionHelpers.cpp

    r34075 r34372  
    4545    string = newString;
    4646}
    47    
     47
    4848JSValue* createError(ExecState* exec, ErrorType e, const char* msg)
    4949{
     
    8383    return createError(exec, ReferenceError, "Can't find variable: %s", ident);
    8484}
    85    
     85
    8686JSValue* createInvalidParamError(ExecState* exec, const char* op, JSValue* v)
    8787{
     
    106106}
    107107
    108 }
     108} // namespace KJS
  • trunk/JavaScriptCore/VM/ExceptionHelpers.h

    r34075 r34372  
    3333
    3434namespace KJS {
     35
    3536    class Node;
     37
    3638    JSValue* createStackOverflowError(ExecState*);
    3739    JSValue* createUndefinedVariableError(ExecState*, const Identifier&);
    3840    JSValue* createInvalidParamError(ExecState*, const char* op, JSValue*);
    39     JSValue* createNotAConstructorError(ExecState* exec, JSValue* value, Node* expr);
    40     JSValue* createNotAFunctionError(ExecState* exec, JSValue* value, Node* expr);
    41 }
     41    JSValue* createNotAConstructorError(ExecState*, JSValue*, Node* expr);
     42    JSValue* createNotAFunctionError(ExecState*, JSValue*, Node* expr);
    4243
    43 #endif
     44} // namespace KJS
     45
     46#endif // ExceptionHelpers_h
  • trunk/JavaScriptCore/VM/Instruction.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef Instruction_h
    3030#define Instruction_h
     
    3737        Instruction(Opcode opcode) { u.opcode = opcode; }
    3838        Instruction(int operand) { u.operand = operand; }
    39            
     39
    4040        union {
    4141            Opcode opcode;
     
    4343        } u;
    4444    };
    45    
     45
    4646} // namespace KJS
    4747
  • trunk/JavaScriptCore/VM/JSPropertyNameIterator.cpp

    r33979 r34372  
    3434#include "PropertyNameArray.h"
    3535
    36 namespace KJS{
     36namespace KJS {
    3737
    3838COMPILE_ASSERT(sizeof(JSPropertyNameIterator) <= CellSize<sizeof(void*)>::m_value, JSPropertyNameIteratorSizeASSERT);
    39    
     39
     40JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v)
     41{
     42    if (v->isUndefinedOrNull())
     43        return new JSPropertyNameIterator(0, 0, 0);
     44
     45    JSObject* o = v->toObject(exec);
     46    PropertyNameArray propertyNames;
     47    o->getPropertyNames(exec, propertyNames);
     48    size_t numProperties = propertyNames.size();
     49    return new JSPropertyNameIterator(o, propertyNames.releaseIdentifiers(), numProperties);
     50}
     51
    4052JSPropertyNameIterator::JSPropertyNameIterator(JSObject* object, Identifier* propertyNames, size_t numProperties)
    4153    : m_object(object)
     
    4557{
    4658}
    47    
    48 JSType JSPropertyNameIterator::type() const {
    49     return UnspecifiedType;
     59
     60JSPropertyNameIterator::~JSPropertyNameIterator()
     61{
     62    delete m_propertyNames;
    5063}
    5164
    52 JSValue *JSPropertyNameIterator::toPrimitive(ExecState *, JSType) const
     65JSType JSPropertyNameIterator::type() const
     66{
     67    return UnspecifiedType;
     68}
     69
     70JSValue* JSPropertyNameIterator::toPrimitive(ExecState*, JSType) const
    5371{
    5472    ASSERT_NOT_REACHED();
    55     return 0; 
     73    return 0;
    5674}
    5775
    58 bool JSPropertyNameIterator::getPrimitiveNumber(ExecState*, double&, JSValue*&) {
    59     ASSERT_NOT_REACHED();
     76bool JSPropertyNameIterator::getPrimitiveNumber(ExecState*, double&, JSValue*&)
     77{
     78    ASSERT_NOT_REACHED();
    6079    return false;
    6180}
    6281
    63 bool JSPropertyNameIterator::toBoolean(ExecState *) const {
    64     ASSERT_NOT_REACHED();
     82bool JSPropertyNameIterator::toBoolean(ExecState*) const
     83{
     84    ASSERT_NOT_REACHED();
    6585    return false;
    6686}
    6787
    68 double JSPropertyNameIterator::toNumber(ExecState *) const
     88double JSPropertyNameIterator::toNumber(ExecState*) const
    6989{
    7090    ASSERT_NOT_REACHED();
    71     return 0; 
     91    return 0;
    7292}
    7393
    74 UString JSPropertyNameIterator::toString(ExecState *) const
     94UString JSPropertyNameIterator::toString(ExecState*) const
    7595{
    7696    ASSERT_NOT_REACHED();
    77     return ""; 
     97    return "";
    7898}
    7999
    80 JSObject *JSPropertyNameIterator::toObject(ExecState *) const
     100JSObject* JSPropertyNameIterator::toObject(ExecState*) const
    81101{
    82102    ASSERT_NOT_REACHED();
    83     return 0; 
     103    return 0;
    84104}
    85105
    86 void JSPropertyNameIterator::mark() {
     106void JSPropertyNameIterator::mark()
     107{
    87108    JSCell::mark();
    88109    if (m_object && !m_object->marked())
     
    91112
    92113JSValue* JSPropertyNameIterator::next(ExecState* exec)
    93 { 
     114{
    94115    while (m_position != m_end) {
    95116        if (m_object->hasProperty(exec, *m_position))
     
    101122}
    102123
    103 void JSPropertyNameIterator::invalidate() 
    104 { 
    105     delete m_propertyNames; 
     124void JSPropertyNameIterator::invalidate()
     125{
     126    delete m_propertyNames;
    106127    m_object = 0;
    107128    m_propertyNames = 0;
    108129}
    109130
    110 JSPropertyNameIterator::~JSPropertyNameIterator()
    111 {
    112     delete m_propertyNames;
    113 }
    114 
    115 
    116 JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v)
    117 {
    118     if (v->isUndefinedOrNull())
    119         return new JSPropertyNameIterator(0, 0, 0);
    120 
    121     JSObject* o = v->toObject(exec);
    122     PropertyNameArray propertyNames;
    123     o->getPropertyNames(exec, propertyNames);   
    124     size_t numProperties = propertyNames.size();
    125     return new JSPropertyNameIterator(o, propertyNames.releaseIdentifiers(), numProperties);
    126 }
    127 
    128 }
     131} // namespace KJS
  • trunk/JavaScriptCore/VM/JSPropertyNameIterator.h

    r33979 r34372  
    3333
    3434namespace KJS {
     35
     36    class Identifier;
    3537    class JSObject;
    36     class Identifier;
    3738
    3839    class JSPropertyNameIterator : public JSCell {
    3940    public:
     41        static JSPropertyNameIterator* create(ExecState*, JSValue*);
     42
     43        virtual ~JSPropertyNameIterator();
     44
    4045        virtual JSType type() const;
    41         virtual JSValue *toPrimitive(ExecState *, JSType) const;
     46        virtual JSValue* toPrimitive(ExecState*, JSType) const;
    4247        virtual bool getPrimitiveNumber(ExecState*, double&, JSValue*&);
    43         virtual bool toBoolean(ExecState *) const;
    44         virtual double toNumber(ExecState *) const;
    45         virtual UString toString(ExecState *) const;
    46         virtual JSObject *toObject(ExecState *) const;
    47        
     48        virtual bool toBoolean(ExecState*) const;
     49        virtual double toNumber(ExecState*) const;
     50        virtual UString toString(ExecState*) const;
     51        virtual JSObject* toObject(ExecState*) const;
     52
    4853        virtual void mark();
    49        
    50         JSValue* next(ExecState* exec);       
     54
     55        JSValue* next(ExecState*);
    5156        void invalidate();
    52        
    53         virtual ~JSPropertyNameIterator();
    54        
    55         static JSPropertyNameIterator* create(ExecState*, JSValue*);
     57
    5658    private:
    57         JSPropertyNameIterator(JSObject* object, Identifier* propertyNames, size_t numProperties);
     59        JSPropertyNameIterator(JSObject*, Identifier* propertyNames, size_t numProperties);
     60
    5861        JSObject* m_object;
    5962        Identifier* m_propertyNames;
     
    6164        Identifier* m_end;
    6265    };
    63 }
    6466
    65 #endif
     67} // namespace KJS
     68
     69#endif // JSPropertyNameIterator_h
  • trunk/JavaScriptCore/VM/LabelID.h

    r34021 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef LabelID_h
    3030#define LabelID_h
     
    101101    private:
    102102        typedef Vector<int, 8> JumpVector;
    103        
     103
    104104        static const unsigned invalidLocation = UINT_MAX;
    105        
     105
    106106        int m_refCount;
    107107        unsigned m_location;
     
    109109        mutable JumpVector m_unresolvedJumps;
    110110    };
    111    
     111
    112112} // namespace KJS
    113113
  • trunk/JavaScriptCore/VM/Machine.cpp

    r34371 r34372  
    8181{
    8282    int scopeDepth = 0;
    83     ScopeChainIterator iter = sc.begin(); 
    84     ScopeChainIterator end = sc.end(); 
     83    ScopeChainIterator iter = sc.begin();
     84    ScopeChainIterator end = sc.end();
    8585    while (!(*iter)->isVariableObject()) {
    8686        ++iter;
     
    8989    return scopeDepth;
    9090}
    91    
     91
    9292static inline bool jsLess(ExecState* exec, JSValue* v1, JSValue* v2)
    9393{
     
    219219    return false;
    220220}
    221    
     221
    222222static bool NEVER_INLINE resolve_skip(ExecState* exec, Instruction* vPC, Register* r, ScopeChainNode* scopeChain, CodeBlock* codeBlock, JSValue*& exceptionValue)
    223223{
     
    225225    int property = (vPC + 2)->u.operand;
    226226    int skip = (vPC + 3)->u.operand + codeBlock->needsFullScopeChain;
    227    
     227
    228228    ScopeChainIterator iter = scopeChain->begin();
    229229    ScopeChainIterator end = scopeChain->end();
     
    280280    int propDst = (vPC + 2)->u.operand;
    281281    int property = (vPC + 3)->u.operand;
    282    
     282
    283283    ScopeChainIterator iter = scopeChain->begin();
    284284    ScopeChainIterator end = scopeChain->end();
    285    
     285
    286286    // FIXME: add scopeDepthIsZero optimization
    287    
     287
    288288    ASSERT(iter != end);
    289    
     289
    290290    Identifier& ident = codeBlock->identifiers[property];
    291291    JSObject* base;
     
    298298            if (exceptionValue)
    299299                return false;
    300             r[propDst].u.jsValue = result;   
     300            r[propDst].u.jsValue = result;
    301301            r[baseDst].u.jsValue = base;
    302302            return true;
     
    304304        ++iter;
    305305    } while (iter != end);
    306    
     306
    307307    exceptionValue = createUndefinedVariableError(exec, ident);
    308308    return false;
     
    317317    ScopeChainIterator iter = scopeChain->begin();
    318318    ScopeChainIterator end = scopeChain->end();
    319    
     319
    320320    // FIXME: add scopeDepthIsZero optimization
    321    
     321
    322322    ASSERT(iter != end);
    323    
     323
    324324    Identifier& ident = codeBlock->identifiers[property];
    325325    JSObject* base;
     
    340340            if (exceptionValue)
    341341                return false;
    342            
     342
    343343            r[baseDst].u.jsValue = thisObj;
    344344            r[funcDst].u.jsValue = result;
     
    385385        }
    386386        r = (*registerBase) + registerOffset;
    387        
     387
    388388        int omittedArgCount = newCodeBlock->numParameters - argc;
    389389        Register* endOfParams = r - newCodeBlock->numVars;
     
    400400        }
    401401        r = (*registerBase) + registerOffset;
    402        
     402
    403403        Register* it = r - newCodeBlock->numLocals - Machine::CallFrameHeaderSize - shift;
    404404        Register* end = it + Machine::CallFrameHeaderSize + newCodeBlock->numParameters;
     
    436436
    437437    JSValue* program = r[argv + 1].u.jsValue;
    438    
     438
    439439    if (!program->isString())
    440440        return program;
    441    
     441
    442442    Profiler** profiler = Profiler::enabledProfilerReference();
    443443    if (*profiler)
     
    448448    UString errMsg;
    449449    RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(static_cast<StringImp*>(program)->value()), &sourceId, &errLine, &errMsg);
    450    
     450
    451451    if (!evalNode) {
    452452        exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, sourceId, NULL);
     
    491491    printf("     use      |   address  |    value   \n");
    492492    printf("----------------------------------------\n");
    493    
     493
    494494    const Register* it;
    495495    const Register* end;
    496    
     496
    497497    if (isGlobalCallFrame(registerFile->basePointer(), r)) {
    498498        it = r - registerFile->numGlobalSlots();
     
    515515            printf("----------------------------------------\n");
    516516        }
    517        
     517
    518518        end = it + codeBlock->numParameters;
    519519        if (it != end) {
     
    559559    CodeBlock* oldCodeBlock = codeBlock;
    560560    Register* callFrame = r - oldCodeBlock->numLocals - CallFrameHeaderSize;
    561    
     561
    562562    if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
    563563        DebuggerCallFrame debuggerCallFrame(this, exec->dynamicGlobalObject(), codeBlock, scopeChain, exceptionValue, registerBase, r - *registerBase);
     
    577577    if (oldCodeBlock->needsFullScopeChain)
    578578        scopeChain->deref();
    579    
     579
    580580    if (isGlobalCallFrame(registerBase, r))
    581581        return false;
     
    620620    // Calculate an exception handler vPC, unwinding call frames as necessary.
    621621
    622     int scopeDepth;       
     622    int scopeDepth;
    623623    Instruction* handlerVPC;
    624624
    625     while (!codeBlock->getHandlerForVPC(vPC, handlerVPC, scopeDepth))
     625    while (!codeBlock->getHandlerForVPC(vPC, handlerVPC, scopeDepth)) {
    626626        if (!unwindCallFrame(exec, exceptionValue, registerBase, vPC, codeBlock, k, scopeChain, r))
    627627            return 0;
     628    }
    628629
    629630    // Now unwind the scope chain within the exception handler's call frame.
    630    
     631
    631632    ScopeChain sc(scopeChain);
    632633    int scopeDelta = depth(sc) - scopeDepth;
     
    659660
    660661    r[ProgramCodeThisRegister].u.jsValue = thisObj;
    661    
     662
    662663    if (codeBlock->needsFullScopeChain)
    663664        scopeChain = scopeChain->copy();
     
    692693    int argv = CallFrameHeaderSize;
    693694    int argc = args.size() + 1; // implicit "this" parameter
    694    
     695
    695696    size_t oldSize = registerFile->size();
    696697    if (!registerFile->grow(oldSize + CallFrameHeaderSize + argc)) {
     
    698699        return 0;
    699700    }
    700        
     701
    701702    Register** registerBase = registerFile->basePointer();
    702703    int registerOffset = oldSize;
    703704    int callFrameOffset = registerOffset;
    704705    Register* callFrame = (*registerBase) + callFrameOffset;
    705    
     706
    706707    // put args in place, including "this"
    707708    Register* dst = callFrame + CallFrameHeaderSize;
    708709    (*dst).u.jsValue = thisObj;
    709    
     710
    710711    List::const_iterator end = args.end();
    711712    for (List::const_iterator it = args.begin(); it != end; ++it)
     
    722723    }
    723724
    724     scopeChain = scopeChainForCall(functionBodyNode, newCodeBlock, scopeChain, registerBase, r);           
     725    scopeChain = scopeChainForCall(functionBodyNode, newCodeBlock, scopeChain, registerBase, r);
    725726
    726727    ExecState newExec(exec, this, registerFile, scopeChain, callFrameOffset);
    727    
     728
    728729    Profiler** profiler = Profiler::enabledProfilerReference();
    729730    if (*profiler)
     
    746747
    747748    EvalCodeBlock* codeBlock = &evalNode->code(scopeChain);
    748    
     749
    749750    JSVariableObject* variableObject;
    750751    for (ScopeChainNode* node = scopeChain; ; node = node->next) {
     
    755756        }
    756757    }
    757    
     758
    758759    const Node::VarStack& varStack = codeBlock->ownerNode->varStack();
    759760    Node::VarStack::const_iterator varStackEnd = varStack.end();
     
    763764            variableObject->put(exec, ident, jsUndefined());
    764765    }
    765    
     766
    766767    const Node::FunctionStack& functionStack = codeBlock->ownerNode->functionStack();
    767768    Node::FunctionStack::const_iterator functionStackEnd = functionStack.end();
    768769    for (Node::FunctionStack::const_iterator it = functionStack.begin(); it != functionStackEnd; ++it)
    769770        variableObject->put(exec, (*it)->m_ident, (*it)->makeFunction(exec, scopeChain));
    770    
     771
    771772    size_t oldSize = registerFile->size();
    772773    size_t newSize = registerOffset + codeBlock->numVars + codeBlock->numTemporaries + CallFrameHeaderSize;
     
    777778
    778779    Register* callFrame = *registerFile->basePointer() + registerOffset;
    779    
     780
    780781    // put call frame in place, using a 0 codeBlock to indicate a built-in caller
    781782    initializeCallFrame(callFrame, 0, 0, 0, registerOffset, 0, 0, 0, 0, 0);
     
    889890    JSValue** k = codeBlock->jsValues.data();
    890891    Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
    891    
     892
    892893#if HAVE(COMPUTED_GOTO)
    893894    // Yet another hack around GCC's various foibles, in this case fetching the
     
    922923    #define BEGIN_OPCODE(opcode) case opcode:
    923924#endif
    924     while(1) // iterator loop begins
     925    while (1) // iterator loop begins
    925926    switch (vPC->u.opcode)
    926927#endif
     
    934935        int src = (++vPC)->u.operand;
    935936        r[dst].u.jsValue = k[src];
    936        
     937
    937938        ++vPC;
    938939        NEXT_OPCODE;
     
    946947        int dst = (++vPC)->u.operand;
    947948        r[dst].u.jsValue = scopeChain->globalObject()->objectConstructor()->construct(exec, exec->emptyList());
    948        
     949
    949950        ++vPC;
    950951        NEXT_OPCODE;
     
    958959        int dst = (++vPC)->u.operand;
    959960        r[dst].u.jsValue = scopeChain->globalObject()->arrayConstructor()->construct(exec, exec->emptyList());
    960        
     961
    961962        ++vPC;
    962963        NEXT_OPCODE;
     
    10461047        else
    10471048            dst = jsBoolean(strictEqual(src1, src2));
    1048        
     1049
    10491050        ++vPC;
    10501051        NEXT_OPCODE;
     
    11171118        VM_CHECK_EXCEPTION();
    11181119        r[srcDst].u.jsValue = result;
    1119        
     1120
    11201121        ++vPC;
    11211122        NEXT_OPCODE;
     
    12811282        /* mod dst(r) dividend(r) divisor(r)
    12821283
    1283            Divides register dividend (converted to number) by 
     1284           Divides register dividend (converted to number) by
    12841285           register divisor (converted to number), and puts the
    12851286           remainder in register dst.
     
    13341335        }
    13351336        dst = result;
    1336        
     1337
    13371338        ++vPC;
    13381339        NEXT_OPCODE;
     
    13561357        }
    13571358        dst = result;
    1358        
     1359
    13591360        ++vPC;
    13601361        NEXT_OPCODE;
     
    13781379        }
    13791380        dst = result;
    1380        
     1381
    13811382        ++vPC;
    13821383        NEXT_OPCODE;
     
    14001401        }
    14011402        dst = result;
    1402        
     1403
    14031404        ++vPC;
    14041405        NEXT_OPCODE;
     
    14221423        }
    14231424        dst = result;
    1424        
     1425
    14251426        ++vPC;
    14261427        NEXT_OPCODE;
     
    14441445        }
    14451446        dst = result;
    1446        
     1447
    14471448        ++vPC;
    14481449        NEXT_OPCODE;
     
    14831484           Tests whether register value is an instance of register
    14841485           constructor, and puts the boolean result in register dst.
    1485          
     1486
    14861487           Raises an exception if register constructor is not an
    14871488           object.
     
    15201521           Tests whether register base has a property named register
    15211522           property, and puts the boolean result in register dst.
    1522          
     1523
    15231524           Raises an exception if register constructor is not an
    15241525           object.
     
    15631564    BEGIN_OPCODE(op_resolve_skip) {
    15641565        /* resolve_skip dst(r) property(id) skip(n)
    1565          
     1566
    15661567         Looks up the property named by identifier property in the
    15671568         scope chain skipping the top 'skip' levels, and writes the resulting
     
    15701571        if (UNLIKELY(!resolve_skip(exec, vPC, r, scopeChain, codeBlock, exceptionValue)))
    15711572            goto vm_throw;
    1572        
     1573
    15731574        vPC += 4;
    1574        
     1575
    15751576        NEXT_OPCODE;
    15761577    }
    15771578    BEGIN_OPCODE(op_get_scoped_var) {
    15781579        /* get_scoped_var dst(r) index(n) skip(n)
    1579          
     1580
    15801581         Loads the contents of the index-th local from the scope skip nodes from
    15811582         the top of the scope chain, and places it in register dst
     
    15841585        int index = (++vPC)->u.operand;
    15851586        int skip = (++vPC)->u.operand + codeBlock->needsFullScopeChain;
    1586        
     1587
    15871588        ScopeChainIterator iter = scopeChain->begin();
    15881589        ScopeChainIterator end = scopeChain->end();
     
    15921593            ASSERT(iter != end);
    15931594        }
    1594        
     1595
    15951596        ASSERT((*iter)->isVariableObject());
    15961597        JSVariableObject* scope = static_cast<JSVariableObject*>(*iter);
     
    16061607        int skip = (++vPC)->u.operand + codeBlock->needsFullScopeChain;
    16071608        int value = (++vPC)->u.operand;
    1608        
     1609
    16091610        ScopeChainIterator iter = scopeChain->begin();
    16101611        ScopeChainIterator end = scopeChain->end();
     
    16141615            ASSERT(iter != end);
    16151616        }
    1616        
     1617
    16171618        ASSERT((*iter)->isVariableObject());
    16181619        JSVariableObject* scope = static_cast<JSVariableObject*>(*iter);
     
    17001701           Sets register value on register base as the property named
    17011702           by identifier property. Base is converted to object first.
    1702  
     1703
    17031704           Unlike many opcodes, this one does not write any output to
    17041705           the register file.
     
    17101711        int registerOffset = r - (*registerBase);
    17111712#endif
    1712        
     1713
    17131714        Identifier& ident = codeBlock->identifiers[property];
    17141715        r[base].u.jsValue->put(exec, ident, r[value].u.jsValue);
    17151716        ASSERT(registerOffset == (r - (*registerBase)));
    1716        
     1717
    17171718        VM_CHECK_EXCEPTION();
    17181719        ++vPC;
     
    17321733
    17331734        JSObject* baseObj = r[base].u.jsValue->toObject(exec);
    1734        
     1735
    17351736        Identifier& ident = codeBlock->identifiers[property];
    17361737        JSValue* result = jsBoolean(baseObj->deleteProperty(exec, ident));
     
    17531754
    17541755        JSValue* baseValue = r[base].u.jsValue;
    1755        
     1756
    17561757        JSValue* subscript = r[property].u.jsValue;
    17571758        JSValue* result;
     
    17721773            result = baseObj->get(exec, property);
    17731774        }
    1774        
     1775
    17751776        VM_CHECK_EXCEPTION();
    17761777        r[dst].u.jsValue = result;
     
    17851786           first. register property is nominally converted to string
    17861787           but numbers are treated more efficiently.
    1787  
     1788
    17881789           Unlike many opcodes, this one does not write any output to
    17891790           the register file.
     
    17941795
    17951796        JSValue* baseValue = r[base].u.jsValue;
    1796        
     1797
    17971798        JSValue* subscript = r[property].u.jsValue;
    17981799
     
    18131814            baseObj->put(exec, property, r[value].u.jsValue);
    18141815        }
    1815        
     1816
    18161817        VM_CHECK_EXCEPTION();
    18171818        ++vPC;
     
    18431844            result = jsBoolean(baseObj->deleteProperty(exec, property));
    18441845        }
    1845        
     1846
    18461847        VM_CHECK_EXCEPTION();
    18471848        r[dst].u.jsValue = result;
     
    18561857           object first. register property is nominally converted to
    18571858           string but numbers are treated more efficiently.
    1858  
     1859
    18591860           Unlike many opcodes, this one does not write any output to
    18601861           the register file.
     
    18731874    BEGIN_OPCODE(op_jmp) {
    18741875        /* jmp target(offset)
    1875          
     1876
    18761877           Jumps unconditionally to offset target from the current
    18771878           instruction.
     
    18841885    BEGIN_OPCODE(op_jtrue) {
    18851886        /* jtrue cond(r) target(offset)
    1886          
     1887
    18871888           Jumps to offset target from the current instruction, if and
    18881889           only if register cond converts to boolean as true.
     
    19001901    BEGIN_OPCODE(op_jfalse) {
    19011902        /* jfalse cond(r) target(offset)
    1902          
     1903
    19031904           Jumps to offset target from the current instruction, if and
    19041905           only if register cond converts to boolean as false.
     
    19661967        JSValue* funcVal = r[func].u.jsValue;
    19671968        JSValue* baseVal = r[thisVal].u.jsValue;
    1968        
     1969
    19691970        if (baseVal == scopeChain->globalObject() && funcVal == scopeChain->globalObject()->evalFunction()) {
    19701971            int registerOffset = r - (*registerBase);
     
    19831984
    19841985            r[dst].u.jsValue = result;
    1985            
     1986
    19861987            ++vPC;
    19871988            NEXT_OPCODE;
    19881989        }
    1989        
     1990
    19901991        // We didn't find the blessed version of eval, so reset vPC and process
    19911992        // this instruction as a normal function call, supplying the proper 'this'
     
    20442045        int firstArg = (++vPC)->u.operand;
    20452046        int argCount = (++vPC)->u.operand;
    2046        
     2047
    20472048        JSValue* v = r[func].u.jsValue;
    2048        
     2049
    20492050        CallData callData;
    20502051        CallType callType = v->getCallData(callData);
    2051        
     2052
    20522053        if (callType == CallTypeJS) {
    20532054            if (*enabledProfilerReference)
     
    21402141            returnValue = thisObject;
    21412142        }
    2142          
     2143
    21432144        codeBlock = callFrame[CallerCodeBlock].u.codeBlock;
    21442145        if (!codeBlock)
    21452146            return returnValue;
    2146        
     2147
    21472148        k = codeBlock->jsValues.data();
    21482149        vPC = callFrame[ReturnVPC].u.vPC;
     
    22542255        JSObject* o = v->toObject(exec);
    22552256        VM_CHECK_EXCEPTION();
    2256        
     2257
    22572258        setScopeChain(exec, scopeChain, scopeChain->push(o));
    22582259
     
    23182319        int count = (++vPC)->u.operand;
    23192320        int target = (++vPC)->u.operand;
    2320        
     2321
    23212322        ScopeChainNode* tmp = scopeChain;
    23222323        while (count--)
    23232324            tmp = tmp->pop();
    23242325        setScopeChain(exec, scopeChain, tmp);
    2325            
     2326
    23262327        vPC += target;
    23272328        NEXT_OPCODE;
     
    23852386        int type = (++vPC)->u.operand;
    23862387        int message = (++vPC)->u.operand;
    2387        
     2388
    23882389        r[dst].u.jsValue = Error::create(exec, (ErrorType)type, k[message]->toString(exec), codeBlock->lineNumberForVPC(vPC), codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->sourceURL());
    2389        
     2390
    23902391        ++vPC;
    23912392        NEXT_OPCODE;
     
    24072408    BEGIN_OPCODE(op_put_getter) {
    24082409        /* put_getter base(r) property(id) function(r)
    2409          
     2410
    24102411           Sets register function on register base as the getter named
    24112412           by identifier property. Base and function are assumed to be
    24122413           objects as this op should only be used for getters defined
    24132414           in object literal form.
    2414          
     2415
    24152416           Unlike many opcodes, this one does not write any output to
    24162417           the register file.
     
    24192420        int property = (++vPC)->u.operand;
    24202421        int function = (++vPC)->u.operand;
    2421        
     2422
    24222423        ASSERT(r[base].u.jsValue->isObject());
    24232424        JSObject* baseObj = static_cast<JSObject*>(r[base].u.jsValue);
     
    24312432    BEGIN_OPCODE(op_put_setter) {
    24322433        /* put_setter base(r) property(id) function(r)
    2433          
     2434
    24342435           Sets register function on register base as the setter named
    24352436           by identifier property. Base and function are assumed to be
    24362437           objects as this op should only be used for setters defined
    24372438           in object literal form.
    2438          
     2439
    24392440           Unlike many opcodes, this one does not write any output to
    24402441           the register file.
     
    24432444        int property = (++vPC)->u.operand;
    24442445        int function = (++vPC)->u.operand;
    2445        
     2446
    24462447        ASSERT(r[base].u.jsValue->isObject());
    24472448        JSObject* baseObj = static_cast<JSObject*>(r[base].u.jsValue);
     
    24492450        ASSERT(r[function].u.jsValue->isObject());
    24502451        baseObj->defineSetter(exec, ident, static_cast<JSObject* >(r[function].u.jsValue));
    2451        
     2452
    24522453        ++vPC;
    24532454        NEXT_OPCODE;
     
    24552456    BEGIN_OPCODE(op_jsr) {
    24562457        /* jsr retAddrDst(r) target(offset)
    2457          
     2458
    24582459           Places the address of the next instruction into the retAddrDst
    24592460           register and jumps to offset target from the current instruction.
     
    24682469    BEGIN_OPCODE(op_sret) {
    24692470        /* sret retAddrSrc(r)
    2470          
     2471
    24712472         Jumps to the address stored in the retAddrSrc register. This
    24722473         differs from op_jmp because the target address is stored in a
     
    24792480    BEGIN_OPCODE(op_debug) {
    24802481        /* debug debugHookID(n) firstLine(n) lastLine(n)
    2481          
     2482
    24822483         Notifies the debugger of the current state of execution. This opcode
    24832484         is only generated while the debugger is attached.
     
    25022503        vPC = handlerVPC;
    25032504        NEXT_OPCODE;
    2504     }         
     2505    }
    25052506    }
    25062507    #undef NEXT_OPCODE
  • trunk/JavaScriptCore/VM/Machine.h

    r34351 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef Machine_h
    3030#define Machine_h
     
    3232#include "Opcode.h"
    3333#include "RegisterFileStack.h"
     34#include <kjs/list.h>
    3435#include <wtf/HashMap.h>
    35 #include <kjs/list.h>
    3636
    3737namespace KJS {
     
    4646    class RegisterFileStack;
    4747    class ScopeChainNode;
    48    
     48
    4949    enum DebugHookID {
    5050        WillExecuteProgram,
     
    6060    class Machine {
    6161    public:
    62         enum { CallerCodeBlock = 0,
    63                ReturnVPC,
    64                CallerScopeChain,
    65                CallerRegisterOffset,
    66                ReturnValueRegister,
    67                ArgumentStartRegister,
    68                ArgumentCount,
    69                CalledAsConstructor,
    70                Callee,
    71                OptionalCalleeActivation,
    72                CallFrameHeaderSize};
    73        
     62        enum {
     63            CallerCodeBlock = 0,
     64            ReturnVPC,
     65            CallerScopeChain,
     66            CallerRegisterOffset,
     67            ReturnValueRegister,
     68            ArgumentStartRegister,
     69            ArgumentCount,
     70            CalledAsConstructor,
     71            Callee,
     72            OptionalCalleeActivation,
     73            CallFrameHeaderSize
     74        };
     75
    7476        enum { ProgramCodeThisRegister = -1 };
    7577
    7678        Machine();
    77        
    78         Opcode getOpcode(OpcodeID id) {
     79
     80        Opcode getOpcode(OpcodeID id)
     81        {
    7982            #if HAVE(COMPUTED_GOTO)
    80                 return m_opcodeTable[id]; 
     83                return m_opcodeTable[id];
    8184            #else
    8285                return id;
     
    8487        }
    8588
    86         OpcodeID getOpcodeID(Opcode opcode) {
     89        OpcodeID getOpcodeID(Opcode opcode)
     90        {
    8791            #if HAVE(COMPUTED_GOTO)
    8892                ASSERT(isOpcode(opcode));
     
    9498
    9599        bool isOpcode(Opcode opcode);
    96        
     100
    97101        JSValue* execute(ProgramNode*, ExecState*, ScopeChainNode*, JSObject* thisObj, RegisterFileStack*, JSValue** exception);
    98102        JSValue* execute(FunctionBodyNode*, ExecState*, FunctionImp*, JSObject* thisObj, const List& args, RegisterFileStack*, ScopeChainNode*, JSValue** exception);
    99103        JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFile*, int registerOffset, ScopeChainNode*, JSValue** exception);
    100104        JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFileStack*, ScopeChainNode*, JSValue** exception);
    101        
     105
    102106        JSValue* retrieveArguments(ExecState*, FunctionImp*) const;
    103107        JSValue* retrieveCaller(ExecState*, FunctionImp*) const;
    104        
     108
    105109        void getFunctionAndArguments(Register** registerBase, Register* callFrame, FunctionImp*&, Register*& argv, int& argc);
    106        
     110
    107111    private:
    108         typedef enum { Normal, InitializeAndReturn } ExecutionFlag;
     112        enum ExecutionFlag { Normal, InitializeAndReturn };
    109113
    110114        ALWAYS_INLINE void setScopeChain(ExecState* exec, ScopeChainNode*&, ScopeChainNode*);
     
    113117        NEVER_INLINE bool unwindCallFrame(ExecState*, JSValue*, Register**, const Instruction*&, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&);
    114118        NEVER_INLINE Instruction* throwException(ExecState*, JSValue*, Register**, const Instruction*, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&);
    115        
     119
    116120        bool getCallFrame(ExecState*, FunctionImp*, Register**& registerBase, int& callFrameOffset) const;
    117121
     
    120124        void dumpCallFrame(const CodeBlock*, ScopeChainNode*, RegisterFile*, const Register*);
    121125        void dumpRegisters(const CodeBlock*, RegisterFile*, const Register*);
    122        
     126
    123127        bool isGlobalCallFrame(Register** registerBase, const Register* r) const { return (*registerBase) == r; }
    124128
    125129        int m_reentryDepth;
    126 #if HAVE(COMPUTED_GOTO)       
     130#if HAVE(COMPUTED_GOTO)
    127131        Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling
    128132        HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling
    129133#endif
    130134    };
    131    
     135
    132136    Machine& machine();
    133137
  • trunk/JavaScriptCore/VM/Opcode.h

    r34371 r34372  
    122122        \
    123123        macro(op_end) // end must be the last opcode in the list
    124        
     124
    125125    #define OPCODE_ID_ENUM(opcode) opcode,
    126126        typedef enum { FOR_EACH_OPCODE_ID(OPCODE_ID_ENUM) } OpcodeID;
  • trunk/JavaScriptCore/VM/Register.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef Register_h
    3030#define Register_h
     
    3636    class CodeBlock;
    3737    class FunctionImp;
    38     struct Instruction;
    3938    class JSObject;
    4039    class JSPropertyNameIterator;
    4140    class JSValue;
    4241    class ScopeChainNode;
    43    
     42    struct Instruction;
     43
    4444    struct Register {
    4545        union {
     
    5454        } u;
    5555    };
    56    
     56
    5757} // namespace KJS
    5858
  • trunk/JavaScriptCore/VM/RegisterFile.cpp

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#include "config.h"
    3030#include "RegisterFile.h"
     31
    3132#include "RegisterFileStack.h"
    32 
    3333#include "Register.h"
    3434
     35using namespace std;
     36
    3537namespace KJS {
    36 
    37 using namespace std;
    3838
    3939size_t RegisterFile::newBuffer(size_t size, size_t capacity, size_t minCapacity, size_t maxSize, size_t offset)
     
    5858    size_t capacity = m_capacity + numGlobalSlots;
    5959    minCapacity += numGlobalSlots;
    60    
     60
    6161    capacity = newBuffer(size, capacity, minCapacity, maxSize, 0);
    6262
     
    7575    size_t capacity = m_capacity + numGlobalSlots;
    7676    size_t minCapacity = size + count;
    77    
     77
    7878    if (minCapacity < capacity)
    7979        memmove(m_buffer + count, m_buffer, size * sizeof(Register));
  • trunk/JavaScriptCore/VM/RegisterFile.h

    r34069 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef RegisterFile_h
    3030#define RegisterFile_h
     
    4040    frame by its offset from "base", the logical first entry in the register
    4141    file. The bottom-most register frame's offset from base is 0.
    42    
     42
    4343    In a program where function "a" calls function "b" (global code -> a -> b),
    4444    the register file might look like this:
     
    5454       |              |                   |                                       |
    5555     buffer    base (frame 0)          frame 1                                 frame 2
    56      
     56
    5757    Since all variables, including globals, are accessed by negative offsets
    5858    from their register frame pointers, to keep old global offsets correct, new
    5959    globals must appear at the beginning of the register file, shifting base
    6060    to the right.
    61    
     61
    6262    If we added one global variable to the register file depicted above, it
    6363    would look like this:
     
    7070    ------------------------------->                                                                    <
    7171    |         <-globals | temps-> |
    72        ^                   ^       
    73        |                   |       
     72       ^                   ^
     73       |                   |
    7474     buffer         base (frame 0)
    7575
     
    7878    clients keep an indirect pointer, so their calculations update
    7979    automatically when base changes.
    80    
     80
    8181    For client simplicity, the RegisterFile measures size and capacity from
    8282    "base", not "buffer".
     
    8484
    8585    class RegisterFileStack;
    86    
     86
    8787    class RegisterFile : Noncopyable {
    8888    public:
    8989        enum { DefaultRegisterFileSize = 2 * 1024 * 1024 };
     90
    9091        RegisterFile(size_t maxSize, RegisterFileStack* m_baseObserver)
    9192            : m_safeForReentry(true)
     
    9899        {
    99100        }
    100        
     101
    101102        ~RegisterFile()
    102103        {
    103104            setBuffer(0);
    104105        }
    105        
     106
    106107        // Pointer to a value that holds the base of this register file.
    107108        Register** basePointer() { return &m_base; }
    108        
     109
    109110        void shrink(size_t size)
    110111        {
     
    128129        size_t size() { return m_size; }
    129130        size_t maxSize() { return m_maxSize; }
    130        
     131
    131132        void clear();
    132133
     
    145146        bool safeForReentry() { return m_safeForReentry; }
    146147        void setSafeForReentry(bool safeForReentry) { m_safeForReentry = safeForReentry; }
     148
    147149    private:
    148150        size_t newBuffer(size_t size, size_t capacity, size_t minCapacity, size_t maxSize, size_t offset);
     
    155157            m_buffer = buffer;
    156158        }
    157        
     159
    158160        void setBase(Register*);
     161
    159162        bool m_safeForReentry;
    160163        size_t m_size;
     
    165168        RegisterFileStack* m_baseObserver;
    166169    };
    167    
     170
    168171} // namespace KJS
    169172
  • trunk/JavaScriptCore/VM/RegisterFileStack.cpp

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#include "config.h"
    3030#include "RegisterFileStack.h"
     
    7070    }
    7171
    72     // Slow case: This is a nested register file: pop this register file and 
     72    // Slow case: This is a nested register file: pop this register file and
    7373    // copy its globals to the previous register file.
    7474    RegisterFile* tmp = m_stack.last();
  • trunk/JavaScriptCore/VM/RegisterFileStack.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef RegisterFileStack_h
    3030#define RegisterFileStack_h
     
    4444
    4545        ~RegisterFileStack();
    46        
     46
    4747        RegisterFile* pushGlobalRegisterFile();
    4848        void popGlobalRegisterFile();
     
    5151
    5252        RegisterFile* current() { return m_stack.last(); }
    53        
     53
    5454        void mark()
    5555        {
    5656            Stack::iterator end = m_stack.end();
    57             for (Stack::iterator it = m_stack.begin(); it != end; ++it) {
     57            for (Stack::iterator it = m_stack.begin(); it != end; ++it)
    5858                (*it)->mark();
    59             }
    6059        }
    6160
     
    6968        }
    7069
    71         bool inImplicitCall() {
    72             for (size_t i = 0; i < m_stack.size(); ++i) {
     70        bool inImplicitCall()
     71        {
     72            for (size_t i = 0; i < m_stack.size(); ++i) {
    7373                if (!m_stack[i]->safeForReentry())
    7474                    return true;
     
    8080        typedef Vector<RegisterFile*, 4> Stack;
    8181
    82         RegisterFile* lastGlobal() {
     82        RegisterFile* lastGlobal()
     83        {
    8384            ASSERT(m_stack.size());
    8485            for (size_t i = m_stack.size() - 1; i > 0; --i) {
  • trunk/JavaScriptCore/VM/RegisterID.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef RegisterID_h
    3030#define RegisterID_h
     
    6363            m_index = index;
    6464        }
    65        
     65
    6666        int index() const
    6767        {
     
    6969            return m_index;
    7070        }
    71        
     71
    7272        bool isTemporary()
    7373        {
     
    9292
    9393    private:
    94    
     94
    9595        int m_refCount;
    9696        int m_index;
     
    9999#endif
    100100    };
    101    
     101
    102102} // namespace KJS
    103103
     
    111111
    112112} // namespace WTF
    113    
     113
    114114#endif // RegisterID_h
  • trunk/JavaScriptCore/VM/SegmentedVector.h

    r33979 r34372  
    3333
    3434namespace KJS {
    35    
     35
    3636    template <typename T, size_t SegmentSize> class SegmentedVector {
    3737    public:
    38         SegmentedVector() 
     38        SegmentedVector()
    3939            : m_size(0)
    4040        {
     
    4848        }
    4949
    50         T& last() 
     50        T& last()
    5151        {
    5252            ASSERT(m_size);
     
    6161            m_size++;
    6262        }
    63        
     63
    6464        void removeLast()
    6565        {
     
    7373        }
    7474
    75         size_t size() const 
     75        size_t size() const
    7676        {
    77             return m_size; 
     77            return m_size;
    7878        }
    7979
    80         T& operator[](size_t index) 
     80        T& operator[](size_t index)
    8181        {
    8282            ASSERT(index < m_size);
     
    133133                numSegments++;
    134134            size_t oldSize = m_segments.size();
    135            
     135
    136136            if (numSegments == oldSize) {
    137137                m_segments.last()->resize(extra);
     
    143143
    144144            m_segments.resize(numSegments);
    145    
     145
    146146            ASSERT(oldSize < m_segments.size());
    147147            for (size_t i = oldSize - 1; i < (numSegments - 1); i++) {
  • trunk/JavaScriptCore/kjs/CallData.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef CallData_h
    3030#define CallData_h
  • trunk/JavaScriptCore/kjs/JSNotAnObject.cpp

    r33979 r34372  
    3434
    3535namespace KJS {
    36     // JSValue methods
    37     JSValue *JSNotAnObject::toPrimitive(ExecState* exec, JSType) const
    38     {
    39         UNUSED_PARAM(exec);
    40         ASSERT(exec->hadException() && exec->exception() == m_exception);
    41         return m_exception;
    42     }
    43    
    44     bool JSNotAnObject::getPrimitiveNumber(ExecState* exec, double&, JSValue*&)
    45     {
    46         UNUSED_PARAM(exec);
    47         ASSERT(exec->hadException() && exec->exception() == m_exception);
    48         return false;
    49     }
    50    
    51     bool JSNotAnObject::toBoolean(ExecState* exec) const
    52     {
    53         UNUSED_PARAM(exec);
    54         ASSERT(exec->hadException() && exec->exception() == m_exception);
    55         return false;
    56     }
    57    
    58     double JSNotAnObject::toNumber(ExecState* exec) const
    59     {
    60         UNUSED_PARAM(exec);
    61         ASSERT(exec->hadException() && exec->exception() == m_exception);
    62         return NaN;
    63     }
    6436
    65     UString JSNotAnObject::toString(ExecState* exec) const
    66     {
    67         UNUSED_PARAM(exec);
    68         ASSERT(exec->hadException() && exec->exception() == m_exception);
    69         return "";
    70     }
    71    
    72     JSObject *JSNotAnObject::toObject(ExecState* exec) const
    73     {
    74         UNUSED_PARAM(exec);
    75         ASSERT(exec->hadException() && exec->exception() == m_exception);
    76         return m_exception;
    77     }
    78    
    79     // marking
    80     void JSNotAnObject::mark()
    81     {
    82         JSCell::mark();
    83         if (!m_exception->marked())
    84             m_exception->mark();
    85     }
    86    
    87     bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, const Identifier&, PropertySlot&)
    88     {
    89         UNUSED_PARAM(exec);
    90         ASSERT(exec->hadException() && exec->exception() == m_exception);
    91         return false;
    92     }
    93    
    94     bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, unsigned, PropertySlot&)
    95     {
    96         UNUSED_PARAM(exec);
    97         ASSERT(exec->hadException() && exec->exception() == m_exception);
    98         return false;
    99     }
    100    
    101     void JSNotAnObject::put(ExecState* exec, const Identifier& , JSValue*)
    102     {
    103         UNUSED_PARAM(exec);
    104         ASSERT(exec->hadException() && exec->exception() == m_exception);
    105     }
    106    
    107     void JSNotAnObject::put(ExecState* exec, unsigned, JSValue*)
    108     {
    109         UNUSED_PARAM(exec);
    110         ASSERT(exec->hadException() && exec->exception() == m_exception);
    111     }
    112    
    113     bool JSNotAnObject::deleteProperty(ExecState* exec, const Identifier &)
    114     {
    115         UNUSED_PARAM(exec);
    116         ASSERT(exec->hadException() && exec->exception() == m_exception);
    117         return false;
    118     }
    119    
    120     bool JSNotAnObject::deleteProperty(ExecState* exec, unsigned)
    121     {
    122         UNUSED_PARAM(exec);
    123         ASSERT(exec->hadException() && exec->exception() == m_exception);
    124         return false;
    125     }
    126    
    127     JSValue *JSNotAnObject::defaultValue(ExecState* exec, JSType) const
    128     {
    129         UNUSED_PARAM(exec);
    130         ASSERT(exec->hadException() && exec->exception() == m_exception);
    131         return m_exception;
    132     }
    133    
    134     JSObject* JSNotAnObject::construct(ExecState* exec, const List&)
    135     {
    136         UNUSED_PARAM(exec);
    137         ASSERT(exec->hadException() && exec->exception() == m_exception);
    138         return m_exception;
    139     }
    140    
    141     JSObject* JSNotAnObject::construct(ExecState* exec, const List&, const Identifier&, const UString&, int)
    142     {
    143         UNUSED_PARAM(exec);
    144         ASSERT(exec->hadException() && exec->exception() == m_exception);
    145         return m_exception;
    146     }
    147    
    148     JSValue* JSNotAnObject::callAsFunction(ExecState* exec, JSObject *, const List &)
    149     {
    150         UNUSED_PARAM(exec);
    151         ASSERT(exec->hadException() && exec->exception() == m_exception);
    152         return m_exception;
    153     }
    154    
    155     void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&)
    156     {
    157         UNUSED_PARAM(exec);
    158         ASSERT(exec->hadException() && exec->exception() == m_exception);       
    159     }
    160    
     37// JSValue methods
     38JSValue* JSNotAnObject::toPrimitive(ExecState* exec, JSType) const
     39{
     40    UNUSED_PARAM(exec);
     41    ASSERT(exec->hadException() && exec->exception() == m_exception);
     42    return m_exception;
    16143}
     44
     45bool JSNotAnObject::getPrimitiveNumber(ExecState* exec, double&, JSValue*&)
     46{
     47    UNUSED_PARAM(exec);
     48    ASSERT(exec->hadException() && exec->exception() == m_exception);
     49    return false;
     50}
     51
     52bool JSNotAnObject::toBoolean(ExecState* exec) const
     53{
     54    UNUSED_PARAM(exec);
     55    ASSERT(exec->hadException() && exec->exception() == m_exception);
     56    return false;
     57}
     58
     59double JSNotAnObject::toNumber(ExecState* exec) const
     60{
     61    UNUSED_PARAM(exec);
     62    ASSERT(exec->hadException() && exec->exception() == m_exception);
     63    return NaN;
     64}
     65
     66UString JSNotAnObject::toString(ExecState* exec) const
     67{
     68    UNUSED_PARAM(exec);
     69    ASSERT(exec->hadException() && exec->exception() == m_exception);
     70    return "";
     71}
     72
     73JSObject* JSNotAnObject::toObject(ExecState* exec) const
     74{
     75    UNUSED_PARAM(exec);
     76    ASSERT(exec->hadException() && exec->exception() == m_exception);
     77    return m_exception;
     78}
     79
     80// Marking
     81void JSNotAnObject::mark()
     82{
     83    JSCell::mark();
     84    if (!m_exception->marked())
     85        m_exception->mark();
     86}
     87
     88// JSObject methods
     89bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, const Identifier&, PropertySlot&)
     90{
     91    UNUSED_PARAM(exec);
     92    ASSERT(exec->hadException() && exec->exception() == m_exception);
     93    return false;
     94}
     95
     96bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, unsigned, PropertySlot&)
     97{
     98    UNUSED_PARAM(exec);
     99    ASSERT(exec->hadException() && exec->exception() == m_exception);
     100    return false;
     101}
     102
     103void JSNotAnObject::put(ExecState* exec, const Identifier& , JSValue*)
     104{
     105    UNUSED_PARAM(exec);
     106    ASSERT(exec->hadException() && exec->exception() == m_exception);
     107}
     108
     109void JSNotAnObject::put(ExecState* exec, unsigned, JSValue*)
     110{
     111    UNUSED_PARAM(exec);
     112    ASSERT(exec->hadException() && exec->exception() == m_exception);
     113}
     114
     115bool JSNotAnObject::deleteProperty(ExecState* exec, const Identifier&)
     116{
     117    UNUSED_PARAM(exec);
     118    ASSERT(exec->hadException() && exec->exception() == m_exception);
     119    return false;
     120}
     121
     122bool JSNotAnObject::deleteProperty(ExecState* exec, unsigned)
     123{
     124    UNUSED_PARAM(exec);
     125    ASSERT(exec->hadException() && exec->exception() == m_exception);
     126    return false;
     127}
     128
     129JSValue* JSNotAnObject::defaultValue(ExecState* exec, JSType) const
     130{
     131    UNUSED_PARAM(exec);
     132    ASSERT(exec->hadException() && exec->exception() == m_exception);
     133    return m_exception;
     134}
     135
     136JSObject* JSNotAnObject::construct(ExecState* exec, const List&)
     137{
     138    UNUSED_PARAM(exec);
     139    ASSERT(exec->hadException() && exec->exception() == m_exception);
     140    return m_exception;
     141}
     142
     143JSObject* JSNotAnObject::construct(ExecState* exec, const List&, const Identifier&, const UString&, int)
     144{
     145    UNUSED_PARAM(exec);
     146    ASSERT(exec->hadException() && exec->exception() == m_exception);
     147    return m_exception;
     148}
     149
     150JSValue* JSNotAnObject::callAsFunction(ExecState* exec, JSObject*, const List&)
     151{
     152    UNUSED_PARAM(exec);
     153    ASSERT(exec->hadException() && exec->exception() == m_exception);
     154    return m_exception;
     155}
     156
     157void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&)
     158{
     159    UNUSED_PARAM(exec);
     160    ASSERT(exec->hadException() && exec->exception() == m_exception);
     161}
     162
     163} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSNotAnObject.h

    r33979 r34372  
    3333
    3434namespace KJS {
    35    
     35
    3636    // This unholy class is used to allow us to avoid multiple exception checks
    3737    // in certain SquirrelFish opcodes -- effectively it just silently consumes
     
    4545
    4646        // JSValue methods
    47         virtual JSValue *toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const;
    48         virtual bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value);
    49         virtual bool toBoolean(ExecState* exec) const;
    50         virtual double toNumber(ExecState* exec) const;
    51         virtual UString toString(ExecState* exec) const;
    52         virtual JSObject *toObject(ExecState* exec) const;
    53        
    54         // marking
     47        virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
     48        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
     49        virtual bool toBoolean(ExecState*) const;
     50        virtual double toNumber(ExecState*) const;
     51        virtual UString toString(ExecState*) const;
     52        virtual JSObject* toObject(ExecState*) const;
     53
     54        // Marking
    5555        virtual void mark();
    5656
    57         virtual bool getOwnPropertySlot(ExecState* , const Identifier&, PropertySlot&);
    58         virtual bool getOwnPropertySlot(ExecState* , unsigned index, PropertySlot&);
     57        // JSObject methods
     58        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     59        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    5960
    60         virtual void put(ExecState*, const Identifier& propertyName, JSValue* value);
    61         virtual void put(ExecState*, unsigned propertyName, JSValue* value);
     61        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     62        virtual void put(ExecState*, unsigned propertyName, JSValue*);
    6263
    63         virtual bool deleteProperty(ExecState* exec, const Identifier &propertyName);
    64         virtual bool deleteProperty(ExecState* exec, unsigned propertyName);
     64        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     65        virtual bool deleteProperty(ExecState*, unsigned propertyName);
    6566
    66         virtual JSValue *defaultValue(ExecState* exec, JSType hint) const;
     67        virtual JSValue* defaultValue(ExecState*, JSType hint) const;
    6768
    68         virtual JSObject* construct(ExecState* exec, const List& args);
    69         virtual JSObject* construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber);
    70        
    71         virtual JSValue *callAsFunction(ExecState* exec, JSObject *thisObj, const List &args);
     69        virtual JSObject* construct(ExecState*, const List&);
     70        virtual JSObject* construct(ExecState*, const List&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
     71
     72        virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List&);
    7273
    7374        virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     
    7677        JSObject* m_exception;
    7778    };
    78 }
    7979
    80 #endif
     80} // namespace KJS
     81
     82#endif // JSNotAnObject_h
  • trunk/JavaScriptCore/kjs/JSVariableObject.h

    r34355 r34372  
    5555
    5656        JSValue*& valueAt(int index) const { return registers()[index].u.jsValue; }
     57
    5758    protected:
    5859        // Subclasses of JSVariableObject can subclass this struct to add data
  • trunk/JavaScriptCore/kjs/LocalStorageEntry.h

    r32259 r34372  
    2323 */
    2424
    25 #ifndef KJS_LOCAL_STORAGE_H
    26 #define KJS_LOCAL_STORAGE_H
     25#ifndef LocalStorageEntry_h
     26#define LocalStorageEntry_h
    2727
    2828#include <wtf/Forward.h>
     
    3030
    3131namespace KJS {
     32
    3233    class JSValue;
    3334
     
    4849
    4950    typedef Vector<LocalStorageEntry, 32> LocalStorage;
    50 }
     51
     52} // namespace KJS
    5153
    5254namespace WTF {
     55
    5356    template<> struct VectorTraits<KJS::LocalStorageEntry> : VectorTraitsBase<true, KJS::LocalStorageEntry> { };
    54 }
    5557
    56 #endif // KJS_LOCAL_STORAGE_H
     58} // namespace WTF
     59
     60#endif // LocalStorageEntry_h
  • trunk/JavaScriptCore/kjs/PropertyNameArray.h

    r33979 r34372  
    2020 */
    2121
    22 #ifndef KJS_PROPERTY_NAME_ARRAY_H
    23 #define KJS_PROPERTY_NAME_ARRAY_H
     22#ifndef PropertyNameArray_h
     23#define PropertyNameArray_h
    2424
    2525#include "identifier.h"
     
    3737        void add(UString::Rep*);
    3838        void addKnownUnique(UString::Rep* identifier) { m_vector.append(identifier); }
     39
    3940        const_iterator begin() const { return m_vector.begin(); }
    4041        const_iterator end() const { return m_vector.end(); }
     42
    4143        size_t size() const { return m_vector.size(); }
    4244
     
    4547
    4648        Identifier* releaseIdentifiers() { return size() ? m_vector.releaseBuffer() : 0; }
     49
    4750    private:
    4851        typedef HashSet<UString::Rep*, PtrHash<UString::Rep*> > IdentifierSet;
     
    5457} // namespace KJS
    5558
    56 
    57 #endif // KJS_PROPERTY_NAME_ARRAY_H
     59#endif // PropertyNameArray_h
  • trunk/JavaScriptCore/kjs/SourceProvider.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef SourceProvider_h
    3030#define SourceProvider_h
     
    3737    class SourceProvider : public RefCounted<SourceProvider> {
    3838    public:
    39         virtual ~SourceProvider() {}
     39        virtual ~SourceProvider() { }
    4040        virtual UString getRange(int start, int end) const = 0;
    4141        virtual const UChar* data() const = 0;
     
    5252
    5353    private:
    54         UStringSourceProvider(const UString& source) : m_source(source) {}
     54        UStringSourceProvider(const UString& source)
     55            : m_source(source)
     56        {
     57        }
     58
    5559        UString m_source;
    5660    };
    5761
    58 }
     62} // namespace KJS
    5963
    6064#endif // SourceProvider_h
  • trunk/JavaScriptCore/kjs/SourceRange.h

    r33979 r34372  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929#ifndef SourceRange_h
    3030#define SourceRange_h
     
    3737    class SourceRange {
    3838    public:
    39         SourceRange(PassRefPtr<SourceProvider> provider, int start, int end) 
     39        SourceRange(PassRefPtr<SourceProvider> provider, int start, int end)
    4040            : m_sourceProvider(provider)
    4141            , m_startChar(start)
     
    4343        {
    4444        }
    45         SourceRange() {}
    4645
    47         UString toString() const { if (!m_sourceProvider) return UString(); return m_sourceProvider->getRange(m_startChar, m_endChar); }
     46        SourceRange()
     47        {
     48        }
     49
     50        UString toString() const
     51        {
     52            if (!m_sourceProvider)
     53                return UString();
     54            return m_sourceProvider->getRange(m_startChar, m_endChar);
     55        }
    4856
    4957    private:
     
    5361    };
    5462
    55 }
     63} // namespace KJS
    5664
    5765#endif // SourceRange_h
  • trunk/JavaScriptCore/kjs/scope_chain.h

    r34007 r34372  
    4545        JSObject* globalThis;
    4646        int refCount;
    47        
     47
    4848        void deref() { if (--refCount == 0) release(); }
    4949        void ref() { ++refCount; }
     
    119119    class ScopeChainIterator {
    120120    public:
    121         ScopeChainIterator(const ScopeChainNode* node) : m_node(node) {}
     121        ScopeChainIterator(const ScopeChainNode* node)
     122            : m_node(node)
     123        {
     124        }
    122125
    123126        JSObject* const & operator*() const { return m_node->object; }
     
    188191        void print() const { _node->print(); }
    189192#endif
    190        
     193
    191194    private:
    192195        ScopeChainNode* _node;
  • trunk/JavaScriptCore/kjs/value.cpp

    r34355 r34372  
    8181static const double D32 = 4294967296.0;
    8282
    83 void *JSCell::operator new(size_t size)
     83void* JSCell::operator new(size_t size)
    8484{
    8585    return Collector::allocate(size);
     
    102102
    103103// ECMA 9.4
    104 double JSValue::toInteger(ExecState *exec) const
     104double JSValue::toInteger(ExecState* exec) const
    105105{
    106106    int32_t i;
     
    111111}
    112112
    113 double JSValue::toIntegerPreserveNaN(ExecState *exec) const
     113double JSValue::toIntegerPreserveNaN(ExecState* exec) const
    114114{
    115115    int32_t i;
     
    172172}
    173173
    174 bool JSCell::getNumber(double &numericValue) const
     174bool JSCell::getNumber(double& numericValue) const
    175175{
    176176    if (!isNumber())
    177177        return false;
    178     numericValue = static_cast<const NumberImp *>(this)->value();
     178    numericValue = static_cast<const NumberImp*>(this)->value();
    179179    return true;
    180180}
     
    182182double JSCell::getNumber() const
    183183{
    184     return isNumber() ? static_cast<const NumberImp *>(this)->value() : NaN;
    185 }
    186 
    187 bool JSCell::getString(UString &stringValue) const
     184    return isNumber() ? static_cast<const NumberImp*>(this)->value() : NaN;
     185}
     186
     187bool JSCell::getString(UString&stringValue) const
    188188{
    189189    if (!isString())
    190190        return false;
    191     stringValue = static_cast<const StringImp *>(this)->value();
     191    stringValue = static_cast<const StringImp*>(this)->value();
    192192    return true;
    193193}
     
    195195UString JSCell::getString() const
    196196{
    197     return isString() ? static_cast<const StringImp *>(this)->value() : UString();
    198 }
    199 
    200 JSObject *JSCell::getObject()
    201 {
    202     return isObject() ? static_cast<JSObject *>(this) : 0;
    203 }
    204 
    205 const JSObject *JSCell::getObject() const
    206 {
    207     return isObject() ? static_cast<const JSObject *>(this) : 0;
     197    return isString() ? static_cast<const StringImp*>(this)->value() : UString();
     198}
     199
     200JSObject*JSCell::getObject()
     201{
     202    return isObject() ? static_cast<JSObject*>(this) : 0;
     203}
     204
     205const JSObject* JSCell::getObject() const
     206{
     207    return isObject() ? static_cast<const JSObject*>(this) : 0;
    208208}
    209209
  • trunk/JavaScriptCore/kjs/value.h

    r34355 r34372  
    5353    friend class JSCell; // so it can derive from this class
    5454    friend class Collector; // so it can call asCell()
    55 
    5655private:
    5756    JSValue();
     
    6867    bool isString() const;
    6968    bool isObject() const;
    70     bool isObject(const ClassInfo *) const;
     69    bool isObject(const ClassInfo*) const;
    7170
    7271    // Extracting the value.
     
    7877    bool getString(UString&) const;
    7978    UString getString() const; // null string if not a string
    80     JSObject *getObject(); // NULL if not an object
    81     const JSObject *getObject() const; // NULL if not an object
     79    JSObject* getObject(); // NULL if not an object
     80    const JSObject* getObject() const; // NULL if not an object
    8281
    8382    CallType getCallData(CallData&);
     
    9089   
    9190    // Basic conversions.
    92     JSValue* toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const;
    93     bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value);
    94 
    95     bool toBoolean(ExecState *exec) const;
     91    JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
     92    bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
     93
     94    bool toBoolean(ExecState*) const;
    9695
    9796    // toNumber conversion is expected to be side effect free if an exception has
    9897    // been set in the ExecState already.
    99     double toNumber(ExecState *exec) const;
     98    double toNumber(ExecState*) const;
    10099    JSValue* toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number.
    101     UString toString(ExecState *exec) const;
    102     JSObject* toObject(ExecState *exec) const;
     100    UString toString(ExecState*) const;
     101    JSObject* toObject(ExecState*) const;
    103102
    104103    // Integer conversions.
     
    138137
    139138    // Implementation details.
    140     JSCell *asCell();
    141     const JSCell *asCell() const;
     139    JSCell* asCell();
     140    const JSCell* asCell() const;
    142141};
    143142
     
    152151    JSCell();
    153152    virtual ~JSCell();
     153
    154154public:
    155155    // Querying the type.
     
    158158    bool isString() const;
    159159    bool isObject() const;
    160     bool isObject(const ClassInfo *) const;
     160    bool isObject(const ClassInfo*) const;
    161161
    162162    // Extracting the value.
     
    165165    bool getString(UString&) const;
    166166    UString getString() const; // null string if not a string
    167     JSObject *getObject(); // NULL if not an object
    168     const JSObject *getObject() const; // NULL if not an object
     167    JSObject* getObject(); // NULL if not an object
     168    const JSObject* getObject() const; // NULL if not an object
    169169   
    170170    virtual CallType getCallData(CallData&);
     
    177177
    178178    // Basic conversions.
    179     virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const = 0;
    180     virtual bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) = 0;
    181     virtual bool toBoolean(ExecState *exec) const = 0;
    182     virtual double toNumber(ExecState *exec) const = 0;
    183     virtual UString toString(ExecState *exec) const = 0;
    184     virtual JSObject *toObject(ExecState *exec) const = 0;
     179    virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const = 0;
     180    virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0;
     181    virtual bool toBoolean(ExecState*) const = 0;
     182    virtual double toNumber(ExecState*) const = 0;
     183    virtual UString toString(ExecState*) const = 0;
     184    virtual JSObject* toObject(ExecState*) const = 0;
    185185
    186186    // Garbage collection.
    187     void *operator new(size_t);
     187    void* operator new(size_t);
    188188    virtual void mark();
    189189    bool marked() const;
     
    200200
    201201class NumberImp : public JSCell {
    202   friend JSValue* jsNumberCell(double);
    203 
     202    friend JSValue* jsNumberCell(double);
    204203public:
    205   double value() const { return val; }
    206 
    207   virtual JSType type() const;
    208 
    209   virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
    210   virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    211   virtual bool toBoolean(ExecState* exec) const;
    212   virtual double toNumber(ExecState* exec) const;
    213   virtual UString toString(ExecState* exec) const;
    214   virtual JSObject* toObject(ExecState* exec) const;
     204    double value() const { return val; }
     205
     206    virtual JSType type() const;
     207
     208    virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
     209    virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     210    virtual bool toBoolean(ExecState*) const;
     211    virtual double toNumber(ExecState*) const;
     212    virtual UString toString(ExecState*) const;
     213    virtual JSObject* toObject(ExecState*) const;
    215214    virtual JSObject* toThisObject(ExecState*) const;
    216215
    217   void* operator new(size_t size)
    218   {
     216    void* operator new(size_t size)
     217    {
    219218#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
    220       return Collector::inlineAllocateNumber(size);
     219        return Collector::inlineAllocateNumber(size);
    221220#else
    222       return Collector::allocateNumber(size);
     221        return Collector::allocateNumber(size);
    223222#endif
    224   }
     223    }
    225224
    226225private:
    227   NumberImp(double v) : val(v) { }
    228 
    229   virtual bool getUInt32(uint32_t&) const;
    230   virtual bool getTruncatedInt32(int32_t&) const;
    231   virtual bool getTruncatedUInt32(uint32_t&) const;
    232 
    233   double val;
     226    NumberImp(double v)
     227        : val(v)
     228    {
     229    }
     230
     231    virtual bool getUInt32(uint32_t&) const;
     232    virtual bool getTruncatedInt32(int32_t&) const;
     233    virtual bool getTruncatedUInt32(uint32_t&) const;
     234
     235    double val;
    234236};
    235237
    236 JSCell *jsString(const UString&); // returns empty string if passed null string
    237 JSCell *jsString(const char* = ""); // returns empty string if passed 0
     238JSCell* jsString(const UString&); // returns empty string if passed null string
     239JSCell* jsString(const char* = ""); // returns empty string if passed 0
    238240
    239241// should be used for strings that are owned by an object that will
    240242// likely outlive the JSValue this makes, such as the parse tree or a
    241243// DOM object that contains a UString
    242 JSCell *jsOwnedString(const UString&);
     244JSCell* jsOwnedString(const UString&);
    243245
    244246extern const double NaN;
     
    252254}
    253255
    254 ALWAYS_INLINE JSValue *jsUndefined()
     256ALWAYS_INLINE JSValue* jsUndefined()
    255257{
    256258    return JSImmediate::undefinedImmediate();
    257259}
    258260
    259 inline JSValue *jsNull()
     261inline JSValue* jsNull()
    260262{
    261263    return JSImmediate::nullImmediate();
    262264}
    263265
    264 inline JSValue *jsNaN()
     266inline JSValue* jsNaN()
    265267{
    266268    return jsNumberCell(NaN);
    267269}
    268270
    269 inline JSValue *jsBoolean(bool b)
     271inline JSValue* jsBoolean(bool b)
    270272{
    271273    return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate();
     
    608610}
    609611
    610 } // namespace
     612} // namespace KJS
    611613
    612614#endif // KJS_VALUE_H
Note: See TracChangeset for help on using the changeset viewer.