Changeset 201641 in webkit
- Timestamp:
- Jun 3, 2016 7:53:16 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r201628 r201641 1 2016-06-03 Mark Lam <mark.lam@apple.com> 2 3 Clean up how StackVisitor dumps its frames. 4 https://bugs.webkit.org/show_bug.cgi?id=158316 5 6 Reviewed by Keith Miller. 7 8 1. Updated to do dumping to a PrintStream. 9 2. Added support for printing a prefix for each frame. 10 This is currently used by JSDollarVMPrototype to print frame numbers. 11 3. Fix the incrementing of the frame index in StackVisitor. 12 It was initialized but never incremented before when iterating the frames. 13 14 * interpreter/StackVisitor.cpp: 15 (JSC::StackVisitor::gotoNextFrame): 16 (JSC::StackVisitor::Frame::codeType): 17 (JSC::StackVisitor::Frame::functionName): 18 (JSC::StackVisitor::Frame::sourceURL): 19 (JSC::StackVisitor::Frame::toString): 20 (JSC::StackVisitor::Frame::createArguments): 21 (JSC::StackVisitor::Frame::computeLineAndColumn): 22 (JSC::StackVisitor::Frame::retrieveExpressionInfo): 23 (JSC::StackVisitor::Frame::setToEnd): 24 (JSC::StackVisitor::Frame::dump): 25 (JSC::StackVisitor::Indent::dump): 26 (JSC::printIndents): Deleted. 27 (JSC::log): Deleted. 28 (JSC::logF): Deleted. 29 (JSC::StackVisitor::Frame::print): Deleted. 30 * interpreter/StackVisitor.h: 31 (JSC::StackVisitor::Indent::Indent): 32 (JSC::StackVisitor::Indent::operator++): 33 (JSC::StackVisitor::Indent::operator--): 34 (JSC::StackVisitor::Frame::isJSFrame): 35 (JSC::StackVisitor::Frame::isInlinedFrame): 36 (JSC::StackVisitor::Frame::vmEntryFrame): 37 (JSC::StackVisitor::Frame::callFrame): 38 (JSC::StackVisitor::Frame::Frame): 39 (JSC::StackVisitor::Frame::~Frame): 40 * tools/JSDollarVMPrototype.cpp: 41 (JSC::PrintFrameFunctor::operator()): 42 1 43 2016-06-02 Saam Barati <sbarati@apple.com> 2 44 -
trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp
r199852 r201641 1 1 /* 2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 58 58 void StackVisitor::gotoNextFrame() 59 59 { 60 m_frame.m_index++; 60 61 #if ENABLE(DFG_JIT) 61 62 if (m_frame.isInlinedFrame()) { … … 209 210 } 210 211 211 String StackVisitor::Frame::functionName() 212 String StackVisitor::Frame::functionName() const 212 213 { 213 214 String traceLine; … … 235 236 } 236 237 237 String StackVisitor::Frame::sourceURL() 238 String StackVisitor::Frame::sourceURL() const 238 239 { 239 240 String traceLine; … … 256 257 } 257 258 258 String StackVisitor::Frame::toString() 259 String StackVisitor::Frame::toString() const 259 260 { 260 261 StringBuilder traceBuild; … … 306 307 } 307 308 308 void StackVisitor::Frame::computeLineAndColumn(unsigned& line, unsigned& column) 309 void StackVisitor::Frame::computeLineAndColumn(unsigned& line, unsigned& column) const 309 310 { 310 311 CodeBlock* codeBlock = this->codeBlock(); … … 329 330 } 330 331 331 void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) 332 void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const 332 333 { 333 334 CodeBlock* codeBlock = this->codeBlock(); … … 344 345 } 345 346 346 static void printIndents(int levels) 347 { 348 while (levels--) 349 dataLogFString(" "); 350 } 351 352 template<typename... Types> 353 void log(unsigned indent, const Types&... values) 354 { 355 printIndents(indent); 356 dataLog(values...); 357 } 358 359 template<typename... Types> 360 void logF(unsigned indent, const char* format, const Types&... values) 361 { 362 printIndents(indent); 363 364 #if COMPILER(GCC_OR_CLANG) 365 #pragma GCC diagnostic push 366 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 367 #pragma GCC diagnostic ignored "-Wmissing-format-attribute" 368 #endif 369 370 dataLogF(format, values...); 371 372 #if COMPILER(GCC_OR_CLANG) 373 #pragma GCC diagnostic pop 374 #endif 375 } 376 377 void StackVisitor::Frame::print(int indent) 347 void StackVisitor::Frame::dump(PrintStream& out, Indenter indent) const 348 { 349 dump(out, indent, [] (PrintStream&) { }); 350 } 351 352 void StackVisitor::Frame::dump(PrintStream& out, Indenter indent, std::function<void(PrintStream&)> prefix) const 378 353 { 379 354 if (!this->callFrame()) { 380 log(indent, "frame 0x0\n");355 out.print(indent, "frame 0x0\n"); 381 356 return; 382 357 } 383 358 384 359 CodeBlock* codeBlock = this->codeBlock(); 385 logF(indent, "frame %p {\n", this->callFrame()); 360 out.print(indent); 361 prefix(out); 362 out.print("frame ", RawPointer(this->callFrame()), " {\n"); 386 363 387 364 { … … 392 369 void* returnPC = callFrame->hasReturnPC() ? callFrame->returnPC().value() : nullptr; 393 370 394 log(indent, "name: ", functionName(), "\n");395 log(indent, "sourceURL: ", sourceURL(), "\n");371 out.print(indent, "name: ", functionName(), "\n"); 372 out.print(indent, "sourceURL: ", sourceURL(), "\n"); 396 373 397 374 bool isInlined = false; 398 375 #if ENABLE(DFG_JIT) 399 376 isInlined = isInlinedFrame(); 400 log(indent, "isInlinedFrame: ", isInlinedFrame(), "\n");377 out.print(indent, "isInlinedFrame: ", isInlinedFrame(), "\n"); 401 378 if (isInlinedFrame()) 402 logF(indent, "InlineCallFrame: %p\n", m_inlineCallFrame);403 #endif 404 405 logF(indent, "callee: %p\n", callee());406 logF(indent, "returnPC: %p\n", returnPC);407 logF(indent, "callerFrame: %p\n", callerFrame);379 out.print(indent, "InlineCallFrame: ", RawPointer(m_inlineCallFrame), "\n"); 380 #endif 381 382 out.print(indent, "callee: ", RawPointer(callee()), "\n"); 383 out.print(indent, "returnPC: ", RawPointer(returnPC), "\n"); 384 out.print(indent, "callerFrame: ", RawPointer(callerFrame), "\n"); 408 385 unsigned locationRawBits = callFrame->callSiteAsRawBits(); 409 logF(indent, "rawLocationBits: %u 0x%x\n", locationRawBits, locationRawBits); 410 logF(indent, "codeBlock: %p ", codeBlock); 386 out.print(indent, "rawLocationBits: ", static_cast<uintptr_t>(locationRawBits), 387 " ", RawPointer(reinterpret_cast<void*>(locationRawBits)), "\n"); 388 out.print(indent, "codeBlock: ", RawPointer(codeBlock)); 411 389 if (codeBlock) 412 dataLog(*codeBlock);413 dataLog("\n");390 out.print(*codeBlock); 391 out.print("\n"); 414 392 if (codeBlock && !isInlined) { 415 393 indent++; … … 417 395 if (callFrame->callSiteBitsAreBytecodeOffset()) { 418 396 unsigned bytecodeOffset = callFrame->bytecodeOffset(); 419 log(indent, "bytecodeOffset: ", bytecodeOffset, " of ", codeBlock->instructions().size(), "\n");397 out.print(indent, "bytecodeOffset: ", bytecodeOffset, " of ", codeBlock->instructions().size(), "\n"); 420 398 #if ENABLE(DFG_JIT) 421 399 } else { 422 log(indent, "hasCodeOrigins: ", codeBlock->hasCodeOrigins(), "\n");400 out.print(indent, "hasCodeOrigins: ", codeBlock->hasCodeOrigins(), "\n"); 423 401 if (codeBlock->hasCodeOrigins()) { 424 402 CallSiteIndex callSiteIndex = callFrame->callSiteIndex(); 425 log(indent, "callSiteIndex: ", callSiteIndex.bits(), " of ", codeBlock->codeOrigins().size(), "\n");403 out.print(indent, "callSiteIndex: ", callSiteIndex.bits(), " of ", codeBlock->codeOrigins().size(), "\n"); 426 404 427 405 JITCode::JITType jitType = codeBlock->jitType(); 428 406 if (jitType != JITCode::FTLJIT) { 429 407 JITCode* jitCode = codeBlock->jitCode().get(); 430 logF(indent, "jitCode: %p start %p end %p\n", jitCode, jitCode->start(), jitCode->end()); 408 out.print(indent, "jitCode: ", RawPointer(jitCode), 409 " start ", RawPointer(jitCode->start()), 410 " end ", RawPointer(jitCode->end()), "\n"); 431 411 } 432 412 } … … 436 416 unsigned column = 0; 437 417 computeLineAndColumn(line, column); 438 log(indent, "line: ", line, "\n");439 log(indent, "column: ", column, "\n");418 out.print(indent, "line: ", line, "\n"); 419 out.print(indent, "column: ", column, "\n"); 440 420 441 421 indent--; … … 443 423 indent--; 444 424 } 445 log(indent, "}\n");425 out.print(indent, "}\n"); 446 426 } 447 427 -
trunk/Source/JavaScriptCore/interpreter/StackVisitor.h
r199852 r201641 28 28 29 29 #include "VMEntryRecord.h" 30 #include <wtf/Indenter.h> 30 31 #include <wtf/text/WTFString.h> 31 32 … … 75 76 bool isInlinedFrame() const { return !!inlineCallFrame(); } 76 77 77 JS_EXPORT_PRIVATE String functionName() ;78 JS_EXPORT_PRIVATE String sourceURL() ;79 JS_EXPORT_PRIVATE String toString() ;78 JS_EXPORT_PRIVATE String functionName() const; 79 JS_EXPORT_PRIVATE String sourceURL() const; 80 JS_EXPORT_PRIVATE String toString() const; 80 81 81 82 intptr_t sourceID(); 82 83 83 84 CodeType codeType() const; 84 JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column) ;85 JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column) const; 85 86 86 87 ClonedArguments* createArguments(); … … 88 89 CallFrame* callFrame() const { return m_callFrame; } 89 90 90 JS_EXPORT_PRIVATE void print(int indentLevel); 91 void dump(PrintStream&, Indenter = Indenter()) const; 92 void dump(PrintStream&, Indenter, std::function<void(PrintStream&)> prefix) const; 91 93 92 94 private: … … 94 96 ~Frame() { } 95 97 96 void retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) ;98 void retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const; 97 99 void setToEnd(); 98 100 -
trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp
r199745 r201641 327 327 { 328 328 m_currentFrame++; 329 if (m_currentFrame > m_framesToSkip) 330 visitor->print(2); 331 329 if (m_currentFrame > m_framesToSkip) { 330 visitor->dump(WTF::dataFile(), Indenter(2), [&] (PrintStream& out) { 331 out.print("[", (m_currentFrame - m_framesToSkip - 1), "] "); 332 }); 333 } 332 334 if (m_action == PrintOne && m_currentFrame > m_framesToSkip) 333 335 return StackVisitor::Done; -
trunk/Source/WTF/ChangeLog
r201629 r201641 1 2016-06-03 Mark Lam <mark.lam@apple.com> 2 3 Clean up how StackVisitor dumps its frames. 4 https://bugs.webkit.org/show_bug.cgi?id=158316 5 6 Reviewed by Keith Miller. 7 8 Added an Indenter class what works with dataLog. 9 10 * WTF.xcodeproj/project.pbxproj: 11 * wtf/Indenter.h: Added. 12 (WTF::Indenter::Indenter): 13 (WTF::Indenter::dump): 14 (WTF::Indenter::operator++): 15 (WTF::Indenter::operator--): 16 1 17 2016-06-02 Said Abou-Hallawa <sabouhallawa@apple,com> 2 18 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r201518 r201641 320 320 EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; }; 321 321 FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8225301B2A1E5B00BA68FD /* NakedPtr.h */; }; 322 FE8925B01D00DAEC0046907E /* Indenter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8925AF1D00DAEC0046907E /* Indenter.h */; }; 322 323 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; }; 323 324 FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; }; … … 651 652 EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; }; 652 653 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; }; 654 FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = "<group>"; }; 653 655 FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; }; 654 656 FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = "<group>"; }; … … 856 858 A8A472BA151A825A004123FF /* HashTraits.h */, 857 859 A8A472BB151A825A004123FF /* HexNumber.h */, 860 FE8925AF1D00DAEC0046907E /* Indenter.h */, 858 861 2684D4351C000D400081D663 /* IndexSparseSet.h */, 859 862 A8A472BC151A825A004123FF /* InlineASM.h */, … … 1361 1364 83FBA93219DF459700F30ADB /* TypeCasts.h in Headers */, 1362 1365 1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */, 1366 FE8925B01D00DAEC0046907E /* Indenter.h in Headers */, 1363 1367 A8A4746D151A825B004123FF /* UnionFind.h in Headers */, 1364 1368 70ECA60F1B02426800449739 /* UniquedStringImpl.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.