Changeset 95310 in webkit


Ignore:
Timestamp:
Sep 16, 2011 11:50:04 AM (13 years ago)
Author:
fpizlo@apple.com
Message:

DFG JIT should inline Math.abs
https://bugs.webkit.org/show_bug.cgi?id=68227

Source/JavaScriptCore:

Reviewed by Oliver Hunt.

This adds the ability to track intrinsic functions throughout the
host function infrastructure, so that the DFG can easily query
whether or not a call's target is intrinsic, and if so, which
intrinsic it is.

On top of this, it adds Math.abs intrinsics to DFG. Call(Math.abs)
is transformed into ValueToNumber<-ArithAbs nodes. These nodes
then get optimized using the usual tricks.

Also had to make a completely unrelated change to
DateInstanceCache.h in order to fix a preexisting alphabetical
sorting problem in JSGlobalData.h

This results in a big win in imaging-gaussian-blur: 61% faster
than before. The net win on Kraken is around 13%.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • create_hash_table:
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::isFunctionConstant):
(JSC::DFG::Graph::valueOfFunctionConstant):

  • dfg/DFGIntrinsic.h: Added.
  • dfg/DFGJITCodeGenerator.h:

(JSC::DFG::JITCodeGenerator::isFunctionConstant):
(JSC::DFG::JITCodeGenerator::valueOfFunctionConstant):

  • dfg/DFGJITCompiler.h:

(JSC::DFG::JITCompiler::isFunctionConstant):
(JSC::DFG::JITCompiler::valueOfFunctionConstant):

  • dfg/DFGNode.h:
  • dfg/DFGPropagator.cpp:

(JSC::DFG::Propagator::propagateNode):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • jit/JITStubs.cpp:

(JSC::JITThunks::hostFunctionStub):

  • jit/JITStubs.h:
  • runtime/DateInstanceCache.h:
  • runtime/Executable.cpp:

(JSC::ExecutableBase::intrinsic):
(JSC::NativeExecutable::intrinsic):

  • runtime/Executable.h:

(JSC::NativeExecutable::create):
(JSC::NativeExecutable::finishCreation):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::getHostFunction):

  • runtime/JSGlobalData.h:
  • runtime/Lookup.cpp:

(JSC::HashTable::createTable):
(JSC::setUpStaticFunctionSlot):

  • runtime/Lookup.h:

(JSC::HashEntry::initialize):
(JSC::HashEntry::intrinsic):

Source/WebCore:

Reviewed by Oliver Hunt.

Added JavaScriptCore/dfg to include path path. Changed the bindings
scripts to handle the presence of intrinsics.

  • CMakeLists.txt:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHashTable):

Source/WebKit:

Reviewed by Oliver Hunt.

Added JavaScriptCore/dfg to include path path.

  • CMakeLists.txt:

Source/WebKit2:

Reviewed by Oliver Hunt.

Added JavaScriptCore/dfg to include path path.

  • CMakeLists.txt:
