summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/parser/Nodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/parser/Nodes.h')
-rw-r--r--JavaScriptCore/parser/Nodes.h154
1 files changed, 132 insertions, 22 deletions
diff --git a/JavaScriptCore/parser/Nodes.h b/JavaScriptCore/parser/Nodes.h
index 58caa19..703b384 100644
--- a/JavaScriptCore/parser/Nodes.h
+++ b/JavaScriptCore/parser/Nodes.h
@@ -39,16 +39,12 @@
namespace JSC {
class ArgumentListNode;
- class BytecodeGenerator;
class CodeBlock;
- class EvalCodeBlock;
- class EvalExecutable;
+ class BytecodeGenerator;
class FuncDeclNode;
- class FunctionBodyNode;
- class FunctionCodeBlock;
+ class EvalCodeBlock;
class JSFunction;
class ProgramCodeBlock;
- class ProgramExecutable;
class PropertyListNode;
class ReadModifyResolveNode;
class RegisterID;
@@ -91,7 +87,7 @@ namespace JSC {
namespace DeclarationStacks {
enum VarAttrs { IsConstant = 1, HasInitializer = 2 };
typedef Vector<std::pair<Identifier, unsigned> > VarStack;
- typedef Vector<FunctionBodyNode*> FunctionStack;
+ typedef Vector<FuncDeclNode*> FunctionStack;
}
struct SwitchInfo {
@@ -361,13 +357,13 @@ namespace JSC {
class RegExpNode : public ExpressionNode, public ThrowableExpressionData {
public:
- RegExpNode(JSGlobalData*, const Identifier& pattern, const Identifier& flags);
+ RegExpNode(JSGlobalData*, const UString& pattern, const UString& flags);
private:
virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- Identifier m_pattern;
- Identifier m_flags;
+ UString m_pattern;
+ UString m_flags;
};
class ThisNode : public ExpressionNode {
@@ -433,7 +429,6 @@ namespace JSC {
enum Type { Constant, Getter, Setter };
PropertyNode(JSGlobalData*, const Identifier& name, ExpressionNode* value, Type);
- PropertyNode(JSGlobalData*, double name, ExpressionNode* value, Type);
const Identifier& name() const { return m_name; }
@@ -1394,6 +1389,8 @@ namespace JSC {
FunctionStack m_functionStack;
int m_numConstants;
StatementVector m_children;
+
+ void markAggregate(MarkStack&);
};
class ScopeNode : public StatementNode, public ParserArenaRefCounted {
@@ -1439,9 +1436,33 @@ namespace JSC {
return m_data->m_numConstants + 2;
}
+ virtual void markAggregate(MarkStack&) { }
+
+#if ENABLE(JIT)
+ JITCode& generatedJITCode()
+ {
+ ASSERT(m_jitCode);
+ return m_jitCode;
+ }
+
+ ExecutablePool* getExecutablePool()
+ {
+ return m_jitCode.getExecutablePool();
+ }
+
+ void setJITCode(const JITCode jitCode)
+ {
+ m_jitCode = jitCode;
+ }
+#endif
+
protected:
void setSource(const SourceCode& source) { m_source = source; }
+#if ENABLE(JIT)
+ JITCode m_jitCode;
+#endif
+
private:
OwnPtr<ScopeNodeData> m_data;
CodeFeatures m_features;
@@ -1452,32 +1473,78 @@ namespace JSC {
public:
static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
+ ProgramCodeBlock& bytecode(ScopeChainNode* scopeChain)
+ {
+ if (!m_code)
+ generateBytecode(scopeChain);
+ return *m_code;
+ }
+
+#if ENABLE(JIT)
+ JITCode& jitCode(ScopeChainNode* scopeChain)
+ {
+ if (!m_jitCode)
+ generateJITCode(scopeChain);
+ return m_jitCode;
+ }
+#endif
+
private:
ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
+ void generateBytecode(ScopeChainNode*);
virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+#if ENABLE(JIT)
+ void generateJITCode(ScopeChainNode*);
+#endif
+
+ OwnPtr<ProgramCodeBlock> m_code;
};
class EvalNode : public ScopeNode {
public:
static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
- void partialDestroyData()
+ EvalCodeBlock& bytecode(ScopeChainNode* scopeChain)
+ {
+ if (!m_code)
+ generateBytecode(scopeChain);
+ return *m_code;
+ }
+
+ EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);
+
+ virtual void markAggregate(MarkStack&);
+
+#if ENABLE(JIT)
+ JITCode& jitCode(ScopeChainNode* scopeChain)
{
- // Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time,
- // so the entire ScopeNodeData cannot be destoyed.
- children().clear();
+ if (!m_jitCode)
+ generateJITCode(scopeChain);
+ return m_jitCode;
}
+#endif
private:
EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
+ void generateBytecode(ScopeChainNode*);
virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
+
+#if ENABLE(JIT)
+ void generateJITCode(ScopeChainNode*);
+#endif
+
+ OwnPtr<EvalCodeBlock> m_code;
};
class FunctionBodyNode : public ScopeNode {
friend class JIT;
public:
+#if ENABLE(JIT)
+ static PassRefPtr<FunctionBodyNode> createNativeThunk(JSGlobalData*);
+#endif
static FunctionBodyNode* create(JSGlobalData*);
static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
virtual ~FunctionBodyNode();
@@ -1489,25 +1556,63 @@ namespace JSC {
virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
- void finishParsing(const SourceCode&, ParameterNode*, const Identifier& ident);
- void finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident);
+ bool isGenerated() const
+ {
+ return m_code;
+ }
+
+ bool isHostFunction() const;
+
+ virtual void markAggregate(MarkStack&);
+
+ void finishParsing(const SourceCode&, ParameterNode*);
+ void finishParsing(Identifier* parameters, size_t parameterCount);
- const Identifier& ident() { return m_ident; }
+ UString toSourceString() const { return source().toString(); }
- void reparseDataIfNecessary(ScopeChainNode* scopeChainNode);
+ CodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);
+#if ENABLE(JIT)
+ JITCode& jitCode(ScopeChainNode* scopeChain)
+ {
+ if (!m_jitCode)
+ generateJITCode(scopeChain);
+ return m_jitCode;
+ }
+#endif
+ CodeBlock& bytecode(ScopeChainNode* scopeChain)
+ {
+ ASSERT(scopeChain);
+ if (!m_code)
+ generateBytecode(scopeChain);
+ return *m_code;
+ }
+
+ CodeBlock& generatedBytecode()
+ {
+ ASSERT(m_code);
+ return *m_code;
+ }
+
private:
FunctionBodyNode(JSGlobalData*);
FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
- Identifier m_ident;
+
+ void generateBytecode(ScopeChainNode*);
+#if ENABLE(JIT)
+ void generateJITCode(ScopeChainNode*);
+#endif
Identifier* m_parameters;
size_t m_parameterCount;
+ OwnPtr<CodeBlock> m_code;
};
- class FuncExprNode : public ExpressionNode {
+ class FuncExprNode : public ExpressionNode, public ParserArenaRefCounted {
public:
FuncExprNode(JSGlobalData*, const Identifier&, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0);
+ JSFunction* makeFunction(ExecState*, ScopeChainNode*);
+
FunctionBodyNode* body() { return m_body.get(); }
private:
@@ -1515,13 +1620,18 @@ namespace JSC {
virtual bool isFuncExprNode() const { return true; }
+ Identifier m_ident;
RefPtr<FunctionBodyNode> m_body;
};
- class FuncDeclNode : public StatementNode {
+ class FuncDeclNode : public StatementNode, public ParserArenaRefCounted {
public:
FuncDeclNode(JSGlobalData*, const Identifier&, FunctionBodyNode*, const SourceCode&, ParameterNode* = 0);
+ JSFunction* makeFunction(ExecState*, ScopeChainNode*);
+
+ Identifier m_ident;
+
FunctionBodyNode* body() { return m_body.get(); }
private: