diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-25 13:35:59 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-25 13:35:59 +0200 |
commit | 79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4 (patch) | |
tree | 0287b1a69d84492c901e8bc820e635e7133809a0 /Source/JavaScriptCore/bytecode | |
parent | 682ab87480e7757346802ce7f54cfdbdfeb2339e (diff) | |
download | qtwebkit-79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4.tar.gz |
Imported WebKit commit c4b613825abd39ac739a47d7b4410468fcef66dc (http://svn.webkit.org/repository/webkit/trunk@121147)
New snapshot that includes Win32 debug build fix (use SVGAllInOne)
Diffstat (limited to 'Source/JavaScriptCore/bytecode')
-rw-r--r-- | Source/JavaScriptCore/bytecode/CodeBlock.cpp | 24 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecode/CodeBlock.h | 13 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecode/GlobalResolveInfo.h | 9 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecode/ResolveGlobalStatus.cpp | 88 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecode/ResolveGlobalStatus.h | 86 |
5 files changed, 207 insertions, 13 deletions
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp index 60596d1c2..bcbb51f63 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp @@ -1583,7 +1583,7 @@ CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other, SymbolTable* symTab) , m_source(other.m_source) , m_sourceOffset(other.m_sourceOffset) #if ENABLE(JIT) - , m_globalResolveInfos(other.m_globalResolveInfos) + , m_globalResolveInfos(other.m_globalResolveInfos.size()) #endif #if ENABLE(VALUE_PROFILER) , m_executionEntryCount(0) @@ -1609,6 +1609,11 @@ CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other, SymbolTable* symTab) optimizeAfterWarmUp(); jitAfterWarmUp(); +#if ENABLE(JIT) + for (unsigned i = m_globalResolveInfos.size(); i--;) + m_globalResolveInfos[i] = GlobalResolveInfo(other.m_globalResolveInfos[i].bytecodeOffset); +#endif + if (other.m_rareData) { createRareDataIfNecessary(); @@ -2258,6 +2263,10 @@ bool CodeBlock::hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset) return false; return true; } +GlobalResolveInfo& CodeBlock::globalResolveInfoForBytecodeOffset(unsigned bytecodeOffset) +{ + return *(binarySearch<GlobalResolveInfo, unsigned, getGlobalResolveInfoBytecodeOffset>(m_globalResolveInfos.begin(), m_globalResolveInfos.size(), bytecodeOffset)); +} #endif void CodeBlock::shrinkToFit(ShrinkMode shrinkMode) @@ -2269,7 +2278,8 @@ void CodeBlock::shrinkToFit(ShrinkMode shrinkMode) #endif #if ENABLE(JIT) m_structureStubInfos.shrinkToFit(); - m_globalResolveInfos.shrinkToFit(); + if (shrinkMode == EarlyShrink) + m_globalResolveInfos.shrinkToFit(); m_callLinkInfos.shrinkToFit(); m_methodCallLinkInfos.shrinkToFit(); #endif @@ -2454,6 +2464,16 @@ void CodeBlock::copyPostParseDataFromAlternative() } #if ENABLE(JIT) +void CodeBlock::reoptimize() +{ + ASSERT(replacement() != this); + ASSERT(replacement()->alternative() == this); + replacement()->tallyFrequentExitSites(); + replacement()->jettison(); + countReoptimization(); + optimizeAfterWarmUp(); +} + CodeBlock* ProgramCodeBlock::replacement() { return &static_cast<ProgramExecutable*>(ownerExecutable())->generatedBytecode(); diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.h b/Source/JavaScriptCore/bytecode/CodeBlock.h index 573d422d3..b73dcb2b6 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.h +++ b/Source/JavaScriptCore/bytecode/CodeBlock.h @@ -69,7 +69,6 @@ #include <wtf/RefPtr.h> #include <wtf/SegmentedVector.h> #include <wtf/Vector.h> -#include "StructureStubInfo.h" namespace JSC { @@ -553,6 +552,8 @@ namespace JSC { } GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; } bool hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset); + GlobalResolveInfo& globalResolveInfoForBytecodeOffset(unsigned bytecodeOffset); + unsigned numberOfGlobalResolveInfos() { return m_globalResolveInfos.size(); } void setNumberOfCallLinkInfos(size_t size) { m_callLinkInfos.grow(size); } size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); } @@ -1104,15 +1105,7 @@ namespace JSC { #endif #if ENABLE(JIT) - void reoptimize() - { - ASSERT(replacement() != this); - ASSERT(replacement()->alternative() == this); - replacement()->tallyFrequentExitSites(); - replacement()->jettison(); - countReoptimization(); - optimizeAfterWarmUp(); - } + void reoptimize(); #endif #if ENABLE(VERBOSE_VALUE_PROFILE) diff --git a/Source/JavaScriptCore/bytecode/GlobalResolveInfo.h b/Source/JavaScriptCore/bytecode/GlobalResolveInfo.h index 5576cfacd..c466c750d 100644 --- a/Source/JavaScriptCore/bytecode/GlobalResolveInfo.h +++ b/Source/JavaScriptCore/bytecode/GlobalResolveInfo.h @@ -31,6 +31,8 @@ namespace JSC { struct GlobalResolveInfo { + GlobalResolveInfo() { } + GlobalResolveInfo(unsigned bytecodeOffset) : offset(0) , bytecodeOffset(bytecodeOffset) @@ -39,9 +41,14 @@ struct GlobalResolveInfo { WriteBarrier<Structure> structure; unsigned offset; - unsigned bytecodeOffset; + unsigned bytecodeOffset; // Only valid in old JIT code. This means nothing in the DFG. }; +inline unsigned getGlobalResolveInfoBytecodeOffset(GlobalResolveInfo* globalResolveInfo) +{ + return globalResolveInfo->bytecodeOffset; +} + } // namespace JSC #endif // GlobalResolveInfo_h diff --git a/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.cpp b/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.cpp new file mode 100644 index 000000000..ff138704c --- /dev/null +++ b/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.cpp @@ -0,0 +1,88 @@ +/* + * 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 "ResolveGlobalStatus.h" + +#include "CodeBlock.h" +#include "JSValue.h" +#include "Structure.h" + +namespace JSC { + +static ResolveGlobalStatus computeForStructure(CodeBlock* codeBlock, Structure* structure, Identifier& identifier) +{ + unsigned attributesIgnored; + JSCell* specificValue; + size_t offset = structure->get( + *codeBlock->globalData(), identifier, attributesIgnored, specificValue); + if (offset == notFound) + return ResolveGlobalStatus(); + + return ResolveGlobalStatus(ResolveGlobalStatus::Simple, structure, offset, specificValue); +} + +static ResolveGlobalStatus computeForLLInt(CodeBlock* codeBlock, unsigned bytecodeIndex, Identifier& identifier) +{ +#if ENABLE(LLINT) + Instruction* instruction = codeBlock->instructions().begin() + bytecodeIndex; + + ASSERT(instruction[0].u.opcode == llint_op_resolve_global); + + Structure* structure = instruction[3].u.structure.get(); + if (!structure) + return ResolveGlobalStatus(); + + return computeForStructure(codeBlock, structure, identifier); +#else + UNUSED_PARAM(codeBlock); + UNUSED_PARAM(bytecodeIndex); + UNUSED_PARAM(identifier); + return ResolveGlobalStatus(); +#endif +} + +ResolveGlobalStatus ResolveGlobalStatus::computeFor(CodeBlock* codeBlock, unsigned bytecodeIndex, Identifier& identifier) +{ +#if ENABLE(JIT) && ENABLE(VALUE_PROFILER) + if (!codeBlock->numberOfGlobalResolveInfos()) + return computeForLLInt(codeBlock, bytecodeIndex, identifier); + + if (codeBlock->likelyToTakeSlowCase(bytecodeIndex)) + return ResolveGlobalStatus(TakesSlowPath); + + GlobalResolveInfo& globalResolveInfo = codeBlock->globalResolveInfoForBytecodeOffset(bytecodeIndex); + + if (!globalResolveInfo.structure) + return computeForLLInt(codeBlock, bytecodeIndex, identifier); + + return computeForStructure(codeBlock, globalResolveInfo.structure.get(), identifier); +#else + return computeForLLInt(codeBlock, bytecodeIndex, identifier); +#endif +} + +} // namespace JSC + diff --git a/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.h b/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.h new file mode 100644 index 000000000..4698332f7 --- /dev/null +++ b/Source/JavaScriptCore/bytecode/ResolveGlobalStatus.h @@ -0,0 +1,86 @@ +/* + * 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 ResolveGlobalStatus_h +#define ResolveGlobalStatus_h + +#include "JSValue.h" +#include <wtf/NotFound.h> + +namespace JSC { + +class CodeBlock; +class Identifier; +class Structure; + +class ResolveGlobalStatus { +public: + enum State { + NoInformation, + Simple, + TakesSlowPath + }; + + ResolveGlobalStatus() + : m_state(NoInformation) + , m_structure(0) + , m_offset(notFound) + { + } + + ResolveGlobalStatus( + State state, Structure* structure = 0, size_t offset = notFound, + JSValue specificValue = JSValue()) + : m_state(state) + , m_structure(structure) + , m_offset(offset) + , m_specificValue(specificValue) + { + } + + static ResolveGlobalStatus computeFor(CodeBlock*, unsigned bytecodeIndex, Identifier&); + + State state() const { return m_state; } + + bool isSet() const { return m_state != NoInformation; } + bool operator!() const { return !isSet(); } + bool isSimple() const { return m_state == Simple; } + bool takesSlowPath() const { return m_state == TakesSlowPath; } + + Structure* structure() const { return m_structure; } + size_t offset() const { return m_offset; } + JSValue specificValue() const { return m_specificValue; } + +private: + State m_state; + Structure* m_structure; + size_t m_offset; + JSValue m_specificValue; +}; // class ResolveGlobalStatus + +} // namespace JSC + +#endif // ResolveGlobalStatus_h + |