Changeset 205321 in webkit


Ignore:
Timestamp:
Sep 1, 2016 3:08:22 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

GetByIdWithThis/GetByValWithThis should have ValueProfiles so that they can predict their result types
https://bugs.webkit.org/show_bug.cgi?id=160922

Patch by JF Bastien <jfbastien@apple.com> on 2016-09-01
Reviewed by Keith Miller.

JSTests:

Benchmark GetBy{Id,Val}WithThis in monomorphic and polymorphic uses.
The value profile is used by the calc functions, which do some mild math with the result.
These benchmarks get ~4% faster with value profiling.

  • microbenchmarks/super-get-by-id-with-this-monomorphic.js: Added.

(A):
(A.prototype.set value):
(A.prototype.get value):
(B.prototype.set value):
(B.prototype.get value):
(B):
(const.bench):

  • microbenchmarks/super-get-by-id-with-this-polymorphic.js: Added.

(A):
(A.prototype.set value):
(A.prototype.get value):
(B.prototype.set value):
(B.prototype.get value):
(B):
(const.bench):

  • microbenchmarks/super-get-by-val-with-this-monomorphic.js: Added.

(value):
(A):
(A.prototype.set v):
(A.prototype.get v):
(B.prototype.set v):
(B.prototype.get v):
(B):
(const.bench):

  • microbenchmarks/super-get-by-val-with-this-polymorphic.js: Added.

(value):
(A):
(A.prototype.set v):
(A.prototype.get v):
(B.prototype.set v):
(B.prototype.get v):
(B):
(const.bench):

Source/JavaScriptCore:

Add value profiling to GetBy{Id,Val}WithThis.

  • bytecode/BytecodeList.json:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::finishCreation):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitGetById):
(JSC::BytecodeGenerator::emitGetByVal):

  • dfg/DFGByteCodeParser.cpp:

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

  • dfg/DFGNode.h:

(JSC::DFG::Node::hasHeapPrediction):

  • dfg/DFGPredictionPropagationPhase.cpp:
  • llint/LowLevelInterpreter.asm:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

