Changeset 47738 in webkit for trunk/JavaScriptCore/runtime/Executable.h
- Timestamp:
- Aug 24, 2009, 7:53:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Executable.h
r47665 r47738 33 33 34 34 class CodeBlock; 35 class Debugger; 35 36 class EvalCodeBlock; 36 37 class ProgramCodeBlock; … … 105 106 : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED) 106 107 , m_source(source) 108 , m_features(0) 107 109 { 108 110 } 109 111 110 112 const SourceCode& source() { return m_source; } 111 intptr_t sourceID() const { return m_ node->sourceID(); }112 const UString& sourceURL() const { return m_ node->sourceURL(); }113 int lineNo() const { return m_ node->lineNo(); }114 int lastLine() const { return m_ node->lastLine(); }115 116 bool usesEval() const { return m_ node->usesEval(); }117 bool usesArguments() const { return m_ node->usesArguments(); }118 bool needsActivation() const { return m_ node->needsActivation(); }113 intptr_t sourceID() const { return m_source.provider()->asID(); } 114 const UString& sourceURL() const { return m_source.provider()->url(); } 115 int lineNo() const { return m_firstLine; } 116 int lastLine() const { return m_lastLine; } 117 118 bool usesEval() const { return m_features & EvalFeature; } 119 bool usesArguments() const { return m_features & ArgumentsFeature; } 120 bool needsActivation() const { return m_features & (EvalFeature | ClosureFeature | WithFeature | CatchFeature); } 119 121 120 122 virtual ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0; 121 123 122 124 protected: 125 void recordParse(CodeFeatures features, int firstLine, int lastLine) 126 { 127 m_features = features; 128 m_firstLine = firstLine; 129 m_lastLine = lastLine; 130 } 131 123 132 SourceCode m_source; 124 RefPtr<ScopeNode> m_node; 133 CodeFeatures m_features; 134 int m_firstLine; 135 int m_lastLine; 125 136 }; 126 137 … … 135 146 ~EvalExecutable(); 136 147 137 JSObject* parse(ExecState*, bool allowDebug = true);138 139 EvalCodeBlock& bytecode(ScopeChainNode* scopeChainNode)140 {141 if (!m_evalCodeBlock)142 generateBytecode(scopeChainNode);148 EvalCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode) 149 { 150 if (!m_evalCodeBlock) { 151 JSObject* error = compile(exec, scopeChainNode); 152 ASSERT_UNUSED(!error, error); 153 } 143 154 return *m_evalCodeBlock; 144 155 } 145 156 157 JSObject* compile(ExecState*, ScopeChainNode*); 158 146 159 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 147 148 160 static PassRefPtr<EvalExecutable> create(const SourceCode& source) { return adoptRef(new EvalExecutable(source)); } 149 161 150 162 private: 151 EvalNode* evalNode() { return static_cast<EvalNode*>(m_node.get()); }152 153 void generateBytecode(ScopeChainNode*);154 155 163 EvalCodeBlock* m_evalCodeBlock; 156 164 157 165 #if ENABLE(JIT) 158 166 public: 159 JITCode& jitCode( ScopeChainNode* scopeChainNode)167 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 160 168 { 161 169 if (!m_jitCode) 162 generateJITCode( scopeChainNode);170 generateJITCode(exec, scopeChainNode); 163 171 return m_jitCode; 164 172 } 165 173 166 174 private: 167 void generateJITCode( ScopeChainNode*);175 void generateJITCode(ExecState*, ScopeChainNode*); 168 176 #endif 169 177 }; … … 179 187 ~ProgramExecutable(); 180 188 181 JSObject* parse(ExecState*, bool allowDebug = true); 182 183 // CodeBlocks for program code are transient and therefore to not gain from from throwing out there exception information. 189 ProgramCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode) 190 { 191 if (!m_programCodeBlock) { 192 JSObject* error = compile(exec, scopeChainNode); 193 ASSERT_UNUSED(!error, error); 194 } 195 return *m_programCodeBlock; 196 } 197 198 JSObject* checkSyntax(ExecState*); 199 JSObject* compile(ExecState*, ScopeChainNode*); 200 201 // CodeBlocks for program code are transient and therefore do not gain from from throwing out there exception information. 184 202 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) { ASSERT_NOT_REACHED(); return 0; } 185 203 186 ProgramCodeBlock& bytecode(ScopeChainNode* scopeChainNode) 187 { 188 if (!m_programCodeBlock) 189 generateBytecode(scopeChainNode); 190 return *m_programCodeBlock; 191 } 192 193 private: 194 ProgramNode* programNode() { return static_cast<ProgramNode*>(m_node.get()); } 195 196 void generateBytecode(ScopeChainNode*); 197 204 private: 198 205 ProgramCodeBlock* m_programCodeBlock; 199 206 200 207 #if ENABLE(JIT) 201 208 public: 202 JITCode& jitCode( ScopeChainNode* scopeChainNode)209 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 203 210 { 204 211 if (!m_jitCode) 205 generateJITCode( scopeChainNode);212 generateJITCode(exec, scopeChainNode); 206 213 return m_jitCode; 207 214 } 208 215 209 216 private: 210 void generateJITCode( ScopeChainNode*);217 void generateJITCode(ExecState*, ScopeChainNode*); 211 218 #endif 212 219 }; … … 215 222 friend class JIT; 216 223 public: 217 FunctionExecutable(const Identifier& name, FunctionBodyNode* body) 218 : ScriptExecutable(body->source()) 224 FunctionExecutable(const Identifier& name, const SourceCode& source, bool forceUsesArguments, Identifier* parameters, int parameterCount, int firstLine, int lastLine) 225 : ScriptExecutable(source) 226 , m_forceUsesArguments(forceUsesArguments) 227 , m_parameters(parameters) 228 , m_parameterCount(parameterCount) 219 229 , m_codeBlock(0) 220 230 , m_name(name) 221 231 , m_numVariables(0) 222 232 { 223 m_node = body; 233 m_firstLine = firstLine; 234 m_lastLine = lastLine; 224 235 } 225 236 226 237 ~FunctionExecutable(); 227 238 228 const Identifier& name() { return m_name; } 229 230 JSFunction* make(ExecState*, ScopeChainNode* scopeChain); 231 232 CodeBlock& bytecode(ScopeChainNode* scopeChainNode) 239 JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain) 240 { 241 return new (exec) JSFunction(exec, this, scopeChain); 242 } 243 244 CodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode) 233 245 { 234 246 ASSERT(scopeChainNode); 235 247 if (!m_codeBlock) 236 generateBytecode(scopeChainNode);248 compile(exec, scopeChainNode); 237 249 return *m_codeBlock; 238 250 } 251 252 bool isGenerated() const 253 { 254 return m_codeBlock; 255 } 256 239 257 CodeBlock& generatedBytecode() 240 258 { … … 243 261 } 244 262 245 bool usesEval() const { return body()->usesEval(); } 246 bool usesArguments() const { return body()->usesArguments(); } 247 size_t parameterCount() const { return body()->parameterCount(); } 263 const Identifier& name() { return m_name; } 264 size_t parameterCount() const { return m_parameterCount; } 248 265 size_t variableCount() const { return m_numVariables; } 249 UString paramString() const { return body()->paramString(); } 250 251 bool isGenerated() const 252 { 253 return m_codeBlock; 254 } 266 UString paramString() const; 255 267 256 268 void recompile(ExecState*); 257 258 269 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 259 260 270 void markAggregate(MarkStack& markStack); 261 262 private: 263 FunctionBodyNode* body() const { return static_cast<FunctionBodyNode*>(m_node.get()); } 264 265 void generateBytecode(ScopeChainNode*); 266 271 static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0); 272 273 private: 274 void compile(ExecState*, ScopeChainNode*); 275 Identifier* copyParameters(); 276 277 bool m_forceUsesArguments; 278 Identifier* m_parameters; 279 int m_parameterCount; 267 280 CodeBlock* m_codeBlock; 268 const Identifier&m_name;281 Identifier m_name; 269 282 size_t m_numVariables; 270 283 271 284 #if ENABLE(JIT) 272 285 public: 273 JITCode& jitCode( ScopeChainNode* scopeChainNode)286 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 274 287 { 275 288 if (!m_jitCode) 276 generateJITCode( scopeChainNode);289 generateJITCode(exec, scopeChainNode); 277 290 return m_jitCode; 278 291 } 279 292 280 293 private: 281 void generateJITCode( ScopeChainNode*);294 void generateJITCode(ExecState*, ScopeChainNode*); 282 295 #endif 283 296 }; … … 289 302 } 290 303 291 inline JSFunction* FunctionExecutable::make(ExecState* exec, ScopeChainNode* scopeChain)292 {293 return new (exec) JSFunction(exec, this, scopeChain);294 }295 296 304 inline bool JSFunction::isHostFunction() const 297 305 {
Note:
See TracChangeset
for help on using the changeset viewer.