Bug 3965 - IndexToNameMap::IndexToNameMap has n-squared behavior
Summary: IndexToNameMap::IndexToNameMap has n-squared behavior
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-12 11:12 PDT by Geoffrey Garen
Modified: 2008-09-21 23:15 PDT (History)
4 users (show)

See Also:


Attachments
Sample SunSpider test (3.29 KB, text/javascript)
2008-03-30 15:36 PDT, David Kilzer (:ddkilzer)
no flags Details
Script to generate function args test suite (568 bytes, text/plain)
2008-04-06 11:52 PDT, David Kilzer (:ddkilzer)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2005-07-12 11:12:47 PDT
For each argument, it searches through each argument to check for duplicate parameter names.

A better solution would move FunctionImp::getParameterName into IndexToNameMap::IndexToNameMap, 
and use a hash table to keep track of already seen parameter names --> better modularity and O(1) 
behavior.
Comment 1 David Kilzer (:ddkilzer) 2008-03-30 15:36:52 PDT
Created attachment 20224 [details]
Sample SunSpider test

SunSpider-0.9 doesn't use the "arguments" object from within a function, so it can't be used to test the performance of the IndexToNameMap constructor code.

This is a test that may be dropped into the SunSpider directory to be run.  I'm sure it doesn't mimic any real-world usage of arguments, but it does exercise the code in the IndexToNameMap constructor.
Comment 2 David Kilzer (:ddkilzer) 2008-04-06 11:52:28 PDT
Created attachment 20370 [details]
Script to generate function args test suite

This script generates tests for use with SunSpider.  It tests passing 0 to 10 arguments to eleven different functions, each of which have 0 to 10 arguments, for a total of 121 tests.

The script should be run from the checked-out SunSpider directory, and generates files of the form:

function-args-M-N.js

where "M" is the number arguments the function is defined with and N is the number of arguments actually passed to that function.

Note that the script outputs a list of function names to stdout, which need to be added to tests/LIST before running SunSpider:

$ ./sunspider --shell ../WebKitBuild/Release/testkjs --tests function-args --run 25
Comment 3 David Kilzer (:ddkilzer) 2008-09-21 18:50:00 PDT
See Bug 20815 Comment #7.
Comment 4 Darin Adler 2008-09-21 19:32:30 PDT
I eliminated IndexToNameMap in http://trac.webkit.org/changeset/36743 and I believe this bug is fixed now.
Comment 5 David Kilzer (:ddkilzer) 2008-09-21 23:15:58 PDT
(In reply to comment #4)
> I eliminated IndexToNameMap in http://trac.webkit.org/changeset/36743 and I
> believe this bug is fixed now.

See Bug 20972.