Changeset 29067 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Jan 1, 2008, 11:35:37 AM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Geoff.

Also included one other speed-up -- remove the call to reserveCapacity from
FunctionBodyNode::processDeclarations in all but the most unusual cases.

Together these make SunSpider 1.016x as fast.

  • JavaScriptCore.exp: Updated.
  • kjs/ExecState.cpp: (KJS::globalEmptyList): Added. Called only when creating global ExecState instances. (KJS::ExecState::ExecState): Broke constructor up into three separate functions, for the three separate node types. Also went through each of the three and streamlined as much as possible, removing dead code. This prevents us from having to access the global in the function body version of the constructor.
  • kjs/ExecState.h: Added emptyList(). Replaced the constructor with a set of three that are specific to the different node types that can create new execution state objects.
  • kjs/array_object.cpp: (KJS::ArrayProtoFuncToLocaleString::callAsFunction): Use exec->emptyList() instead of List::empty(). (KJS::ArrayProtoFuncConcat::callAsFunction): Ditto. (KJS::ArrayProtoFuncSlice::callAsFunction): Ditto. (KJS::ArrayProtoFuncSplice::callAsFunction): Ditto. (KJS::ArrayProtoFuncFilter::callAsFunction): Ditto.
  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): Updated to call new ExecState constructor. (KJS::GlobalFuncImp::callAsFunction): Ditto (for eval).
  • kjs/function_object.cpp: (FunctionObjectImp::construct): Use exec->emptyList() instead of List::empty().
  • kjs/list.cpp: Removed List::empty.
  • kjs/list.h: Ditto.
  • kjs/nodes.cpp: (KJS::ElementNode::evaluate): Use exec->emptyList() instead of List::empty(). (KJS::ArrayNode::evaluate): Ditto. (KJS::ObjectLiteralNode::evaluate): Ditto. (KJS::PropertyListNode::evaluate): Ditto. (KJS::FunctionBodyNode::processDeclarations): Another speed-up. Check the capacity before calling reserveCapacity, because it doesn't get inlined the local storage vector is almost always big enough -- saving the function call overhead is a big deal. (KJS::FuncDeclNode::makeFunction): Use exec->emptyList() instead of List::empty(). (KJS::FuncExprNode::evaluate): Ditto.
  • kjs/object.cpp: (KJS::tryGetAndCallProperty): Ditto.
  • kjs/property_slot.cpp: (KJS::PropertySlot::functionGetter): Ditto.
  • kjs/string_object.cpp: (KJS::StringProtoFuncSplit::callAsFunction): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r29059 r29067  
    636636JSValue *ElementNode::evaluate(ExecState *exec)
    637637{
    638   JSObject *array = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, List::empty());
     638  JSObject* array = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList());
    639639  int length = 0;
    640640  for (ElementNode *n = this; n; n = n->next.get()) {
     
    667667    length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0;
    668668  } else {
    669     JSValue *newArr = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec,List::empty());
     669    JSValue* newArr = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList());
    670670    array = static_cast<JSObject*>(newArr);
    671671    length = 0;
     
    692692    return list->evaluate(exec);
    693693
    694   return exec->lexicalGlobalObject()->objectConstructor()->construct(exec,List::empty());
     694  return exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
    695695}
    696696
     
    707707JSValue *PropertyListNode::evaluate(ExecState *exec)
    708708{
    709   JSObject *obj = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty());
     709  JSObject* obj = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
    710710 
    711711  for (PropertyListNode *p = this; p; p = p->next.get()) {
     
    43624362    // We can't just resize localStorage here because that would temporarily
    43634363    // leave uninitialized entries, which would crash GC during the mark phase.
    4364     localStorage.reserveCapacity(m_varStack.size() + m_parameters.size() + m_functionStack.size());
     4364    size_t totalSize = m_varStack.size() + m_parameters.size() + m_functionStack.size();
     4365    if (totalSize > localStorage.capacity()) // Doing this check inline avoids function call overhead.
     4366        localStorage.reserveCapacity(totalSize);
    43654367   
    43664368    int minAttributes = Internal | DontDelete;
     
    45444546  FunctionImp *func = new FunctionImp(exec, ident, body.get(), exec->scopeChain());
    45454547
    4546   JSObject *proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty());
     4548  JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
    45474549  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
    45484550  func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
     
    45804582
    45814583  FunctionImp* func = new FunctionImp(exec, ident, body.get(), exec->scopeChain());
    4582   JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty());
     4584  JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
    45834585  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
    45844586  func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
Note: See TracChangeset for help on using the changeset viewer.