Changeset 174113 in webkit for trunk/Source/JavaScriptCore/replay


Ignore:
Timestamp:
Sep 30, 2014, 12:21:25 PM (11 years ago)
Author:
Brian Burg
Message:

Web Replay: use static Strings instead of AtomicStrings for replay input type tags
https://bugs.webkit.org/show_bug.cgi?id=137086

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

This pattern doesn't work when we want to define some inputs in WebKit2.
The ReplayInputTypes class was generated from WebCore inputs only. This
patch moves all input traits to use static local Strings as type tags.

  • replay/scripts/CodeGeneratorReplayInputs.py: Remove configuration of how

type tags are generated, since all framework targets now generate the same code.

  • replay/NondeterministicInput.h:
  • replay/scripts/CodeGeneratorReplayInputs.py: Simplify and rebase test results.

(Generator.generate_input_trait_implementation):

  • replay/scripts/CodeGeneratorReplayInputsTemplates.py: Simplify templates.
  • replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::SavedMouseButton>::type):

  • replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::SavedMouseButton>::type):

  • replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::HandleWheelEvent>::type):

  • replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::FormCombo>::type):

  • replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::GetCurrentTime>::type):
(JSC::InputTraits<Test::SetRandomSeed>::type):

  • replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ArrayOfThings>::type):
(JSC::InputTraits<Test::SavedHistory>::type):

  • replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ScalarInput1>::type):
(JSC::InputTraits<Test::ScalarInput2>::type):

  • replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.h:
  • replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ScalarInput>::type):
(JSC::InputTraits<Test::MapInput>::type):

  • replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.h:

Source/WebCore:

This pattern doesn't work when we want to define some inputs in WebKit2,
since the ReplayInputTypes class is generated from WebCore inputs only.

Replace tag-checking uses of ReplayInputTypes with InputTraits<T>::type().
Remove thread-local input types, and switch to using a plain const String instead
of const AtomicString.

No new tests, no behavior changed.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • inspector/InspectorReplayAgent.cpp:

(WebCore::SerializeInputToJSONFunctor::operator()):

  • platform/ThreadGlobalData.cpp:

(WebCore::ThreadGlobalData::ThreadGlobalData):
(WebCore::ThreadGlobalData::destroy):

  • platform/ThreadGlobalData.h:

(WebCore::ThreadGlobalData::inputTypes): Deleted.

  • replay/AllReplayInputs.h:
  • replay/EventLoopInput.h:
  • replay/EventLoopInputDispatcher.cpp:

(WebCore::EventLoopInputDispatcher::dispatchInput):

  • replay/MemoizedDOMResult.cpp:

(WebCore::MemoizedDOMResultBase::type):
(JSC::InputTraits<MemoizedDOMResultBase>::type):

  • replay/MemoizedDOMResult.h:
  • replay/ReplayInputTypes.cpp: Removed.
  • replay/ReplayInputTypes.h: Removed.
  • replay/ReplayingInputCursor.cpp:

(WebCore::ReplayingInputCursor::loadInput):

  • replay/SegmentedInputStorage.cpp:

(WebCore::SegmentedInputStorage::load):
(WebCore::SegmentedInputStorage::store):

  • replay/SerializationMethods.cpp:

(JSC::EncodingTraits<NondeterministicInputBase>::encodeValue):
(JSC::EncodingTraits<NondeterministicInputBase>::decodeValue):

