summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/Executable.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/runtime/Executable.h')
-rw-r--r--JavaScriptCore/runtime/Executable.h123
1 files changed, 85 insertions, 38 deletions
diff --git a/JavaScriptCore/runtime/Executable.h b/JavaScriptCore/runtime/Executable.h
index ac691e4..3e1609e 100644
--- a/JavaScriptCore/runtime/Executable.h
+++ b/JavaScriptCore/runtime/Executable.h
@@ -36,6 +36,7 @@ namespace JSC {
class CodeBlock;
class Debugger;
class EvalCodeBlock;
+ class FunctionCodeBlock;
class ProgramCodeBlock;
class ScopeChainNode;
@@ -50,32 +51,40 @@ namespace JSC {
public:
ExecutableBase(int numParameters)
- : m_numParameters(numParameters)
+ : m_numParametersForCall(numParameters)
+ , m_numParametersForConstruct(numParameters)
{
}
virtual ~ExecutableBase() {}
- bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; }
+ bool isHostFunction() const
+ {
+ ASSERT((m_numParametersForCall == NUM_PARAMETERS_IS_HOST) == (m_numParametersForConstruct == NUM_PARAMETERS_IS_HOST));
+ return m_numParametersForCall == NUM_PARAMETERS_IS_HOST;
+ }
protected:
- int m_numParameters;
+ int m_numParametersForCall;
+ int m_numParametersForConstruct;
#if ENABLE(JIT)
public:
- JITCode& generatedJITCode()
+ JITCode& generatedJITCodeForCall()
{
- ASSERT(m_jitCode);
- return m_jitCode;
+ ASSERT(m_jitCodeForCall);
+ return m_jitCodeForCall;
}
- ExecutablePool* getExecutablePool()
+ JITCode& generatedJITCodeForConstruct()
{
- return m_jitCode.getExecutablePool();
+ ASSERT(m_jitCodeForConstruct);
+ return m_jitCodeForConstruct;
}
protected:
- JITCode m_jitCode;
+ JITCode m_jitCodeForCall;
+ JITCode m_jitCodeForConstruct;
#endif
};
@@ -85,12 +94,14 @@ namespace JSC {
NativeExecutable(ExecState* exec)
: ExecutableBase(NUM_PARAMETERS_IS_HOST)
{
- m_jitCode = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCode;
+ m_jitCodeForCall = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall;
+ m_jitCodeForConstruct = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall; // FIXME: this thunk should have a construct form
}
NativeExecutable(JITCode thunk)
: ExecutableBase(NUM_PARAMETERS_IS_HOST)
{
- m_jitCode = thunk;
+ m_jitCodeForCall = thunk;
+ m_jitCodeForConstruct = thunk;
}
~NativeExecutable();
@@ -192,9 +203,9 @@ namespace JSC {
public:
JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
{
- if (!m_jitCode)
+ if (!m_jitCodeForCall)
generateJITCode(exec, scopeChainNode);
- return m_jitCode;
+ return m_jitCodeForCall;
}
private:
@@ -238,9 +249,9 @@ namespace JSC {
public:
JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
{
- if (!m_jitCode)
+ if (!m_jitCodeForCall)
generateJITCode(exec, scopeChainNode);
- return m_jitCode;
+ return m_jitCodeForCall;
}
private:
@@ -268,29 +279,49 @@ namespace JSC {
return new (exec) JSFunction(exec, this, scopeChain);
}
- CodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
+ FunctionCodeBlock& bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
+ {
+ ASSERT(scopeChainNode);
+ if (!m_codeBlockForCall)
+ compileForCall(exec, scopeChainNode);
+ return *m_codeBlockForCall;
+ }
+
+ bool isGeneratedForCall() const
+ {
+ return m_codeBlockForCall;
+ }
+
+ FunctionCodeBlock& generatedBytecodeForCall()
+ {
+ ASSERT(m_codeBlockForCall);
+ return *m_codeBlockForCall;
+ }
+
+ FunctionCodeBlock& bytecodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
{
ASSERT(scopeChainNode);
- if (!m_codeBlock)
- compile(exec, scopeChainNode);
- return *m_codeBlock;
+ if (!m_codeBlockForConstruct)
+ compileForConstruct(exec, scopeChainNode);
+ return *m_codeBlockForConstruct;
}
- bool isGenerated() const
+ bool isGeneratedForConstruct() const
{
- return m_codeBlock;
+ return m_codeBlockForConstruct;
}
- CodeBlock& generatedBytecode()
+ FunctionCodeBlock& generatedBytecodeForConstruct()
{
- ASSERT(m_codeBlock);
- return *m_codeBlock;
+ ASSERT(m_codeBlockForConstruct);
+ return *m_codeBlockForConstruct;
}
const Identifier& name() { return m_name; }
size_t parameterCount() const { return m_parameters->size(); }
- size_t variableCount() const { return m_numVariables; }
+ unsigned variableCount() const { return m_numVariables; }
UString paramString() const;
+ SharedSymbolTable* symbolTable() const { return m_symbolTable; }
void recompile(ExecState*);
ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
@@ -300,11 +331,13 @@ namespace JSC {
private:
FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
: ScriptExecutable(globalData, source)
+ , m_numVariables(0)
, m_forceUsesArguments(forceUsesArguments)
, m_parameters(parameters)
- , m_codeBlock(0)
+ , m_codeBlockForCall(0)
+ , m_codeBlockForConstruct(0)
, m_name(name)
- , m_numVariables(0)
+ , m_symbolTable(0)
{
m_firstLine = firstLine;
m_lastLine = lastLine;
@@ -312,35 +345,49 @@ namespace JSC {
FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
: ScriptExecutable(exec, source)
+ , m_numVariables(0)
, m_forceUsesArguments(forceUsesArguments)
, m_parameters(parameters)
- , m_codeBlock(0)
+ , m_codeBlockForCall(0)
+ , m_codeBlockForConstruct(0)
, m_name(name)
- , m_numVariables(0)
+ , m_symbolTable(0)
{
m_firstLine = firstLine;
m_lastLine = lastLine;
}
- void compile(ExecState*, ScopeChainNode*);
+ void compileForCall(ExecState*, ScopeChainNode*);
+ void compileForConstruct(ExecState*, ScopeChainNode*);
+
+ unsigned m_numVariables : 31;
+ bool m_forceUsesArguments : 1;
- bool m_forceUsesArguments;
RefPtr<FunctionParameters> m_parameters;
- CodeBlock* m_codeBlock;
+ FunctionCodeBlock* m_codeBlockForCall;
+ FunctionCodeBlock* m_codeBlockForConstruct;
Identifier m_name;
- size_t m_numVariables;
+ SharedSymbolTable* m_symbolTable;
#if ENABLE(JIT)
public:
- JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
+ JITCode& jitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
{
- if (!m_jitCode)
- generateJITCode(exec, scopeChainNode);
- return m_jitCode;
+ if (!m_jitCodeForCall)
+ generateJITCodeForCall(exec, scopeChainNode);
+ return m_jitCodeForCall;
+ }
+
+ JITCode& jitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
+ {
+ if (!m_jitCodeForConstruct)
+ generateJITCodeForConstruct(exec, scopeChainNode);
+ return m_jitCodeForConstruct;
}
private:
- void generateJITCode(ExecState*, ScopeChainNode*);
+ void generateJITCodeForCall(ExecState*, ScopeChainNode*);
+ void generateJITCodeForConstruct(ExecState*, ScopeChainNode*);
#endif
};