1. 29 Nov, 2012 1 commit
    • fpizlo@apple.com's avatar
      It should be easy to find code blocks in debug dumps · 0bfcc38a
      fpizlo@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=103623
      
      Source/JavaScriptCore: 
      
      Reviewed by Goeffrey Garen.
      
      This gives CodeBlock a relatively strong, but also relatively compact, hash. We compute
      it lazily so that it only impacts run-time when debug support is enabled. We stringify
      it smartly so that it's short and easy to type. We base it on the source code so that
      the optimization level is irrelevant. And, we use SHA1 since it's already in our code
      base. Now, when a piece of code wants to print some debugging to say that it's operating
      on some code block, it can use this CodeBlockHash instead of memory addresses.
      
      This also takes CodeBlock debugging into the new world of print() and dataLog(). In
      particular, CodeBlock::dump() corresponds to the thing you want printed if you do:
      
      dataLog("I heart ", *myCodeBlock);
      
      Probably, you want to just print some identifying information at this point rather than
      the full bytecode dump. So, the existing CodeBlock::dump() has been renamed to
      CodeBlock::dumpBytecode(), and CodeBlock::dump() now prints the CodeBlockHash plus just
      a few little tidbits.
              
      Here's an example of CodeBlock::dump() output:
              
      EkILzr:[0x103883a00, BaselineFunctionCall]
              
      EkILzr is the CodeBlockHash. 0x103883a00 is the CodeBlock's address in memory. The other
      part is self-explanatory.
      
      Finally, this new notion of CodeBlockHash is available for other purposes like bisecting
      breakage. As such CodeBlockHash has all of the comparison operator overloads. When
      bisecting in DFGDriver.cpp, you can now say things like:
              
      if (codeBlock->hash() < CodeBlockHash("CAAAAA"))
          return false;
              
      And yes, CAAAAA is near the median hash, and the largest one is smaller than E99999. Such
      is life when you use base 62 to encode a 32-bit number.
      
      * CMakeLists.txt:
      * GNUmakefile.list.am:
      * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * Target.pri:
      * bytecode/CallLinkInfo.h:
      (CallLinkInfo):
      (JSC::CallLinkInfo::specializationKind):
      * bytecode/CodeBlock.cpp:
      (JSC::CodeBlock::hash):
      (JSC):
      (JSC::CodeBlock::dumpAssumingJITType):
      (JSC::CodeBlock::dump):
      (JSC::CodeBlock::dumpBytecode):
      (JSC::CodeBlock::CodeBlock):
      (JSC::CodeBlock::finalizeUnconditionally):
      (JSC::CodeBlock::resetStubInternal):
      (JSC::CodeBlock::reoptimize):
      (JSC::ProgramCodeBlock::jettison):
      (JSC::EvalCodeBlock::jettison):
      (JSC::FunctionCodeBlock::jettison):
      (JSC::CodeBlock::shouldOptimizeNow):
      (JSC::CodeBlock::tallyFrequentExitSites):
      (JSC::CodeBlock::dumpValueProfiles):
      * bytecode/CodeBlock.h:
      (JSC::CodeBlock::specializationKind):
      (CodeBlock):
      (JSC::CodeBlock::getJITType):
      * bytecode/CodeBlockHash.cpp: Added.
      (JSC):
      (JSC::CodeBlockHash::CodeBlockHash):
      (JSC::CodeBlockHash::dump):
      * bytecode/CodeBlockHash.h: Added.
      (JSC):
      (CodeBlockHash):
      (JSC::CodeBlockHash::CodeBlockHash):
      (JSC::CodeBlockHash::hash):
      (JSC::CodeBlockHash::operator==):
      (JSC::CodeBlockHash::operator!=):
      (JSC::CodeBlockHash::operator<):
      (JSC::CodeBlockHash::operator>):
      (JSC::CodeBlockHash::operator<=):
      (JSC::CodeBlockHash::operator>=):
      * bytecode/CodeBlockWithJITType.h: Added.
      (JSC):
      (CodeBlockWithJITType):
      (JSC::CodeBlockWithJITType::CodeBlockWithJITType):
      (JSC::CodeBlockWithJITType::dump):
      * bytecode/CodeOrigin.cpp: Added.
      (JSC):
      (JSC::CodeOrigin::inlineDepthForCallFrame):
      (JSC::CodeOrigin::inlineDepth):
      (JSC::CodeOrigin::inlineStack):
      (JSC::InlineCallFrame::hash):
      * bytecode/CodeOrigin.h:
      (InlineCallFrame):
      (JSC::InlineCallFrame::specializationKind):
      (JSC):
      * bytecode/CodeType.cpp: Added.
      (WTF):
      (WTF::printInternal):
      * bytecode/CodeType.h:
      (WTF):
      * bytecode/ExecutionCounter.cpp:
      (JSC::ExecutionCounter::dump):
      * bytecode/ExecutionCounter.h:
      (ExecutionCounter):
      * dfg/DFGByteCodeParser.cpp:
      (JSC::DFG::ByteCodeParser::parseCodeBlock):
      * dfg/DFGDisassembler.cpp:
      (JSC::DFG::Disassembler::dump):
      * dfg/DFGGraph.cpp:
      (JSC::DFG::Graph::dumpCodeOrigin):
      * dfg/DFGOSRExitCompiler.cpp:
      * dfg/DFGOperations.cpp:
      * dfg/DFGRepatch.cpp:
      (JSC::DFG::generateProtoChainAccessStub):
      (JSC::DFG::tryCacheGetByID):
      (JSC::DFG::tryBuildGetByIDList):
      (JSC::DFG::emitPutReplaceStub):
      (JSC::DFG::emitPutTransitionStub):
      (JSC::DFG::dfgLinkClosureCall):
      * interpreter/Interpreter.cpp:
      (JSC::Interpreter::dumpCallFrame):
      * jit/JITCode.cpp: Added.
      (WTF):
      (WTF::printInternal):
      * jit/JITCode.h:
      (JSC::JITCode::jitType):
      (WTF):
      * jit/JITDisassembler.cpp:
      (JSC::JITDisassembler::dump):
      (JSC::JITDisassembler::dumpForInstructions):
      * jit/JITPropertyAccess.cpp:
      (JSC::JIT::privateCompilePutByIdTransition):
      (JSC::JIT::privateCompilePatchGetArrayLength):
      (JSC::JIT::privateCompileGetByIdProto):
      (JSC::JIT::privateCompileGetByIdSelfList):
      (JSC::JIT::privateCompileGetByIdProtoList):
      (JSC::JIT::privateCompileGetByIdChainList):
      (JSC::JIT::privateCompileGetByIdChain):
      (JSC::JIT::privateCompileGetByVal):
      (JSC::JIT::privateCompilePutByVal):
      * jit/JITPropertyAccess32_64.cpp:
      (JSC::JIT::privateCompilePutByIdTransition):
      (JSC::JIT::privateCompilePatchGetArrayLength):
      (JSC::JIT::privateCompileGetByIdProto):
      (JSC::JIT::privateCompileGetByIdSelfList):
      (JSC::JIT::privateCompileGetByIdProtoList):
      (JSC::JIT::privateCompileGetByIdChainList):
      (JSC::JIT::privateCompileGetByIdChain):
      * jit/JITStubs.cpp:
      (JSC::DEFINE_STUB_FUNCTION):
      * runtime/CodeSpecializationKind.cpp: Added.
      (WTF):
      (WTF::printInternal):
      * runtime/CodeSpecializationKind.h:
      (JSC::specializationFromIsCall):
      (JSC):
      (JSC::specializationFromIsConstruct):
      (WTF):
      * runtime/Executable.cpp:
      (JSC::ExecutableBase::hashFor):
      (JSC):
      (JSC::NativeExecutable::hashFor):
      (JSC::ScriptExecutable::hashFor):
      * runtime/Executable.h:
      (ExecutableBase):
      (NativeExecutable):
      (ScriptExecutable):
      (JSC::ScriptExecutable::source):
      
      Source/WTF: 
      
      Reviewed by Geoffrey Garen.
      
      Changed RawPointer to accept both const void* and void*, and use the former internally.
              
      Cleaned up SHA1 so that the functionality already used internally for self-testing is
      available via the API. This includes addBytes(CString) and computing hex digests.
      
      * wtf/RawPointer.h:
      (WTF::RawPointer::RawPointer):
      (RawPointer):
      (WTF::RawPointer::value):
      * wtf/SHA1.cpp:
      (WTF::expectSHA1):
      (WTF::SHA1::hexDigest):
      (WTF::SHA1::computeHexDigest):
      * wtf/SHA1.h:
      (WTF::SHA1::addBytes):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136199 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      0bfcc38a
  2. 20 Nov, 2012 1 commit
    • fpizlo@apple.com's avatar
      DFG should be able to cache closure calls (part 2/2) · 4092e56d
      fpizlo@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=102662
      
      Reviewed by Gavin Barraclough.
      
      Added caching of calls where the JSFunction* varies, but the Structure* and ExecutableBase*
      stay the same. This is accomplished by replacing the branch that compares against a constant
      JSFunction* with a jump to a closure call stub. The closure call stub contains a fast path,
      and jumps slow directly to the virtual call thunk.
      
      Looks like a 1% win on V8v7.
      
      * CMakeLists.txt:
      * GNUmakefile.list.am:
      * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * Target.pri:
      * bytecode/CallLinkInfo.cpp:
      (JSC::CallLinkInfo::unlink):
      * bytecode/CallLinkInfo.h:
      (CallLinkInfo):
      (JSC::CallLinkInfo::isLinked):
      (JSC::getCallLinkInfoBytecodeIndex):
      * bytecode/CodeBlock.cpp:
      (JSC::CodeBlock::finalizeUnconditionally):
      (JSC):
      (JSC::CodeBlock::findClosureCallForReturnPC):
      (JSC::CodeBlock::bytecodeOffset):
      (JSC::CodeBlock::codeOriginForReturn):
      * bytecode/CodeBlock.h:
      (JSC::CodeBlock::getCallLinkInfo):
      (CodeBlock):
      (JSC::CodeBlock::isIncomingCallAlreadyLinked):
      * dfg/DFGJITCompiler.cpp:
      (JSC::DFG::JITCompiler::link):
      * dfg/DFGJITCompiler.h:
      (JSC::DFG::JITCompiler::addJSCall):
      (JSC::DFG::JITCompiler::JSCallRecord::JSCallRecord):
      (JSCallRecord):
      * dfg/DFGOperations.cpp:
      * dfg/DFGOperations.h:
      * dfg/DFGRepatch.cpp:
      (JSC::DFG::linkSlowFor):
      (DFG):
      (JSC::DFG::dfgLinkFor):
      (JSC::DFG::dfgLinkSlowFor):
      (JSC::DFG::dfgLinkClosureCall):
      * dfg/DFGRepatch.h:
      (DFG):
      * dfg/DFGSpeculativeJIT32_64.cpp:
      (JSC::DFG::SpeculativeJIT::emitCall):
      * dfg/DFGSpeculativeJIT64.cpp:
      (JSC::DFG::SpeculativeJIT::emitCall):
      * dfg/DFGThunks.cpp:
      (DFG):
      (JSC::DFG::linkClosureCallThunkGenerator):
      * dfg/DFGThunks.h:
      (DFG):
      * heap/Heap.h:
      (Heap):
      (JSC::Heap::jitStubRoutines):
      * heap/JITStubRoutineSet.h:
      (JSC::JITStubRoutineSet::size):
      (JSC::JITStubRoutineSet::at):
      (JITStubRoutineSet):
      * jit/ClosureCallStubRoutine.cpp: Added.
      (JSC):
      (JSC::ClosureCallStubRoutine::ClosureCallStubRoutine):
      (JSC::ClosureCallStubRoutine::~ClosureCallStubRoutine):
      (JSC::ClosureCallStubRoutine::markRequiredObjectsInternal):
      * jit/ClosureCallStubRoutine.h: Added.
      (JSC):
      (ClosureCallStubRoutine):
      (JSC::ClosureCallStubRoutine::structure):
      (JSC::ClosureCallStubRoutine::executable):
      (JSC::ClosureCallStubRoutine::codeOrigin):
      * jit/GCAwareJITStubRoutine.cpp:
      (JSC::GCAwareJITStubRoutine::GCAwareJITStubRoutine):
      * jit/GCAwareJITStubRoutine.h:
      (GCAwareJITStubRoutine):
      (JSC::GCAwareJITStubRoutine::isClosureCall):
      * jit/JIT.cpp:
      (JSC::JIT::privateCompile):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      4092e56d
  3. 11 Jul, 2012 1 commit
    • fpizlo@apple.com's avatar
      DFG should have fast virtual calls · 5e135773
      fpizlo@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=90924
      
      Source/JavaScriptCore: 
      
      Reviewed by Gavin Barraclough.
              
      Implements virtual call support in the style of the old JIT, with the
      caveat that we still use the same slow path for both InternalFunction
      calls and JSFunction calls. Also rationalized the way that our
      CodeOrigin indices tie into exception checks (previously it was a
      strange one-to-one mapping with fairly limited assertions; now it's a
      one-to-many mapping for CodeOrigins to exception checks, respectively).
      I also took the opportunity to clean up
      CallLinkInfo::callReturnLocation, which previously was either a Call or
      a NearCall. Now it's just a NearCall. As well, exceptions during slow
      path call resolution are now handled by returning an exception throwing
      thunk rather than returning null. And finally, I made a few things
      public that were previously private-with-lots-of-friends, because I
      truly despise the thought of listing each thunk generating function as
      a friend of JSValue and friends.
              
      * bytecode/CallLinkInfo.cpp:
      (JSC::CallLinkInfo::unlink):
      * bytecode/CallLinkInfo.h:
      (CallLinkInfo):
      * bytecode/CodeOrigin.h:
      (JSC::CodeOrigin::CodeOrigin):
      (JSC::CodeOrigin::isSet):
      * dfg/DFGAssemblyHelpers.h:
      (JSC::DFG::AssemblyHelpers::AssemblyHelpers):
      * dfg/DFGCCallHelpers.h:
      (JSC::DFG::CCallHelpers::CCallHelpers):
      * dfg/DFGGPRInfo.h:
      (GPRInfo):
      * dfg/DFGJITCompiler.cpp:
      (JSC::DFG::JITCompiler::link):
      (JSC::DFG::JITCompiler::compileFunction):
      * dfg/DFGJITCompiler.h:
      (JSC::DFG::CallBeginToken::CallBeginToken):
      (JSC::DFG::CallBeginToken::~CallBeginToken):
      (CallBeginToken):
      (JSC::DFG::CallBeginToken::set):
      (JSC::DFG::CallBeginToken::registerWithExceptionCheck):
      (JSC::DFG::CallBeginToken::codeOrigin):
      (JSC::DFG::CallExceptionRecord::CallExceptionRecord):
      (CallExceptionRecord):
      (JSC::DFG::JITCompiler::currentCodeOriginIndex):
      (JITCompiler):
      (JSC::DFG::JITCompiler::beginCall):
      (JSC::DFG::JITCompiler::notifyCall):
      (JSC::DFG::JITCompiler::prepareForExceptionCheck):
      (JSC::DFG::JITCompiler::addExceptionCheck):
      (JSC::DFG::JITCompiler::addFastExceptionCheck):
      * dfg/DFGOperations.cpp:
      * dfg/DFGRepatch.cpp:
      (JSC::DFG::dfgLinkFor):
      * dfg/DFGSpeculativeJIT.h:
      (JSC::DFG::SpeculativeJIT::appendCallWithExceptionCheck):
      * dfg/DFGSpeculativeJIT32_64.cpp:
      (JSC::DFG::SpeculativeJIT::emitCall):
      * dfg/DFGSpeculativeJIT64.cpp:
      (JSC::DFG::SpeculativeJIT::emitCall):
      * dfg/DFGThunks.cpp:
      (JSC::DFG::emitPointerValidation):
      (DFG):
      (JSC::DFG::throwExceptionFromCallSlowPathGenerator):
      (JSC::DFG::slowPathFor):
      (JSC::DFG::linkForThunkGenerator):
      (JSC::DFG::linkCallThunkGenerator):
      (JSC::DFG::linkConstructThunkGenerator):
      (JSC::DFG::virtualForThunkGenerator):
      (JSC::DFG::virtualCallThunkGenerator):
      (JSC::DFG::virtualConstructThunkGenerator):
      * dfg/DFGThunks.h:
      (DFG):
      * jit/JIT.cpp:
      (JSC::JIT::privateCompile):
      (JSC::JIT::linkFor):
      * runtime/Executable.h:
      (ExecutableBase):
      (JSC::ExecutableBase::offsetOfJITCodeFor):
      (JSC::ExecutableBase::offsetOfNumParametersFor):
      * runtime/JSValue.h:
      (JSValue):
      
      LayoutTests: 
      
      Rubber stamped by Oliver Hunt.
      
      This changes which piece of code appears on top of the stack at the point of a stack
      overflow. As far as Oliver and I can tell, it doesn't matter, so I just rebased the
      test.
      
      * fast/js/stack-trace-expected.txt:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      5e135773
  4. 26 Jan, 2012 1 commit
  5. 10 Jan, 2012 1 commit
    • fpizlo@apple.com's avatar
      CodeBlock.h declares too many things · ea74cb1c
      fpizlo@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=76001
      
      Rubber stamped by Gavin Barraclough.
              
      Removed all non-CodeBlock type declarations from CodeBlock.h, and put them
      into separate header files. Also removed all non-CodeBlock method implementations
      from CodeBlock.cpp and put them into corresponding cpp files.
      
      * CMakeLists.txt:
      * GNUmakefile.list.am:
      * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * Target.pri:
      * assembler/RepatchBuffer.h:
      * bytecode/CallLinkInfo.cpp: Added.
      (JSC::CallLinkInfo::unlink):
      * bytecode/CallLinkInfo.h: Added.
      (JSC::CallLinkInfo::callTypeFor):
      (JSC::CallLinkInfo::CallLinkInfo):
      (JSC::CallLinkInfo::~CallLinkInfo):
      (JSC::CallLinkInfo::isLinked):
      (JSC::CallLinkInfo::seenOnce):
      (JSC::CallLinkInfo::setSeen):
      (JSC::getCallLinkInfoReturnLocation):
      (JSC::getCallLinkInfoBytecodeIndex):
      * bytecode/CallReturnOffsetToBytecodeOffset.h: Added.
      (JSC::CallReturnOffsetToBytecodeOffset::CallReturnOffsetToBytecodeOffset):
      (JSC::getCallReturnOffset):
      * bytecode/CodeBlock.cpp:
      * bytecode/CodeBlock.h:
      * bytecode/CodeType.h: Added.
      * bytecode/ExpressionRangeInfo.h: Added.
      * bytecode/GlobalResolveInfo.h: Added.
      (JSC::GlobalResolveInfo::GlobalResolveInfo):
      * bytecode/HandlerInfo.h: Added.
      * bytecode/LineInfo.h: Added.
      * bytecode/MethodCallLinkInfo.cpp: Added.
      (JSC::MethodCallLinkInfo::reset):
      * bytecode/MethodCallLinkInfo.h: Added.
      (JSC::MethodCallLinkInfo::MethodCallLinkInfo):
      (JSC::MethodCallLinkInfo::seenOnce):
      (JSC::MethodCallLinkInfo::setSeen):
      (JSC::getMethodCallLinkInfoReturnLocation):
      (JSC::getMethodCallLinkInfoBytecodeIndex):
      * bytecode/StructureStubInfo.h:
      (JSC::getStructureStubInfoReturnLocation):
      (JSC::getStructureStubInfoBytecodeIndex):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104646 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      ea74cb1c