Location:
trunk/Source/JavaScriptCore/replay
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/replay/NondeterministicInput.h

    r164007 r174113  
    4848struct JS_EXPORT_PRIVATE InputTraits {
    4949    static InputQueue queue();
    50     static AtomicString& type();
     50    static String& type();
    5151
    5252    static void encode(EncodedValue& encodedInput, InputType& decodedInput);
     
    6060    virtual ~NondeterministicInputBase() { }
    6161
    62     virtual const AtomicString& type() const = 0;
     62    virtual const String& type() const = 0;
    6363    virtual InputQueue queue() const = 0;
    6464};
     
    6666template<typename InputType>
    6767class NondeterministicInput : public NondeterministicInputBase {
    68     virtual const AtomicString& type() const override
     68    virtual const String& type() const override
    6969    {
    7070        return InputTraits<InputType>::type();
  • trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py

    r171684 r174113  
    7373    "implIncludes": [
    7474        (["WebCore"],
    75             ("WebCore", "replay/ReplayInputTypes.h")
    76         ),
    77         (["WebCore"],
    7875            ("WebCore", "replay/SerializationMethods.h")
    7976        ),
     
    8178            ("JavaScriptCore", "inspector/InspectorValues.h")
    8279        ),
    83         (["JavaScriptCore"],
     80        (["WebCore", "JavaScriptCore"],
    8481            ("WTF", "wtf/NeverDestroyed.h")
    85         ),
    86         (["JavaScriptCore"],
    87             ("WTF", "wtf/text/AtomicString.h")
    8882        ),
    8983
     
    112106        "namespace": "JSC",
    113107        "exportMacro": "JS_EXPORT_PRIVATE",
    114         "inputTypeTemplate": Templates.InputTypeFromStaticLocal,
    115108    },
    116109    "WebCore": {
    117110        "prefix": "Web",
    118111        "namespace": "WebCore",
    119         "inputTypeTemplate": Templates.InputTypeFromThreadLocal,
    120112    },
    121113    # Used for bindings tests.
     
    123115        "prefix": "Test",
    124116        "namespace": "Test",
    125         "inputTypeTemplate": Templates.InputTypeFromStaticLocal,
    126117    }
    127118}
     
    875866        template_arguments = {
    876867            'inputsNamespace': self.target_framework.setting('namespace'),
    877             'inputTypeImplementation': Template(self.setting('inputTypeTemplate')).substitute(None, inputName=_input.name),
     868            'inputNameStringLiteral': '"%s"' % _input.name,
    878869            'qualifiedInputName': self.qualified_input_name(_input),
    879870            'constructorArguments': self.generate_constructor_arguments_list(_input),
  • trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py

    r163918 r174113  
    9999    """template<> ${structOrClass} InputTraits<${qualifiedInputName}> {
    100100    static InputQueue queue() { return InputQueue::${queueType}; }
    101     static const AtomicString& type();
     101    static const String& type();
    102102
    103103    static void encode(JSC::EncodedValue&, const ${qualifiedInputName}&);
     
    153153
    154154    InputTraitsImplementation = (
    155     """const AtomicString& InputTraits<${qualifiedInputName}>::type()
    156 {
    157 $inputTypeImplementation
     155    """const String& InputTraits<${qualifiedInputName}>::type()
     156{
     157    static NeverDestroyed<const String> type(ASCIILiteral(${inputNameStringLiteral}));
     158    return type;
    158159}
    159160
     
    227228            enumValue = static_cast<${qualifiedEnumName}>(enumValue | ${qualifiedEnumValue});""")
    228229
    229     InputTypeFromStaticLocal = (
    230     """    static NeverDestroyed<const AtomicString> type("${inputName}", AtomicString::ConstructFromLiteral);
    231     return type;""")
    232 
    233     InputTypeFromThreadLocal = "    return WebCore::inputTypes().${inputName};"
    234 
    235230    InputClassImplementation = (
    236231    """${inputName}::${inputName}(${constructorFormalsList})
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp

    r163918 r174113  
    4949
    5050namespace JSC {
    51 const AtomicString& InputTraits<Test::SavedMouseButton>::type()
     51const String& InputTraits<Test::SavedMouseButton>::type()
    5252{
    53     static NeverDestroyed<const AtomicString> type("SavedMouseButton", AtomicString::ConstructFromLiteral);
     53    static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton"));
    5454    return type;
    5555}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h

    r163918 r174113  
    4747template<> struct InputTraits<Test::SavedMouseButton> {
    4848    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    49     static const AtomicString& type();
     49    static const String& type();
    5050
    5151    static void encode(JSC::EncodedValue&, const Test::SavedMouseButton&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp

    r163918 r174113  
    5050
    5151namespace JSC {
    52 const AtomicString& InputTraits<Test::SavedMouseButton>::type()
     52const String& InputTraits<Test::SavedMouseButton>::type()
    5353{
    54     static NeverDestroyed<const AtomicString> type("SavedMouseButton", AtomicString::ConstructFromLiteral);
     54    static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton"));
    5555    return type;
    5656}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h

    r163918 r174113  
    5151template<> struct InputTraits<Test::SavedMouseButton> {
    5252    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    53     static const AtomicString& type();
     53    static const String& type();
    5454
    5555    static void encode(JSC::EncodedValue&, const Test::SavedMouseButton&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp

    r170774 r174113  
    4949
    5050namespace JSC {
    51 const AtomicString& InputTraits<Test::HandleWheelEvent>::type()
     51const String& InputTraits<Test::HandleWheelEvent>::type()
    5252{
    53     static NeverDestroyed<const AtomicString> type("HandleWheelEvent", AtomicString::ConstructFromLiteral);
     53    static NeverDestroyed<const String> type(ASCIILiteral("HandleWheelEvent"));
    5454    return type;
    5555}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.h

    r169889 r174113  
    4848template<> struct InputTraits<Test::HandleWheelEvent> {
    4949    static InputQueue queue() { return InputQueue::EventLoopInput; }
    50     static const AtomicString& type();
     50    static const String& type();
    5151
    5252    static void encode(JSC::EncodedValue&, const Test::HandleWheelEvent&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp

    r171683 r174113  
    5151
    5252namespace JSC {
    53 const AtomicString& InputTraits<Test::FormCombo>::type()
     53const String& InputTraits<Test::FormCombo>::type()
    5454{
    55     static NeverDestroyed<const AtomicString> type("FormCombo", AtomicString::ConstructFromLiteral);
     55    static NeverDestroyed<const String> type(ASCIILiteral("FormCombo"));
    5656    return type;
    5757}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h

    r171683 r174113  
    4747template<> struct InputTraits<Test::FormCombo> {
    4848    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    49     static const AtomicString& type();
     49    static const String& type();
    5050
    5151    static void encode(JSC::EncodedValue&, const Test::FormCombo&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp

    r163918 r174113  
    6161namespace JSC {
    6262#if ENABLE(DUMMY_FEATURE)
    63 const AtomicString& InputTraits<Test::GetCurrentTime>::type()
     63const String& InputTraits<Test::GetCurrentTime>::type()
    6464{
    65     static NeverDestroyed<const AtomicString> type("GetCurrentTime", AtomicString::ConstructFromLiteral);
     65    static NeverDestroyed<const String> type(ASCIILiteral("GetCurrentTime"));
    6666    return type;
    6767}
     
    8383#endif // ENABLE(DUMMY_FEATURE)
    8484
    85 const AtomicString& InputTraits<Test::SetRandomSeed>::type()
     85const String& InputTraits<Test::SetRandomSeed>::type()
    8686{
    87     static NeverDestroyed<const AtomicString> type("SetRandomSeed", AtomicString::ConstructFromLiteral);
     87    static NeverDestroyed<const String> type(ASCIILiteral("SetRandomSeed"));
    8888    return type;
    8989}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.h

    r163918 r174113  
    4848template<> struct InputTraits<Test::GetCurrentTime> {
    4949    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    50     static const AtomicString& type();
     50    static const String& type();
    5151
    5252    static void encode(JSC::EncodedValue&, const Test::GetCurrentTime&);
     
    5757template<> struct InputTraits<Test::SetRandomSeed> {
    5858    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    59     static const AtomicString& type();
     59    static const String& type();
    6060
    6161    static void encode(JSC::EncodedValue&, const Test::SetRandomSeed&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp

    r171684 r174113  
    6262
    6363namespace JSC {
    64 const AtomicString& InputTraits<Test::ArrayOfThings>::type()
     64const String& InputTraits<Test::ArrayOfThings>::type()
    6565{
    66     static NeverDestroyed<const AtomicString> type("ArrayOfThings", AtomicString::ConstructFromLiteral);
     66    static NeverDestroyed<const String> type(ASCIILiteral("ArrayOfThings"));
    6767    return type;
    6868}
     
    9393}
    9494
    95 const AtomicString& InputTraits<Test::SavedHistory>::type()
     95const String& InputTraits<Test::SavedHistory>::type()
    9696{
    97     static NeverDestroyed<const AtomicString> type("SavedHistory", AtomicString::ConstructFromLiteral);
     97    static NeverDestroyed<const String> type(ASCIILiteral("SavedHistory"));
    9898    return type;
    9999}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h

    r171684 r174113  
    4949template<> struct InputTraits<Test::ArrayOfThings> {
    5050    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    51     static const AtomicString& type();
     51    static const String& type();
    5252
    5353    static void encode(JSC::EncodedValue&, const Test::ArrayOfThings&);
     
    5757template<> struct InputTraits<Test::SavedHistory> {
    5858    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    59     static const AtomicString& type();
     59    static const String& type();
    6060
    6161    static void encode(JSC::EncodedValue&, const Test::SavedHistory&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp

    r163918 r174113  
    5858
    5959namespace JSC {
    60 const AtomicString& InputTraits<Test::ScalarInput1>::type()
     60const String& InputTraits<Test::ScalarInput1>::type()
    6161{
    62     static NeverDestroyed<const AtomicString> type("ScalarInput1", AtomicString::ConstructFromLiteral);
     62    static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput1"));
    6363    return type;
    6464}
     
    7979}
    8080
    81 const AtomicString& InputTraits<Test::ScalarInput2>::type()
     81const String& InputTraits<Test::ScalarInput2>::type()
    8282{
    83     static NeverDestroyed<const AtomicString> type("ScalarInput2", AtomicString::ConstructFromLiteral);
     83    static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput2"));
    8484    return type;
    8585}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.h

    r163918 r174113  
    4545template<> struct InputTraits<Test::ScalarInput1> {
    4646    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    47     static const AtomicString& type();
     47    static const String& type();
    4848
    4949    static void encode(JSC::EncodedValue&, const Test::ScalarInput1&);
     
    5353template<> struct InputTraits<Test::ScalarInput2> {
    5454    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    55     static const AtomicString& type();
     55    static const String& type();
    5656
    5757    static void encode(JSC::EncodedValue&, const Test::ScalarInput2&);
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp

    r170774 r174113  
    5858
    5959namespace JSC {
    60 const AtomicString& InputTraits<Test::ScalarInput>::type()
     60const String& InputTraits<Test::ScalarInput>::type()
    6161{
    62     static NeverDestroyed<const AtomicString> type("ScalarInput", AtomicString::ConstructFromLiteral);
     62    static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput"));
    6363    return type;
    6464}
     
    7979}
    8080
    81 const AtomicString& InputTraits<Test::MapInput>::type()
     81const String& InputTraits<Test::MapInput>::type()
    8282{
    83     static NeverDestroyed<const AtomicString> type("MapInput", AtomicString::ConstructFromLiteral);
     83    static NeverDestroyed<const String> type(ASCIILiteral("MapInput"));
    8484    return type;
    8585}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.h

    r163918 r174113  
    4545template<> struct InputTraits<Test::ScalarInput> {
    4646    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    47     static const AtomicString& type();
     47    static const String& type();
    4848
    4949    static void encode(JSC::EncodedValue&, const Test::ScalarInput&);
     
    5353template<> struct InputTraits<Test::MapInput> {
    5454    static InputQueue queue() { return InputQueue::ScriptMemoizedData; }
    55     static const AtomicString& type();
     55    static const String& type();
    5656
    5757    static void encode(JSC::EncodedValue&, const Test::MapInput&);
Note: See TracChangeset for help on using the changeset viewer.