Ignore:
Timestamp:
Jun 3, 2008, 5:40:47 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-06-03 Darin Adler <Darin Adler>

Reviewed by Geoff.

Makes standalone SunSpider 1.025x as fast as before.

The getOwnPropertySlot virtual function now takes care of the toObject call
for get. Similarly, the put function (and later deleteProperty) does the
same for those operations. To do this, the virtual functions were moved from
the JSObject class to the JSCell class. Also, since the caller no longer knows
the identity of the "original object", which is used by JavaScript-function
based getters, changed the PropertySlot class so the original object is
already stored in the slot when getOwnPropertySlot is called, if the caller
intends to call getValue.

This affected the old interpreter code enough that the easiest thing for me
was to just delete it. While I am not certain the mysterious slowdown is not
still occurring, the net change is definitely a significant speedup.

  • VM/Machine.cpp: Moved the UNLIKELY macro into AlwaysInline.h. (KJS::resolve): Set up the originalObject in the PropertySlot before calling getPropertySlot. Also removed the originalObject argument from getValue. (KJS::resolve_skip): Ditto. (KJS::resolveBaseAndProperty): Ditto. (KJS::resolveBaseAndFunc): Ditto. (KJS::Machine::privateExecute): Removed the toObject calls from the get and put functions where possible, instead calling directly with JSValue and letting the JSValue and JSCell calls handle toObject. Same for toThisObject.
  • kjs/ExecState.h: Removed OldInterpreterExecState.
  • API/JSBase.cpp: Updated includes.
  • kjs/LocalStorageEntry.h: Removed contents. Later we can remove the file too.
  • kjs/array_instance.cpp: (KJS::ArrayInstance::lengthGetter): Removed originalObject argumet. (KJS::ArrayInstance::inlineGetOwnPropertySlot): Don't pass a base value to setValueSlot. Also use UNLIKELY around the "getting elements past the end of the array" code path; less common than successfully getting an element.
  • kjs/array_object.cpp: (KJS::getProperty): Initialize the PropertySlot with the original object. Don't pass the original object to the get function. (KJS::arrayProtoFuncFilter): Ditto. (KJS::arrayProtoFuncMap): Ditto. (KJS::arrayProtoFuncEvery): Ditto. (KJS::arrayProtoFuncForEach): Ditto. (KJS::arrayProtoFuncSome): Ditto.
  • kjs/function_object.cpp: (KJS::FunctionObjectImp::construct): Removed an obsolete comment.
  • kjs/grammar.y: Eliminated support for some of the node types that were used to optimize executing from the syntax tree.
  • kjs/internal.cpp: (KJS::StringImp::toThisObject): Added. Same as toObject. (KJS::NumberImp::toThisObject): Ditto. (KJS::GetterSetterImp::getOwnPropertySlot): Added. Not reached. (KJS::GetterSetterImp::put): Ditto. (KJS::GetterSetterImp::toThisObject): Ditto.
  • kjs/internal.h: Added toThisObject to NumberImp for speed.
  • kjs/lexer.cpp: (KJS::Lexer::shift): Changed shift to just do a single character, to unroll the loop and especially to make the one character case faster. (KJS::Lexer::setCode): Call shift multiple times instead of passing a number. (KJS::Lexer::lex): Ditto. (KJS::Lexer::matchPunctuator): Ditto. Also removed unneeded elses after returns. (KJS::Lexer::scanRegExp): Ditto.
  • kjs/lexer.h: Removed the count argument from shift.
  • kjs/math_object.cpp: (KJS::mathProtoFuncPow): Call jsNaN instead of jsNumber(NaN).
  • kjs/nodes.cpp: Removed some of the things needed only for the pre-SquirrelFish execution model. (KJS::ForNode::emitCode): Handle cases where some expressions are missing by not emitting any code at all. The old way was to emit code for "true", but this is an unnecessary remnant of the old way of doing things.
  • kjs/nodes.h: Removed some of the things needed only for the pre-SquirrelFish execution model.
  • kjs/object.cpp: (KJS::JSObject::fillGetterPropertySlot): Changed to only pass in the getter function. The old code passed in a base, but it was never used when actually getting the property; the toThisObject call was pointless. Also changed to not pass a base for setUndefined.
  • kjs/object.h: Added the new JSCell operations to GetterSetterImp. Never called. (KJS::JSObject::get): Initialize the object in the PropertySlot and don't pass it in getValue. (KJS::JSObject::getOwnPropertySlotForWrite): Removed the base argument in calls to setValueSlot. (KJS::JSObject::getOwnPropertySlot): Ditto. (KJS::JSValue::get): Added. Here because it calls through to JSObject. A version of JSObject::get that also handles the other types of JSValue by creating the appropriate wrapper. Saves the virtual call to toObject. (KJS::JSValue::put): Ditto. (KJS::JSValue::deleteProperty): Ditto.
  • kjs/property_slot.cpp: (KJS::PropertySlot::undefinedGetter): Removed the originalObject argument. (KJS::PropertySlot::ungettableGetter): Ditto. (KJS::PropertySlot::functionGetter): Ditto. Use the value in the base as the "this" object, which will be set to the original object by the new PropertySlot initialization code. Also call toThisObject. The old code did not do this, but needed to so we can properly handle the activation object like the other similar code paths.
  • kjs/property_slot.h: (KJS::PropertySlot::PropertySlot): Added a constructor that takes a base object. In debug builds, set the base to 0 if you don't pass one. (KJS::PropertySlot::getValue): Don't take or pass the originalObject. (KJS::PropertySlot::setValueSlot): Don't take a base object, and clear the base object in debug builds. (KJS::PropertySlot::setGetterSlot): Ditto. (KJS::PropertySlot::setUndefined): Ditto. (KJS::PropertySlot::setUngettable): Ditto. (KJS::PropertySlot::slotBase): Assert that a base object is present. This will fire if someone actually calls the get function without having passed in a base object and the getter needs it. (KJS::PropertySlot::setBase): Added. Used by the code that implements toObject so it can supply the original object after the fact. (KJS::PropertySlot::clearBase): Added. Clears the base, but is debug-only code because it's an error to fetch the base if you don't have a guarantee it was set.
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: (KJS::JSCallbackObject::cachedValueGetter): (KJS::JSCallbackObject::staticValueGetter): (KJS::JSCallbackObject::staticFunctionGetter): (KJS::JSCallbackObject::callbackGetter):
  • kjs/JSActivation.cpp: (KJS::JSActivation::getOwnPropertySlot): (KJS::JSActivation::argumentsGetter):
  • kjs/JSActivation.h:
  • kjs/JSVariableObject.h: (KJS::JSVariableObject::symbolTableGet):
  • kjs/array_instance.h:
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::FunctionImp::callerGetter): (KJS::FunctionImp::lengthGetter): (KJS::Arguments::mappedIndexGetter):
  • kjs/function.h:
  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::staticValueGetter):
  • kjs/string_object.cpp: (KJS::StringInstance::lengthGetter): (KJS::StringInstance::indexGetter): (KJS::stringInstanceNumericPropertyGetter):
  • kjs/string_object.h: Removed originalObject arguments from getters. Don't pass base values to the various PropertySlot functions that no longer take them.
  • kjs/value.cpp: (KJS::JSCell::getOwnPropertySlot): Added. Calls toObject and then sets the slot. This function has to always return true, because the caller can't walk the prototype chain. Because of that, we do a getPropertySlot, not getOwnPropertySlot, which works for the caller. This is private, only called by getOwnPropertySlotInternal. (KJS::JSCell::put): Added. Calls toObject and then put. (KJS::JSCell::toThisObject): Added. Calls toObject.
  • kjs/value.h: Added get, put, and toThisObject to both JSValue and JSCell. These take care of the toObject operation without an additional virtual function call, and so make the common "already an object" case faster.
  • wtf/AlwaysInline.h: Moved the UNLIKELY macro here for now. Maybe we can find a better place later, or rename this header.

