Changeset 48662 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 22, 2009, 5:40:58 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r48650 r48662 1 2009-09-22 Oliver Hunt <[email protected]> 2 3 Reviewed by Geoff Garen. 4 5 Code sampling builds are broken. 6 https://bugs.webkit.org/show_bug.cgi?id=29662 7 8 Fix build. 9 10 * bytecode/EvalCodeCache.h: 11 (JSC::EvalCodeCache::get): 12 * bytecode/SamplingTool.cpp: 13 (JSC::ScriptSampleRecord::sample): 14 (JSC::SamplingTool::doRun): 15 (JSC::SamplingTool::notifyOfScope): 16 (JSC::compareScriptSampleRecords): 17 (JSC::SamplingTool::dump): 18 * bytecode/SamplingTool.h: 19 (JSC::ScriptSampleRecord::ScriptSampleRecord): 20 (JSC::ScriptSampleRecord::~ScriptSampleRecord): 21 (JSC::SamplingTool::SamplingTool): 22 * bytecompiler/BytecodeGenerator.cpp: 23 (JSC::BytecodeGenerator::BytecodeGenerator): 24 (JSC::BytecodeGenerator::emitNewFunction): 25 (JSC::BytecodeGenerator::emitNewFunctionExpression): 26 * bytecompiler/BytecodeGenerator.h: 27 (JSC::BytecodeGenerator::makeFunction): 28 * debugger/Debugger.cpp: 29 (JSC::evaluateInGlobalCallFrame): 30 * debugger/DebuggerCallFrame.cpp: 31 (JSC::DebuggerCallFrame::evaluate): 32 * parser/Nodes.cpp: 33 (JSC::ScopeNode::ScopeNode): 34 * runtime/Completion.cpp: 35 (JSC::checkSyntax): 36 (JSC::evaluate): 37 * runtime/Executable.cpp: 38 (JSC::FunctionExecutable::fromGlobalCode): 39 * runtime/Executable.h: 40 (JSC::ScriptExecutable::ScriptExecutable): 41 (JSC::EvalExecutable::EvalExecutable): 42 (JSC::EvalExecutable::create): 43 (JSC::ProgramExecutable::ProgramExecutable): 44 (JSC::FunctionExecutable::create): 45 (JSC::FunctionExecutable::FunctionExecutable): 46 * runtime/JSGlobalObjectFunctions.cpp: 47 (JSC::globalFuncEval): 48 1 49 2009-09-22 Darin Adler <[email protected]> 2 50 -
trunk/JavaScriptCore/bytecode/EvalCodeCache.h
r47738 r48662 51 51 52 52 if (!evalExecutable) { 53 evalExecutable = EvalExecutable::create( makeSource(evalSource));53 evalExecutable = EvalExecutable::create(exec, makeSource(evalSource)); 54 54 exceptionValue = evalExecutable->compile(exec, scopeChain); 55 55 if (exceptionValue) -
trunk/JavaScriptCore/bytecode/SamplingTool.cpp
r47412 r48662 158 158 159 159 160 void Sc opeSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC)160 void ScriptSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC) 161 161 { 162 162 if (!m_samples) { … … 197 197 #if ENABLE(CODEBLOCK_SAMPLING) 198 198 if (CodeBlock* codeBlock = sample.codeBlock()) { 199 MutexLocker locker(m_sc opeSampleMapMutex);200 Sc opeSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable());199 MutexLocker locker(m_scriptSampleMapMutex); 200 ScriptSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable()); 201 201 ASSERT(record); 202 202 record->sample(codeBlock, sample.vPC()); … … 210 210 } 211 211 212 void SamplingTool::notifyOfScope(Sc opeNode* scope)212 void SamplingTool::notifyOfScope(ScriptExecutable* script) 213 213 { 214 214 #if ENABLE(CODEBLOCK_SAMPLING) 215 MutexLocker locker(m_sc opeSampleMapMutex);216 m_scopeSampleMap->set(sc ope, new ScopeSampleRecord(scope));215 MutexLocker locker(m_scriptSampleMapMutex); 216 m_scopeSampleMap->set(script, new ScriptSampleRecord(script)); 217 217 #else 218 UNUSED_PARAM(sc ope);218 UNUSED_PARAM(script); 219 219 #endif 220 220 } … … 255 255 } 256 256 257 static int compareSc opeSampleRecords(const void* left, const void* right)258 { 259 const Sc opeSampleRecord* const leftValue = *static_cast<const ScopeSampleRecord* const *>(left);260 const Sc opeSampleRecord* const rightValue = *static_cast<const ScopeSampleRecord* const *>(right);257 static int compareScriptSampleRecords(const void* left, const void* right) 258 { 259 const ScriptSampleRecord* const leftValue = *static_cast<const ScriptSampleRecord* const *>(left); 260 const ScriptSampleRecord* const rightValue = *static_cast<const ScriptSampleRecord* const *>(right); 261 261 262 262 return (leftValue->m_sampleCount < rightValue->m_sampleCount) ? 1 : (leftValue->m_sampleCount > rightValue->m_sampleCount) ? -1 : 0; … … 319 319 320 320 int scopeCount = m_scopeSampleMap->size(); 321 Vector<Sc opeSampleRecord*> codeBlockSamples(scopeCount);322 Sc opeSampleRecordMap::iterator iter = m_scopeSampleMap->begin();321 Vector<ScriptSampleRecord*> codeBlockSamples(scopeCount); 322 ScriptSampleRecordMap::iterator iter = m_scopeSampleMap->begin(); 323 323 for (int i = 0; i < scopeCount; ++i, ++iter) 324 324 codeBlockSamples[i] = iter->second; 325 325 326 qsort(codeBlockSamples.begin(), scopeCount, sizeof(Sc opeSampleRecord*), compareScopeSampleRecords);326 qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScriptSampleRecord*), compareScriptSampleRecords); 327 327 328 328 // (4) Print data from 'codeBlockSamples' array. … … 331 331 332 332 for (int i = 0; i < scopeCount; ++i) { 333 Sc opeSampleRecord* record = codeBlockSamples[i];333 ScriptSampleRecord* record = codeBlockSamples[i]; 334 334 CodeBlock* codeBlock = record->m_codeBlock; 335 335 … … 338 338 if (blockPercent >= 1) { 339 339 //Instruction* code = codeBlock->instructions().begin(); 340 printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_ scope->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);340 printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent); 341 341 if (i < 10) { 342 342 HashMap<unsigned,unsigned> lineCounts; -
trunk/JavaScriptCore/bytecode/SamplingTool.h
r46528 r48662 39 39 namespace JSC { 40 40 41 class ScriptExecutable; 42 41 43 class SamplingFlags { 42 44 friend class JIT; … … 93 95 struct Instruction; 94 96 95 struct Sc opeSampleRecord {96 Sc opeSampleRecord(ScopeNode* scope)97 : m_ scope(scope)97 struct ScriptSampleRecord { 98 ScriptSampleRecord(ScriptExecutable* executable) 99 : m_executable(executable) 98 100 , m_codeBlock(0) 99 101 , m_sampleCount(0) … … 104 106 } 105 107 106 ~Sc opeSampleRecord()108 ~ScriptSampleRecord() 107 109 { 108 110 if (m_samples) … … 112 114 void sample(CodeBlock*, Instruction*); 113 115 114 RefPtr<ScopeNode> m_scope;116 ScriptExecutable* m_executable; 115 117 CodeBlock* m_codeBlock; 116 118 int m_sampleCount; … … 120 122 }; 121 123 122 typedef WTF::HashMap<Sc opeNode*, ScopeSampleRecord*> ScopeSampleRecordMap;124 typedef WTF::HashMap<ScriptExecutable*, ScriptSampleRecord*> ScriptSampleRecordMap; 123 125 124 126 class SamplingThread { … … 194 196 , m_opcodeSampleCount(0) 195 197 #if ENABLE(CODEBLOCK_SAMPLING) 196 , m_scopeSampleMap(new Sc opeSampleRecordMap())198 , m_scopeSampleMap(new ScriptSampleRecordMap()) 197 199 #endif 198 200 { … … 211 213 void dump(ExecState*); 212 214 213 void notifyOfScope(Sc opeNode* scope);215 void notifyOfScope(ScriptExecutable* scope); 214 216 215 217 void sample(CodeBlock* codeBlock, Instruction* vPC) … … 267 269 268 270 #if ENABLE(CODEBLOCK_SAMPLING) 269 Mutex m_sc opeSampleMapMutex;270 OwnPtr<Sc opeSampleRecordMap> m_scopeSampleMap;271 Mutex m_scriptSampleMapMutex; 272 OwnPtr<ScriptSampleRecordMap> m_scopeSampleMap; 271 273 #endif 272 274 }; -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r47775 r48662 274 274 for (size_t i = 0; i < functionStack.size(); ++i) { 275 275 FunctionBodyNode* function = functionStack[i]; 276 globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction( function), scopeChain.node()), DontDelete);276 globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain.node()), DontDelete); 277 277 } 278 278 for (size_t i = 0; i < varStack.size(); ++i) { … … 400 400 const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack(); 401 401 for (size_t i = 0; i < functionStack.size(); ++i) 402 m_codeBlock->addFunctionDecl(makeFunction( functionStack[i]));402 m_codeBlock->addFunctionDecl(makeFunction(m_globalData, functionStack[i])); 403 403 404 404 const DeclarationStacks::VarStack& varStack = evalNode->varStack(); … … 1317 1317 RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function) 1318 1318 { 1319 unsigned index = m_codeBlock->addFunctionDecl(makeFunction( function));1319 unsigned index = m_codeBlock->addFunctionDecl(makeFunction(m_globalData, function)); 1320 1320 1321 1321 emitOpcode(op_new_func); … … 1337 1337 { 1338 1338 FunctionBodyNode* function = n->body(); 1339 unsigned index = m_codeBlock->addFunctionExpr(makeFunction( function));1339 unsigned index = m_codeBlock->addFunctionExpr(makeFunction(m_globalData, function)); 1340 1340 1341 1341 emitOpcode(op_new_func_exp); -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r47775 r48662 418 418 unsigned addRegExp(RegExp*); 419 419 420 PassRefPtr<FunctionExecutable> makeFunction(FunctionBodyNode* body) 421 { 422 return FunctionExecutable::create(body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine()); 420 PassRefPtr<FunctionExecutable> makeFunction(ExecState* exec, FunctionBodyNode* body) 421 { 422 return FunctionExecutable::create(exec, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine()); 423 } 424 425 PassRefPtr<FunctionExecutable> makeFunction(JSGlobalData* globalData, FunctionBodyNode* body) 426 { 427 return FunctionExecutable::create(globalData, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine()); 423 428 } 424 429 -
trunk/JavaScriptCore/debugger/Debugger.cpp
r47738 r48662 101 101 CallFrame* globalCallFrame = globalObject->globalExec(); 102 102 103 EvalExecutable eval( makeSource(script));103 EvalExecutable eval(globalCallFrame, makeSource(script)); 104 104 JSObject* error = eval.compile(globalCallFrame, globalCallFrame->scopeChain()); 105 105 if (error) -
trunk/JavaScriptCore/debugger/DebuggerCallFrame.cpp
r47738 r48662 80 80 return JSValue(); 81 81 82 EvalExecutable eval(m akeSource(script));82 EvalExecutable eval(m_callFrame, makeSource(script)); 83 83 JSObject* error = eval.compile(m_callFrame, m_callFrame->scopeChain()); 84 84 if (error) -
trunk/JavaScriptCore/parser/Nodes.cpp
r47775 r48662 1887 1887 , m_features(NoFeatures) 1888 1888 { 1889 #if ENABLE(CODEBLOCK_SAMPLING)1890 if (SamplingTool* sampler = globalData->interpreter->sampler())1891 sampler->notifyOfScope(this);1892 #endif1893 1889 } 1894 1890 … … 1900 1896 , m_source(source) 1901 1897 { 1902 #if ENABLE(CODEBLOCK_SAMPLING)1903 if (SamplingTool* sampler = globalData->interpreter->sampler())1904 sampler->notifyOfScope(this);1905 #endif1906 1898 } 1907 1899 -
trunk/JavaScriptCore/runtime/Completion.cpp
r48048 r48662 38 38 JSLock lock(exec); 39 39 40 ProgramExecutable program( source);40 ProgramExecutable program(exec, source); 41 41 JSObject* error = program.checkSyntax(exec); 42 42 if (error) … … 50 50 JSLock lock(exec); 51 51 52 ProgramExecutable program( source);52 ProgramExecutable program(exec, source); 53 53 JSObject* error = program.compile(exec, scopeChain.node()); 54 54 if (error) -
trunk/JavaScriptCore/runtime/Executable.cpp
r47775 r48662 260 260 FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body(); 261 261 ASSERT(body); 262 return FunctionExecutable::create( functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());262 return FunctionExecutable::create(&exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine()); 263 263 } 264 264 -
trunk/JavaScriptCore/runtime/Executable.h
r47775 r48662 28 28 29 29 #include "JSFunction.h" 30 #include "Interpreter.h" 30 31 #include "Nodes.h" 32 #include "SamplingTool.h" 31 33 32 34 namespace JSC { … … 103 105 class ScriptExecutable : public ExecutableBase { 104 106 public: 105 ScriptExecutable( const SourceCode& source)107 ScriptExecutable(JSGlobalData* globalData, const SourceCode& source) 106 108 : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED) 107 109 , m_source(source) 108 110 , m_features(0) 109 111 { 112 #if ENABLE(CODEBLOCK_SAMPLING) 113 if (SamplingTool* sampler = globalData->interpreter->sampler()) 114 sampler->notifyOfScope(this); 115 #else 116 UNUSED_PARAM(globalData); 117 #endif 118 } 119 120 ScriptExecutable(ExecState* exec, const SourceCode& source) 121 : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED) 122 , m_source(source) 123 , m_features(0) 124 { 125 #if ENABLE(CODEBLOCK_SAMPLING) 126 if (SamplingTool* sampler = exec->globalData().interpreter->sampler()) 127 sampler->notifyOfScope(this); 128 #else 129 UNUSED_PARAM(exec); 130 #endif 110 131 } 111 132 … … 138 159 class EvalExecutable : public ScriptExecutable { 139 160 public: 140 EvalExecutable( const SourceCode& source)141 : ScriptExecutable( source)161 EvalExecutable(ExecState* exec, const SourceCode& source) 162 : ScriptExecutable(exec, source) 142 163 , m_evalCodeBlock(0) 143 164 { … … 158 179 159 180 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 160 static PassRefPtr<EvalExecutable> create( const SourceCode& source) { return adoptRef(new EvalExecutable(source)); }181 static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); } 161 182 162 183 private: … … 179 200 class ProgramExecutable : public ScriptExecutable { 180 201 public: 181 ProgramExecutable( const SourceCode& source)182 : ScriptExecutable( source)202 ProgramExecutable(ExecState* exec, const SourceCode& source) 203 : ScriptExecutable(exec, source) 183 204 , m_programCodeBlock(0) 184 205 { … … 222 243 friend class JIT; 223 244 public: 224 static PassRefPtr<FunctionExecutable> create(const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) 225 { 226 return adoptRef(new FunctionExecutable(name, source, forceUsesArguments, parameters, firstLine, lastLine)); 245 static PassRefPtr<FunctionExecutable> create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) 246 { 247 return adoptRef(new FunctionExecutable(exec, name, source, forceUsesArguments, parameters, firstLine, lastLine)); 248 } 249 250 static PassRefPtr<FunctionExecutable> create(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) 251 { 252 return adoptRef(new FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, firstLine, lastLine)); 227 253 } 228 254 … … 264 290 265 291 private: 266 FunctionExecutable( const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)267 : ScriptExecutable( source)292 FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) 293 : ScriptExecutable(globalData, source) 268 294 , m_forceUsesArguments(forceUsesArguments) 269 295 , m_parameters(parameters) … … 276 302 } 277 303 304 FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) 305 : ScriptExecutable(exec, source) 306 , m_forceUsesArguments(forceUsesArguments) 307 , m_parameters(parameters) 308 , m_codeBlock(0) 309 , m_name(name) 310 , m_numVariables(0) 311 { 312 m_firstLine = firstLine; 313 m_lastLine = lastLine; 314 } 315 278 316 void compile(ExecState*, ScopeChainNode*); 279 317 -
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r47738 r48662 287 287 return parsedObject; 288 288 289 EvalExecutable eval( makeSource(s));289 EvalExecutable eval(exec, makeSource(s)); 290 290 JSObject* error = eval.compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()); 291 291 if (error)
Note:
See TracChangeset
for help on using the changeset viewer.