Location:
trunk/Source
Files:
1 added
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95308 r95310  
     12011-09-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT should inline Math.abs
     4        https://bugs.webkit.org/show_bug.cgi?id=68227
     5
     6        Reviewed by Oliver Hunt.
     7       
     8        This adds the ability to track intrinsic functions throughout the
     9        host function infrastructure, so that the DFG can easily query
     10        whether or not a call's target is intrinsic, and if so, which
     11        intrinsic it is.
     12       
     13        On top of this, it adds Math.abs intrinsics to DFG. Call(Math.abs)
     14        is transformed into ValueToNumber<-ArithAbs nodes. These nodes
     15        then get optimized using the usual tricks.
     16       
     17        Also had to make a completely unrelated change to
     18        DateInstanceCache.h in order to fix a preexisting alphabetical
     19        sorting problem in JSGlobalData.h
     20       
     21        This results in a big win in imaging-gaussian-blur: 61% faster
     22        than before. The net win on Kraken is around 13%.
     23
     24        * JavaScriptCore.xcodeproj/project.pbxproj:
     25        * create_hash_table:
     26        * dfg/DFGByteCodeParser.cpp:
     27        (JSC::DFG::ByteCodeParser::parseBlock):
     28        * dfg/DFGGraph.h:
     29        (JSC::DFG::Graph::isFunctionConstant):
     30        (JSC::DFG::Graph::valueOfFunctionConstant):
     31        * dfg/DFGIntrinsic.h: Added.
     32        * dfg/DFGJITCodeGenerator.h:
     33        (JSC::DFG::JITCodeGenerator::isFunctionConstant):
     34        (JSC::DFG::JITCodeGenerator::valueOfFunctionConstant):
     35        * dfg/DFGJITCompiler.h:
     36        (JSC::DFG::JITCompiler::isFunctionConstant):
     37        (JSC::DFG::JITCompiler::valueOfFunctionConstant):
     38        * dfg/DFGNode.h:
     39        * dfg/DFGPropagator.cpp:
     40        (JSC::DFG::Propagator::propagateNode):
     41        * dfg/DFGSpeculativeJIT.cpp:
     42        (JSC::DFG::SpeculativeJIT::compile):
     43        * jit/JITStubs.cpp:
     44        (JSC::JITThunks::hostFunctionStub):
     45        * jit/JITStubs.h:
     46        * runtime/DateInstanceCache.h:
     47        * runtime/Executable.cpp:
     48        (JSC::ExecutableBase::intrinsic):
     49        (JSC::NativeExecutable::intrinsic):
     50        * runtime/Executable.h:
     51        (JSC::NativeExecutable::create):
     52        (JSC::NativeExecutable::finishCreation):
     53        * runtime/JSGlobalData.cpp:
     54        (JSC::JSGlobalData::getHostFunction):
     55        * runtime/JSGlobalData.h:
     56        * runtime/Lookup.cpp:
     57        (JSC::HashTable::createTable):
     58        (JSC::setUpStaticFunctionSlot):
     59        * runtime/Lookup.h:
     60        (JSC::HashEntry::initialize):
     61        (JSC::HashEntry::intrinsic):
     62
    1632011-09-16  Filip Pizlo  <fpizlo@apple.com>
    264
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r95240 r95310  
    7474                0FD82E86141F3FF100179C94 /* PredictedType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E84141F3FDA00179C94 /* PredictedType.cpp */; };
    7575                0FD82E9014207A5F00179C94 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E8E14207A5100179C94 /* ValueProfile.cpp */; };
     76                0FD82EF51423075B00179C94 /* DFGIntrinsic.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82EF31423073900179C94 /* DFGIntrinsic.h */; settings = {ATTRIBUTES = (Private, ); }; };
    7677                1400067712A6F7830064D123 /* OSAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400067612A6F7830064D123 /* OSAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    7778                1400069312A6F9E10064D123 /* OSAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */; };
     
    814815                0FD82E84141F3FDA00179C94 /* PredictedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PredictedType.cpp; sourceTree = "<group>"; };
    815816                0FD82E8E14207A5100179C94 /* ValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValueProfile.cpp; sourceTree = "<group>"; };
     817                0FD82EF31423073900179C94 /* DFGIntrinsic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGIntrinsic.h; path = dfg/DFGIntrinsic.h; sourceTree = "<group>"; };
    816818                1400067612A6F7830064D123 /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; };
    817819                1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPosix.cpp; sourceTree = "<group>"; };
     
    22282230                        isa = PBXGroup;
    22292231                        children = (
     2232                                0FD82EF31423073900179C94 /* DFGIntrinsic.h */,
    22302233                                0FD82E52141DAEDE00179C94 /* DFGOSREntry.cpp */,
    22312234                                0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */,
     
    24272430                                86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
    24282431                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
     2432                                0FD82EF51423075B00179C94 /* DFGIntrinsic.h in Headers */,
    24292433                                0FD82E85141F3FE300179C94 /* BoundsCheckedPointer.h in Headers */,
    24302434                                0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */,
  • trunk/Source/JavaScriptCore/create_hash_table

    r90237 r95310  
    253253    print "#define THUNK_GENERATOR(generator)\n";
    254254    print "#endif\n";
     255    print "#if ENABLE(DFG_JIT)\n";
     256    print "#define INTRINSIC(intrinsic) , intrinsic\n";
     257    print "#else\n";
     258    print "#define INTRINSIC(intrinsic)\n";
     259    print "#endif\n";
    255260    print "\nstatic const struct HashTableValue ${nameEntries}\[$count\] = {\n";
    256261    my $i = 0;
     
    273278        }
    274279        my $thunkGenerator = "0";
     280        my $intrinsic = "DFG::NoIntrinsic";
    275281        if ($key eq "charCodeAt") {
    276282            $thunkGenerator = "charCodeAtThunkGenerator";
     
    291297            if ($key eq "abs") {
    292298                $thunkGenerator = "absThunkGenerator";
     299                $intrinsic = "DFG::AbsIntrinsic";
    293300            }
    294301            if ($key eq "floor") {
     
    308315            }
    309316        }
    310         print "   { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue THUNK_GENERATOR($thunkGenerator) },\n";
     317        print "   { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue THUNK_GENERATOR($thunkGenerator) INTRINSIC($intrinsic) },\n";
    311318        $i++;
    312319    }
    313     print "   { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n";
     320    print "   { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }\n";
    314321    print "};\n\n";
    315322    print "#undef THUNK_GENERATOR\n";
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r95273 r95310  
    3333#include "DFGScoreBoard.h"
    3434#include "CodeBlock.h"
     35#include <wtf/MathExtras.h>
    3536
    3637namespace JSC { namespace DFG {
     
    5051        , m_constantUndefined(UINT_MAX)
    5152        , m_constantNull(UINT_MAX)
     53        , m_constantNaN(UINT_MAX)
    5254        , m_constant1(UINT_MAX)
    5355        , m_constants(codeBlock->numberOfConstantRegisters())
     
    6567
    6668private:
     69    // Handle intrinsic functions.
     70    bool handleIntrinsic(bool usesResult, int resultOperand, Intrinsic, int firstArg, int lastArg);
    6771    // Parse a single basic block of bytecode instructions.
    6872    bool parseBlock(unsigned limit);
     
    357361    }
    358362   
     363    // This method returns a DoubleConstant with the value NaN.
     364    NodeIndex constantNaN()
     365    {
     366        JSValue nan = jsNaN();
     367       
     368        // Has m_constantNaN been set up yet?
     369        if (m_constantNaN == UINT_MAX) {
     370            // Search the constant pool for the value NaN, if we find it, we can just reuse this!
     371            unsigned numberOfConstants = m_codeBlock->numberOfConstantRegisters();
     372            for (m_constantNaN = 0; m_constantNaN < numberOfConstants; ++m_constantNaN) {
     373                JSValue testMe = m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN);
     374                if (JSValue::encode(testMe) == JSValue::encode(nan))
     375                    return getJSConstant(m_constantNaN);
     376            }
     377
     378            // Add the value nan to the CodeBlock's constants, and add a corresponding slot in m_constants.
     379            ASSERT(m_constants.size() == numberOfConstants);
     380            m_codeBlock->addConstant(nan);
     381            m_constants.append(ConstantRecord());
     382            ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
     383        }
     384
     385        // m_constantNaN must refer to an entry in the CodeBlock's constant pool that has the value nan.
     386        ASSERT(m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN).isDouble());
     387        ASSERT(isnan(m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN).asDouble()));
     388        return getJSConstant(m_constantNaN);
     389    }
     390   
    359391    CodeOrigin currentCodeOrigin()
    360392    {
     
    507539    unsigned m_constantUndefined;
    508540    unsigned m_constantNull;
     541    unsigned m_constantNaN;
    509542    unsigned m_constant1;
    510543
     
    569602    m_currentIndex += OPCODE_LENGTH(name); \
    570603    return !m_parseFailed
     604
     605bool ByteCodeParser::handleIntrinsic(bool usesResult, int resultOperand, Intrinsic intrinsic, int firstArg, int lastArg)
     606{
     607    switch (intrinsic) {
     608    case AbsIntrinsic: {
     609        if (!usesResult) {
     610            // There is no such thing as executing abs for effect, so this
     611            // is dead code.
     612            return true;
     613        }
     614       
     615        // We don't care about the this argument. If we don't have a first
     616        // argument then make this JSConstant(NaN).
     617        int absArg = firstArg + 1;
     618        if (absArg > lastArg)
     619            set(resultOperand, constantNaN());
     620        else
     621            set(resultOperand, addToGraph(ArithAbs, getToNumber(absArg)));
     622        return true;
     623    }
     624       
     625    default:
     626        ASSERT(intrinsic == NoIntrinsic);
     627        return false;
     628    }
     629}
    571630
    572631bool ByteCodeParser::parseBlock(unsigned limit)
     
    11701229           
    11711230        case op_call: {
     1231            NodeIndex callTarget = get(currentInstruction[1].u.operand);
     1232            if (m_graph.isFunctionConstant(m_codeBlock, *m_globalData, callTarget)) {
     1233                int argCount = currentInstruction[2].u.operand;
     1234                int registerOffset = currentInstruction[3].u.operand;
     1235                int firstArg = registerOffset - argCount - RegisterFile::CallFrameHeaderSize;
     1236                int lastArg = firstArg + argCount - 1;
     1237               
     1238                // Do we have a result?
     1239                bool usesResult = false;
     1240                int resultOperand = 0; // make compiler happy
     1241                Instruction* putInstruction = currentInstruction + OPCODE_LENGTH(op_call);
     1242                if (interpreter->getOpcodeID(putInstruction->u.opcode) == op_call_put_result) {
     1243                    resultOperand = putInstruction[1].u.operand;
     1244                    usesResult = true;
     1245                }
     1246               
     1247                DFG::Intrinsic intrinsic = m_graph.valueOfFunctionConstant(m_codeBlock, *m_globalData, callTarget)->executable()->intrinsic();
     1248               
     1249                if (handleIntrinsic(usesResult, resultOperand, intrinsic, firstArg, lastArg)) {
     1250                    // NEXT_OPCODE() has to be inside braces.
     1251                    NEXT_OPCODE(op_call);
     1252                }
     1253            }
     1254           
    11721255            NodeIndex call = addCall(interpreter, currentInstruction, Call);
    11731256            aliases.recordCall(call);
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r95273 r95310  
    239239        return at(nodeIndex).isBooleanConstant(codeBlock);
    240240    }
     241    bool isFunctionConstant(CodeBlock* codeBlock, JSGlobalData& globalData, NodeIndex nodeIndex)
     242    {
     243        if (!isJSConstant(nodeIndex))
     244            return false;
     245        if (!getJSFunction(globalData, valueOfJSConstant(codeBlock, nodeIndex)))
     246            return false;
     247        return true;
     248    }
    241249    // Helper methods get constant values from nodes.
    242250    JSValue valueOfJSConstant(CodeBlock* codeBlock, NodeIndex nodeIndex)
     
    257265    {
    258266        return valueOfJSConstantNode(codeBlock, nodeIndex).getBoolean();
     267    }
     268    JSFunction* valueOfFunctionConstant(CodeBlock* codeBlock, JSGlobalData& globalData, NodeIndex nodeIndex)
     269    {
     270        JSCell* function = getJSFunction(globalData, valueOfJSConstant(codeBlock, nodeIndex));
     271        ASSERT(function);
     272        return asFunction(function);
    259273    }
    260274
  • trunk/Source/JavaScriptCore/dfg/DFGJITCodeGenerator.h

    r95273 r95310  
    427427    bool isNumberConstant(NodeIndex nodeIndex) { return m_jit.isNumberConstant(nodeIndex); }
    428428    bool isBooleanConstant(NodeIndex nodeIndex) { return m_jit.isBooleanConstant(nodeIndex); }
     429    bool isFunctionConstant(NodeIndex nodeIndex) { return m_jit.isFunctionConstant(nodeIndex); }
    429430    int32_t valueOfInt32Constant(NodeIndex nodeIndex) { return m_jit.valueOfInt32Constant(nodeIndex); }
    430431    double valueOfNumberConstant(NodeIndex nodeIndex) { return m_jit.valueOfNumberConstant(nodeIndex); }
    431432    JSValue valueOfJSConstant(NodeIndex nodeIndex) { return m_jit.valueOfJSConstant(nodeIndex); }
    432433    bool valueOfBooleanConstant(NodeIndex nodeIndex) { return m_jit.valueOfBooleanConstant(nodeIndex); }
     434    JSFunction* valueOfFunctionConstant(NodeIndex nodeIndex) { return m_jit.valueOfFunctionConstant(nodeIndex); }
    433435    bool isNullConstant(NodeIndex nodeIndex)
    434436    {
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.h

    r95240 r95310  
    252252    bool isNumberConstant(NodeIndex nodeIndex) { return graph().isNumberConstant(codeBlock(), nodeIndex); }
    253253    bool isBooleanConstant(NodeIndex nodeIndex) { return graph().isBooleanConstant(codeBlock(), nodeIndex); }
     254    bool isFunctionConstant(NodeIndex nodeIndex) { return graph().isFunctionConstant(codeBlock(), *globalData(), nodeIndex); }
    254255    // Helper methods get constant values from nodes.
    255256    JSValue valueOfJSConstant(NodeIndex nodeIndex) { return graph().valueOfJSConstant(codeBlock(), nodeIndex); }
     
    257258    double valueOfNumberConstant(NodeIndex nodeIndex) { return graph().valueOfNumberConstant(codeBlock(), nodeIndex); }
    258259    bool valueOfBooleanConstant(NodeIndex nodeIndex) { return graph().valueOfBooleanConstant(codeBlock(), nodeIndex); }
     260    JSFunction* valueOfFunctionConstant(NodeIndex nodeIndex) { return graph().valueOfFunctionConstant(codeBlock(), *globalData(), nodeIndex); }
    259261
    260262    // These methods JIT generate dynamic, debug-only checks - akin to ASSERTs.
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r95273 r95310  
    152152    macro(ArithDiv, NodeResultNumber) \
    153153    macro(ArithMod, NodeResultNumber) \
     154    macro(ArithAbs, NodeResultNumber) \
    154155    /* Arithmetic operators call ToNumber on their operands. */\
    155156    macro(ValueToNumber, NodeResultNumber | NodeMustGenerate) \
  • trunk/Source/JavaScriptCore/dfg/DFGPropagator.cpp

    r95273 r95310  
    216216        }
    217217           
     218        case ArithAbs: {
     219            PredictedType child = m_predictions[node.child1()];
     220            if (isStrongPrediction(child))
     221                changed |= mergePrediction(child);
     222            break;
     223        }
     224           
    218225        case LogicalNot:
    219226        case CompareLess:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r95273 r95310  
    10581058        break;
    10591059    }
     1060       
     1061    case ArithAbs: {
     1062        if (shouldSpeculateInteger(node.child1())) {
     1063            SpeculateIntegerOperand op1(this, node.child1());
     1064            GPRTemporary result(this, op1);
     1065            GPRTemporary scratch(this);
     1066           
     1067            m_jit.zeroExtend32ToPtr(op1.gpr(), result.gpr());
     1068            m_jit.rshift32(result.gpr(), MacroAssembler::TrustedImm32(31), scratch.gpr());
     1069            m_jit.add32(scratch.gpr(), result.gpr());
     1070            m_jit.xor32(scratch.gpr(), result.gpr());
     1071            speculationCheck(m_jit.branch32(MacroAssembler::Equal, result.gpr(), MacroAssembler::TrustedImm32(1 << 31)));
     1072            integerResult(result.gpr(), m_compileIndex);
     1073            break;
     1074        }
     1075       
     1076        SpeculateDoubleOperand op1(this, node.child1());
     1077        FPRTemporary result(this);
     1078       
     1079        static const double negativeZeroConstant = -0.0;
     1080       
     1081        m_jit.loadDouble(&negativeZeroConstant, result.fpr());
     1082        m_jit.andnotDouble(op1.fpr(), result.fpr());
     1083        doubleResult(result.fpr(), m_compileIndex);
     1084        break;
     1085    }
    10601086
    10611087    case LogicalNot: {
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r95134 r95310  
    36873687    std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
    36883688    if (!*entry.first->second)
    3689         entry.first->second.set(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor));
     3689        entry.first->second.set(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor, DFG::NoIntrinsic));
    36903690    return entry.first->second.get();
    36913691}
    36923692
    3693 NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator)
     3693NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator, DFG::Intrinsic intrinsic)
    36943694{
    36953695    std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
    36963696    if (!*entry.first->second) {
    36973697        MacroAssemblerCodeRef code = globalData->canUseJIT() ? generator(globalData) : MacroAssemblerCodeRef();
    3698         entry.first->second.set(*globalData, NativeExecutable::create(*globalData, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor));
     3698        entry.first->second.set(*globalData, NativeExecutable::create(*globalData, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor, intrinsic));
    36993699    }
    37003700    return entry.first->second.get();
  • trunk/Source/JavaScriptCore/jit/JITStubs.h

    r94920 r95310  
    3232
    3333#include "CallData.h"
     34#include "DFGIntrinsic.h"
    3435#include "MacroAssemblerCodeRef.h"
    3536#include "Register.h"
     
    298299
    299300        NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction);
    300         NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction, ThunkGenerator);
     301        NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction, ThunkGenerator, DFG::Intrinsic);
    301302
    302303        void clearHostFunctionStubs();
  • trunk/Source/JavaScriptCore/runtime/DateInstanceCache.h

    r88587 r95310  
    2828
    2929#include <wtf/DateMath.h>
     30#include <wtf/FixedArray.h>
    3031#include <wtf/HashFunctions.h>
    3132#include <wtf/PassRefPtr.h>
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r95016 r95310  
    5151}
    5252
     53#if ENABLE(DFG_JIT)
     54DFG::Intrinsic ExecutableBase::intrinsic() const
     55{
     56    return DFG::NoIntrinsic;
     57}
     58#endif
     59
    5360class ExecutableFinalizer : public WeakHandleOwner {
    5461    virtual void finalize(Handle<Unknown> handle, void*)
     
    7077{
    7178}
     79
     80#if ENABLE(DFG_JIT)
     81DFG::Intrinsic NativeExecutable::intrinsic() const
     82{
     83    return m_intrinsic;
     84}
     85#endif
    7286
    7387const ClassInfo ScriptExecutable::s_info = { "ScriptExecutable", &ExecutableBase::s_info, 0, 0 };
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r94929 r95310  
    157157        }
    158158
     159#if ENABLE(DFG_JIT)
     160        virtual DFG::Intrinsic intrinsic() const;
     161#endif
     162
    159163    protected:
    160164        JITCode m_jitCodeForCall;
     
    174178
    175179#if ENABLE(JIT)
    176         static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodeRef callThunk, NativeFunction function, MacroAssemblerCodeRef constructThunk, NativeFunction constructor)
     180        static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodeRef callThunk, NativeFunction function, MacroAssemblerCodeRef constructThunk, NativeFunction constructor, DFG::Intrinsic intrinsic)
    177181        {
    178182            NativeExecutable* executable;
    179183            if (!callThunk) {
    180184                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
    181                 executable->finishCreation(globalData, JITCode(), JITCode());
     185                executable->finishCreation(globalData, JITCode(), JITCode(), intrinsic);
    182186            } else {
    183187                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
    184                 executable->finishCreation(globalData, JITCode::HostFunction(callThunk), JITCode::HostFunction(constructThunk));
     188                executable->finishCreation(globalData, JITCode::HostFunction(callThunk), JITCode::HostFunction(constructThunk), intrinsic);
    185189            }
    186190            return executable;
     
    205209    protected:
    206210#if ENABLE(JIT)
    207         void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk)
     211        void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk, DFG::Intrinsic intrinsic)
    208212        {
    209213            Base::finishCreation(globalData);
     
    212216            m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
    213217            m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
    214         }
     218#if ENABLE(DFG_JIT)
     219            m_intrinsic = intrinsic;
     220#endif
     221        }
     222#endif
     223       
     224#if ENABLE(DFG_JIT)
     225        virtual DFG::Intrinsic intrinsic() const;
    215226#endif
    216227 
     
    236247        // trampoline. It may be easier to make NativeFunction be passed 'this' as a part of the ArgList.
    237248        NativeFunction m_constructor;
     249       
     250        DFG::Intrinsic m_intrinsic;
    238251    };
    239252
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r95240 r95310  
    411411    return jitStubs->hostFunctionStub(this, function);
    412412}
    413 NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, ThunkGenerator generator)
    414 {
    415     return jitStubs->hostFunctionStub(this, function, generator);
     413NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, ThunkGenerator generator, DFG::Intrinsic intrinsic)
     414{
     415    return jitStubs->hostFunctionStub(this, function, generator, intrinsic);
    416416}
    417417#else
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r95240 r95310  
    3131
    3232#include "CachedTranscendentalFunction.h"
    33 #include "Heap.h"
     33#include "DFGIntrinsic.h"
    3434#include "DateInstanceCache.h"
    3535#include "ExecutableAllocator.h"
     36#include "Heap.h"
    3637#include "Strong.h"
    3738#include "JITStubs.h"
     
    220221            return jitStubs->ctiStub(this, generator);
    221222        }
    222         NativeExecutable* getHostFunction(NativeFunction, ThunkGenerator);
     223        NativeExecutable* getHostFunction(NativeFunction, ThunkGenerator, DFG::Intrinsic);
    223224#endif
    224225        NativeExecutable* getHostFunction(NativeFunction);
  • trunk/Source/JavaScriptCore/runtime/Lookup.cpp

    r94701 r95310  
    5050#if ENABLE(JIT)
    5151                          , values[i].generator
     52#if ENABLE(DFG_JIT)
     53                          , values[i].intrinsic
     54#endif
    5255#endif
    5356                          );
     
    8083#if ENABLE(JIT)
    8184        if (entry->generator())
    82             function = JSFunction::create(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
     85            function = JSFunction::create(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator(), entry->intrinsic()));
    8386        else
    8487#endif
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r94701 r95310  
    2323
    2424#include "CallFrame.h"
     25#include "DFGIntrinsic.h"
    2526#include "Identifier.h"
    2627#include "JSGlobalObject.h"
     
    4546#if ENABLE(JIT)
    4647        ThunkGenerator generator;
     48#if ENABLE(DFG_JIT)
     49        DFG::Intrinsic intrinsic;
     50#endif
    4751#endif
    4852    };
     
    5963#if ENABLE(JIT)
    6064                        , ThunkGenerator generator = 0
     65#if ENABLE(DFG_JIT)
     66                        , DFG::Intrinsic intrinsic = DFG::NoIntrinsic
     67#endif
    6168#endif
    6269                        )
     
    6875#if ENABLE(JIT)
    6976            m_u.function.generator = generator;
     77#if ENABLE(DFG_JIT)
     78            m_u.function.intrinsic = intrinsic;
     79#endif
    7080#endif
    7181            m_next = 0;
     
    7989#if ENABLE(JIT)
    8090        ThunkGenerator generator() const { ASSERT(m_attributes & Function); return m_u.function.generator; }
     91        DFG::Intrinsic intrinsic() const
     92        {
     93            ASSERT(m_attributes & Function);
     94#if ENABLE(DFG_JIT)
     95            return m_u.function.intrinsic;
     96#else
     97            return DFG::NoIntrinsic;
     98#endif
     99        }
    81100#endif
    82101        NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; }
     
    105124#if ENABLE(JIT)
    106125                ThunkGenerator generator;
     126#if ENABLE(DFG_JIT)
     127                DFG::Intrinsic intrinsic;
     128#endif
    107129#endif
    108130            } function;
  • trunk/Source/WebCore/CMakeLists.txt

    r95271 r95310  
    7070    "${JAVASCRIPTCORE_DIR}/bytecode"
    7171    "${JAVASCRIPTCORE_DIR}/bytecompiler"
     72    "${JAVASCRIPTCORE_DIR}/dfg"
    7273    "${JAVASCRIPTCORE_DIR}/heap"
    7374    "${JAVASCRIPTCORE_DIR}/debugger"
  • trunk/Source/WebCore/ChangeLog

    r95309 r95310  
     12011-09-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT should inline Math.abs
     4        https://bugs.webkit.org/show_bug.cgi?id=68227
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Added JavaScriptCore/dfg to include path path. Changed the bindings
     9        scripts to handle the presence of intrinsics.
     10
     11        * CMakeLists.txt:
     12        * bindings/scripts/CodeGeneratorJS.pm:
     13        (GenerateHashTable):
     14
    1152011-09-16  Iain Merrick  <husky@google.com>
    216
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r95250 r95310  
    29372937    push(@implContent, "#define THUNK_GENERATOR(generator)\n");
    29382938    push(@implContent, "#endif\n");
     2939    push(@implContent, "#if ENABLE(DFG_JIT)\n");
     2940    push(@implContent, "#define INTRINSIC(intrinsic) , intrinsic\n");
     2941    push(@implContent, "#else\n");
     2942    push(@implContent, "#define INTRINSIC(intrinsic)\n");
     2943    push(@implContent, "#endif\n");
    29392944    push(@implContent, "\nstatic const HashTableValue $nameEntries\[\] =\n\{\n");
    29402945    $i = 0;
     
    29562961            $targetType = "static_cast<PropertySlot::GetValueFunc>";
    29572962        }
    2958         push(@implContent, "    { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] THUNK_GENERATOR(0) },\n");
     2963        push(@implContent, "    { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },\n");
    29592964        if ($conditional) {
    29602965            push(@implContent, "#endif\n");
     
    29622967        ++$i;
    29632968    }
    2964     push(@implContent, "    { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n");
     2969    push(@implContent, "    { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }\n");
    29652970    push(@implContent, "};\n\n");
    29662971    push(@implContent, "#undef THUNK_GENERATOR\n");
  • trunk/Source/WebKit/CMakeLists.txt

    r93637 r95310  
    3838    "${JAVASCRIPTCORE_DIR}/bytecode"
    3939    "${JAVASCRIPTCORE_DIR}/bytecompiler"
     40    "${JAVASCRIPTCORE_DIR}/dfg"
    4041    "${JAVASCRIPTCORE_DIR}/heap"
    4142    "${JAVASCRIPTCORE_DIR}/debugger"
  • trunk/Source/WebKit/ChangeLog

    r95130 r95310  
     12011-09-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT should inline Math.abs
     4        https://bugs.webkit.org/show_bug.cgi?id=68227
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Added JavaScriptCore/dfg to include path path.
     9
     10        * CMakeLists.txt:
     11
    1122011-09-14  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/Source/WebKit2/CMakeLists.txt

    r95303 r95310  
    7676    "${JAVASCRIPTCORE_DIR}/bytecode"
    7777    "${JAVASCRIPTCORE_DIR}/bytecompiler"
     78    "${JAVASCRIPTCORE_DIR}/dfg"
    7879    "${JAVASCRIPTCORE_DIR}/collector/handles"
    7980    "${JAVASCRIPTCORE_DIR}/heap"
  • trunk/Source/WebKit2/ChangeLog

    r95303 r95310  
     12011-09-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT should inline Math.abs
     4        https://bugs.webkit.org/show_bug.cgi?id=68227
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Added JavaScriptCore/dfg to include path path.
     9
     10        * CMakeLists.txt:
     11
    1122011-09-16  Igor Oliveira  <igor.oliveira@openbossa.org>
    213
Note: See TracChangeset for help on using the changeset viewer.