JavaScriptGlue:

2008-06-03 Darin Adler <Darin Adler>

  • UserObjectImp.cpp: (UserObjectImp::userObjectGetter): Removed originalObject argument.
  • UserObjectImp.h: Ditto.

WebCore:

2008-06-03 Justin Garcia <[email protected]>

Reviewed by John.

<rdar://problem/5763082> GMail: Hang when removing indent from nested list
<rdar://problem/5775449> In Gmail and GoogleDocs, a hang occurs when I attempt to apply a list style to a large selection of text
<rdar://problem/5937624> 9D32: Hang in Safari. Using 100% of processor

  • editing/InsertListCommand.cpp: (WebCore::InsertListCommand::modifyRange): doApply() may operate on and remove the last paragraph of the selection from the document if it's in the same list item as startOfCurrentParagraph. Return early to avoid an infinite loop and because there is no more work to be done. Added a FIXME (<rdar://problem/5983974>) about the incorrect endingSelection()s.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.h

    r34071 r34355  
    105105
    106106    private:
    107         // Default constructor required for OldInterpreterExecState with gcc 3.
    108         ExecState() {};
     107        // Default constructor required for gcc 3.
     108        ExecState() { }
    109109
    110110        ExecState(ExecState*, Machine*, RegisterFile*, ScopeChainNode*, int callFrameOffset);
     
    127127    };
    128128
    129     // This code is now defunct:
    130 
    131129    enum CodeType { GlobalCode, EvalCode, FunctionCode };
    132     class OldInterpreterExecState : public ExecState {
    133     public:
    134         void pushSwitch() { m_switchDepth++; }
    135         void popSwitch() { m_switchDepth--; }
    136         bool inSwitch() const { return (m_switchDepth > 0); }
    137 
    138         // These are only valid right after calling execute().
    139         ComplType completionType() const { return m_completionType; }
    140         const Identifier& breakOrContinueTarget() const
    141         {
    142             ASSERT(m_completionType == Break || m_completionType == Continue);
    143             return *m_breakOrContinueTarget;
    144         }
    145 
    146         // Only for use in the implementation of execute().
    147         void setCompletionType(ComplType type)
    148         {
    149             ASSERT(type != Break);
    150             ASSERT(type != Continue);
    151             m_completionType = type;
    152         }
    153         JSValue* setNormalCompletion()
    154         {
    155             ASSERT(!hadException());
    156             m_completionType = Normal;
    157             return 0;
    158         }
    159         JSValue* setNormalCompletion(JSValue* value)
    160         {
    161             ASSERT(!hadException());
    162             m_completionType = Normal;
    163             return value;
    164         }
    165         JSValue* setBreakCompletion(const Identifier* target)
    166         {
    167             ASSERT(!hadException());
    168             m_completionType = Break;
    169             m_breakOrContinueTarget = target;
    170             return 0;
    171         }
    172         JSValue* setContinueCompletion(const Identifier* target)
    173         {
    174             ASSERT(!hadException());
    175             m_completionType = Continue;
    176             m_breakOrContinueTarget = target;
    177             return 0;
    178         }
    179         JSValue* setReturnValueCompletion(JSValue* returnValue)
    180         {
    181             ASSERT(!hadException());
    182             ASSERT(returnValue);
    183             m_completionType = ReturnValue;
    184             return returnValue;
    185         }
    186         JSValue* setThrowCompletion(JSValue* exception)
    187         {
    188             ASSERT(!hadException());
    189             ASSERT(exception);
    190             m_completionType = Throw;
    191             return exception;
    192         }
    193         JSValue* setInterruptedCompletion()
    194         {
    195             ASSERT(!hadException());
    196             m_completionType = Interrupted;
    197             return 0;
    198         }
    199         CodeType codeType() { return m_codeType; }
    200         void pushIteration() { m_iterationDepth++; }
    201         void popIteration() { m_iterationDepth--; }
    202         bool inIteration() const { return (m_iterationDepth > 0); }
    203         LabelStack& seenLabels() { return m_labelStack; }
    204         void pushScope(JSObject* s) { m_scopeChain.push(s); }
    205         void popScope() { m_scopeChain.pop(); }
    206         JSVariableObject* variableObject() const { ASSERT_NOT_REACHED(); return m_variableObject; }
    207         void setVariableObject(JSVariableObject* v) { m_variableObject = v; }
    208         ExecState* callingExecState() { return m_callingExec; }
    209         ScopeNode* scopeNode() { return m_scopeNode; }
    210         const List* arguments() const { return m_arguments; }
    211         FunctionImp* function() const { return m_function; }
    212         LocalStorage& localStorage() { ASSERT_NOT_REACHED(); return *(LocalStorage*)0; }
    213         void setLocalStorage(LocalStorage*) { ASSERT_NOT_REACHED(); }
    214         ScopeChain& scopeChain() { return m_scopeChain; }
    215         JSObject* thisValue() const { return m_thisValue; }
    216        
    217         ComplType m_completionType;
    218         const Identifier* m_breakOrContinueTarget;
    219         int m_switchDepth;
    220         CodeType m_codeType;
    221         int m_iterationDepth;
    222         LabelStack m_labelStack;
    223         ScopeChainNode m_inlineScopeChainNode;
    224         ScopeChain m_scopeChain;
    225         JSVariableObject* m_variableObject;
    226         ScopeNode* m_scopeNode;
    227         const List* m_arguments;
    228         FunctionImp* m_function;
    229         ExecState* m_callingExec;
    230         JSObject* m_thisValue;
    231     };
    232130
    233131} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.