Changeset 10148 in webkit for trunk/JavaScriptCore/kjs/nodes.h


Ignore:
Timestamp:
Aug 12, 2005, 12:36:00 AM (20 years ago)
Author:
mjs
Message:

Reviewed by hyatt.

  • refactor function calls, 3% speedup on JS iBench.
  • kjs/grammar.y:
  • kjs/nodes.cpp: (Node::throwError): Added new useful variants. (FunctionCallValueNode::evaluate): New node to handle calls on expressions that are strictly values, not references. (FunctionCallValueNode::ref): ditto (FunctionCallValueNode::deref): ditto (FunctionCallResolveNode::evaluate): New node to handle calls on identifier expressions, so that they are looked up in the scope chain. (FunctionCallResolveNode::ref): ditto (FunctionCallResolveNode::deref): ditto (FunctionCallBracketNode::evaluate): New node to handle calls on bracket dereferences, so that the expression before brackets is used as the this object. (FunctionCallBracketNode::ref): ditto (FunctionCallBracketNode::deref): ditto (FunctionCallDotNode::evaluate): New node to handle calls on dot dereferences, so that the expression before the dot is used as the this object. (FunctionCallDotNode::ref): ditto (FunctionCallDotNode::deref): ditto (dotExprNotAnObjectString): helper function to avoid global variable access. (dotExprDoesNotAllowCallsString): ditto
  • kjs/nodes.h: Declared new classes.
  • kjs/nodes2string.cpp: (FunctionCallValueNode::streamTo): Added - serializes the appropriate function call (FunctionCallResolveNode::streamTo): ditto (FunctionCallBracketNode::streamTo): ditto (FunctionCallParenBracketNode::streamTo): ditto (FunctionCallDotNode::streamTo): ditto (FunctionCallParenDotNode::streamTo): ditto
  • kjs/object.h: (KJS::ObjectImp::isActivation): Change how activation objects are detected in the scope chain, a virtual function is cheaper than the old inheritance test.
  • kjs/function.h: (KJS::ActivationImp::isActivation): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.h

    r10135 r10148  
    107107    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr);
    108108    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
     109    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Identifier ident);
     110    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *e1, Node *e2);
     111    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr, Identifier ident);
     112
    109113    void setExceptionDetailsIfNeeded(ExecState *exec);
    110114    int line;
     
    361365  };
    362366
    363   class FunctionCallNode : public Node {
    364   public:
    365     FunctionCallNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
     367  class FunctionCallValueNode : public Node {
     368  public:
     369    FunctionCallValueNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
    366370    virtual void ref();
    367371    virtual bool deref();
     
    371375    Node *expr;
    372376    ArgumentsNode *args;
     377  };
     378
     379  class FunctionCallResolveNode : public Node {
     380  public:
     381    FunctionCallResolveNode(const Identifier& i, ArgumentsNode *a) : ident(i), args(a) {}
     382    virtual void ref();
     383    virtual bool deref();
     384    ValueImp *evaluate(ExecState *exec);
     385    virtual void streamTo(SourceStream &s) const;
     386  private:
     387    Identifier ident;
     388    ArgumentsNode *args;
     389  };
     390
     391  class FunctionCallBracketNode : public Node {
     392  public:
     393    FunctionCallBracketNode(Node *b, Node *s, ArgumentsNode *a) : base(b), subscript(s), args(a) {}
     394    virtual void ref();
     395    virtual bool deref();
     396    ValueImp *evaluate(ExecState *exec);
     397    virtual void streamTo(SourceStream &s) const;
     398  private:
     399    Node *base;
     400    Node *subscript;
     401    ArgumentsNode *args;
     402  };
     403
     404  class FunctionCallParenBracketNode : public Node {
     405  public:
     406    FunctionCallParenBracketNode(Node *b, Node *s, ArgumentsNode *a) : FunctionCallBracketNode(b, s, a) {}
     407    virtual void streamTo(SourceStream &s) const;
     408  };
     409
     410  class FunctionCallDotNode : public Node {
     411  public:
     412    FunctionCallDotNode(Node *b, const Identifier &i, ArgumentsNode *a) : base(b), ident(i), args(a) {}
     413    virtual void ref();
     414    virtual bool deref();
     415    ValueImp *evaluate(ExecState *exec);
     416    virtual void streamTo(SourceStream &s) const;
     417  private:
     418    Node *base;
     419    Identifier ident;
     420    ArgumentsNode *args;
     421  };
     422
     423  class FunctionCallParenDotNode : public Node {
     424  public:
     425    FunctionCallDotNode(Node *b, const Identifier &i, ArgumentsNode *a) : FunctionCallDotNode(b, i, a) {}
     426    virtual void streamTo(SourceStream &s) const;
    373427  };
    374428
Note: See TracChangeset for help on using the changeset viewer.