diff options
Diffstat (limited to 'Source/JavaScriptCore')
40 files changed, 1028 insertions, 203 deletions
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt index 7e5656025..0a7a8bd3f 100644 --- a/Source/JavaScriptCore/CMakeLists.txt +++ b/Source/JavaScriptCore/CMakeLists.txt @@ -45,6 +45,9 @@ SET(JavaScriptCore_SOURCES bytecode/CallLinkInfo.cpp bytecode/CallLinkStatus.cpp bytecode/CodeBlock.cpp + bytecode/CodeBlockHash.cpp + bytecode/CodeOrigin.cpp + bytecode/CodeType.cpp bytecode/DFGExitProfile.cpp bytecode/ExecutionCounter.cpp bytecode/GetByIdStatus.cpp @@ -150,6 +153,7 @@ SET(JavaScriptCore_SOURCES jit/JITArithmetic.cpp jit/JITCall32_64.cpp jit/JITCall.cpp + jit/JITCode.cpp jit/JIT.cpp jit/JITDisassembler.cpp jit/JITExceptions.cpp @@ -182,6 +186,7 @@ SET(JavaScriptCore_SOURCES runtime/BooleanPrototype.cpp runtime/CallData.cpp runtime/CodeCache.cpp + runtime/CodeSpecializationKind.cpp runtime/CommonIdentifiers.cpp runtime/Completion.cpp runtime/ConstructData.cpp diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 9ab660ba2..13066e436 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,225 @@ +2012-11-30 Tor Arne Vestbø <tor.arne.vestbo@digia.com> + + [Qt] Place the LLIntOffsetsExtractor binaries in debug/release subdirs on Mac + + Otherwise we'll end up using the same LLIntAssembly.h for both build + configs of JavaScriptCore -- one of them which will be for the wrong + config. + + Reviewed by Simon Hausmann. + + * LLIntOffsetsExtractor.pro: + +2012-11-30 Julien BRIANCEAU <jbrianceau@nds.com> + + [sh4] Fix compilation warnings in JavaScriptCore JIT for sh4 arch + https://bugs.webkit.org/show_bug.cgi?id=103378 + + Reviewed by Filip Pizlo. + + * assembler/MacroAssemblerSH4.h: + (JSC::MacroAssemblerSH4::branchTest32): + (JSC::MacroAssemblerSH4::branchAdd32): + (JSC::MacroAssemblerSH4::branchMul32): + (JSC::MacroAssemblerSH4::branchSub32): + (JSC::MacroAssemblerSH4::branchOr32): + +2012-11-29 Rafael Weinstein <rafaelw@chromium.org> + + [HTMLTemplateElement] Add feature flag + https://bugs.webkit.org/show_bug.cgi?id=103694 + + Reviewed by Adam Barth. + + This flag will guard the implementation of the HTMLTemplateElement. + http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html + + * Configurations/FeatureDefines.xcconfig: + +2012-11-29 Filip Pizlo <fpizlo@apple.com> + + It should be easy to find code blocks in debug dumps + https://bugs.webkit.org/show_bug.cgi?id=103623 + + 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): + +2012-11-29 Michael Saboff <msaboff@apple.com> + + Speculative Windows build fix after r136086. + + Unreviewed build fix. + + Suspect that ?setDumpsGeneratedCode@BytecodeGenerator@JSC@@SAX_N@Z needs to be removed from Windows + export list since the symbol was removed in r136086. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + 2012-11-28 Filip Pizlo <fpizlo@apple.com> SpeculatedType dumping should not use the static char buffer[thingy] idiom diff --git a/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig b/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig index 588ddb80b..00678accd 100644 --- a/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig +++ b/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig @@ -143,6 +143,7 @@ ENABLE_SVG = ENABLE_SVG; ENABLE_SVG_DOM_OBJC_BINDINGS = $(ENABLE_SVG_DOM_OBJC_BINDINGS_$(PLATFORM_NAME)); ENABLE_SVG_DOM_OBJC_BINDINGS_macosx = ENABLE_SVG_DOM_OBJC_BINDINGS; ENABLE_SVG_FONTS = ENABLE_SVG_FONTS; +ENABLE_TEMPLATE_ELEMENT = ; ENABLE_TEXT_AUTOSIZING = ; ENABLE_TEXT_NOTIFICATIONS_ONLY = ENABLE_TEXT_NOTIFICATIONS_ONLY; ENABLE_TOUCH_ICON_LOADING = ; @@ -158,5 +159,5 @@ ENABLE_WORKERS = ENABLE_WORKERS; ENABLE_XHR_TIMEOUT = ENABLE_XHR_TIMEOUT; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_BACKGROUND) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_BACKGROUND) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEMPLATE_ELEMENT) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT); diff --git a/Source/JavaScriptCore/Configurations/Version.xcconfig b/Source/JavaScriptCore/Configurations/Version.xcconfig index 4f8baa4f2..943e88ecf 100644 --- a/Source/JavaScriptCore/Configurations/Version.xcconfig +++ b/Source/JavaScriptCore/Configurations/Version.xcconfig @@ -22,7 +22,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MAJOR_VERSION = 537; -MINOR_VERSION = 20; +MINOR_VERSION = 21; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); diff --git a/Source/JavaScriptCore/GNUmakefile.list.am b/Source/JavaScriptCore/GNUmakefile.list.am index c42ee7dfe..701d80fae 100644 --- a/Source/JavaScriptCore/GNUmakefile.list.am +++ b/Source/JavaScriptCore/GNUmakefile.list.am @@ -94,9 +94,14 @@ javascriptcore_sources += \ Source/JavaScriptCore/bytecode/CallLinkStatus.cpp \ Source/JavaScriptCore/bytecode/CallLinkStatus.h \ Source/JavaScriptCore/bytecode/CallReturnOffsetToBytecodeOffset.h \ + Source/JavaScriptCore/bytecode/CodeType.cpp \ Source/JavaScriptCore/bytecode/CodeType.h \ Source/JavaScriptCore/bytecode/CodeBlock.cpp \ Source/JavaScriptCore/bytecode/CodeBlock.h \ + Source/JavaScriptCore/bytecode/CodeBlockHash.cpp \ + Source/JavaScriptCore/bytecode/CodeBlockHash.h \ + Source/JavaScriptCore/bytecode/CodeBlockWithJITType.h \ + Source/JavaScriptCore/bytecode/CodeOrigin.cpp \ Source/JavaScriptCore/bytecode/CodeOrigin.h \ Source/JavaScriptCore/bytecode/Comment.h \ Source/JavaScriptCore/bytecode/DataFormat.h \ @@ -399,6 +404,7 @@ javascriptcore_sources += \ Source/JavaScriptCore/jit/JITArithmetic.cpp \ Source/JavaScriptCore/jit/JITCall32_64.cpp \ Source/JavaScriptCore/jit/JITCall.cpp \ + Source/JavaScriptCore/jit/JITCode.cpp \ Source/JavaScriptCore/jit/JITCode.h \ Source/JavaScriptCore/jit/JITCompilationEffort.h \ Source/JavaScriptCore/jit/JITDisassembler.cpp \ @@ -499,6 +505,7 @@ javascriptcore_sources += \ Source/JavaScriptCore/runtime/ClassInfo.h \ Source/JavaScriptCore/runtime/CodeCache.cpp \ Source/JavaScriptCore/runtime/CodeCache.h \ + Source/JavaScriptCore/runtime/CodeSpecializationKind.cpp \ Source/JavaScriptCore/runtime/CodeSpecializationKind.h \ Source/JavaScriptCore/runtime/CommonIdentifiers.cpp \ Source/JavaScriptCore/runtime/CommonIdentifiers.h \ diff --git a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def index 7aa5673d8..422aac464 100755 --- a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def +++ b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def @@ -340,7 +340,6 @@ EXPORTS ?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVString@WTF@@AAVJSValue@2@@Z ?setConfigurable@PropertyDescriptor@JSC@@QAEX_N@Z ?setDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@I@Z - ?setDumpsGeneratedCode@BytecodeGenerator@JSC@@SAX_N@Z ?setEnumerable@PropertyDescriptor@JSC@@QAEX_N@Z ?setGarbageCollectionTimerEnabled@Heap@JSC@@QAEX_N@Z ?setGetter@PropertyDescriptor@JSC@@QAEXVJSValue@2@@Z diff --git a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj index d26a3b645..e8eda62f9 100644 --- a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj +++ b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj @@ -646,6 +646,14 @@ >
</File>
<File
+ RelativePath="..\..\runtime\CodeSpecializationKind.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\runtime\CodeSpecializationKind.h"
+ >
+ </File>
+ <File
RelativePath="..\..\runtime\CommonIdentifiers.cpp"
>
</File>
@@ -1630,6 +1638,22 @@ >
</File>
<File
+ RelativePath="..\..\bytecode\CodeBlockHash.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\bytecode\CodeBlockHash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\bytecode\CodeBlockWithJITType.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\bytecode\CodeOrigin.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\bytecode\CodeOrigin.h"
>
</File>
@@ -1638,6 +1662,10 @@ >
</File>
<File
+ RelativePath="..\..\bytecode\CodeType.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\bytecode\Comment.h"
>
</File>
@@ -1982,6 +2010,10 @@ >
</File>
<File
+ RelativePath="..\..\jit\JITCode.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\jit\JITCode.h"
>
</File>
diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index a2c4b5f52..61867036a 100644 --- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -170,6 +170,12 @@ 0F8335B71639C1E6001443B5 /* ArrayAllocationProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8335B41639C1E3001443B5 /* ArrayAllocationProfile.cpp */; }; 0F8335B81639C1EA001443B5 /* ArrayAllocationProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8335B51639C1E3001443B5 /* ArrayAllocationProfile.h */; settings = {ATTRIBUTES = (Private, ); }; }; 0F8364B7164B0C110053329A /* DFGBranchDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8364B5164B0C0E0053329A /* DFGBranchDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 0F8F943C1667631300D61971 /* CodeSpecializationKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */; }; + 0F8F94401667633000D61971 /* CodeBlockHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */; }; + 0F8F94411667633200D61971 /* CodeBlockHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8F943E1667632D00D61971 /* CodeBlockHash.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 0F8F94421667633500D61971 /* CodeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F943F1667632D00D61971 /* CodeType.cpp */; }; + 0F8F94441667635400D61971 /* JITCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F94431667635200D61971 /* JITCode.cpp */; }; + 0F8F9446166764F100D61971 /* CodeOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F9445166764EE00D61971 /* CodeOrigin.cpp */; }; 0F919D0C157EE09F004A4E7D /* JSSymbolTableObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F919D09157EE09D004A4E7D /* JSSymbolTableObject.cpp */; }; 0F919D0D157EE0A2004A4E7D /* JSSymbolTableObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F919D0A157EE09D004A4E7D /* JSSymbolTableObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 0F919D10157F3329004A4E7D /* JSSegmentedVariableObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F919D0E157F3327004A4E7D /* JSSegmentedVariableObject.cpp */; }; @@ -185,6 +191,7 @@ 0F9332A414CA7DD90085F3C6 /* PutByIdStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F93329A14CA7DC10085F3C6 /* PutByIdStatus.h */; settings = {ATTRIBUTES = (Private, ); }; }; 0F9332A514CA7DDD0085F3C6 /* StructureSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F93329B14CA7DC10085F3C6 /* StructureSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F96EBB116676EF4008BADE3 /* CodeBlockWithJITType.h */; settings = {ATTRIBUTES = (Private, ); }; }; 0F9D3370165DBB90005AD387 /* Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D336E165DBB8D005AD387 /* Disassembler.cpp */; }; 0F9FC8C314E1B5FE00D52AE0 /* PolymorphicPutByIdList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9FC8BF14E1B5FB00D52AE0 /* PolymorphicPutByIdList.cpp */; }; 0F9FC8C414E1B60000D52AE0 /* PolymorphicPutByIdList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9FC8C014E1B5FB00D52AE0 /* PolymorphicPutByIdList.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -968,6 +975,12 @@ 0F8335B41639C1E3001443B5 /* ArrayAllocationProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayAllocationProfile.cpp; sourceTree = "<group>"; }; 0F8335B51639C1E3001443B5 /* ArrayAllocationProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayAllocationProfile.h; sourceTree = "<group>"; }; 0F8364B5164B0C0E0053329A /* DFGBranchDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBranchDirection.h; path = dfg/DFGBranchDirection.h; sourceTree = "<group>"; }; + 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeSpecializationKind.cpp; sourceTree = "<group>"; }; + 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeBlockHash.cpp; sourceTree = "<group>"; }; + 0F8F943E1667632D00D61971 /* CodeBlockHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeBlockHash.h; sourceTree = "<group>"; }; + 0F8F943F1667632D00D61971 /* CodeType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeType.cpp; sourceTree = "<group>"; }; + 0F8F94431667635200D61971 /* JITCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITCode.cpp; sourceTree = "<group>"; }; + 0F8F9445166764EE00D61971 /* CodeOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeOrigin.cpp; sourceTree = "<group>"; }; 0F919D09157EE09D004A4E7D /* JSSymbolTableObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSymbolTableObject.cpp; sourceTree = "<group>"; }; 0F919D0A157EE09D004A4E7D /* JSSymbolTableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSymbolTableObject.h; sourceTree = "<group>"; }; 0F919D0E157F3327004A4E7D /* JSSegmentedVariableObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSegmentedVariableObject.cpp; sourceTree = "<group>"; }; @@ -983,6 +996,7 @@ 0F93329A14CA7DC10085F3C6 /* PutByIdStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PutByIdStatus.h; sourceTree = "<group>"; }; 0F93329B14CA7DC10085F3C6 /* StructureSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureSet.h; sourceTree = "<group>"; }; 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueProfile.h; sourceTree = "<group>"; }; + 0F96EBB116676EF4008BADE3 /* CodeBlockWithJITType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeBlockWithJITType.h; sourceTree = "<group>"; }; 0F9D336E165DBB8D005AD387 /* Disassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disassembler.cpp; path = disassembler/Disassembler.cpp; sourceTree = "<group>"; }; 0F9FC8BF14E1B5FB00D52AE0 /* PolymorphicPutByIdList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolymorphicPutByIdList.cpp; sourceTree = "<group>"; }; 0F9FC8C014E1B5FB00D52AE0 /* PolymorphicPutByIdList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolymorphicPutByIdList.h; sourceTree = "<group>"; }; @@ -1838,6 +1852,7 @@ A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */, 86CC85A20EE79B7400288682 /* JITCall.cpp */, 146FE51111A710430087AE66 /* JITCall32_64.cpp */, + 0F8F94431667635200D61971 /* JITCode.cpp */, 86CCEFDD0F413F8900FD7F9E /* JITCode.h */, 0F0776BD14FF002800102332 /* JITCompilationEffort.h */, 0FAF7EFA165BA919000C8455 /* JITDisassembler.cpp */, @@ -2136,6 +2151,7 @@ BCA62DFE0E2826230004F30D /* CallData.cpp */, 145C507F0D9DF63B0088F6B9 /* CallData.h */, BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */, + 0F8F943A1667631100D61971 /* CodeSpecializationKind.cpp */, 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */, 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */, 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */, @@ -2560,9 +2576,14 @@ 0F93329314CA7DC10085F3C6 /* CallLinkStatus.cpp */, 0F93329414CA7DC10085F3C6 /* CallLinkStatus.h */, 0F0B83B814BCF95B00885B4F /* CallReturnOffsetToBytecodeOffset.h */, + 0F8F943D1667632D00D61971 /* CodeBlockHash.cpp */, + 0F8F943E1667632D00D61971 /* CodeBlockHash.h */, + 0F96EBB116676EF4008BADE3 /* CodeBlockWithJITType.h */, 969A07900ED1D3AE00F1F681 /* CodeBlock.cpp */, 969A07910ED1D3AE00F1F681 /* CodeBlock.h */, + 0F8F9445166764EE00D61971 /* CodeOrigin.cpp */, 0FBD7E671447998F00481315 /* CodeOrigin.h */, + 0F8F943F1667632D00D61971 /* CodeType.cpp */, 0F0B83A514BCF50400885B4F /* CodeType.h */, FEB63AA2159B9DA3008932A6 /* Comment.h */, 0F426A4A1460CD6B00131F8F /* DataFormat.h */, @@ -3054,6 +3075,8 @@ 0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */, 0F73D7AF165A143000ACAB71 /* ClosureCallStubRoutine.h in Headers */, 0FDDBFB61666EEDA00C55FEF /* DFGVariableAccessDataDump.h in Headers */, + 0F8F94411667633200D61971 /* CodeBlockHash.h in Headers */, + 0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3637,6 +3660,11 @@ 0F73D7AE165A142D00ACAB71 /* ClosureCallStubRoutine.cpp in Sources */, 0F9D3370165DBB90005AD387 /* Disassembler.cpp in Sources */, 0FDDBFB51666EED800C55FEF /* DFGVariableAccessDataDump.cpp in Sources */, + 0F8F943C1667631300D61971 /* CodeSpecializationKind.cpp in Sources */, + 0F8F94401667633000D61971 /* CodeBlockHash.cpp in Sources */, + 0F8F94421667633500D61971 /* CodeType.cpp in Sources */, + 0F8F94441667635400D61971 /* JITCode.cpp in Sources */, + 0F8F9446166764F100D61971 /* CodeOrigin.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/JavaScriptCore/LLIntOffsetsExtractor.pro b/Source/JavaScriptCore/LLIntOffsetsExtractor.pro index ae635c1b5..50cdd44ef 100644 --- a/Source/JavaScriptCore/LLIntOffsetsExtractor.pro +++ b/Source/JavaScriptCore/LLIntOffsetsExtractor.pro @@ -8,6 +8,8 @@ TEMPLATE = app TARGET = LLIntOffsetsExtractor +macx: DESTDIR = $$activeBuildConfig() + debug_and_release { CONFIG += force_build_all CONFIG += build_all diff --git a/Source/JavaScriptCore/Target.pri b/Source/JavaScriptCore/Target.pri index e1caa725f..f609de10b 100644 --- a/Source/JavaScriptCore/Target.pri +++ b/Source/JavaScriptCore/Target.pri @@ -55,6 +55,9 @@ SOURCES += \ bytecode/CallLinkInfo.cpp \ bytecode/CallLinkStatus.cpp \ bytecode/CodeBlock.cpp \ + bytecode/CodeBlockHash.cpp \ + bytecode/CodeOrigin.cpp \ + bytecode/CodeType.cpp \ bytecode/DFGExitProfile.cpp \ bytecode/ExecutionCounter.cpp \ bytecode/GetByIdStatus.cpp \ @@ -155,6 +158,7 @@ SOURCES += \ jit/JITArithmetic32_64.cpp \ jit/JITCall.cpp \ jit/JITCall32_64.cpp \ + jit/JITCode.cpp \ jit/JIT.cpp \ jit/JITDisassembler.cpp \ jit/JITExceptions.cpp \ @@ -191,6 +195,7 @@ SOURCES += \ runtime/BooleanPrototype.cpp \ runtime/CallData.cpp \ runtime/CodeCache.cpp \ + runtime/CodeSpecializationKind.cpp \ runtime/CommonIdentifiers.cpp \ runtime/Completion.cpp \ runtime/ConstructData.cpp \ diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h b/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h index ec025cec3..0c7fe12c6 100644 --- a/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h +++ b/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h @@ -1793,7 +1793,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) m_assembler.testlRegReg(reg, mask); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1807,7 +1807,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) else testlImm(mask.m_value, reg); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1821,7 +1821,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) else testImm(mask.m_value, address.offset, address.base); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1842,7 +1842,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) releaseScratch(scr); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1895,7 +1895,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) m_assembler.addlRegReg(src, dest); compare32(0, dest, Equal); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1930,7 +1930,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) compare32(0, dest, Equal); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1964,7 +1964,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) compare32(0, dest, static_cast<RelationalCondition>(cond)); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -1999,7 +1999,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) sub32(src, dest); compare32(0, dest, static_cast<RelationalCondition>(cond)); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } @@ -2040,7 +2040,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) or32(src, dest); compare32(0, dest, static_cast<RelationalCondition>(cond)); - if (cond == NotEqual) + if (cond == NonZero) // NotEqual return branchFalse(); return branchTrue(); } diff --git a/Source/JavaScriptCore/bytecode/CallLinkInfo.h b/Source/JavaScriptCore/bytecode/CallLinkInfo.h index 89403b0ca..57608435c 100644 --- a/Source/JavaScriptCore/bytecode/CallLinkInfo.h +++ b/Source/JavaScriptCore/bytecode/CallLinkInfo.h @@ -28,6 +28,7 @@ #include "ClosureCallStubRoutine.h" #include "CodeLocation.h" +#include "CodeSpecializationKind.h" #include "JITWriteBarrier.h" #include "JSFunction.h" #include "Opcode.h" @@ -65,6 +66,11 @@ struct CallLinkInfo : public BasicRawSentinelNode<CallLinkInfo> { if (isOnList()) remove(); } + + CodeSpecializationKind specializationKind() const + { + return specializationFromIsConstruct(callType == Construct); + } CodeLocationNearCall callReturnLocation; CodeLocationDataLabelPtr hotPathBegin; diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp index 6e1edaa0e..00209f236 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp @@ -62,6 +62,24 @@ namespace JSC { using namespace DFG; #endif +CodeBlockHash CodeBlock::hash() const +{ + return CodeBlockHash(ownerExecutable()->source(), specializationKind()); +} + +void CodeBlock::dumpAssumingJITType(PrintStream& out, JITCode::JITType jitType) const +{ + out.print("#", hash(), ":[", RawPointer(this), ", ", jitType, codeType()); + if (codeType() == FunctionCode) + out.print(specializationKind()); + out.print("]"); +} + +void CodeBlock::dump(PrintStream& out) const +{ + dumpAssumingJITType(out, getJITType()); +} + static String escapeQuotes(const String& str) { String result = str; @@ -480,7 +498,7 @@ void CodeBlock::printStructures(const Instruction* vPC) ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_call) || vPC[0].u.opcode == interpreter->getOpcode(op_call_eval) || vPC[0].u.opcode == interpreter->getOpcode(op_construct)); } -void CodeBlock::dump() +void CodeBlock::dumpBytecode() { // We only use the ExecState* for things that don't actually lead to JS execution, // like converting a JSString to a String. Hence the globalExec is appropriate. @@ -491,12 +509,12 @@ void CodeBlock::dump() for (size_t i = 0; i < instructions().size(); i += opcodeLengths[exec->interpreter()->getOpcodeID(instructions()[i].u.opcode)]) ++instructionCount; + dataLog(*this); dataLogF( - "%lu m_instructions; %lu bytes at %p (%s); %d parameter(s); %d callee register(s); %d variable(s)", + ": %lu m_instructions; %lu bytes; %d parameter(s); %d callee register(s); %d variable(s)", static_cast<unsigned long>(instructions().size()), static_cast<unsigned long>(instructions().size() * sizeof(Instruction)), - this, codeTypeToString(codeType()), m_numParameters, m_numCalleeRegisters, - m_numVars); + m_numParameters, m_numCalleeRegisters, m_numVars); if (symbolTable() && symbolTable()->captureCount()) dataLogF("; %d captured var(s)", symbolTable()->captureCount()); if (usesArguments()) { @@ -512,7 +530,7 @@ void CodeBlock::dump() const Instruction* begin = instructions().begin(); const Instruction* end = instructions().end(); for (const Instruction* it = begin; it != end; ++it) - dump(exec, begin, it); + dumpBytecode(exec, begin, it); if (!m_identifiers.isEmpty()) { dataLogF("\nIdentifiers:\n"); @@ -607,7 +625,7 @@ void CodeBlock::dump() dataLogF("\n"); } -void CodeBlock::dump(ExecState* exec, const Instruction* begin, const Instruction*& it) +void CodeBlock::dumpBytecode(ExecState* exec, const Instruction* begin, const Instruction*& it) { int location = it - begin; switch (exec->interpreter()->getOpcodeID(it->u.opcode)) { @@ -1458,11 +1476,11 @@ void CodeBlock::dump(ExecState* exec, const Instruction* begin, const Instructio } } -void CodeBlock::dump(unsigned bytecodeOffset) +void CodeBlock::dumpBytecode(unsigned bytecodeOffset) { ExecState* exec = m_globalObject->globalExec(); const Instruction* it = instructions().begin() + bytecodeOffset; - dump(exec, instructions().begin(), it); + dumpBytecode(exec, instructions().begin(), it); } #if DUMP_CODE_BLOCK_STATISTICS @@ -1892,7 +1910,7 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlin m_instructions = WTF::RefCountedArray<Instruction>(instructions); if (Options::dumpGeneratedBytecodes()) - dump(); + dumpBytecode(); m_globalData->finishedCompiling(this); } @@ -2186,7 +2204,7 @@ void CodeBlock::finalizeUnconditionally() for (unsigned i = 0; i < m_llintCallLinkInfos.size(); ++i) { if (m_llintCallLinkInfos[i].isLinked() && !Heap::isMarked(m_llintCallLinkInfos[i].callee.get())) { if (verboseUnlinking) - dataLogF("Clearing LLInt call from %p.\n", this); + dataLog("Clearing LLInt call from ", *this, "\n"); m_llintCallLinkInfos[i].unlink(); } if (!!m_llintCallLinkInfos[i].lastSeenCallee && !Heap::isMarked(m_llintCallLinkInfos[i].lastSeenCallee.get())) @@ -2199,14 +2217,14 @@ void CodeBlock::finalizeUnconditionally() // Check if we're not live. If we are, then jettison. if (!(shouldImmediatelyAssumeLivenessDuringScan() || m_dfgData->livenessHasBeenProved)) { if (verboseUnlinking) - dataLogF("Code block %p (executable %p) has dead weak references, jettisoning during GC.\n", this, ownerExecutable()); + dataLog(*this, " has dead weak references, jettisoning during GC.\n"); // Make sure that the baseline JIT knows that it should re-warm-up before // optimizing. alternative()->optimizeAfterWarmUp(); if (DFG::shouldShowDisassembly()) { - dataLogF("DFG CodeBlock %p will be jettisoned because of the following dead references:\n", this); + dataLog(*this, "will be jettisoned because of the following dead references:\n"); for (unsigned i = 0; i < m_dfgData->transitions.size(); ++i) { WeakReferenceTransition& transition = m_dfgData->transitions[i]; JSCell* origin = transition.m_codeOrigin.get(); @@ -2234,7 +2252,7 @@ void CodeBlock::finalizeUnconditionally() for (size_t size = m_putToBaseOperations.size(), i = 0; i < size; ++i) { if (m_putToBaseOperations[i].m_structure && !Heap::isMarked(m_putToBaseOperations[i].m_structure.get())) { if (verboseUnlinking) - dataLogF("Clearing putToBase info in %p.\n", this); + dataLog("Clearing putToBase info in ", *this, "\n"); m_putToBaseOperations[i].m_structure.clear(); } } @@ -2248,7 +2266,7 @@ void CodeBlock::finalizeUnconditionally() m_resolveOperations[i].last().m_structure.clear(); if (m_resolveOperations[i].last().m_structure && !Heap::isMarked(m_resolveOperations[i].last().m_structure.get())) { if (verboseUnlinking) - dataLogF("Clearing resolve info in %p.\n", this); + dataLog("Clearing resolve info in ", *this, "\n"); m_resolveOperations[i].last().m_structure.clear(); } } @@ -2262,13 +2280,23 @@ void CodeBlock::finalizeUnconditionally() if (ClosureCallStubRoutine* stub = callLinkInfo(i).stub.get()) { if (!Heap::isMarked(stub->structure()) || !Heap::isMarked(stub->executable())) { - if (verboseUnlinking) - dataLogF("Clearing closure call from %p to %p, stub routine %p.\n", this, stub->executable(), stub); + if (verboseUnlinking) { + dataLog( + "Clearing closure call from ", *this, " to ", + stub->executable()->hashFor(callLinkInfo(i).specializationKind()), + ", stub routine ", RawPointer(stub), ".\n"); + } callLinkInfo(i).unlink(*m_globalData, repatchBuffer); } } else if (!Heap::isMarked(callLinkInfo(i).callee.get())) { - if (verboseUnlinking) - dataLogF("Clearing call from %p to %p.\n", this, callLinkInfo(i).callee.get()); + if (verboseUnlinking) { + dataLog( + "Clearing call from ", *this, " to ", + RawPointer(callLinkInfo(i).callee.get()), " (", + callLinkInfo(i).callee.get()->executable()->hashFor( + callLinkInfo(i).specializationKind()), + ").\n"); + } callLinkInfo(i).unlink(*m_globalData, repatchBuffer); } } @@ -2303,7 +2331,7 @@ void CodeBlock::resetStubInternal(RepatchBuffer& repatchBuffer, StructureStubInf AccessType accessType = static_cast<AccessType>(stubInfo.accessType); if (verboseUnlinking) - dataLogF("Clearing structure cache (kind %d) in %p.\n", stubInfo.accessType, this); + dataLog("Clearing structure cache (kind ", static_cast<int>(stubInfo.accessType), ") in ", *this, ".\n"); if (isGetByIdAccess(accessType)) { if (getJITCode().jitType() == JITCode::DFGJIT) @@ -2769,7 +2797,7 @@ void CodeBlock::reoptimize() ASSERT(replacement()->alternative() == this); replacement()->tallyFrequentExitSites(); if (DFG::shouldShowDisassembly()) - dataLogF("DFG CodeBlock %p will be jettisoned due to reoptimization of %p.\n", replacement(), this); + dataLog(*replacement(), " will be jettisoned due to reoptimization of ", *this, ".\n"); replacement()->jettison(); countReoptimization(); optimizeAfterWarmUp(); @@ -2836,7 +2864,7 @@ void ProgramCodeBlock::jettison() ASSERT(JITCode::isOptimizingJIT(getJITType())); ASSERT(this == replacement()); if (DFG::shouldShowDisassembly()) - dataLogF("Jettisoning DFG CodeBlock %p.\n", this); + dataLog("Jettisoning ", *this, ".\n"); static_cast<ProgramExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData()); } @@ -2845,7 +2873,7 @@ void EvalCodeBlock::jettison() ASSERT(JITCode::isOptimizingJIT(getJITType())); ASSERT(this == replacement()); if (DFG::shouldShowDisassembly()) - dataLogF("Jettisoning DFG CodeBlock %p.\n", this); + dataLog("Jettisoning ", *this, ".\n"); static_cast<EvalExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData()); } @@ -2854,7 +2882,7 @@ void FunctionCodeBlock::jettison() ASSERT(JITCode::isOptimizingJIT(getJITType())); ASSERT(this == replacement()); if (DFG::shouldShowDisassembly()) - dataLogF("Jettisoning DFG CodeBlock %p.\n", this); + dataLog("Jettisoning ", *this, ".\n"); static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(*globalData(), m_isConstructor ? CodeForConstruct : CodeForCall); } @@ -2948,7 +2976,7 @@ void CodeBlock::updateAllPredictions(OperationInProgress operation) bool CodeBlock::shouldOptimizeNow() { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Considering optimizing %p...\n", this); + dataLog("Considering optimizing ", *this, "...\n"); #endif #if ENABLE(VERBOSE_VALUE_PROFILE) @@ -2996,7 +3024,7 @@ void CodeBlock::tallyFrequentExitSites() continue; #if DFG_ENABLE(DEBUG_VERBOSE) - dataLogF("OSR exit #%u (bc#%u, @%u, %s) for code block %p occurred frequently; counting as frequent exit site.\n", i, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex, DFG::exitKindToString(exit.m_kind), this); + dataLog("OSR exit #", i, " (bc#", exit.m_codeOrigin.bytecodeIndex, ", @", exit.m_nodeIndex, ", ", DFG::exitKindToString(exit.m_kind), ") for ", *this, " occurred frequently: counting as frequent exit site.\n"); #endif } } @@ -3005,7 +3033,7 @@ void CodeBlock::tallyFrequentExitSites() #if ENABLE(VERBOSE_VALUE_PROFILE) void CodeBlock::dumpValueProfiles() { - dataLogF("ValueProfile for %p:\n", this); + dataLog("ValueProfile for ", *this, ":\n"); for (unsigned i = 0; i < totalNumberOfValueProfiles(); ++i) { ValueProfile* profile = getFromAllValueProfiles(i); if (profile->m_bytecodeOffset < 0) { @@ -3020,12 +3048,12 @@ void CodeBlock::dumpValueProfiles() profile->dump(WTF::dataFile()); dataLogF("\n"); } - dataLogF("RareCaseProfile for %p:\n", this); + dataLog("RareCaseProfile for ", *this, ":\n"); for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) { RareCaseProfile* profile = rareCaseProfile(i); dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter); } - dataLogF("SpecialFastCaseProfile for %p:\n", this); + dataLog("SpecialFastCaseProfile for ", *this, ":\n"); for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) { RareCaseProfile* profile = specialFastCaseProfile(i); dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter); diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.h b/Source/JavaScriptCore/bytecode/CodeBlock.h index 63a03630e..20f1e7452 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.h +++ b/Source/JavaScriptCore/bytecode/CodeBlock.h @@ -35,6 +35,7 @@ #include "BytecodeConventions.h" #include "CallLinkInfo.h" #include "CallReturnOffsetToBytecodeOffset.h" +#include "CodeBlockHash.h" #include "CodeOrigin.h" #include "CodeType.h" #include "Comment.h" @@ -128,6 +129,10 @@ namespace JSC { public: JS_EXPORT_PRIVATE virtual ~CodeBlock(); + CodeBlockHash hash() const; + void dumpAssumingJITType(PrintStream&, JITCode::JITType) const; + void dump(PrintStream&) const; + int numParameters() const { return m_numParameters; } void setNumParameters(int newValue); @@ -138,11 +143,9 @@ namespace JSC { PassOwnPtr<CodeBlock> releaseAlternative() { return m_alternative.release(); } void setAlternative(PassOwnPtr<CodeBlock> alternative) { m_alternative = alternative; } - CodeSpecializationKind specializationKind() + CodeSpecializationKind specializationKind() const { - if (m_isConstructor) - return CodeForConstruct; - return CodeForCall; + return specializationFromIsConstruct(m_isConstructor); } #if ENABLE(JIT) @@ -163,8 +166,8 @@ namespace JSC { static void dumpStatistics(); - void dump(); - void dump(unsigned bytecodeOffset); + void dumpBytecode(); + void dumpBytecode(unsigned bytecodeOffset); void printStructures(const Instruction*); void printStructure(const char* name, const Instruction*, int operand); @@ -472,7 +475,7 @@ namespace JSC { } JITCode& getJITCode() { return m_jitCode; } MacroAssemblerCodePtr getJITCodeWithArityCheck() { return m_jitCodeWithArityCheck; } - JITCode::JITType getJITType() { return m_jitCode.jitType(); } + JITCode::JITType getJITType() const { return m_jitCode.jitType(); } ExecutableMemoryHandle* executableMemory() { return getJITCode().getExecutableMemory(); } virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex) = 0; virtual void jettison() = 0; @@ -1212,7 +1215,7 @@ namespace JSC { m_constantRegisters[i].set(*m_globalData, ownerExecutable(), constants[i].get()); } - void dump(ExecState*, const Instruction* begin, const Instruction*&); + void dumpBytecode(ExecState*, const Instruction* begin, const Instruction*&); CString registerName(ExecState*, int r) const; void printUnaryOp(ExecState*, int location, const Instruction*&, const char* op); diff --git a/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp b/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp new file mode 100644 index 000000000..79fe9ccb5 --- /dev/null +++ b/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CodeBlockHash.h" + +#include "SourceCode.h" +#include <wtf/SHA1.h> + +namespace JSC { + +#define TABLE ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") + +CodeBlockHash::CodeBlockHash(const char* string) + : m_hash(0) +{ + if (strlen(string) != 6) + CRASH(); + + for (unsigned i = 0; i < 6; ++i) { + m_hash *= 62; + unsigned c = string[i]; + if (c >= 'A' && c <= 'Z') { + m_hash += c - 'A'; + continue; + } + if (c >= 'a' && c <= 'z') { + m_hash += c - 'a' + 26; + continue; + } + ASSERT(c >= '0' && c <= '9'); + m_hash += c - '0' + 26 * 2; + } +} + +CodeBlockHash::CodeBlockHash(const SourceCode& sourceCode, CodeSpecializationKind kind) + : m_hash(0) +{ + SHA1 sha1; + sha1.addBytes(sourceCode.toString().utf8()); + Vector<uint8_t, 20> digest; + sha1.computeHash(digest); + m_hash += digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24); + m_hash ^= static_cast<unsigned>(kind); +} + +void CodeBlockHash::dump(PrintStream& out) const +{ + ASSERT(strlen(TABLE) == 62); + + char buffer[7]; + unsigned accumulator = m_hash; + for (unsigned i = 6; i--;) { + buffer[i] = TABLE[accumulator % 62]; + accumulator /= 62; + } + buffer[6] = 0; + +#if !ASSERT_DISABLED + CodeBlockHash recompute(buffer); + ASSERT(recompute == *this); +#endif // !ASSERT_DISABLED + + out.print(buffer); +} + +} // namespace JSC + diff --git a/Source/JavaScriptCore/bytecode/CodeBlockHash.h b/Source/JavaScriptCore/bytecode/CodeBlockHash.h new file mode 100644 index 000000000..20de8ed48 --- /dev/null +++ b/Source/JavaScriptCore/bytecode/CodeBlockHash.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CodeBlockHash_h +#define CodeBlockHash_h + +#include "CodeSpecializationKind.h" +#include <wtf/PrintStream.h> + +// CodeBlock hashes are useful for informally identifying code blocks. They correspond +// to the low 32 bits of a SHA1 hash of the source code with two low bit flipped +// according to the role that the code block serves (call, construct). Additionally, the +// hashes are typically operated over using a string in which the hash is transformed +// into a 6-byte alphanumeric representation. This can be retrieved by using +// toString(const CodeBlockHash&). Finally, we support CodeBlockHashes for native +// functions, in which case the hash is replaced by the function address. + +namespace JSC { + +class SourceCode; + +class CodeBlockHash { +public: + CodeBlockHash() + : m_hash(0) + { + } + + explicit CodeBlockHash(unsigned hash) + : m_hash(hash) + { + } + + CodeBlockHash(const SourceCode&, CodeSpecializationKind); + + explicit CodeBlockHash(const char*); + + unsigned hash() const { return m_hash; } + + void dump(PrintStream&) const; + + // Comparison methods useful for bisection. + bool operator==(const CodeBlockHash& other) const { return hash() == other.hash(); } + bool operator!=(const CodeBlockHash& other) const { return hash() != other.hash(); } + bool operator<(const CodeBlockHash& other) const { return hash() < other.hash(); } + bool operator>(const CodeBlockHash& other) const { return hash() > other.hash(); } + bool operator<=(const CodeBlockHash& other) const { return hash() <= other.hash(); } + bool operator>=(const CodeBlockHash& other) const { return hash() >= other.hash(); } + +private: + unsigned m_hash; +}; + +} // namespace JSC + +#endif // CodeBlockHash_h diff --git a/Source/JavaScriptCore/bytecode/CodeBlockWithJITType.h b/Source/JavaScriptCore/bytecode/CodeBlockWithJITType.h new file mode 100644 index 000000000..d87085841 --- /dev/null +++ b/Source/JavaScriptCore/bytecode/CodeBlockWithJITType.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CodeBlockWithJITType_h +#define CodeBlockWithJITType_h + +#include "CodeBlock.h" + +namespace JSC { + +// We sometimes what to print the CodeBlock's ID before setting its JITCode. At that +// point the CodeBlock will claim a bogus JITType. This helper class lets us do that. + +class CodeBlockWithJITType { +public: + CodeBlockWithJITType(CodeBlock* codeBlock, JITCode::JITType jitType) + : m_codeBlock(codeBlock) + , m_jitType(jitType) + { + } + + void dump(PrintStream& out) const + { + m_codeBlock->dumpAssumingJITType(out, m_jitType); + } +private: + CodeBlock* m_codeBlock; + JITCode::JITType m_jitType; +}; + +} // namespace JSC + +#endif // CodeBlockWithJITType_h + diff --git a/Source/JavaScriptCore/bytecode/CodeOrigin.cpp b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp new file mode 100644 index 000000000..92e2b0fc9 --- /dev/null +++ b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CodeOrigin.h" + +#include "Executable.h" + +namespace JSC { + +unsigned CodeOrigin::inlineDepthForCallFrame(InlineCallFrame* inlineCallFrame) +{ + unsigned result = 1; + for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame) + result++; + return result; +} + +unsigned CodeOrigin::inlineDepth() const +{ + return inlineDepthForCallFrame(inlineCallFrame); +} + +Vector<CodeOrigin> CodeOrigin::inlineStack() const +{ + Vector<CodeOrigin> result(inlineDepth()); + result.last() = *this; + unsigned index = result.size() - 2; + for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame) + result[index--] = current->caller; + return result; +} + +CodeBlockHash InlineCallFrame::hash() const +{ + return executable->hashFor(specializationKind()); +} + +} // namespace JSC + diff --git a/Source/JavaScriptCore/bytecode/CodeOrigin.h b/Source/JavaScriptCore/bytecode/CodeOrigin.h index c9c0f7005..d8fbf7328 100644 --- a/Source/JavaScriptCore/bytecode/CodeOrigin.h +++ b/Source/JavaScriptCore/bytecode/CodeOrigin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,6 +26,8 @@ #ifndef CodeOrigin_h #define CodeOrigin_h +#include "CodeBlockHash.h" +#include "CodeSpecializationKind.h" #include "ValueRecovery.h" #include "WriteBarrier.h" #include <wtf/BitVector.h> @@ -98,6 +100,10 @@ struct InlineCallFrame { BitVector capturedVars; // Indexed by the machine call frame's variable numbering. unsigned stackOffset : 31; bool isCall : 1; + + CodeSpecializationKind specializationKind() const { return specializationFromIsCall(isCall); } + + CodeBlockHash hash() const; }; struct CodeOriginAtCallReturnOffset { @@ -105,36 +111,12 @@ struct CodeOriginAtCallReturnOffset { unsigned callReturnOffset; }; -inline unsigned CodeOrigin::inlineDepthForCallFrame(InlineCallFrame* inlineCallFrame) -{ - unsigned result = 1; - for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame) - result++; - return result; -} - -inline unsigned CodeOrigin::inlineDepth() const -{ - return inlineDepthForCallFrame(inlineCallFrame); -} - inline bool CodeOrigin::operator==(const CodeOrigin& other) const { return bytecodeIndex == other.bytecodeIndex && inlineCallFrame == other.inlineCallFrame; } -// Get the inline stack. This is slow, and is intended for debugging only. -inline Vector<CodeOrigin> CodeOrigin::inlineStack() const -{ - Vector<CodeOrigin> result(inlineDepth()); - result.last() = *this; - unsigned index = result.size() - 2; - for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame) - result[index--] = current->caller; - return result; -} - inline unsigned getCallReturnOffsetForCodeOrigin(CodeOriginAtCallReturnOffset* data) { return data->callReturnOffset; diff --git a/Source/JavaScriptCore/bytecode/CodeType.cpp b/Source/JavaScriptCore/bytecode/CodeType.cpp new file mode 100644 index 000000000..8b2cad56a --- /dev/null +++ b/Source/JavaScriptCore/bytecode/CodeType.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CodeType.h" + +#include <wtf/PrintStream.h> + +namespace WTF { + +void printInternal(PrintStream& out, JSC::CodeType codeType) +{ + switch (codeType) { + case JSC::GlobalCode: + out.print("Global"); + return; + case JSC::EvalCode: + out.print("Eval"); + return; + case JSC::FunctionCode: + out.print("Function"); + return; + default: + CRASH(); + return; + } +} + +} // namespace WTF + diff --git a/Source/JavaScriptCore/bytecode/CodeType.h b/Source/JavaScriptCore/bytecode/CodeType.h index d33677ae7..04afc1109 100644 --- a/Source/JavaScriptCore/bytecode/CodeType.h +++ b/Source/JavaScriptCore/bytecode/CodeType.h @@ -32,22 +32,14 @@ namespace JSC { enum CodeType { GlobalCode, EvalCode, FunctionCode }; -inline const char* codeTypeToString(CodeType codeType) -{ - switch (codeType) { - case GlobalCode: - return "GlobalCode"; - case EvalCode: - return "EvalCode"; - case FunctionCode: - return "FunctionCode"; - default: - ASSERT_NOT_REACHED(); - return 0; - } -} - } // namespace JSC +namespace WTF { + +class PrintStream; +void printInternal(PrintStream&, JSC::CodeType); + +} // namespace WTF + #endif // CodeType_h diff --git a/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp b/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp index 12a404981..e619a0376 100644 --- a/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp +++ b/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp @@ -160,11 +160,9 @@ void ExecutionCounter::reset() m_activeThreshold = 0; } -const char* ExecutionCounter::status() const +void ExecutionCounter::dump(PrintStream& out) const { - static char result[80]; - snprintf(result, sizeof(result), "%lf/%lf, %d", count(), static_cast<double>(m_activeThreshold), m_counter); - return result; + out.printf("%lf/%lf, %d", count(), static_cast<double>(m_activeThreshold), m_counter); } } // namespace JSC diff --git a/Source/JavaScriptCore/bytecode/ExecutionCounter.h b/Source/JavaScriptCore/bytecode/ExecutionCounter.h index f40650a31..c755c0445 100644 --- a/Source/JavaScriptCore/bytecode/ExecutionCounter.h +++ b/Source/JavaScriptCore/bytecode/ExecutionCounter.h @@ -28,6 +28,7 @@ #include "JSGlobalObject.h" #include "Options.h" +#include <wtf/PrintStream.h> #include <wtf/SimpleStats.h> namespace JSC { @@ -41,7 +42,7 @@ public: void setNewThreshold(int32_t threshold, CodeBlock*); void deferIndefinitely(); double count() const { return static_cast<double>(m_totalCount) + m_counter; } - const char* status() const; + void dump(PrintStream&) const; static double applyMemoryUsageHeuristics(int32_t value, CodeBlock*); static int32_t applyMemoryUsageHeuristicsAndConvertToInt(int32_t value, CodeBlock*); template<typename T> diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp index c5ffb1fc6..3facd63bb 100644 --- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp +++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp @@ -3645,21 +3645,23 @@ void ByteCodeParser::parseCodeBlock() CodeBlock* codeBlock = m_inlineStackTop->m_codeBlock; #if DFG_ENABLE(DEBUG_VERBOSE) - dataLogF("Parsing code block %p. codeType = %s, captureCount = %u, needsFullScopeChain = %s, needsActivation = %s, isStrictMode = %s\n", - codeBlock, - codeTypeToString(codeBlock->codeType()), - codeBlock->symbolTable() ? codeBlock->symbolTable()->captureCount() : 0, - codeBlock->needsFullScopeChain()?"true":"false", - codeBlock->ownerExecutable()->needsActivation()?"true":"false", - codeBlock->ownerExecutable()->isStrictMode()?"true":"false"); - codeBlock->baselineVersion()->dump(); + dataLog( + "Parsing ", *codeBlock, + ": captureCount = ", codeBlock->symbolTable() ? codeBlock->symbolTable()->captureCount() : 0, + ", needsFullScopeChain = ", codeBlock->needsFullScopeChain(), + ", needsActivation = ", codeBlock->ownerExecutable()->needsActivation(), + ", isStrictMode = ", codeBlock->ownerExecutable()->isStrictMode(), "\n"); + codeBlock->baselineVersion()->dumpBytecode(); #endif for (unsigned jumpTargetIndex = 0; jumpTargetIndex <= codeBlock->numberOfJumpTargets(); ++jumpTargetIndex) { // The maximum bytecode offset to go into the current basicblock is either the next jump target, or the end of the instructions. unsigned limit = jumpTargetIndex < codeBlock->numberOfJumpTargets() ? codeBlock->jumpTarget(jumpTargetIndex) : codeBlock->instructions().size(); #if DFG_ENABLE(DEBUG_VERBOSE) - dataLogF("Parsing bytecode with limit %p bc#%u at inline depth %u.\n", m_inlineStackTop->executable(), limit, CodeOrigin::inlineDepthForCallFrame(m_inlineStackTop->m_inlineCallFrame)); + dataLog( + "Parsing bytecode with limit ", m_inlineStackTop->m_inlineCallFrame->hash(), + " bc#", limit, " at inline depth ", + CodeOrigin::inlineDepthForCallFrame(m_inlineStackTop->m_inlineCallFrame), ".\n"); #endif ASSERT(m_currentIndex < limit); diff --git a/Source/JavaScriptCore/dfg/DFGDisassembler.cpp b/Source/JavaScriptCore/dfg/DFGDisassembler.cpp index f09b974a5..a7fccd58f 100644 --- a/Source/JavaScriptCore/dfg/DFGDisassembler.cpp +++ b/Source/JavaScriptCore/dfg/DFGDisassembler.cpp @@ -28,6 +28,7 @@ #if ENABLE(DFG_JIT) +#include "CodeBlockWithJITType.h" #include "DFGGraph.h" namespace JSC { namespace DFG { @@ -43,7 +44,7 @@ void Disassembler::dump(PrintStream& out, LinkBuffer& linkBuffer) { m_graph.m_dominators.computeIfNecessary(m_graph); - out.print("Generated JIT code for DFG CodeBlock ", RawPointer(m_graph.m_codeBlock), ", instruction count = ", m_graph.m_codeBlock->instructionCount(), ":\n"); + out.print("Generated JIT code for ", CodeBlockWithJITType(m_graph.m_codeBlock, JITCode::DFGJIT), ", instruction count = ", m_graph.m_codeBlock->instructionCount(), ":\n"); out.print(" Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n"); const char* prefix = " "; diff --git a/Source/JavaScriptCore/dfg/DFGGraph.cpp b/Source/JavaScriptCore/dfg/DFGGraph.cpp index 270f53b87..c8008230a 100644 --- a/Source/JavaScriptCore/dfg/DFGGraph.cpp +++ b/Source/JavaScriptCore/dfg/DFGGraph.cpp @@ -88,14 +88,14 @@ void Graph::dumpCodeOrigin(PrintStream& out, const char* prefix, NodeIndex prevN for (unsigned i = previousInlineStack.size(); i-- > indexOfDivergence;) { out.print(prefix); printWhiteSpace(out, i * 2); - out.print("<-- ", RawPointer(previousInlineStack[i].inlineCallFrame->executable.get()), "\n"); + out.print("<-- #", previousInlineStack[i].inlineCallFrame->hash(), "\n"); } // Print the pushes. for (unsigned i = indexOfDivergence; i < currentInlineStack.size(); ++i) { out.print(prefix); printWhiteSpace(out, i * 2); - out.print("--> ", RawPointer(currentInlineStack[i].inlineCallFrame->executable.get()), "\n"); + out.print("--> #", currentInlineStack[i].inlineCallFrame->hash(), "\n"); } } diff --git a/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp b/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp index c65443e29..5d2155cba 100644 --- a/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp +++ b/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp @@ -32,6 +32,7 @@ #include "DFGCommon.h" #include "LinkBuffer.h" #include "RepatchBuffer.h" +#include <wtf/StringPrintStream.h> namespace JSC { namespace DFG { @@ -81,7 +82,10 @@ void compileOSRExit(ExecState* exec) recovery = &codeBlock->speculationRecovery(exit.m_recoveryIndex - 1); #if DFG_ENABLE(DEBUG_VERBOSE) - dataLogF("Generating OSR exit #%u (seq#%u, bc#%u, @%u, %s) for code block %p.\n", exitIndex, exit.m_streamIndex, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex, exitKindToString(exit.m_kind), codeBlock); + dataLog( + "Generating OSR exit #", exitIndex, " (seq#", exit.m_streamIndex, + ", bc#", exit.m_codeOrigin.bytecodeIndex, ", @", exit.m_nodeIndex, ", ", + exitKindToString(exit.m_kind), ") for ", *codeBlock, ".\n"); #endif { @@ -95,9 +99,9 @@ void compileOSRExit(ExecState* exec) exit.m_code = FINALIZE_CODE_IF( shouldShowDisassembly(), patchBuffer, - ("DFG OSR exit #%u (bc#%u, @%u, %s) from CodeBlock %p", - exitIndex, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex, - exitKindToString(exit.m_kind), codeBlock)); + ("DFG OSR exit #%u (bc#%u, @%u, %s) from %s", + exitIndex, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex, + exitKindToString(exit.m_kind), toCString(*codeBlock).data())); } { diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp index 909c657a1..ad595ae1b 100644 --- a/Source/JavaScriptCore/dfg/DFGOperations.cpp +++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp @@ -1522,22 +1522,24 @@ void DFG_OPERATION debugOperationPrintSpeculationFailure(ExecState* exec, void* SpeculationFailureDebugInfo* debugInfo = static_cast<SpeculationFailureDebugInfo*>(debugInfoRaw); CodeBlock* codeBlock = debugInfo->codeBlock; CodeBlock* alternative = codeBlock->alternative(); - dataLogF("Speculation failure in %p at @%u with executeCounter = %s, " - "reoptimizationRetryCounter = %u, optimizationDelayCounter = %u, " - "osrExitCounter = %u\n", - codeBlock, - debugInfo->nodeIndex, - alternative ? alternative->jitExecuteCounter().status() : 0, - alternative ? alternative->reoptimizationRetryCounter() : 0, - alternative ? alternative->optimizationDelayCounter() : 0, - codeBlock->osrExitCounter()); + dataLog( + "Speculation failure in ", *codeBlock, " at @", debugInfo->nodeIndex, + " with "); + if (alternative) { + dataLog( + "executeCounter = ", alternative->jitExecuteCounter(), + ", reoptimizationRetryCounter = ", alternative->reoptimizationRetryCounter(), + ", optimizationDelayCounter = ", alternative->optimizationDelayCounter()); + } else + dataLog("no alternative code block (i.e. we've been jettisoned)"); + dataLog(", osrExitCounter = ", codeBlock->osrExitCounter(), "\n"); } #endif extern "C" void DFG_OPERATION triggerReoptimizationNow(CodeBlock* codeBlock) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("%p: Entered reoptimize\n", codeBlock); + dataLog(*codeBlock, ": Entered reoptimize\n"); #endif // We must be called with the baseline code block. ASSERT(JITCode::isBaselineCode(codeBlock->getJITType())); diff --git a/Source/JavaScriptCore/dfg/DFGRepatch.cpp b/Source/JavaScriptCore/dfg/DFGRepatch.cpp index a20eb544a..07a509061 100644 --- a/Source/JavaScriptCore/dfg/DFGRepatch.cpp +++ b/Source/JavaScriptCore/dfg/DFGRepatch.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,6 +37,7 @@ #include "Operations.h" #include "PolymorphicPutByIdList.h" #include "RepatchBuffer.h" +#include <wtf/StringPrintStream.h> namespace JSC { namespace DFG { @@ -235,8 +236,8 @@ static void generateProtoChainAccessStub(ExecState* exec, StructureStubInfo& stu stubRoutine = FINALIZE_CODE_FOR_DFG_STUB( patchBuffer, - ("DFG prototype chain access stub for CodeBlock %p, return point %p", - exec->codeBlock(), successLabel.executableAddress())); + ("DFG prototype chain access stub for %s, return point %p", + toCString(*exec->codeBlock()).data(), successLabel.executableAddress())); } static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo) @@ -296,9 +297,9 @@ static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier stubInfo.stubRoutine = FINALIZE_CODE_FOR_DFG_STUB( patchBuffer, - ("DFG GetById array length stub for CodeBlock %p, return point %p", - exec->codeBlock(), stubInfo.callReturnLocation.labelAtOffset( - stubInfo.patch.dfg.deltaCallToDone).executableAddress())); + ("DFG GetById array length stub for %s, return point %p", + toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset( + stubInfo.patch.dfg.deltaCallToDone).executableAddress())); RepatchBuffer repatchBuffer(codeBlock); replaceWithJump(repatchBuffer, stubInfo, stubInfo.stubRoutine->code().code()); @@ -525,9 +526,9 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi createJITStubRoutine( FINALIZE_DFG_CODE( patchBuffer, - ("DFG GetById polymorphic list access for CodeBlock %p, return point %p", - exec->codeBlock(), stubInfo.callReturnLocation.labelAtOffset( - stubInfo.patch.dfg.deltaCallToDone).executableAddress())), + ("DFG GetById polymorphic list access for %s, return point %p", + toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset( + stubInfo.patch.dfg.deltaCallToDone).executableAddress())), *globalData, codeBlock->ownerExecutable(), slot.cachedPropertyType() == PropertySlot::Getter @@ -737,9 +738,9 @@ static void emitPutReplaceStub( stubRoutine = FINALIZE_CODE_FOR_DFG_STUB( patchBuffer, - ("DFG PutById replace stub for CodeBlock %p, return point %p", - exec->codeBlock(), stubInfo.callReturnLocation.labelAtOffset( - stubInfo.patch.dfg.deltaCallToDone).executableAddress())); + ("DFG PutById replace stub for %s, return point %p", + toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset( + stubInfo.patch.dfg.deltaCallToDone).executableAddress())); } static void emitPutTransitionStub( @@ -937,11 +938,11 @@ static void emitPutTransitionStub( createJITStubRoutine( FINALIZE_DFG_CODE( patchBuffer, - ("DFG PutById %stransition stub (%p -> %p) for CodeBlock %p, return point %p", - structure->outOfLineCapacity() != oldStructure->outOfLineCapacity() ? "reallocating " : "", - oldStructure, structure, - exec->codeBlock(), stubInfo.callReturnLocation.labelAtOffset( - stubInfo.patch.dfg.deltaCallToDone).executableAddress())), + ("DFG PutById %stransition stub (%p -> %p) for %s, return point %p", + structure->outOfLineCapacity() != oldStructure->outOfLineCapacity() ? "reallocating " : "", + oldStructure, structure, + toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset( + stubInfo.patch.dfg.deltaCallToDone).executableAddress())), *globalData, exec->codeBlock()->ownerExecutable(), structure->outOfLineCapacity() != oldStructure->outOfLineCapacity(), @@ -1230,9 +1231,9 @@ void dfgLinkClosureCall(ExecState* exec, CallLinkInfo& callLinkInfo, CodeBlock* RefPtr<ClosureCallStubRoutine> stubRoutine = adoptRef(new ClosureCallStubRoutine( FINALIZE_DFG_CODE( patchBuffer, - ("DFG closure call stub for CodeBlock %p, return point %p, target %p (CodeBlock %p)", - callerCodeBlock, callLinkInfo.callReturnLocation.labelAtOffset(0).executableAddress(), - codePtr.executableAddress(), calleeCodeBlock)), + ("DFG closure call stub for %s, return point %p, target %p (%s)", + toCString(*callerCodeBlock).data(), callLinkInfo.callReturnLocation.labelAtOffset(0).executableAddress(), + codePtr.executableAddress(), toCString(*calleeCodeBlock).data())), *globalData, callerCodeBlock->ownerExecutable(), structure, executable, callLinkInfo.codeOrigin)); RepatchBuffer repatchBuffer(callerCodeBlock); diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp index ad89505fc..9b69d1b3d 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.cpp +++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp @@ -380,7 +380,7 @@ void Interpreter::dumpCallFrame(CallFrame*) void Interpreter::dumpCallFrame(CallFrame* callFrame) { - callFrame->codeBlock()->dump(); + callFrame->codeBlock()->dumpBytecode(); dumpRegisters(callFrame); } diff --git a/Source/JavaScriptCore/jit/JITCode.cpp b/Source/JavaScriptCore/jit/JITCode.cpp new file mode 100644 index 000000000..5cfa6304b --- /dev/null +++ b/Source/JavaScriptCore/jit/JITCode.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JITCode.h" + +#include <wtf/PrintStream.h> + +namespace WTF { + +void printInternal(PrintStream& out, JSC::JITCode::JITType type) +{ + switch (type) { + case JSC::JITCode::None: + out.print("None"); + return; + case JSC::JITCode::HostCallThunk: + out.print("Host"); + return; + case JSC::JITCode::InterpreterThunk: + out.print("LLInt"); + return; + case JSC::JITCode::BaselineJIT: + out.print("Baseline"); + return; + case JSC::JITCode::DFGJIT: + out.print("DFG"); + return; + default: + CRASH(); + return; + } +} + +} // namespace WTF + diff --git a/Source/JavaScriptCore/jit/JITCode.h b/Source/JavaScriptCore/jit/JITCode.h index 93fa88a23..0929397ee 100644 --- a/Source/JavaScriptCore/jit/JITCode.h +++ b/Source/JavaScriptCore/jit/JITCode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -157,7 +157,7 @@ namespace JSC { return m_ref.executableMemory(); } - JITType jitType() + JITType jitType() const { return m_jitType; } @@ -187,6 +187,13 @@ namespace JSC { #endif // ENABLE(JIT) || ENABLE(LLINT) }; -}; +} // namespace JSC + +namespace WTF { + +class PrintStream; +void printInternal(PrintStream&, JSC::JITCode::JITType); + +} // namespace WTF #endif diff --git a/Source/JavaScriptCore/jit/JITDisassembler.cpp b/Source/JavaScriptCore/jit/JITDisassembler.cpp index 0ec72e205..eaef844bf 100644 --- a/Source/JavaScriptCore/jit/JITDisassembler.cpp +++ b/Source/JavaScriptCore/jit/JITDisassembler.cpp @@ -29,6 +29,7 @@ #if ENABLE(JIT) #include "CodeBlock.h" +#include "CodeBlockWithJITType.h" #include "JIT.h" namespace JSC { @@ -46,7 +47,7 @@ JITDisassembler::~JITDisassembler() void JITDisassembler::dump(PrintStream& out, LinkBuffer& linkBuffer) { - out.print("Baseline JIT code for CodeBlock ", RawPointer(m_codeBlock), ", instruction count = ", m_codeBlock->instructionCount(), "\n"); + out.print("Baseline JIT code for ", CodeBlockWithJITType(m_codeBlock, JITCode::BaselineJIT), ", instruction count = ", m_codeBlock->instructionCount(), "\n"); out.print(" Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n"); dumpDisassembly(out, linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]); @@ -78,7 +79,7 @@ void JITDisassembler::dumpForInstructions(PrintStream& out, LinkBuffer& linkBuff continue; } out.print(prefix); - m_codeBlock->dump(i); + m_codeBlock->dumpBytecode(i); for (unsigned nextIndex = i + 1; ; nextIndex++) { if (nextIndex >= labels.size()) { dumpDisassembly(out, linkBuffer, labels[i], endLabel); diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp index 57a5685eb..e377c8adb 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp @@ -42,6 +42,7 @@ #include "RepatchBuffer.h" #include "ResultType.h" #include "SamplingTool.h" +#include <wtf/StringPrintStream.h> #ifndef NDEBUG #include <stdio.h> @@ -746,8 +747,8 @@ void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure stubInfo->stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline put_by_id transition for CodeBlock %p, return point %p", - m_codeBlock, returnAddress.value())), + ("Baseline put_by_id transition for %s, return point %p", + toCString(*m_codeBlock).data(), returnAddress.value())), *m_globalData, m_codeBlock->ownerExecutable(), willNeedStorageRealloc, @@ -815,9 +816,10 @@ void JIT::privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress) // Track the stub we have created so that it will be deleted later. stubInfo->stubRoutine = FINALIZE_CODE_FOR_STUB( patchBuffer, - ("Basline JIT get_by_id array length stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())); + ("Basline JIT get_by_id array length stub for %s, return point %p", + toCString(*m_codeBlock).data(), + stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())); // Finally patch the jump to slow case back in the hot path to jump here instead. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck); @@ -883,9 +885,9 @@ void JIT::privateCompileGetByIdProto(StructureStubInfo* stubInfo, Structure* str stubInfo->stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline JIT get_by_id proto stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline JIT get_by_id proto stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -948,9 +950,9 @@ void JIT::privateCompileGetByIdSelfList(StructureStubInfo* stubInfo, Polymorphic RefPtr<JITStubRoutine> stubCode = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline JIT get_by_id list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline JIT get_by_id list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1022,9 +1024,9 @@ void JIT::privateCompileGetByIdProtoList(StructureStubInfo* stubInfo, Polymorphi RefPtr<JITStubRoutine> stubCode = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline JIT get_by_id proto list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline JIT get_by_id proto list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1099,9 +1101,9 @@ void JIT::privateCompileGetByIdChainList(StructureStubInfo* stubInfo, Polymorphi RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline JIT get_by_id chain list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline JIT get_by_id chain list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1174,9 +1176,9 @@ void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* str RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline JIT get_by_id chain stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline JIT get_by_id chain stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1428,7 +1430,7 @@ void JIT::privateCompileGetByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAd byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB( patchBuffer, - ("Baseline get_by_val stub for CodeBlock %p, return point %p", m_codeBlock, returnAddress.value())); + ("Baseline get_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value())); RepatchBuffer repatchBuffer(m_codeBlock); repatchBuffer.relink(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code())); @@ -1498,7 +1500,7 @@ void JIT::privateCompilePutByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAd byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB( patchBuffer, - ("Baseline put_by_val stub for CodeBlock %p, return point %p", m_codeBlock, returnAddress.value())); + ("Baseline put_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value())); RepatchBuffer repatchBuffer(m_codeBlock); repatchBuffer.relink(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code())); diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp index be146a402..391dd1d8c 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp @@ -42,6 +42,7 @@ #include "RepatchBuffer.h" #include "ResultType.h" #include "SamplingTool.h" +#include <wtf/StringPrintStream.h> #ifndef NDEBUG #include <stdio.h> @@ -704,8 +705,8 @@ void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure stubInfo->stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline put_by_id transition stub for CodeBlock %p, return point %p", - m_codeBlock, returnAddress.value())), + ("Baseline put_by_id transition stub for %s, return point %p", + toCString(*m_codeBlock).data(), returnAddress.value())), *m_globalData, m_codeBlock->ownerExecutable(), willNeedStorageRealloc, @@ -778,9 +779,9 @@ void JIT::privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress) // Track the stub we have created so that it will be deleted later. stubInfo->stubRoutine = FINALIZE_CODE_FOR_STUB( patchBuffer, - ("Baseline get_by_id array length stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())); + ("Baseline get_by_id array length stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())); // Finally patch the jump to slow case back in the hot path to jump here instead. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck); @@ -849,9 +850,9 @@ void JIT::privateCompileGetByIdProto(StructureStubInfo* stubInfo, Structure* str stubInfo->stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline get_by_id proto stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline get_by_id proto stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -915,9 +916,9 @@ void JIT::privateCompileGetByIdSelfList(StructureStubInfo* stubInfo, Polymorphic RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline get_by_id self list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline get_by_id self list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -988,9 +989,9 @@ void JIT::privateCompileGetByIdProtoList(StructureStubInfo* stubInfo, Polymorphi RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline get_by_id proto list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline get_by_id proto list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1066,9 +1067,9 @@ void JIT::privateCompileGetByIdChainList(StructureStubInfo* stubInfo, Polymorphi RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline get_by_id chain list stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline get_by_id chain list stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); @@ -1140,9 +1141,9 @@ void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* str RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine( FINALIZE_CODE( patchBuffer, - ("Baseline get_by_id chain stub for CodeBlock %p, return point %p", - m_codeBlock, stubInfo->hotPathBegin.labelAtOffset( - stubInfo->patch.baseline.u.get.putResult).executableAddress())), + ("Baseline get_by_id chain stub for %s, return point %p", + toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset( + stubInfo->patch.baseline.u.get.putResult).executableAddress())), *m_globalData, m_codeBlock->ownerExecutable(), needsStubLink); diff --git a/Source/JavaScriptCore/jit/JITStubs.cpp b/Source/JavaScriptCore/jit/JITStubs.cpp index 760ffd429..f47ac08ef 100644 --- a/Source/JavaScriptCore/jit/JITStubs.cpp +++ b/Source/JavaScriptCore/jit/JITStubs.cpp @@ -1808,12 +1808,16 @@ DEFINE_STUB_FUNCTION(void, optimize) unsigned bytecodeIndex = stackFrame.args[0].int32(); #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("%p: Entered optimize with bytecodeIndex = %u, executeCounter = %s, reoptimizationRetryCounter = %u, optimizationDelayCounter = %u, exitCounter = ", codeBlock, bytecodeIndex, codeBlock->jitExecuteCounter().status(), codeBlock->reoptimizationRetryCounter(), codeBlock->optimizationDelayCounter()); + dataLog( + *codeBlock, ": Entered optimize with bytecodeIndex = ", bytecodeIndex, + ", executeCounter = ", codeBlock->jitExecuteCounter(), + ", optimizationDelayCounter = ", codeBlock->reoptimizationRetryCounter(), + ", exitCounter = "); if (codeBlock->hasOptimizedReplacement()) - dataLogF("%u", codeBlock->replacement()->osrExitCounter()); + dataLog(codeBlock->replacement()->osrExitCounter()); else - dataLogF("N/A"); - dataLogF("\n"); + dataLog("N/A"); + dataLog("\n"); #endif if (!codeBlock->checkIfOptimizationThresholdReached()) { @@ -1823,7 +1827,7 @@ DEFINE_STUB_FUNCTION(void, optimize) if (codeBlock->hasOptimizedReplacement()) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Considering OSR into %p(%p).\n", codeBlock, codeBlock->replacement()); + dataLogF("Considering OSR ", *codeBlock, " -> ", *codeBlock->replacement(), ".\n"); #endif // If we have an optimized replacement, then it must be the case that we entered // cti_optimize from a loop. That's because is there's an optimized replacement, @@ -1840,7 +1844,7 @@ DEFINE_STUB_FUNCTION(void, optimize) // additional checking anyway, to reduce the amount of recompilation thrashing. if (codeBlock->replacement()->shouldReoptimizeFromLoopNow()) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Triggering reoptimization of %p(%p) (in loop).\n", codeBlock, codeBlock->replacement()); + dataLogF("Triggering reoptimization of ", *codeBlock, "(", *codeBlock->replacement(), ") (in loop).\n"); #endif codeBlock->reoptimize(); return; @@ -1848,7 +1852,7 @@ DEFINE_STUB_FUNCTION(void, optimize) } else { if (!codeBlock->shouldOptimizeNow()) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Delaying optimization for %p (in loop) because of insufficient profiling.\n", codeBlock); + dataLogF("Delaying optimization for ", *codeBlock, " (in loop) because of insufficient profiling.\n"); #endif return; } @@ -1864,7 +1868,7 @@ DEFINE_STUB_FUNCTION(void, optimize) if (codeBlock->replacement() == codeBlock) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Optimizing %p failed.\n", codeBlock); + dataLogF("Optimizing ", *codeBlock, " failed.\n"); #endif ASSERT(codeBlock->getJITType() == JITCode::BaselineJIT); @@ -1878,12 +1882,12 @@ DEFINE_STUB_FUNCTION(void, optimize) if (void* address = DFG::prepareOSREntry(callFrame, optimizedCodeBlock, bytecodeIndex)) { if (Options::showDFGDisassembly()) { - dataLogF( - "Performing OSR from code block %p to code block %p, address %p to %p.\n", - codeBlock, optimizedCodeBlock, (STUB_RETURN_ADDRESS).value(), address); + dataLog( + "Performing OSR ", *codeBlock, " -> ", *optimizedCodeBlock, ", address ", + RawPointer((STUB_RETURN_ADDRESS).value()), " -> ", RawPointer(address), ".\n"); } #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Optimizing %p succeeded, performing OSR after a delay of %u.\n", codeBlock, codeBlock->optimizationDelayCounter()); + dataLogF("Optimizing ", *codeBlock, " succeeded, performing OSR after a delay of ", codeBlock->optimizationDelayCounter(), ".\n"); #endif codeBlock->optimizeSoon(); @@ -1892,7 +1896,7 @@ DEFINE_STUB_FUNCTION(void, optimize) } #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Optimizing %p succeeded, OSR failed, after a delay of %u.\n", codeBlock, codeBlock->optimizationDelayCounter()); + dataLogF("Optimizing ", *codeBlock, " succeeded, OSR failed, after a delay of ", codeBlock->optimizationDelayCounter(), ".\n"); #endif // Count the OSR failure as a speculation failure. If this happens a lot, then @@ -1900,7 +1904,7 @@ DEFINE_STUB_FUNCTION(void, optimize) optimizedCodeBlock->countOSRExit(); #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Encountered OSR failure into %p(%p).\n", codeBlock, codeBlock->replacement()); + dataLogF("Encountered OSR failure ", *codeBlock, " -> ", *codeBlock->replacement(), ".\n"); #endif // We are a lot more conservative about triggering reoptimization after OSR failure than @@ -1913,7 +1917,7 @@ DEFINE_STUB_FUNCTION(void, optimize) // reoptimization trigger. if (optimizedCodeBlock->shouldReoptimizeNow()) { #if ENABLE(JIT_VERBOSE_OSR) - dataLogF("Triggering reoptimization of %p(%p) (after OSR fail).\n", codeBlock, codeBlock->replacement()); + dataLogF("Triggering reoptimization of ", *codeBlock, " -> ", *codeBlock->replacement(), " (after OSR fail).\n"); #endif codeBlock->reoptimize(); return; diff --git a/Source/JavaScriptCore/runtime/CodeSpecializationKind.cpp b/Source/JavaScriptCore/runtime/CodeSpecializationKind.cpp new file mode 100644 index 000000000..202a1d9c7 --- /dev/null +++ b/Source/JavaScriptCore/runtime/CodeSpecializationKind.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CodeSpecializationKind.h" + +#include <wtf/PrintStream.h> + +namespace WTF { + +void printInternal(PrintStream& out, JSC::CodeSpecializationKind kind) +{ + if (kind == JSC::CodeForCall) { + out.print("Call"); + return; + } + + ASSERT(kind == JSC::CodeForConstruct); + out.print("Construct"); +} + +} // namespace WTF + + + diff --git a/Source/JavaScriptCore/runtime/CodeSpecializationKind.h b/Source/JavaScriptCore/runtime/CodeSpecializationKind.h index ba2a54f37..5c408c6df 100644 --- a/Source/JavaScriptCore/runtime/CodeSpecializationKind.h +++ b/Source/JavaScriptCore/runtime/CodeSpecializationKind.h @@ -30,7 +30,24 @@ namespace JSC { enum CodeSpecializationKind { CodeForCall, CodeForConstruct }; +inline CodeSpecializationKind specializationFromIsCall(bool isCall) +{ + return isCall ? CodeForCall : CodeForConstruct; +} + +inline CodeSpecializationKind specializationFromIsConstruct(bool isConstruct) +{ + return isConstruct ? CodeForConstruct : CodeForCall; +} + } // namespace JSC +namespace WTF { + +class PrintStream; +void printInternal(PrintStream&, JSC::CodeSpecializationKind); + +} // namespace WTF + #endif // CodeSpecializationKind_h diff --git a/Source/JavaScriptCore/runtime/Executable.cpp b/Source/JavaScriptCore/runtime/Executable.cpp index 49a0e256d..746e281e3 100644 --- a/Source/JavaScriptCore/runtime/Executable.cpp +++ b/Source/JavaScriptCore/runtime/Executable.cpp @@ -665,4 +665,26 @@ String FunctionExecutable::paramString() const return m_unlinkedExecutable->paramString(); } +CodeBlockHash ExecutableBase::hashFor(CodeSpecializationKind kind) const +{ + if (this->classInfo() == &NativeExecutable::s_info) + return jsCast<const NativeExecutable*>(this)->hashFor(kind); + + return jsCast<const ScriptExecutable*>(this)->hashFor(kind); +} + +CodeBlockHash NativeExecutable::hashFor(CodeSpecializationKind kind) const +{ + if (kind == CodeForCall) + return CodeBlockHash(static_cast<unsigned>(bitwise_cast<size_t>(m_function))); + + ASSERT(kind == CodeForConstruct); + return CodeBlockHash(static_cast<unsigned>(bitwise_cast<size_t>(m_constructor))); +} + +CodeBlockHash ScriptExecutable::hashFor(CodeSpecializationKind kind) const +{ + return CodeBlockHash(source(), kind); +} + } diff --git a/Source/JavaScriptCore/runtime/Executable.h b/Source/JavaScriptCore/runtime/Executable.h index c1c044b0e..83eb602c4 100644 --- a/Source/JavaScriptCore/runtime/Executable.h +++ b/Source/JavaScriptCore/runtime/Executable.h @@ -27,6 +27,7 @@ #define Executable_h #include "CallData.h" +#include "CodeBlockHash.h" #include "CodeSpecializationKind.h" #include "HandlerInfo.h" #include "JSFunction.h" @@ -86,6 +87,8 @@ namespace JSC { static const bool hasImmortalStructure = true; static void destroy(JSCell*); #endif + + CodeBlockHash hashFor(CodeSpecializationKind) const; bool isFunctionExecutable() { @@ -295,6 +298,8 @@ namespace JSC { static void destroy(JSCell*); #endif + CodeBlockHash hashFor(CodeSpecializationKind) const; + NativeFunction function() { return m_function; } NativeFunction constructor() { return m_constructor; } @@ -352,8 +357,10 @@ namespace JSC { #if ENABLE(JIT) static void destroy(JSCell*); #endif + + CodeBlockHash hashFor(CodeSpecializationKind) const; - const SourceCode& source() { return m_source; } + const SourceCode& source() const { return m_source; } intptr_t sourceID() const { return m_source.providerID(); } const String& sourceURL() const { return m_source.provider()->url(); } int lineNo() const { return m_firstLine; } |