Ignore:
Timestamp:
Apr 22, 2007, 9:16:42 PM (18 years ago)
Author:
mjs
Message:

Reviewed by Darin.


Based an idea by Christopher E. Hyde <[email protected]>. His patch to do
this also had many other List changes and I found this much simpler subset of the changes
was actually a hair faster.


This optimization is valid because the arguments list is only kept around to
lazily make the arguments object. If it's not made by the time the function
exits, it never will be, since any function that captures the continuation will
have its own local arguments variable in scope.


Besides the 1.7% speed improvement, it shrinks List by 4 bytes
(which in turn shrinks ActivationImp by 4 bytes).


  • kjs/Context.cpp: (KJS::Context::~Context): Clear the activation's arguments list.
  • kjs/function.cpp: (KJS::ActivationImp::ActivationImp): Adjusted for list changes. (KJS::ActivationImp::mark): No need to mark, lists are always protected (this doesn't cause a ref-cycle for reasons stated above). (KJS::ActivationImp::createArgumentsObject): Clear arguments list.
  • kjs/function.h:
  • kjs/list.cpp: (KJS::List::List): No more needsMarking boolean (KJS::List::operator=): ditto
  • kjs/list.h: (KJS::List::List): ditto (KJS::List::reset): ditto (KJS::List::deref): ditto
File:
1 edited

Legend:

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

    r14834 r21019  
    1 // -*- c-basic-offset: 2 -*-
     1// -*- mode: c++; c-basic-offset: 4 -*-
    22/*
    33 *  This file is part of the KDE libraries
    44 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
    6  *  Copyright (C) 2003, 2006 Apple Computer, Inc.
     6 *  Copyright (C) 2003, 2006-2007 Apple Computer, Inc.
    77 *
    88 *  This library is free software; you can redistribute it and/or
     
    8585{
    8686    m_interpreter->setContext(m_callingContext);
     87
     88    // The arguments list is only needed to potentially create the  arguments object,
     89    // which isn't accessible from nested scopes so we can discard the list as soon
     90    // as the function is done running.
     91    // This prevents lists of Lists from building up, waiting to be garbage collected
     92    ActivationImp* activation = static_cast<ActivationImp*>(m_activation);
     93    if (activation)
     94        activation->releaseArguments();
    8795}
    8896
Note: See TracChangeset for help on using the changeset viewer.