Location:
trunk
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r205317 r205321  
     12016-09-01  JF Bastien  <jfbastien@apple.com>
     2
     3        GetByIdWithThis/GetByValWithThis should have ValueProfiles so that they can predict their result types
     4        https://bugs.webkit.org/show_bug.cgi?id=160922
     5
     6        Reviewed by Keith Miller.
     7
     8        Benchmark GetBy{Id,Val}WithThis in monomorphic and polymorphic uses.
     9        The value profile is used by the calc functions, which do some mild math with the result.
     10        These benchmarks get ~4% faster with value profiling.
     11
     12        * microbenchmarks/super-get-by-id-with-this-monomorphic.js: Added.
     13        (A):
     14        (A.prototype.set value):
     15        (A.prototype.get value):
     16        (B.prototype.set value):
     17        (B.prototype.get value):
     18        (B):
     19        (const.bench):
     20        * microbenchmarks/super-get-by-id-with-this-polymorphic.js: Added.
     21        (A):
     22        (A.prototype.set value):
     23        (A.prototype.get value):
     24        (B.prototype.set value):
     25        (B.prototype.get value):
     26        (B):
     27        (const.bench):
     28        * microbenchmarks/super-get-by-val-with-this-monomorphic.js: Added.
     29        (value):
     30        (A):
     31        (A.prototype.set v):
     32        (A.prototype.get v):
     33        (B.prototype.set v):
     34        (B.prototype.get v):
     35        (B):
     36        (const.bench):
     37        * microbenchmarks/super-get-by-val-with-this-polymorphic.js: Added.
     38        (value):
     39        (A):
     40        (A.prototype.set v):
     41        (A.prototype.get v):
     42        (B.prototype.set v):
     43        (B.prototype.get v):
     44        (B):
     45        (const.bench):
     46
    1472016-09-01  Benjamin Poulain  <bpoulain@apple.com>
    248
  • trunk/Source/JavaScriptCore/ChangeLog

    r205309 r205321  
     12016-09-01  JF Bastien  <jfbastien@apple.com>
     2
     3        GetByIdWithThis/GetByValWithThis should have ValueProfiles so that they can predict their result types
     4        https://bugs.webkit.org/show_bug.cgi?id=160922
     5
     6        Reviewed by Keith Miller.
     7
     8        Add value profiling to GetBy{Id,Val}WithThis.
     9
     10        * bytecode/BytecodeList.json:
     11        * bytecode/CodeBlock.cpp:
     12        (JSC::CodeBlock::dumpBytecode):
     13        (JSC::CodeBlock::finishCreation):
     14        * bytecompiler/BytecodeGenerator.cpp:
     15        (JSC::BytecodeGenerator::emitGetById):
     16        (JSC::BytecodeGenerator::emitGetByVal):
     17        * dfg/DFGByteCodeParser.cpp:
     18        (JSC::DFG::ByteCodeParser::parseBlock):
     19        * dfg/DFGNode.h:
     20        (JSC::DFG::Node::hasHeapPrediction):
     21        * dfg/DFGPredictionPropagationPhase.cpp:
     22        * llint/LowLevelInterpreter.asm:
     23        * runtime/CommonSlowPaths.cpp:
     24        (JSC::SLOW_PATH_DECL):
     25
    1262016-09-01  Keith Miller  <keith_miller@apple.com>
    227
  • trunk/Source/JavaScriptCore/bytecode/BytecodeList.json

    r204994 r205321  
    6666            { "name" : "op_get_by_id_proto_load", "length" : 9 },
    6767            { "name" : "op_get_by_id_unset", "length" : 9 },
    68             { "name" : "op_get_by_id_with_this", "length" : 5 },
    69             { "name" : "op_get_by_val_with_this", "length" : 5 },
     68            { "name" : "op_get_by_id_with_this", "length" : 6 },
     69            { "name" : "op_get_by_val_with_this", "length" : 6 },
    7070            { "name" : "op_try_get_by_id", "length" : 5 },
    7171            { "name" : "op_put_by_id", "length" : 9 },
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r204994 r205321  
    11501150            int id0 = (++it)->u.operand;
    11511151            out.printf("%s, %s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data(), idName(id0, identifier(id0)).data());
     1152            dumpValueProfiling(out, it, hasPrintedProfiling);
    11521153            break;
    11531154        }
     
    11591160            printLocationAndOp(out, exec, location, it, "get_by_val_with_this");
    11601161            out.printf("%s, %s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data(), registerName(r3).data());
     1162            dumpValueProfiling(out, it, hasPrintedProfiling);
    11611163            break;
    11621164        }
     
    20772079        case op_get_direct_pname:
    20782080        case op_get_by_id:
     2081        case op_get_by_id_with_this:
    20792082        case op_try_get_by_id:
     2083        case op_get_by_val_with_this:
    20802084        case op_get_from_arguments:
    20812085        case op_to_number: {
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r204994 r205321  
    24932493    ASSERT_WITH_MESSAGE(!parseIndex(property), "Indexed properties should be handled with get_by_val.");
    24942494
    2495     emitOpcode(op_get_by_id_with_this);
     2495    UnlinkedValueProfile profile = emitProfiledOpcode(op_get_by_id_with_this);
    24962496    instructions().append(kill(dst));
    24972497    instructions().append(base->index());
    24982498    instructions().append(thisVal->index());
    24992499    instructions().append(addConstant(property));
     2500    instructions().append(profile);
    25002501    return dst;
    25012502}
     
    26652666RegisterID* BytecodeGenerator::emitGetByVal(RegisterID* dst, RegisterID* base, RegisterID* thisValue, RegisterID* property)
    26662667{
    2667     emitOpcode(op_get_by_val_with_this);
     2668    UnlinkedValueProfile profile = emitProfiledOpcode(op_get_by_val_with_this);
    26682669    instructions().append(kill(dst));
    26692670    instructions().append(base->index());
    26702671    instructions().append(thisValue->index());
    26712672    instructions().append(property->index());
     2673    instructions().append(profile);
    26722674    return dst;
    26732675}
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r204992 r205321  
    41304130
    41314131        case op_get_by_val_with_this: {
     4132            SpeculatedType prediction = getPrediction();
     4133
    41324134            Node* base = get(VirtualRegister(currentInstruction[2].u.operand));
    41334135            Node* thisValue = get(VirtualRegister(currentInstruction[3].u.operand));
    41344136            Node* property = get(VirtualRegister(currentInstruction[4].u.operand));
    4135             Node* getByValWithThis = addToGraph(GetByValWithThis, base, thisValue, property);
     4137            Node* getByValWithThis = addToGraph(GetByValWithThis, OpInfo(prediction), base, thisValue, property);
    41364138            set(VirtualRegister(currentInstruction[1].u.operand), getByValWithThis);
    41374139
     
    42274229        }
    42284230        case op_get_by_id_with_this: {
     4231            SpeculatedType prediction = getPrediction();
     4232
    42294233            Node* base = get(VirtualRegister(currentInstruction[2].u.operand));
    42304234            Node* thisValue = get(VirtualRegister(currentInstruction[3].u.operand));
     
    42324236
    42334237            set(VirtualRegister(currentInstruction[1].u.operand),
    4234                 addToGraph(GetByIdWithThis, OpInfo(identifierNumber), base, thisValue));
     4238                addToGraph(GetByIdWithThis, OpInfo(identifierNumber), OpInfo(prediction), base, thisValue));
    42354239
    42364240            NEXT_OPCODE(op_get_by_id_with_this);
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r205112 r205321  
    13961396        case GetById:
    13971397        case GetByIdFlush:
     1398        case GetByIdWithThis:
    13981399        case TryGetById:
    13991400        case GetByVal:
     1401        case GetByValWithThis:
    14001402        case Call:
    14011403        case TailCallInlinedCaller:
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r205112 r205321  
    681681        }
    682682
    683         case GetByValWithThis:
    684         case GetByIdWithThis: {
    685             setPrediction(SpecBytecodeTop);
    686             break;
    687         }
    688683        case ArrayPop:
    689684        case ArrayPush:
     
    694689        case GetById:
    695690        case GetByIdFlush:
     691        case GetByIdWithThis:
    696692        case TryGetById:
     693        case GetByValWithThis:
    697694        case GetByOffset:
    698695        case MultiGetByOffset:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r204994 r205321  
    18071807    traceExecution()
    18081808    callOpcodeSlowPath(_slow_path_get_by_id_with_this)
    1809     dispatch(5)
     1809    dispatch(6)
    18101810
    18111811_llint_op_get_by_val_with_this:
    18121812    traceExecution()
    18131813    callOpcodeSlowPath(_slow_path_get_by_val_with_this)
    1814     dispatch(5)
     1814    dispatch(6)
    18151815
    18161816_llint_op_put_by_id_with_this:
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r205198 r205321  
    829829    PropertySlot slot(thisVal, PropertySlot::PropertySlot::InternalMethodType::Get);
    830830    JSValue result = baseValue.get(exec, ident, slot);
    831     RETURN(result);
     831    RETURN_PROFILED(op_get_by_id_with_this, result);
    832832}
    833833
     
    846846            if (RefPtr<AtomicStringImpl> existingAtomicString = asString(subscript)->toExistingAtomicString(exec)) {
    847847                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomicString.get()))
    848                     RETURN(result);
     848                    RETURN_PROFILED(op_get_by_val_with_this, result);
    849849            }
    850850        }
     
    855855        uint32_t i = subscript.asUInt32();
    856856        if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i))
    857             RETURN(asString(baseValue)->getIndex(exec, i));
     857            RETURN_PROFILED(op_get_by_val_with_this, asString(baseValue)->getIndex(exec, i));
    858858       
    859         RETURN(baseValue.get(exec, i, slot));
     859        RETURN_PROFILED(op_get_by_val_with_this, baseValue.get(exec, i, slot));
    860860    }
    861861
     
    864864    auto property = subscript.toPropertyKey(exec);
    865865    CHECK_EXCEPTION();
    866     RETURN(baseValue.get(exec, property, slot));
     866    RETURN_PROFILED(op_get_by_val_with_this, baseValue.get(exec, property, slot));
    867867}
    868868
Note: See TracChangeset for help on using the changeset viewer.