Bug 122084 (JSArraySetLength) - optimize jsarray setlength
Summary: optimize jsarray setlength
Status: RESOLVED INVALID
Alias: JSArraySetLength
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-29 19:33 PDT by Peng Xinchao
Modified: 2022-02-27 23:36 PST (History)
1 user (show)

See Also:


Attachments
optimze jsarray setlength (8.39 KB, patch)
2013-09-29 19:35 PDT, Peng Xinchao
ggaren: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peng Xinchao 2013-09-29 19:33:54 PDT
JSC Engine Optimize 'var ret =[] ; ret.length=1024' .When type of  ret is undefine and it   is setted length , its only public length is setted ,but its vector is not setted . the memory of variable ret is not changed .When the type of variable ret is confirm , its will allocate memory by public length.
Comment 1 Peng Xinchao 2013-09-29 19:35:06 PDT
Created attachment 212944 [details]
optimze jsarray setlength

 JSC Engine Optimize 'var ret =[] ; ret.length=1024' .When type of  ret is undefine and it   is setted length , its only public length is setted ,but its vector is not setted . the memory of variable ret is not changed .When the type of variable ret is confirm , its will allocate memory by public length.
Comment 2 Geoffrey Garen 2013-09-29 21:43:18 PDT
Can you provide a benchmark that demonstrates why you did this?
Comment 3 Peng Xinchao 2013-09-29 22:13:30 PDT
sunsprider and v8benchmark is not changed . It is to improve Drameo/JavaScript Arrays .
 The first item of Arrays is "Array Construction, []". its source code 
:
    for ( var j = 0; j < i * 15; j++ ) {
			ret = [];
			ret.length = 1024;
		}
 
My purpose is here.
Comment 4 Geoffrey Garen 2013-09-29 23:07:50 PDT
I'm pretty skeptical about a change just for this benchmark. Real programs typically use their arrays. Have you seen behavior like this in any real programs?
Comment 5 Peng Xinchao 2013-10-02 04:35:45 PDT
I don't argree with you.  When type of array is undefine and  array is setted length , That allocate memory directly is not necessary . I think that Memory will be allocated when it is really require.
Comment 6 Geoffrey Garen 2013-10-02 12:14:11 PDT
> I don't argree with you.

This isn't a matter of opinion. If a real program or website uses this idiom, you should be able to provide an empirical example.
Comment 7 Geoffrey Garen 2013-11-07 14:27:37 PST
Comment on attachment 212944 [details]
optimze jsarray setlength

Marking r- because we don't have an example of a website that uses this idiom.