Bug 19718

Summary: Named anonymous functions are slow accessing global variables
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Description Flags
Testcase none

Description Timothy Hatcher 2008-06-22 18:58:55 PDT
A named anonymous function that accesses a global or closure scope variable is slower than a non-named anonymous function. See the attached test case. This is a regression since SquirrelFish.
Comment 1 Timothy Hatcher 2008-06-22 18:59:28 PDT
Created attachment 21876 [details]
Comment 2 Geoffrey Garen 2008-06-23 12:49:51 PDT
Can you give more data on the SquirrelFish regression:

* Is access to a global from a named anonymous function slower in SF than it was before SF?

* How big (%) is the regression?

The cause of the relative slowness is that, according to the spec, a named anonymous function should have a vanilla (i.e. unoptimized) object inserted into its scope chain, with one property: the function's name. 

We can / should improve this situation, but that's how things are implemented today (and how they've always been implemented).
Comment 3 Timothy Hatcher 2008-06-23 13:16:54 PDT
It is not a regression, since SquirrelFish is faster than Safari 3.1. But there is now a difference in speed between named anonymous functions and non-named anonymous function that didn't exist in Safari 3.1.
Comment 4 Oliver Hunt 2008-07-25 20:53:50 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	JavaScriptCore/ChangeLog
	M	JavaScriptCore/GNUmakefile.am
	M	JavaScriptCore/JavaScriptCore.pri
	M	JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
	M	JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
	M	JavaScriptCore/VM/CodeGenerator.cpp
	M	JavaScriptCore/VM/CodeGenerator.h
	M	JavaScriptCore/kjs/AllInOneFile.cpp
	A	JavaScriptCore/kjs/JSStaticScopeObject.cpp
	A	JavaScriptCore/kjs/JSStaticScopeObject.h
	M	JavaScriptCore/kjs/nodes.cpp
	M	LayoutTests/ChangeLog
	M	LayoutTests/fast/js/const-expected.txt
	M	LayoutTests/fast/js/resources/const.js
Committed r35368