*
*/
-#ifndef NODES_H_
-#define NODES_H_
+#ifndef Nodes_h
+#define Nodes_h
#include "Error.h"
+#include "JITCode.h"
#include "Opcode.h"
+#include "ParserArena.h"
#include "ResultType.h"
#include "SourceCode.h"
#include "SymbolTable.h"
#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(X86) && COMPILER(GCC)
-#define JSC_FAST_CALL __attribute__((regparm(3)))
-#else
-#define JSC_FAST_CALL
-#endif
namespace JSC {
- class CodeBlock;
+ class ArgumentListNode;
class BytecodeGenerator;
- class FuncDeclNode;
- class EvalCodeBlock;
- class JSFunction;
- class NodeReleaser;
- class ProgramCodeBlock;
+ class FunctionBodyNode;
+ class Label;
class PropertyListNode;
+ class ReadModifyResolveNode;
class RegisterID;
class ScopeChainNode;
+ class ScopeNode;
typedef unsigned CodeFeatures;
const CodeFeatures WithFeature = 1 << 4;
const CodeFeatures CatchFeature = 1 << 5;
const CodeFeatures ThisFeature = 1 << 6;
- const CodeFeatures AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature;
+ const CodeFeatures StrictModeFeature = 1 << 7;
+ const CodeFeatures ShadowsArgumentsFeature = 1 << 8;
+
+
+ const CodeFeatures AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature;
enum Operator {
OpEqual,
OpLogicalOr
};
+ typedef HashSet<RefPtr<StringImpl>, IdentifierRepHash> IdentifierSet;
+
namespace DeclarationStacks {
enum VarAttrs { IsConstant = 1, HasInitializer = 2 };
- typedef Vector<std::pair<Identifier, unsigned> > VarStack;
- typedef Vector<RefPtr<FuncDeclNode> > FunctionStack;
+ typedef Vector<std::pair<const Identifier*, unsigned> > VarStack;
+ typedef Vector<FunctionBodyNode*> FunctionStack;
}
struct SwitchInfo {
SwitchType switchType;
};
- class ParserRefCounted : Noncopyable {
- protected:
- ParserRefCounted(JSGlobalData*) JSC_FAST_CALL;
-
+ class ParserArenaFreeable {
public:
- virtual ~ParserRefCounted();
-
- // Nonrecursive destruction.
- virtual void releaseNodes(NodeReleaser&);
-
- void ref() JSC_FAST_CALL;
- void deref() JSC_FAST_CALL;
- bool hasOneRef() JSC_FAST_CALL;
-
- static void deleteNewObjects(JSGlobalData*) JSC_FAST_CALL;
-
- private:
- JSGlobalData* m_globalData;
+ // ParserArenaFreeable objects are are freed when the arena is deleted.
+ // Destructors are not called. Clients must not call delete on such objects.
+ void* operator new(size_t, JSGlobalData*);
};
- class Node : public ParserRefCounted {
+ class ParserArenaDeletable {
public:
- Node(JSGlobalData*) JSC_FAST_CALL;
+ virtual ~ParserArenaDeletable() { }
+
+ // ParserArenaDeletable objects are deleted when the arena is deleted.
+ // Clients must not call delete directly on such objects.
+ void* operator new(size_t, JSGlobalData*);
+ };
- /*
- Return value: The register holding the production's value.
- dst: An optional parameter specifying the most efficient
- destination at which to store the production's value.
- The callee must honor dst.
+ class ParserArenaRefCounted : public RefCounted<ParserArenaRefCounted> {
+ protected:
+ ParserArenaRefCounted(JSGlobalData*);
- dst provides for a crude form of copy propagation. For example,
+ public:
+ virtual ~ParserArenaRefCounted()
+ {
+ ASSERT(deletionHasBegun());
+ }
+ };
- x = 1
+ class Node : public ParserArenaFreeable {
+ protected:
+ Node(JSGlobalData*);
- becomes
-
- load r[x], 1
-
- instead of
+ public:
+ virtual ~Node() { }
- load r0, 1
- mov r[x], r0
-
- because the assignment node, "x =", passes r[x] as dst to the number
- node, "1".
- */
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* dst = 0) JSC_FAST_CALL = 0;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* destination = 0) = 0;
int lineNo() const { return m_line; }
};
class ExpressionNode : public Node {
- public:
- ExpressionNode(JSGlobalData* globalData, ResultType resultDesc = ResultType::unknownType()) JSC_FAST_CALL
- : Node(globalData)
- , m_resultDesc(resultDesc)
- {
- }
-
- virtual bool isNumber() const JSC_FAST_CALL { return false; }
- virtual bool isString() const JSC_FAST_CALL { return false; }
- virtual bool isNull() const JSC_FAST_CALL { return false; }
- virtual bool isPure(BytecodeGenerator&) const JSC_FAST_CALL { return false; }
- virtual bool isLocation() const JSC_FAST_CALL { return false; }
- virtual bool isResolveNode() const JSC_FAST_CALL { return false; }
- virtual bool isBracketAccessorNode() const JSC_FAST_CALL { return false; }
- virtual bool isDotAccessorNode() const JSC_FAST_CALL { return false; }
- virtual bool isFuncExprNode() const JSC_FAST_CALL { return false; }
+ protected:
+ ExpressionNode(JSGlobalData*, ResultType = ResultType::unknownType());
+
+ public:
+ virtual bool isNumber() const { return false; }
+ virtual bool isString() const { return false; }
+ virtual bool isNull() const { return false; }
+ virtual bool isPure(BytecodeGenerator&) const { return false; }
+ virtual bool isLocation() const { return false; }
+ virtual bool isResolveNode() const { return false; }
+ virtual bool isBracketAccessorNode() const { return false; }
+ virtual bool isDotAccessorNode() const { return false; }
+ virtual bool isFuncExprNode() const { return false; }
+ virtual bool isCommaNode() const { return false; }
+ virtual bool isSimpleArray() const { return false; }
+ virtual bool isAdd() const { return false; }
+ virtual bool isSubtract() const { return false; }
+ virtual bool hasConditionContextCodegen() const { return false; }
+
+ virtual void emitBytecodeInConditionContext(BytecodeGenerator&, Label*, Label*, bool) { ASSERT_NOT_REACHED(); }
virtual ExpressionNode* stripUnaryPlus() { return this; }
- ResultType resultDescriptor() const JSC_FAST_CALL { return m_resultDesc; }
-
- // This needs to be in public in order to compile using GCC 3.x
- typedef enum { EvalOperator, FunctionCall } CallerType;
+ ResultType resultDescriptor() const { return m_resultType; }
private:
- ResultType m_resultDesc;
+ ResultType m_resultType;
};
class StatementNode : public Node {
+ protected:
+ StatementNode(JSGlobalData*);
+
public:
- StatementNode(JSGlobalData*) JSC_FAST_CALL;
- void setLoc(int line0, int line1) JSC_FAST_CALL;
- int firstLine() const JSC_FAST_CALL { return lineNo(); }
- int lastLine() const JSC_FAST_CALL { return m_lastLine; }
+ void setLoc(int firstLine, int lastLine);
+ int firstLine() const { return lineNo(); }
+ int lastLine() const { return m_lastLine; }
- virtual bool isEmptyStatement() const JSC_FAST_CALL { return false; }
- virtual bool isReturnNode() const JSC_FAST_CALL { return false; }
- virtual bool isExprStatement() const JSC_FAST_CALL { return false; }
+ virtual bool isEmptyStatement() const { return false; }
+ virtual bool isReturnNode() const { return false; }
+ virtual bool isExprStatement() const { return false; }
- virtual bool isBlock() const JSC_FAST_CALL { return false; }
- virtual bool isLoop() const JSC_FAST_CALL { return false; }
+ virtual bool isBlock() const { return false; }
private:
int m_lastLine;
class NullNode : public ExpressionNode {
public:
- NullNode(JSGlobalData* globalData) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::nullType())
- {
- }
+ NullNode(JSGlobalData*);
- virtual bool isNull() const JSC_FAST_CALL { return true; }
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ virtual bool isNull() const { return true; }
};
class BooleanNode : public ExpressionNode {
public:
- BooleanNode(JSGlobalData* globalData, bool value) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::booleanType())
- , m_value(value)
- {
- }
+ BooleanNode(JSGlobalData*, bool value);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual bool isPure(BytecodeGenerator&) const JSC_FAST_CALL { return true; }
+ virtual bool isPure(BytecodeGenerator&) const { return true; }
- private:
bool m_value;
};
class NumberNode : public ExpressionNode {
public:
- NumberNode(JSGlobalData* globalData, double v) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::numberType())
- , m_double(v)
- {
- }
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ NumberNode(JSGlobalData*, double value);
- virtual bool isNumber() const JSC_FAST_CALL { return true; }
- virtual bool isPure(BytecodeGenerator&) const JSC_FAST_CALL { return true; }
- double value() const JSC_FAST_CALL { return m_double; }
- void setValue(double d) JSC_FAST_CALL { m_double = d; }
+ double value() const { return m_value; }
+ void setValue(double value) { m_value = value; }
private:
- double m_double;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ virtual bool isNumber() const { return true; }
+ virtual bool isPure(BytecodeGenerator&) const { return true; }
+
+ double m_value;
};
class StringNode : public ExpressionNode {
public:
- StringNode(JSGlobalData* globalData, const Identifier& v) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::stringType())
- , m_value(v)
- {
- }
+ StringNode(JSGlobalData*, const Identifier&);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isString() const JSC_FAST_CALL { return true; }
const Identifier& value() { return m_value; }
- virtual bool isPure(BytecodeGenerator&) const JSC_FAST_CALL { return true; }
private:
- Identifier m_value;
+ virtual bool isPure(BytecodeGenerator&) const { return true; }
+
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ virtual bool isString() const { return true; }
+
+ const Identifier& m_value;
};
class ThrowableExpressionData {
uint16_t endOffset() const { return m_endOffset; }
protected:
- RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* msg);
- RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* msg, const Identifier&);
+ RegisterID* emitThrowReferenceError(BytecodeGenerator&, const UString& message);
private:
uint32_t m_divot;
class ThrowableSubExpressionData : public ThrowableExpressionData {
public:
ThrowableSubExpressionData()
- : ThrowableExpressionData()
- , m_subexpressionDivotOffset(0)
+ : m_subexpressionDivotOffset(0)
, m_subexpressionEndOffset(0)
{
}
class ThrowablePrefixedSubExpressionData : public ThrowableExpressionData {
public:
ThrowablePrefixedSubExpressionData()
- : ThrowableExpressionData()
- , m_subexpressionDivotOffset(0)
+ : m_subexpressionDivotOffset(0)
, m_subexpressionStartOffset(0)
{
}
class RegExpNode : public ExpressionNode, public ThrowableExpressionData {
public:
- RegExpNode(JSGlobalData* globalData, const UString& pattern, const UString& flags) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_pattern(pattern)
- , m_flags(flags)
- {
- }
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ RegExpNode(JSGlobalData*, const Identifier& pattern, const Identifier& flags);
private:
- UString m_pattern;
- UString m_flags;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_pattern;
+ const Identifier& m_flags;
};
class ThisNode : public ExpressionNode {
public:
- ThisNode(JSGlobalData* globalData) JSC_FAST_CALL
- : ExpressionNode(globalData)
- {
- }
+ ThisNode(JSGlobalData*);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class ResolveNode : public ExpressionNode {
public:
- ResolveNode(JSGlobalData* globalData, const Identifier& ident, int startOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_ident(ident)
- , m_startOffset(startOffset)
- {
- }
+ ResolveNode(JSGlobalData*, const Identifier&, int startOffset);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isPure(BytecodeGenerator&) const JSC_FAST_CALL;
- virtual bool isLocation() const JSC_FAST_CALL { return true; }
- virtual bool isResolveNode() const JSC_FAST_CALL { return true; }
- const Identifier& identifier() const JSC_FAST_CALL { return m_ident; }
+ const Identifier& identifier() const { return m_ident; }
private:
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ virtual bool isPure(BytecodeGenerator&) const ;
+ virtual bool isLocation() const { return true; }
+ virtual bool isResolveNode() const { return true; }
+
+ const Identifier& m_ident;
int32_t m_startOffset;
};
- class ElementNode : public ParserRefCounted {
+ class ElementNode : public ParserArenaFreeable {
public:
- ElementNode(JSGlobalData* globalData, int elision, ExpressionNode* node) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_elision(elision)
- , m_node(node)
- {
- }
-
- ElementNode(JSGlobalData* globalData, ElementNode* l, int elision, ExpressionNode* node) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_elision(elision)
- , m_node(node)
- {
- l->m_next = this;
- }
-
- virtual ~ElementNode();
- virtual void releaseNodes(NodeReleaser&);
+ ElementNode(JSGlobalData*, int elision, ExpressionNode*);
+ ElementNode(JSGlobalData*, ElementNode*, int elision, ExpressionNode*);
int elision() const { return m_elision; }
- ExpressionNode* value() { return m_node.get(); }
-
- ElementNode* next() { return m_next.get(); }
+ ExpressionNode* value() { return m_node; }
+ ElementNode* next() { return m_next; }
private:
- RefPtr<ElementNode> m_next;
+ ElementNode* m_next;
int m_elision;
- RefPtr<ExpressionNode> m_node;
+ ExpressionNode* m_node;
};
class ArrayNode : public ExpressionNode {
public:
- ArrayNode(JSGlobalData* globalData, int elision) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_elision(elision)
- , m_optional(true)
- {
- }
-
- ArrayNode(JSGlobalData* globalData, ElementNode* element) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_element(element)
- , m_elision(0)
- , m_optional(false)
- {
- }
+ ArrayNode(JSGlobalData*, int elision);
+ ArrayNode(JSGlobalData*, ElementNode*);
+ ArrayNode(JSGlobalData*, int elision, ElementNode*);
- ArrayNode(JSGlobalData* globalData, int elision, ElementNode* element) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_element(element)
- , m_elision(elision)
- , m_optional(true)
- {
- }
+ ArgumentListNode* toArgumentList(JSGlobalData*) const;
- virtual ~ArrayNode();
- virtual void releaseNodes(NodeReleaser&);
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ virtual bool isSimpleArray() const ;
- private:
- RefPtr<ElementNode> m_element;
+ ElementNode* m_element;
int m_elision;
bool m_optional;
};
- class PropertyNode : public ParserRefCounted {
+ class PropertyNode : public ParserArenaFreeable {
public:
- enum Type { Constant, Getter, Setter };
-
- PropertyNode(JSGlobalData* globalData, const Identifier& name, ExpressionNode* assign, Type type) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_name(name)
- , m_assign(assign)
- , m_type(type)
- {
- }
+ enum Type { Constant = 1, Getter = 2, Setter = 4 };
- virtual ~PropertyNode();
- virtual void releaseNodes(NodeReleaser&);
+ PropertyNode(JSGlobalData*, const Identifier& name, ExpressionNode* value, Type);
+ PropertyNode(JSGlobalData*, double name, ExpressionNode* value, Type);
const Identifier& name() const { return m_name; }
+ Type type() const { return m_type; }
private:
friend class PropertyListNode;
- Identifier m_name;
- RefPtr<ExpressionNode> m_assign;
+ const Identifier& m_name;
+ ExpressionNode* m_assign;
Type m_type;
};
class PropertyListNode : public Node {
public:
- PropertyListNode(JSGlobalData* globalData, PropertyNode* node) JSC_FAST_CALL
- : Node(globalData)
- , m_node(node)
- {
- }
-
- PropertyListNode(JSGlobalData* globalData, PropertyNode* node, PropertyListNode* list) JSC_FAST_CALL
- : Node(globalData)
- , m_node(node)
- {
- list->m_next = this;
- }
+ PropertyListNode(JSGlobalData*, PropertyNode*);
+ PropertyListNode(JSGlobalData*, PropertyNode*, PropertyListNode*);
- virtual ~PropertyListNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
private:
- RefPtr<PropertyNode> m_node;
- RefPtr<PropertyListNode> m_next;
+ PropertyNode* m_node;
+ PropertyListNode* m_next;
};
class ObjectLiteralNode : public ExpressionNode {
public:
- ObjectLiteralNode(JSGlobalData* globalData) JSC_FAST_CALL
- : ExpressionNode(globalData)
- {
- }
-
- ObjectLiteralNode(JSGlobalData* globalData, PropertyListNode* list) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_list(list)
- {
- }
-
- virtual ~ObjectLiteralNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ObjectLiteralNode(JSGlobalData*);
+ ObjectLiteralNode(JSGlobalData*, PropertyListNode*);
private:
- RefPtr<PropertyListNode> m_list;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ PropertyListNode* m_list;
};
class BracketAccessorNode : public ExpressionNode, public ThrowableExpressionData {
public:
- BracketAccessorNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_base(base)
- , m_subscript(subscript)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- {
- }
+ BracketAccessorNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments);
- virtual ~BracketAccessorNode();
- virtual void releaseNodes(NodeReleaser&);
+ ExpressionNode* base() const { return m_base; }
+ ExpressionNode* subscript() const { return m_subscript; }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual bool isLocation() const JSC_FAST_CALL { return true; }
- virtual bool isBracketAccessorNode() const JSC_FAST_CALL { return true; }
- ExpressionNode* base() JSC_FAST_CALL { return m_base.get(); }
- ExpressionNode* subscript() JSC_FAST_CALL { return m_subscript.get(); }
+ virtual bool isLocation() const { return true; }
+ virtual bool isBracketAccessorNode() const { return true; }
- private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
bool m_subscriptHasAssignments;
};
class DotAccessorNode : public ExpressionNode, public ThrowableExpressionData {
public:
- DotAccessorNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_base(base)
- , m_ident(ident)
- {
- }
+ DotAccessorNode(JSGlobalData*, ExpressionNode* base, const Identifier&);
- virtual ~DotAccessorNode();
- virtual void releaseNodes(NodeReleaser&);
+ ExpressionNode* base() const { return m_base; }
+ const Identifier& identifier() const { return m_ident; }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual bool isLocation() const JSC_FAST_CALL { return true; }
- virtual bool isDotAccessorNode() const JSC_FAST_CALL { return true; }
- ExpressionNode* base() const JSC_FAST_CALL { return m_base.get(); }
- const Identifier& identifier() const JSC_FAST_CALL { return m_ident; }
+ virtual bool isLocation() const { return true; }
+ virtual bool isDotAccessorNode() const { return true; }
- private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
};
class ArgumentListNode : public Node {
public:
- ArgumentListNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : Node(globalData)
- , m_expr(expr)
- {
- }
-
- ArgumentListNode(JSGlobalData* globalData, ArgumentListNode* listNode, ExpressionNode* expr) JSC_FAST_CALL
- : Node(globalData)
- , m_expr(expr)
- {
- listNode->m_next = this;
- }
-
- virtual ~ArgumentListNode();
- virtual void releaseNodes(NodeReleaser&);
+ ArgumentListNode(JSGlobalData*, ExpressionNode*);
+ ArgumentListNode(JSGlobalData*, ArgumentListNode*, ExpressionNode*);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ArgumentListNode* m_next;
+ ExpressionNode* m_expr;
- RefPtr<ArgumentListNode> m_next;
- RefPtr<ExpressionNode> m_expr;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
- class ArgumentsNode : public ParserRefCounted {
+ class ArgumentsNode : public ParserArenaFreeable {
public:
- ArgumentsNode(JSGlobalData* globalData) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- {
- }
-
- ArgumentsNode(JSGlobalData* globalData, ArgumentListNode* listNode) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_listNode(listNode)
- {
- }
+ ArgumentsNode(JSGlobalData*);
+ ArgumentsNode(JSGlobalData*, ArgumentListNode*);
- virtual ~ArgumentsNode();
- virtual void releaseNodes(NodeReleaser&);
-
- RefPtr<ArgumentListNode> m_listNode;
+ ArgumentListNode* m_listNode;
};
class NewExprNode : public ExpressionNode, public ThrowableExpressionData {
public:
- NewExprNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_expr(expr)
- {
- }
-
- NewExprNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_expr(expr)
- , m_args(args)
- {
- }
-
- virtual ~NewExprNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ NewExprNode(JSGlobalData*, ExpressionNode*);
+ NewExprNode(JSGlobalData*, ExpressionNode*, ArgumentsNode*);
private:
- RefPtr<ExpressionNode> m_expr;
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
+ ArgumentsNode* m_args;
};
class EvalFunctionCallNode : public ExpressionNode, public ThrowableExpressionData {
public:
- EvalFunctionCallNode(JSGlobalData* globalData, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_args(args)
- {
- }
-
- virtual ~EvalFunctionCallNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ EvalFunctionCallNode(JSGlobalData*, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ArgumentsNode* m_args;
};
class FunctionCallValueNode : public ExpressionNode, public ThrowableExpressionData {
public:
- FunctionCallValueNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_expr(expr)
- , m_args(args)
- {
- }
-
- virtual ~FunctionCallValueNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ FunctionCallValueNode(JSGlobalData*, ExpressionNode*, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_expr;
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
+ ArgumentsNode* m_args;
};
class FunctionCallResolveNode : public ExpressionNode, public ThrowableExpressionData {
public:
- FunctionCallResolveNode(JSGlobalData* globalData, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_ident(ident)
- , m_args(args)
- {
- }
-
- virtual ~FunctionCallResolveNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ FunctionCallResolveNode(JSGlobalData*, const Identifier&, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- Identifier m_ident;
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
+ ArgumentsNode* m_args;
size_t m_index; // Used by LocalVarFunctionCallNode.
size_t m_scopeDepth; // Used by ScopedVarFunctionCallNode and NonLocalVarFunctionCallNode
};
class FunctionCallBracketNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- FunctionCallBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- , m_args(args)
- {
- }
-
- virtual ~FunctionCallBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ FunctionCallBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
+ ArgumentsNode* m_args;
};
class FunctionCallDotNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- FunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- , m_args(args)
- {
- }
+ FunctionCallDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
+
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ protected:
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
+ ArgumentsNode* m_args;
+ };
- virtual ~FunctionCallDotNode();
- virtual void releaseNodes(NodeReleaser&);
+ class CallFunctionCallDotNode : public FunctionCallDotNode {
+ public:
+ CallFunctionCallDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+ };
+
+ class ApplyFunctionCallDotNode : public FunctionCallDotNode {
+ public:
+ ApplyFunctionCallDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
- RefPtr<ArgumentsNode> m_args;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class PrePostResolveNode : public ExpressionNode, public ThrowableExpressionData {
public:
- PrePostResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::numberType()) // could be reusable for pre?
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_ident(ident)
- {
- }
+ PrePostResolveNode(JSGlobalData*, const Identifier&, unsigned divot, unsigned startOffset, unsigned endOffset);
protected:
- Identifier m_ident;
+ const Identifier& m_ident;
};
class PostfixResolveNode : public PrePostResolveNode {
public:
- PostfixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
- , m_operator(oper)
- {
- }
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PostfixResolveNode(JSGlobalData*, const Identifier&, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
Operator m_operator;
};
class PostfixBracketNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- PostfixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- , m_operator(oper)
- {
- }
-
- virtual ~PostfixBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PostfixBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
Operator m_operator;
};
class PostfixDotNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- PostfixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- , m_operator(oper)
- {
- }
-
- virtual ~PostfixDotNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PostfixDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
Operator m_operator;
};
class PostfixErrorNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- PostfixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_expr(expr)
- , m_operator(oper)
- {
- }
-
- virtual ~PostfixErrorNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PostfixErrorNode(JSGlobalData*, ExpressionNode*, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
Operator m_operator;
};
class DeleteResolveNode : public ExpressionNode, public ThrowableExpressionData {
public:
- DeleteResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_ident(ident)
- {
- }
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ DeleteResolveNode(JSGlobalData*, const Identifier&, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
};
class DeleteBracketNode : public ExpressionNode, public ThrowableExpressionData {
public:
- DeleteBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- {
- }
-
- virtual ~DeleteBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ DeleteBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
};
class DeleteDotNode : public ExpressionNode, public ThrowableExpressionData {
public:
- DeleteDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- {
- }
-
- virtual ~DeleteDotNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ DeleteDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
};
class DeleteValueNode : public ExpressionNode {
public:
- DeleteValueNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_expr(expr)
- {
- }
-
- virtual ~DeleteValueNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ DeleteValueNode(JSGlobalData*, ExpressionNode*);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
};
class VoidNode : public ExpressionNode {
public:
- VoidNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_expr(expr)
- {
- }
-
- virtual ~VoidNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ VoidNode(JSGlobalData*, ExpressionNode*);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
};
class TypeOfResolveNode : public ExpressionNode {
public:
- TypeOfResolveNode(JSGlobalData* globalData, const Identifier& ident) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::stringType())
- , m_ident(ident)
- {
- }
+ TypeOfResolveNode(JSGlobalData*, const Identifier&);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- const Identifier& identifier() const JSC_FAST_CALL { return m_ident; }
+ const Identifier& identifier() const { return m_ident; }
private:
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
};
class TypeOfValueNode : public ExpressionNode {
public:
- TypeOfValueNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::stringType())
- , m_expr(expr)
- {
- }
-
- virtual ~TypeOfValueNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ TypeOfValueNode(JSGlobalData*, ExpressionNode*);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
};
class PrefixResolveNode : public PrePostResolveNode {
public:
- PrefixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
- , m_operator(oper)
- {
- }
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PrefixResolveNode(JSGlobalData*, const Identifier&, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
Operator m_operator;
};
class PrefixBracketNode : public ExpressionNode, public ThrowablePrefixedSubExpressionData {
public:
- PrefixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- , m_operator(oper)
- {
- }
-
- virtual ~PrefixBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PrefixBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
Operator m_operator;
};
class PrefixDotNode : public ExpressionNode, public ThrowablePrefixedSubExpressionData {
public:
- PrefixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- , m_operator(oper)
- {
- }
-
- virtual ~PrefixDotNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PrefixDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
Operator m_operator;
};
class PrefixErrorNode : public ExpressionNode, public ThrowableExpressionData {
public:
- PrefixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_expr(expr)
- , m_operator(oper)
- {
- }
-
- virtual ~PrefixErrorNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ PrefixErrorNode(JSGlobalData*, ExpressionNode*, Operator, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
Operator m_operator;
};
class UnaryOpNode : public ExpressionNode {
public:
- UnaryOpNode(JSGlobalData* globalData, ExpressionNode* expr)
- : ExpressionNode(globalData)
- , m_expr(expr)
- {
- }
+ UnaryOpNode(JSGlobalData*, ResultType, ExpressionNode*, OpcodeID);
- UnaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr)
- : ExpressionNode(globalData, type)
- , m_expr(expr)
- {
- }
+ protected:
+ ExpressionNode* expr() { return m_expr; }
+ const ExpressionNode* expr() const { return m_expr; }
- virtual ~UnaryOpNode();
- virtual void releaseNodes(NodeReleaser&);
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual OpcodeID opcodeID() const JSC_FAST_CALL = 0;
+ OpcodeID opcodeID() const { return m_opcodeID; }
- protected:
- RefPtr<ExpressionNode> m_expr;
+ ExpressionNode* m_expr;
+ OpcodeID m_opcodeID;
};
class UnaryPlusNode : public UnaryOpNode {
public:
- UnaryPlusNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : UnaryOpNode(globalData, ResultType::numberType(), expr)
- {
- }
-
- virtual ExpressionNode* stripUnaryPlus() { return m_expr.get(); }
+ UnaryPlusNode(JSGlobalData*, ExpressionNode*);
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_to_jsnumber; }
+ private:
+ virtual ExpressionNode* stripUnaryPlus() { return expr(); }
};
class NegateNode : public UnaryOpNode {
public:
- NegateNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : UnaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_negate; }
+ NegateNode(JSGlobalData*, ExpressionNode*);
};
class BitwiseNotNode : public UnaryOpNode {
public:
- BitwiseNotNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : UnaryOpNode(globalData, ResultType::forBitOp(), expr)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_bitnot; }
+ BitwiseNotNode(JSGlobalData*, ExpressionNode*);
};
class LogicalNotNode : public UnaryOpNode {
public:
- LogicalNotNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : UnaryOpNode(globalData, ResultType::booleanType(), expr)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_not; }
+ LogicalNotNode(JSGlobalData*, ExpressionNode*);
+ private:
+ void emitBytecodeInConditionContext(BytecodeGenerator&, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue);
+ virtual bool hasConditionContextCodegen() const { return expr()->hasConditionContextCodegen(); }
};
class BinaryOpNode : public ExpressionNode {
public:
- BinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : ExpressionNode(globalData)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
+ BinaryOpNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
+ BinaryOpNode(JSGlobalData*, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
- BinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : ExpressionNode(globalData, type)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
+ RegisterID* emitStrcat(BytecodeGenerator& generator, RegisterID* destination, RegisterID* lhs = 0, ReadModifyResolveNode* emitExpressionInfoForMe = 0);
- virtual ~BinaryOpNode();
- virtual void releaseNodes(NodeReleaser&);
+ ExpressionNode* lhs() { return m_expr1; };
+ ExpressionNode* rhs() { return m_expr2; };
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual OpcodeID opcodeID() const JSC_FAST_CALL = 0;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
protected:
- RefPtr<ExpressionNode> m_expr1;
- RefPtr<ExpressionNode> m_expr2;
+ OpcodeID opcodeID() const { return m_opcodeID; }
+
+ protected:
+ ExpressionNode* m_expr1;
+ ExpressionNode* m_expr2;
+ private:
+ OpcodeID m_opcodeID;
+ protected:
bool m_rightHasAssignments;
};
class ReverseBinaryOpNode : public BinaryOpNode {
public:
- ReverseBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(globalData, expr1, expr2, rightHasAssignments)
- {
- }
-
- ReverseBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(globalData, type, expr1, expr2, rightHasAssignments)
- {
- }
+ ReverseBinaryOpNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
+ ReverseBinaryOpNode(JSGlobalData*, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class MultNode : public BinaryOpNode {
public:
- MultNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_mul; }
+ MultNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class DivNode : public BinaryOpNode {
public:
- DivNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_div; }
+ DivNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class ModNode : public BinaryOpNode {
public:
- ModNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_mod; }
+ ModNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class AddNode : public BinaryOpNode {
public:
- AddNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, rightHasAssignments)
- {
- }
+ AddNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_add; }
+ virtual bool isAdd() const { return true; }
};
class SubNode : public BinaryOpNode {
public:
- SubNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, rightHasAssignments)
- {
- }
+ SubNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_sub; }
+ virtual bool isSubtract() const { return true; }
};
class LeftShiftNode : public BinaryOpNode {
public:
- LeftShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_lshift; }
+ LeftShiftNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class RightShiftNode : public BinaryOpNode {
public:
- RightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_rshift; }
+ RightShiftNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class UnsignedRightShiftNode : public BinaryOpNode {
public:
- UnsignedRightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_urshift; }
+ UnsignedRightShiftNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class LessNode : public BinaryOpNode {
public:
- LessNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_less; }
+ LessNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class GreaterNode : public ReverseBinaryOpNode {
public:
- GreaterNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_less; }
+ GreaterNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class LessEqNode : public BinaryOpNode {
public:
- LessEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_lesseq; }
+ LessEqNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class GreaterEqNode : public ReverseBinaryOpNode {
public:
- GreaterEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_lesseq; }
+ GreaterEqNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class ThrowableBinaryOpNode : public BinaryOpNode, public ThrowableExpressionData {
public:
- ThrowableBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, type, expr1, expr2, rightHasAssignments)
- {
- }
- ThrowableBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, expr1, expr2, rightHasAssignments)
- {
- }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ThrowableBinaryOpNode(JSGlobalData*, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
+ ThrowableBinaryOpNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments);
+
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class InstanceOfNode : public ThrowableBinaryOpNode {
public:
- InstanceOfNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : ThrowableBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_instanceof; }
+ InstanceOfNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class InNode : public ThrowableBinaryOpNode {
public:
- InNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : ThrowableBinaryOpNode(globalData, expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_in; }
+ InNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class EqualNode : public BinaryOpNode {
public:
- EqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
+ EqualNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_eq; }
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class NotEqualNode : public BinaryOpNode {
public:
- NotEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_neq; }
+ NotEqualNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class StrictEqualNode : public BinaryOpNode {
public:
- StrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
+ StrictEqualNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_stricteq; }
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class NotStrictEqualNode : public BinaryOpNode {
public:
- NotStrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_nstricteq; }
+ NotStrictEqualNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class BitAndNode : public BinaryOpNode {
public:
- BitAndNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_bitand; }
+ BitAndNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class BitOrNode : public BinaryOpNode {
public:
- BitOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_bitor; }
+ BitOrNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
class BitXOrNode : public BinaryOpNode {
public:
- BitXOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) JSC_FAST_CALL
- : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, rightHasAssignments)
- {
- }
-
- virtual OpcodeID opcodeID() const JSC_FAST_CALL { return op_bitxor; }
+ BitXOrNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
};
- /**
- * m_expr1 && m_expr2, m_expr1 || m_expr2
- */
+ // m_expr1 && m_expr2, m_expr1 || m_expr2
class LogicalOpNode : public ExpressionNode {
public:
- LogicalOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper) JSC_FAST_CALL
- : ExpressionNode(globalData, ResultType::booleanType())
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_operator(oper)
- {
- }
-
- virtual ~LogicalOpNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ LogicalOpNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator);
private:
- RefPtr<ExpressionNode> m_expr1;
- RefPtr<ExpressionNode> m_expr2;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+ void emitBytecodeInConditionContext(BytecodeGenerator&, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue);
+ virtual bool hasConditionContextCodegen() const { return true; }
+
+ ExpressionNode* m_expr1;
+ ExpressionNode* m_expr2;
LogicalOperator m_operator;
};
- /**
- * The ternary operator, "m_logical ? m_expr1 : m_expr2"
- */
+ // The ternary operator, "m_logical ? m_expr1 : m_expr2"
class ConditionalNode : public ExpressionNode {
public:
- ConditionalNode(JSGlobalData* globalData, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_logical(logical)
- , m_expr1(expr1)
- , m_expr2(expr2)
- {
- }
-
- virtual ~ConditionalNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ConditionalNode(JSGlobalData*, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2);
private:
- RefPtr<ExpressionNode> m_logical;
- RefPtr<ExpressionNode> m_expr1;
- RefPtr<ExpressionNode> m_expr2;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_logical;
+ ExpressionNode* m_expr1;
+ ExpressionNode* m_expr2;
};
class ReadModifyResolveNode : public ExpressionNode, public ThrowableExpressionData {
public:
- ReadModifyResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_ident(ident)
- , m_right(right)
- , m_operator(oper)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~ReadModifyResolveNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ReadModifyResolveNode(JSGlobalData*, const Identifier&, Operator, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- Identifier m_ident;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
+ ExpressionNode* m_right;
size_t m_index; // Used by ReadModifyLocalVarNode.
- Operator m_operator : 31;
- bool m_rightHasAssignments : 1;
+ Operator m_operator;
+ bool m_rightHasAssignments;
};
class AssignResolveNode : public ExpressionNode, public ThrowableExpressionData {
public:
- AssignResolveNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_ident(ident)
- , m_right(right)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~AssignResolveNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ AssignResolveNode(JSGlobalData*, const Identifier&, ExpressionNode* right, bool rightHasAssignments);
private:
- Identifier m_ident;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
+ ExpressionNode* m_right;
size_t m_index; // Used by ReadModifyLocalVarNode.
bool m_rightHasAssignments;
};
class ReadModifyBracketNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- ReadModifyBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- , m_right(right)
- , m_operator(oper)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~ReadModifyBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ReadModifyBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, Operator, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
+ ExpressionNode* m_right;
Operator m_operator : 30;
bool m_subscriptHasAssignments : 1;
bool m_rightHasAssignments : 1;
class AssignBracketNode : public ExpressionNode, public ThrowableExpressionData {
public:
- AssignBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_subscript(subscript)
- , m_right(right)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~AssignBracketNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ AssignBracketNode(JSGlobalData*, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- RefPtr<ExpressionNode> m_subscript;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ ExpressionNode* m_subscript;
+ ExpressionNode* m_right;
bool m_subscriptHasAssignments : 1;
bool m_rightHasAssignments : 1;
};
class AssignDotNode : public ExpressionNode, public ThrowableExpressionData {
public:
- AssignDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- , m_right(right)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~AssignDotNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ AssignDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
+ ExpressionNode* m_right;
bool m_rightHasAssignments;
};
class ReadModifyDotNode : public ExpressionNode, public ThrowableSubExpressionData {
public:
- ReadModifyDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableSubExpressionData(divot, startOffset, endOffset)
- , m_base(base)
- , m_ident(ident)
- , m_right(right)
- , m_operator(oper)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
-
- virtual ~ReadModifyDotNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ReadModifyDotNode(JSGlobalData*, ExpressionNode* base, const Identifier&, Operator, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_base;
- Identifier m_ident;
- RefPtr<ExpressionNode> m_right;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_base;
+ const Identifier& m_ident;
+ ExpressionNode* m_right;
Operator m_operator : 31;
bool m_rightHasAssignments : 1;
};
class AssignErrorNode : public ExpressionNode, public ThrowableExpressionData {
public:
- AssignErrorNode(JSGlobalData* globalData, ExpressionNode* left, Operator oper, ExpressionNode* right, unsigned divot, unsigned startOffset, unsigned endOffset) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , ThrowableExpressionData(divot, startOffset, endOffset)
- , m_left(left)
- , m_operator(oper)
- , m_right(right)
- {
- }
-
- virtual ~AssignErrorNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ AssignErrorNode(JSGlobalData*, ExpressionNode* left, Operator, ExpressionNode* right, unsigned divot, unsigned startOffset, unsigned endOffset);
private:
- RefPtr<ExpressionNode> m_left;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_left;
Operator m_operator;
- RefPtr<ExpressionNode> m_right;
+ ExpressionNode* m_right;
};
+
+ typedef Vector<ExpressionNode*, 8> ExpressionVector;
- class CommaNode : public ExpressionNode {
+ class CommaNode : public ExpressionNode, public ParserArenaDeletable {
public:
- CommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_expr1(expr1)
- , m_expr2(expr2)
- {
- }
+ CommaNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2);
- virtual ~CommaNode();
- virtual void releaseNodes(NodeReleaser&);
+ using ParserArenaDeletable::operator new;
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ void append(ExpressionNode* expr) { m_expressions.append(expr); }
private:
- RefPtr<ExpressionNode> m_expr1;
- RefPtr<ExpressionNode> m_expr2;
+ virtual bool isCommaNode() const { return true; }
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionVector m_expressions;
};
- class VarDeclCommaNode : public CommaNode {
- public:
- VarDeclCommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) JSC_FAST_CALL
- : CommaNode(globalData, expr1, expr2)
- {
- }
- };
-
class ConstDeclNode : public ExpressionNode {
public:
- ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* in) JSC_FAST_CALL;
+ ConstDeclNode(JSGlobalData*, const Identifier&, ExpressionNode*);
- virtual ~ConstDeclNode();
- virtual void releaseNodes(NodeReleaser&);
+ bool hasInitializer() const { return m_init; }
+ const Identifier& ident() { return m_ident; }
- Identifier m_ident;
- RefPtr<ConstDeclNode> m_next;
- RefPtr<ExpressionNode> m_init;
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual RegisterID* emitCodeSingle(BytecodeGenerator&) JSC_FAST_CALL;
- };
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+ virtual RegisterID* emitCodeSingle(BytecodeGenerator&);
+
+ const Identifier& m_ident;
- class ConstStatementNode : public StatementNode {
public:
- ConstStatementNode(JSGlobalData* globalData, ConstDeclNode* next) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_next(next)
- {
- }
+ ConstDeclNode* m_next;
- virtual ~ConstStatementNode();
- virtual void releaseNodes(NodeReleaser&);
+ private:
+ ExpressionNode* m_init;
+ };
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ class ConstStatementNode : public StatementNode {
+ public:
+ ConstStatementNode(JSGlobalData*, ConstDeclNode* next);
private:
- RefPtr<ConstDeclNode> m_next;
- };
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- typedef Vector<RefPtr<StatementNode> > StatementVector;
+ ConstDeclNode* m_next;
+ };
- class SourceElements : public ParserRefCounted {
+ class SourceElements : public ParserArenaDeletable {
public:
- SourceElements(JSGlobalData* globalData) : ParserRefCounted(globalData) {}
+ SourceElements(JSGlobalData*);
- void append(PassRefPtr<StatementNode>);
- void releaseContentsIntoVector(StatementVector& destination)
- {
- ASSERT(destination.isEmpty());
- m_statements.swap(destination);
- destination.shrinkToFit();
- }
+ void append(StatementNode*);
+
+ StatementNode* singleStatement() const;
+ StatementNode* lastStatement() const;
+
+ void emitBytecode(BytecodeGenerator&, RegisterID* destination);
private:
- StatementVector m_statements;
+ Vector<StatementNode*> m_statements;
};
class BlockNode : public StatementNode {
public:
- BlockNode(JSGlobalData*, SourceElements* children) JSC_FAST_CALL;
+ BlockNode(JSGlobalData*, SourceElements* = 0);
- virtual ~BlockNode();
- virtual void releaseNodes(NodeReleaser&);
+ StatementNode* singleStatement() const;
+ StatementNode* lastStatement() const;
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- StatementVector& children() { return m_children; }
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual bool isBlock() const JSC_FAST_CALL { return true; }
+ virtual bool isBlock() const { return true; }
- private:
- StatementVector m_children;
+ SourceElements* m_statements;
};
class EmptyStatementNode : public StatementNode {
public:
- EmptyStatementNode(JSGlobalData* globalData) JSC_FAST_CALL // debug
- : StatementNode(globalData)
- {
- }
+ EmptyStatementNode(JSGlobalData*);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- virtual bool isEmptyStatement() const JSC_FAST_CALL { return true; }
+ virtual bool isEmptyStatement() const { return true; }
};
class DebuggerStatementNode : public StatementNode {
public:
- DebuggerStatementNode(JSGlobalData* globalData) JSC_FAST_CALL
- : StatementNode(globalData)
- {
- }
+ DebuggerStatementNode(JSGlobalData*);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class ExprStatementNode : public StatementNode {
public:
- ExprStatementNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- {
- }
+ ExprStatementNode(JSGlobalData*, ExpressionNode*);
- virtual bool isExprStatement() const JSC_FAST_CALL { return true; }
+ ExpressionNode* expr() const { return m_expr; }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ private:
+ virtual bool isExprStatement() const { return true; }
- ExpressionNode* expr() const { return m_expr.get(); }
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- private:
- RefPtr<ExpressionNode> m_expr;
+ ExpressionNode* m_expr;
};
class VarStatementNode : public StatementNode {
public:
- VarStatementNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- {
- }
-
- virtual ~VarStatementNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ VarStatementNode(JSGlobalData*, ExpressionNode*);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
};
class IfNode : public StatementNode {
public:
- IfNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_condition(condition)
- , m_ifBlock(ifBlock)
- {
- }
-
- virtual ~IfNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ IfNode(JSGlobalData*, ExpressionNode* condition, StatementNode* ifBlock);
protected:
- RefPtr<ExpressionNode> m_condition;
- RefPtr<StatementNode> m_ifBlock;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_condition;
+ StatementNode* m_ifBlock;
};
class IfElseNode : public IfNode {
public:
- IfElseNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock) JSC_FAST_CALL
- : IfNode(globalData, condition, ifBlock)
- , m_elseBlock(elseBlock)
- {
- }
-
- virtual ~IfElseNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ IfElseNode(JSGlobalData*, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock);
private:
- RefPtr<StatementNode> m_elseBlock;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ StatementNode* m_elseBlock;
};
class DoWhileNode : public StatementNode {
public:
- DoWhileNode(JSGlobalData* globalData, StatementNode* statement, ExpressionNode* expr) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_statement(statement)
- , m_expr(expr)
- {
- }
-
- virtual ~DoWhileNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isLoop() const JSC_FAST_CALL { return true; }
+ DoWhileNode(JSGlobalData*, StatementNode* statement, ExpressionNode*);
private:
- RefPtr<StatementNode> m_statement;
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ StatementNode* m_statement;
+ ExpressionNode* m_expr;
};
class WhileNode : public StatementNode {
public:
- WhileNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- , m_statement(statement)
- {
- }
-
- virtual ~WhileNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isLoop() const JSC_FAST_CALL { return true; }
+ WhileNode(JSGlobalData*, ExpressionNode*, StatementNode* statement);
private:
- RefPtr<ExpressionNode> m_expr;
- RefPtr<StatementNode> m_statement;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
+ StatementNode* m_statement;
};
class ForNode : public StatementNode {
public:
- ForNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_expr3(expr3)
- , m_statement(statement)
- , m_expr1WasVarDecl(expr1 && expr1WasVarDecl)
- {
- ASSERT(statement);
- }
-
- virtual ~ForNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isLoop() const JSC_FAST_CALL { return true; }
+ ForNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl);
private:
- RefPtr<ExpressionNode> m_expr1;
- RefPtr<ExpressionNode> m_expr2;
- RefPtr<ExpressionNode> m_expr3;
- RefPtr<StatementNode> m_statement;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr1;
+ ExpressionNode* m_expr2;
+ ExpressionNode* m_expr3;
+ StatementNode* m_statement;
bool m_expr1WasVarDecl;
};
class ForInNode : public StatementNode, public ThrowableExpressionData {
public:
- ForInNode(JSGlobalData*, ExpressionNode*, ExpressionNode*, StatementNode*) JSC_FAST_CALL;
- ForInNode(JSGlobalData*, const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*, int divot, int startOffset, int endOffset) JSC_FAST_CALL;
-
- virtual ~ForInNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- virtual bool isLoop() const JSC_FAST_CALL { return true; }
+ ForInNode(JSGlobalData*, ExpressionNode*, ExpressionNode*, StatementNode*);
+ ForInNode(JSGlobalData*, const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*, int divot, int startOffset, int endOffset);
private:
- Identifier m_ident;
- RefPtr<ExpressionNode> m_init;
- RefPtr<ExpressionNode> m_lexpr;
- RefPtr<ExpressionNode> m_expr;
- RefPtr<StatementNode> m_statement;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
+ ExpressionNode* m_init;
+ ExpressionNode* m_lexpr;
+ ExpressionNode* m_expr;
+ StatementNode* m_statement;
bool m_identIsVarDecl;
};
class ContinueNode : public StatementNode, public ThrowableExpressionData {
public:
- ContinueNode(JSGlobalData* globalData) JSC_FAST_CALL
- : StatementNode(globalData)
- {
- }
-
- ContinueNode(JSGlobalData* globalData, const Identifier& ident) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_ident(ident)
- {
- }
+ ContinueNode(JSGlobalData*);
+ ContinueNode(JSGlobalData*, const Identifier&);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
private:
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
};
class BreakNode : public StatementNode, public ThrowableExpressionData {
public:
- BreakNode(JSGlobalData* globalData) JSC_FAST_CALL
- : StatementNode(globalData)
- {
- }
-
- BreakNode(JSGlobalData* globalData, const Identifier& ident) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_ident(ident)
- {
- }
+ BreakNode(JSGlobalData*);
+ BreakNode(JSGlobalData*, const Identifier&);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
private:
- Identifier m_ident;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_ident;
};
class ReturnNode : public StatementNode, public ThrowableExpressionData {
public:
- ReturnNode(JSGlobalData* globalData, ExpressionNode* value) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_value(value)
- {
- }
-
- virtual ~ReturnNode();
- virtual void releaseNodes(NodeReleaser&);
+ ReturnNode(JSGlobalData*, ExpressionNode* value);
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- virtual bool isReturnNode() const JSC_FAST_CALL { return true; }
+ ExpressionNode* value() { return m_value; }
private:
- RefPtr<ExpressionNode> m_value;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ virtual bool isReturnNode() const { return true; }
+
+ ExpressionNode* m_value;
};
class WithNode : public StatementNode {
public:
- WithNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement, uint32_t divot, uint32_t expressionLength) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- , m_statement(statement)
- , m_divot(divot)
- , m_expressionLength(expressionLength)
- {
- }
-
- virtual ~WithNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ WithNode(JSGlobalData*, ExpressionNode*, StatementNode*, uint32_t divot, uint32_t expressionLength);
private:
- RefPtr<ExpressionNode> m_expr;
- RefPtr<StatementNode> m_statement;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
+ StatementNode* m_statement;
uint32_t m_divot;
uint32_t m_expressionLength;
};
class LabelNode : public StatementNode, public ThrowableExpressionData {
public:
- LabelNode(JSGlobalData* globalData, const Identifier& name, StatementNode* statement) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_name(name)
- , m_statement(statement)
- {
- }
-
- virtual ~LabelNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ LabelNode(JSGlobalData*, const Identifier& name, StatementNode*);
private:
- Identifier m_name;
- RefPtr<StatementNode> m_statement;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ const Identifier& m_name;
+ StatementNode* m_statement;
};
class ThrowNode : public StatementNode, public ThrowableExpressionData {
public:
- ThrowNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- {
- }
-
- virtual ~ThrowNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ThrowNode(JSGlobalData*, ExpressionNode*);
private:
- RefPtr<ExpressionNode> m_expr;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
};
class TryNode : public StatementNode {
public:
- TryNode(JSGlobalData* globalData, StatementNode* tryBlock, const Identifier& exceptionIdent, bool catchHasEval, StatementNode* catchBlock, StatementNode* finallyBlock) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_tryBlock(tryBlock)
- , m_exceptionIdent(exceptionIdent)
- , m_catchBlock(catchBlock)
- , m_finallyBlock(finallyBlock)
- , m_catchHasEval(catchHasEval)
- {
- }
-
- virtual ~TryNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* dst = 0) JSC_FAST_CALL;
+ TryNode(JSGlobalData*, StatementNode* tryBlock, const Identifier& exceptionIdent, bool catchHasEval, StatementNode* catchBlock, StatementNode* finallyBlock);
private:
- RefPtr<StatementNode> m_tryBlock;
- Identifier m_exceptionIdent;
- RefPtr<StatementNode> m_catchBlock;
- RefPtr<StatementNode> m_finallyBlock;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ StatementNode* m_tryBlock;
+ const Identifier& m_exceptionIdent;
+ StatementNode* m_catchBlock;
+ StatementNode* m_finallyBlock;
bool m_catchHasEval;
};
- class ParameterNode : public ParserRefCounted {
+ class ParameterNode : public ParserArenaFreeable {
public:
- ParameterNode(JSGlobalData* globalData, const Identifier& ident) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_ident(ident)
- {
- }
+ ParameterNode(JSGlobalData*, const Identifier&);
+ ParameterNode(JSGlobalData*, ParameterNode*, const Identifier&);
- ParameterNode(JSGlobalData* globalData, ParameterNode* l, const Identifier& ident) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_ident(ident)
- {
- l->m_next = this;
- }
-
- virtual ~ParameterNode();
- virtual void releaseNodes(NodeReleaser&);
-
- const Identifier& ident() const JSC_FAST_CALL { return m_ident; }
- ParameterNode* nextParam() const JSC_FAST_CALL { return m_next.get(); }
+ const Identifier& ident() const { return m_ident; }
+ ParameterNode* nextParam() const { return m_next; }
private:
- Identifier m_ident;
- RefPtr<ParameterNode> m_next;
+ const Identifier& m_ident;
+ ParameterNode* m_next;
};
struct ScopeNodeData {
+ WTF_MAKE_FAST_ALLOCATED;
+ public:
typedef DeclarationStacks::VarStack VarStack;
typedef DeclarationStacks::FunctionStack FunctionStack;
- ScopeNodeData(SourceElements*, VarStack*, FunctionStack*, int numConstants);
+ ScopeNodeData(ParserArena&, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, int numConstants);
+ ParserArena m_arena;
VarStack m_varStack;
FunctionStack m_functionStack;
int m_numConstants;
- StatementVector m_children;
-
- void mark();
+ SourceElements* m_statements;
+ IdentifierSet m_capturedVariables;
};
- class ScopeNode : public StatementNode {
+ class ScopeNode : public StatementNode, public ParserArenaRefCounted {
public:
typedef DeclarationStacks::VarStack VarStack;
typedef DeclarationStacks::FunctionStack FunctionStack;
- ScopeNode(JSGlobalData*) JSC_FAST_CALL;
- ScopeNode(JSGlobalData*, const SourceCode&, SourceElements*, VarStack*, FunctionStack*, CodeFeatures, int numConstants) JSC_FAST_CALL;
- virtual ~ScopeNode();
- virtual void releaseNodes(NodeReleaser&);
+ ScopeNode(JSGlobalData*, bool inStrictContext);
+ ScopeNode(JSGlobalData*, const SourceCode&, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, CodeFeatures, int numConstants);
+
+ using ParserArenaRefCounted::operator new;
- void adoptData(std::auto_ptr<ScopeNodeData> data) { m_data.adopt(data); }
ScopeNodeData* data() const { return m_data.get(); }
void destroyData() { m_data.clear(); }
const SourceCode& source() const { return m_source; }
- const UString& sourceURL() const JSC_FAST_CALL { return m_source.provider()->url(); }
+ const UString& sourceURL() const { return m_source.provider()->url(); }
intptr_t sourceID() const { return m_source.provider()->asID(); }
void setFeatures(CodeFeatures features) { m_features = features; }
CodeFeatures features() { return m_features; }
bool usesEval() const { return m_features & EvalFeature; }
- bool usesArguments() const { return m_features & ArgumentsFeature; }
+ bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); }
+ bool isStrictMode() const { return m_features & StrictModeFeature; }
void setUsesArguments() { m_features |= ArgumentsFeature; }
bool usesThis() const { return m_features & ThisFeature; }
- bool needsActivation() const { return m_features & (EvalFeature | ClosureFeature | WithFeature | CatchFeature); }
+ bool needsActivationForMoreThanVariables() const { ASSERT(m_data); return m_features & (EvalFeature | WithFeature | CatchFeature); }
+ bool needsActivation() const { ASSERT(m_data); return (hasCapturedVariables()) || (m_features & (EvalFeature | WithFeature | CatchFeature)); }
+ bool hasCapturedVariables() const { return !!m_data->m_capturedVariables.size(); }
+ size_t capturedVariableCount() const { return m_data->m_capturedVariables.size(); }
+ bool captures(const Identifier& ident) { return m_data->m_capturedVariables.contains(ident.impl()); }
VarStack& varStack() { ASSERT(m_data); return m_data->m_varStack; }
FunctionStack& functionStack() { ASSERT(m_data); return m_data->m_functionStack; }
- StatementVector& children() { ASSERT(m_data); return m_data->m_children; }
-
int neededConstants()
{
ASSERT(m_data);
return m_data->m_numConstants + 2;
}
- virtual void mark() { }
+ StatementNode* singleStatement() const;
+
+ void emitStatementsBytecode(BytecodeGenerator&, RegisterID* destination);
protected:
void setSource(const SourceCode& source) { m_source = source; }
class ProgramNode : public ScopeNode {
public:
- static ProgramNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
+ static const bool isFunctionNode = false;
+ static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- ProgramCodeBlock& bytecode(ScopeChainNode* scopeChain) JSC_FAST_CALL
- {
- if (!m_code)
- generateBytecode(scopeChain);
- return *m_code;
- }
+ static const bool scopeIsFunction = false;
private:
- ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
-
- void generateBytecode(ScopeChainNode*) JSC_FAST_CALL;
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- OwnPtr<ProgramCodeBlock> m_code;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
class EvalNode : public ScopeNode {
public:
- static EvalNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
-
- EvalCodeBlock& bytecode(ScopeChainNode* scopeChain) JSC_FAST_CALL
- {
- if (!m_code)
- generateBytecode(scopeChain);
- return *m_code;
- }
-
- EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*) JSC_FAST_CALL;
+ static const bool isFunctionNode = false;
+ static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- virtual void mark();
+ static const bool scopeIsFunction = false;
private:
- EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
+ EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- void generateBytecode(ScopeChainNode*) JSC_FAST_CALL;
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- OwnPtr<EvalCodeBlock> m_code;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
};
- class FunctionBodyNode : public ScopeNode {
- friend class JIT;
+ class FunctionParameters : public Vector<Identifier>, public RefCounted<FunctionParameters> {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- static FunctionBodyNode* create(JSGlobalData*) JSC_FAST_CALL;
- static FunctionBodyNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
- virtual ~FunctionBodyNode();
-
- const Identifier* parameters() const JSC_FAST_CALL { return m_parameters; }
- size_t parameterCount() const { return m_parameterCount; }
- UString paramString() const JSC_FAST_CALL;
- Identifier* copyParameters();
+ static PassRefPtr<FunctionParameters> create(ParameterNode* firstParameter) { return adoptRef(new FunctionParameters(firstParameter)); }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- CodeBlock& bytecode(ScopeChainNode* scopeChain) JSC_FAST_CALL
- {
- ASSERT(scopeChain);
- if (!m_code)
- generateBytecode(scopeChain);
- return *m_code;
- }
+ private:
+ FunctionParameters(ParameterNode*);
+ };
- CodeBlock& generatedBytecode() JSC_FAST_CALL
- {
- ASSERT(m_code);
- return *m_code;
- }
+ class FunctionBodyNode : public ScopeNode {
+ public:
+ static const bool isFunctionNode = true;
+ static FunctionBodyNode* create(JSGlobalData*, bool isStrictMode);
+ static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- bool isGenerated() JSC_FAST_CALL
- {
- return m_code;
- }
+ FunctionParameters* parameters() const { return m_parameters.get(); }
+ size_t parameterCount() const { return m_parameters->size(); }
- virtual void mark();
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- void finishParsing(const SourceCode&, ParameterNode*);
- void finishParsing(Identifier* parameters, size_t parameterCount);
+ void finishParsing(const SourceCode&, ParameterNode*, const Identifier&);
+ void finishParsing(PassRefPtr<FunctionParameters>, const Identifier&);
- UString toSourceString() const JSC_FAST_CALL { return source().toString(); }
-
- // These objects are ref/deref'd a lot in the scope chain, so this is a faster ref/deref.
- // If the virtual machine changes so this doesn't happen as much we can change back.
- void ref()
- {
- if (++m_refCount == 1)
- ScopeNode::ref();
- }
- void deref()
- {
- ASSERT(m_refCount);
- if (!--m_refCount)
- ScopeNode::deref();
- }
+ const Identifier& ident() { return m_ident; }
- CodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*) JSC_FAST_CALL;
+ static const bool scopeIsFunction = true;
private:
- FunctionBodyNode(JSGlobalData*) JSC_FAST_CALL;
- FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
+ FunctionBodyNode(JSGlobalData*, bool inStrictContext);
+ FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
- void generateBytecode(ScopeChainNode*) JSC_FAST_CALL;
-
- Identifier* m_parameters;
- size_t m_parameterCount;
- OwnPtr<CodeBlock> m_code;
- unsigned m_refCount;
+ Identifier m_ident;
+ RefPtr<FunctionParameters> m_parameters;
};
class FuncExprNode : public ExpressionNode {
public:
- FuncExprNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0) JSC_FAST_CALL
- : ExpressionNode(globalData)
- , m_ident(ident)
- , m_parameter(parameter)
- , m_body(body)
- {
- m_body->finishParsing(source, m_parameter.get());
- }
-
- virtual ~FuncExprNode();
- virtual void releaseNodes(NodeReleaser&);
+ FuncExprNode(JSGlobalData*, const Identifier&, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0);
- virtual bool isFuncExprNode() const JSC_FAST_CALL { return true; }
+ FunctionBodyNode* body() { return m_body; }
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
- JSFunction* makeFunction(ExecState*, ScopeChainNode*) JSC_FAST_CALL;
+ private:
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- FunctionBodyNode* body() { return m_body.get(); }
+ virtual bool isFuncExprNode() const { return true; }
- private:
- Identifier m_ident;
- RefPtr<ParameterNode> m_parameter;
- RefPtr<FunctionBodyNode> m_body;
+ FunctionBodyNode* m_body;
};
class FuncDeclNode : public StatementNode {
public:
- FuncDeclNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_ident(ident)
- , m_parameter(parameter)
- , m_body(body)
- {
- m_body->finishParsing(source, m_parameter.get());
- }
-
- virtual ~FuncDeclNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
-
- JSFunction* makeFunction(ExecState*, ScopeChainNode*) JSC_FAST_CALL;
-
- Identifier m_ident;
+ FuncDeclNode(JSGlobalData*, const Identifier&, FunctionBodyNode*, const SourceCode&, ParameterNode* = 0);
- FunctionBodyNode* body() { return m_body.get(); }
+ FunctionBodyNode* body() { return m_body; }
private:
- RefPtr<ParameterNode> m_parameter;
- RefPtr<FunctionBodyNode> m_body;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ FunctionBodyNode* m_body;
};
- class CaseClauseNode : public ParserRefCounted {
+ class CaseClauseNode : public ParserArenaFreeable {
public:
- CaseClauseNode(JSGlobalData* globalData, ExpressionNode* expr) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_expr(expr)
- {
- }
-
- CaseClauseNode(JSGlobalData* globalData, ExpressionNode* expr, SourceElements* children) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_expr(expr)
- {
- if (children)
- children->releaseContentsIntoVector(m_children);
- }
+ CaseClauseNode(JSGlobalData*, ExpressionNode*, SourceElements* = 0);
- virtual ~CaseClauseNode();
- virtual void releaseNodes(NodeReleaser&);
+ ExpressionNode* expr() const { return m_expr; }
- ExpressionNode* expr() const { return m_expr.get(); }
- StatementVector& children() { return m_children; }
+ void emitBytecode(BytecodeGenerator&, RegisterID* destination);
private:
- RefPtr<ExpressionNode> m_expr;
- StatementVector m_children;
+ ExpressionNode* m_expr;
+ SourceElements* m_statements;
};
- class ClauseListNode : public ParserRefCounted {
+ class ClauseListNode : public ParserArenaFreeable {
public:
- ClauseListNode(JSGlobalData* globalData, CaseClauseNode* clause) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_clause(clause)
- {
- }
-
- ClauseListNode(JSGlobalData* globalData, ClauseListNode* clauseList, CaseClauseNode* clause) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_clause(clause)
- {
- clauseList->m_next = this;
- }
-
- virtual ~ClauseListNode();
- virtual void releaseNodes(NodeReleaser&);
+ ClauseListNode(JSGlobalData*, CaseClauseNode*);
+ ClauseListNode(JSGlobalData*, ClauseListNode*, CaseClauseNode*);
- CaseClauseNode* getClause() const JSC_FAST_CALL { return m_clause.get(); }
- ClauseListNode* getNext() const JSC_FAST_CALL { return m_next.get(); }
+ CaseClauseNode* getClause() const { return m_clause; }
+ ClauseListNode* getNext() const { return m_next; }
private:
- RefPtr<CaseClauseNode> m_clause;
- RefPtr<ClauseListNode> m_next;
+ CaseClauseNode* m_clause;
+ ClauseListNode* m_next;
};
- class CaseBlockNode : public ParserRefCounted {
+ class CaseBlockNode : public ParserArenaFreeable {
public:
- CaseBlockNode(JSGlobalData* globalData, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) JSC_FAST_CALL
- : ParserRefCounted(globalData)
- , m_list1(list1)
- , m_defaultClause(defaultClause)
- , m_list2(list2)
- {
- }
-
- virtual ~CaseBlockNode();
- virtual void releaseNodes(NodeReleaser&);
+ CaseBlockNode(JSGlobalData*, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2);
- RegisterID* emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* dst = 0) JSC_FAST_CALL;
+ RegisterID* emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* destination);
private:
SwitchInfo::SwitchType tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
- RefPtr<ClauseListNode> m_list1;
- RefPtr<CaseClauseNode> m_defaultClause;
- RefPtr<ClauseListNode> m_list2;
+ ClauseListNode* m_list1;
+ CaseClauseNode* m_defaultClause;
+ ClauseListNode* m_list2;
};
class SwitchNode : public StatementNode {
public:
- SwitchNode(JSGlobalData* globalData, ExpressionNode* expr, CaseBlockNode* block) JSC_FAST_CALL
- : StatementNode(globalData)
- , m_expr(expr)
- , m_block(block)
- {
- }
-
- virtual ~SwitchNode();
- virtual void releaseNodes(NodeReleaser&);
-
- virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) JSC_FAST_CALL;
+ SwitchNode(JSGlobalData*, ExpressionNode*, CaseBlockNode*);
private:
- RefPtr<ExpressionNode> m_expr;
- RefPtr<CaseBlockNode> m_block;
+ virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+ ExpressionNode* m_expr;
+ CaseBlockNode* m_block;
};
struct ElementList {
} // namespace JSC
-#endif // NODES_H_
+#endif // Nodes_h