Changeset 47641 in webkit for trunk/JavaScriptCore/runtime/Executable.h
- Timestamp:
- Aug 21, 2009, 2:54:20 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Executable.h
r47620 r47641 28 28 29 29 #include "Nodes.h" 30 #include "JSFunction.h" 30 31 31 32 namespace JSC { … … 38 39 struct ExceptionInfo; 39 40 40 class ExecutableBase {41 class ExecutableBase : public RefCounted<ExecutableBase> { 41 42 friend class JIT; 42 public: 43 enum Mode { 44 NoJITCode, 45 HasJITCode, 46 IsHost 47 }; 43 44 protected: 48 45 static const int NUM_PARAMETERS_IS_HOST = 0; 49 46 static const int NUM_PARAMETERS_NOT_COMPILED = -1; 50 47 48 public: 49 ExecutableBase(int numParameters) 50 : m_numParameters(numParameters) 51 { 52 } 53 51 54 virtual ~ExecutableBase() {} 52 55 53 ExecutableBase(const SourceCode& source) 54 : m_source(source) 55 , m_numParameters(NUM_PARAMETERS_NOT_COMPILED) 56 bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; } 57 58 protected: 59 int m_numParameters; 60 61 #if ENABLE(JIT) 62 public: 63 JITCode& generatedJITCode() 64 { 65 ASSERT(m_jitCode); 66 return m_jitCode; 67 } 68 69 ExecutablePool* getExecutablePool() 70 { 71 return m_jitCode.getExecutablePool(); 72 } 73 74 protected: 75 JITCode m_jitCode; 76 #endif 77 }; 78 79 class NativeExecutable : public ExecutableBase { 80 public: 81 NativeExecutable(ExecState* exec) 82 : ExecutableBase(NUM_PARAMETERS_IS_HOST) 83 { 84 m_jitCode = JITCode(JITCode::HostFunction(exec->globalData().jitStubs.ctiNativeCallThunk())); 85 } 86 87 ~NativeExecutable(); 88 }; 89 90 class VPtrHackExecutable : public ExecutableBase { 91 public: 92 VPtrHackExecutable() 93 : ExecutableBase(NUM_PARAMETERS_IS_HOST) 94 { 95 } 96 97 ~VPtrHackExecutable(); 98 }; 99 100 class ScriptExecutable : public ExecutableBase { 101 public: 102 ScriptExecutable(const SourceCode& source) 103 : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED) 104 , m_source(source) 56 105 { 57 106 } … … 70 119 71 120 protected: 121 SourceCode m_source; 72 122 RefPtr<ScopeNode> m_node; 73 SourceCode m_source; 74 int m_numParameters; 75 76 private: 77 // For use making native thunk. 78 friend class FunctionExecutable; 79 ExecutableBase() 80 { 81 } 82 83 #if ENABLE(JIT) 84 public: 85 JITCode& generatedJITCode() 86 { 87 ASSERT(m_jitCode); 88 return m_jitCode; 89 } 90 91 ExecutablePool* getExecutablePool() 92 { 93 return m_jitCode.getExecutablePool(); 94 } 95 96 protected: 97 JITCode m_jitCode; 98 #endif 99 }; 100 101 class EvalExecutable : public ExecutableBase { 123 }; 124 125 class EvalExecutable : public ScriptExecutable { 102 126 public: 103 127 EvalExecutable(const SourceCode& source) 104 : ExecutableBase(source)128 : ScriptExecutable(source) 105 129 , m_evalCodeBlock(0) 106 130 { … … 120 144 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 121 145 146 static PassRefPtr<EvalExecutable> create(const SourceCode& source) { return adoptRef(new EvalExecutable(source)); } 147 122 148 private: 123 149 EvalNode* evalNode() { return static_cast<EvalNode*>(m_node.get()); } … … 141 167 }; 142 168 143 class CacheableEvalExecutable : public EvalExecutable, public RefCounted<CacheableEvalExecutable> { 144 public: 145 static PassRefPtr<CacheableEvalExecutable> create(const SourceCode& source) { return adoptRef(new CacheableEvalExecutable(source)); } 146 147 private: 148 CacheableEvalExecutable(const SourceCode& source) 149 : EvalExecutable(source) 150 { 151 } 152 }; 153 154 class ProgramExecutable : public ExecutableBase { 169 class ProgramExecutable : public ScriptExecutable { 155 170 public: 156 171 ProgramExecutable(const SourceCode& source) 157 : ExecutableBase(source)172 : ScriptExecutable(source) 158 173 , m_programCodeBlock(0) 159 174 { … … 195 210 }; 196 211 197 class FunctionExecutable : public ExecutableBase, public RefCounted<FunctionExecutable>{212 class FunctionExecutable : public ScriptExecutable { 198 213 friend class JIT; 199 214 public: 200 215 FunctionExecutable(const Identifier& name, FunctionBodyNode* body) 201 : ExecutableBase(body->source())216 : ScriptExecutable(body->source()) 202 217 , m_codeBlock(0) 203 218 , m_name(name) … … 232 247 UString paramString() const { return body()->paramString(); } 233 248 234 bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; }235 249 bool isGenerated() const 236 250 { … … 262 276 } 263 277 264 static PassRefPtr<FunctionExecutable> createNativeThunk(ExecState* exec) 265 { 266 return adoptRef(new FunctionExecutable(exec)); 267 } 268 269 private: 270 FunctionExecutable(ExecState* exec); 278 private: 271 279 void generateJITCode(ScopeChainNode*); 272 280 #endif 273 281 }; 274 282 275 }; 276 277 #endif 283 inline FunctionExecutable* JSFunction::jsExecutable() const { ASSERT(!isHostFunctionNonInline()); return static_cast<FunctionExecutable*>(m_executable.get()); } 284 285 inline JSFunction* FunctionExecutable::make(ExecState* exec, ScopeChainNode* scopeChain) 286 { 287 return new (exec) JSFunction(exec, this, scopeChain); 288 } 289 290 inline bool JSFunction::isHostFunction() const 291 { 292 ASSERT(m_executable); 293 return m_executable->isHostFunction(); 294 } 295 296 } 297 298 #endif
Note:
See TracChangeset
for help on using the changeset viewer.