Project: v8 Issues People Development process History Sign in
New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Issue 1506 Optimization for arguments.length
Starred by 15 users Reported by sra@google.com, Jun 28 2011 Back to list
Status: Available
Owner: ----
Cc:
Components:
HW: ----
OS: ----
Priority: 3
Type: FeatureRequest



Sign in to add a comment
Functions containing 'arguments' only as the expression 'arguments.length' could be much more efficient.  There is no need to allocate the arguments array.  arguments.length could be replaced with %_ArgumentsLength()

 
Owner: kmillikin@chromium.org
Comment 2 by sra@google.com, Dec 1 2014
Has this been improved?

Comment 3 by sra@google.com, Dec 2 2014
There is some improvement, but the compiler seems to think that the result of arguments-length might not fit in a Smi, even though it is stored as a Smi in the adaptor frame or would require a parameter list of several gigabytes.
Perhaps it should have an InferRange.


--- Raw source ---
(a, b) {
  "use strict";
  return arguments.length;
}
 
 
--- Optimized code ---
optimization_id = 0
source_position = 13
kind = OPTIMIZED_FUNCTION
name = foo
stack_slots = 2
Instructions (size = 212)
0x4ac531e0     0  55             push ebp
0x4ac531e1     1  89e5           mov ebp,esp
0x4ac531e3     3  56             push esi
0x4ac531e4     4  57             push edi
0x4ac531e5     5  83ec08         sub esp,0x8
                  ;;; Store dynamic frame alignment tag for spilled doubles
0x4ac531e8     8  c745f400000000 mov [ebp-0xc],0x0
                  ;;; <@0,#0> -------------------- B0 --------------------
                  ;;; <@2,#1> context
0x4ac531ef    15  8b45fc         mov eax,[ebp-0x4]
                  ;;; <@3,#1> gap
0x4ac531f2    18  8945f0         mov [ebp-0x10],eax
                  ;;; <@12,#9> -------------------- B1 --------------------
                  ;;; <@13,#9> gap
0x4ac531f5    21  89c6           mov esi,eax
                  ;;; <@14,#11> stack-check
0x4ac531f7    23  3b25406c230b   cmp esp,[0xb236c40]
0x4ac531fd    29  7305           jnc 36  (0x4ac53204)
0x4ac531ff    31  e8bcfffdff     call StackCheck  (0x4ac331c0)    ;; code: BUILTIN
                  ;;; <@16,#11> lazy-bailout
                  ;;; <@18,#13> arguments-elements
0x4ac53204    36  8b4500         mov eax,[ebp+0x0]
0x4ac53207    39  8b40fc         mov eax,[eax-0x4]
0x4ac5320a    42  83f814         cmp eax,0x14
0x4ac5320d    45  7404           jz 51  (0x4ac53213)
0x4ac5320f    47  8bc5           mov eax,ebp
0x4ac53211    49  eb03           jmp 54  (0x4ac53216)
0x4ac53213    51  8b4500         mov eax,[ebp+0x0]
                  ;;; <@20,#14> arguments-length
0x4ac53216    54  3be8           cmp ebp,eax
0x4ac53218    56  b902000000     mov ecx,0x2
0x4ac5321d    61  7408           jz 71  (0x4ac53227)
0x4ac5321f    63  8b4d00         mov ecx,[ebp+0x0]
0x4ac53222    66  8b49f4         mov ecx,[ecx-0xc]
0x4ac53225    69  d1f9           sar ecx,1
                  ;;; <@22,#18> number-tag-i
0x4ac53227    71  03c9           add ecx,ecx
0x4ac53229    73  0f8008000000   jo 87  (0x4ac53237)
                  ;;; <@23,#18> gap
0x4ac5322f    79  89c8           mov eax,ecx
                  ;;; <@24,#16> return
0x4ac53231    81  89ec           mov esp,ebp
0x4ac53233    83  5d             pop ebp
0x4ac53234    84  c20c00         ret 0xc
                  ;;; <@22,#18> -------------------- Deferred number-tag-i --------------------
0x4ac53237    87  d1f9           sar ecx,1
0x4ac53239    89  81f100000080   xor ecx,0x80000000
0x4ac5323f    95  0f57c0         xorps xmm0,xmm0
0x4ac53242    98  f20f2ac1       cvtsi2sd xmm0,ecx
0x4ac53246   102  8b0d743c230b   mov ecx,[0xb233c74]
0x4ac5324c   108  89c8           mov eax,ecx
0x4ac5324e   110  83c00c         add eax,0xc
0x4ac53251   113  0f821c000000   jc 147  (0x4ac53273)
0x4ac53257   119  3b05783c230b   cmp eax,[0xb233c78]
0x4ac5325d   125  0f8710000000   ja 147  (0x4ac53273)
0x4ac53263   131  8905743c230b   mov [0xb233c74],eax
0x4ac53269   137  41             inc ecx
0x4ac5326a   138  c741ff7181b040 mov [ecx-0x1],0x40b08171    ;; object: 0x40b08171 <Map(elements=3)>
0x4ac53271   145  eb17           jmp 170  (0x4ac5328a)
0x4ac53273   147  33c9           xor ecx,ecx
0x4ac53275   149  60             pushad
0x4ac53276   150  8b75fc         mov esi,[ebp-0x4]
0x4ac53279   153  33c0           xor eax,eax
0x4ac5327b   155  bb00df2d08     mov ebx,0x82ddf00
0x4ac53280   160  e8db6efbff     call 0x4ac0a160             ;; code: STUB, CEntryStub, minor: 1
0x4ac53285   165  89442418       mov [esp+0x18],eax
0x4ac53289   169  61             popad
0x4ac5328a   170  f20f114103     movsd [ecx+0x3],xmm0
0x4ac5328f   175  eb9e           jmp 79  (0x4ac5322f)
0x4ac53291   177  90             nop
0x4ac53292   178  90             nop
0x4ac53293   179  90             nop
0x4ac53294   180  90             nop
0x4ac53295   181  90             nop
0x4ac53296   182  66             nop
0x4ac53297   183  90             nop

Cc: kmillikin@chromium.org
Labels: Type-FeatureRequest Area-Compiler Priority-Low
Owner: ----
Status: Available
Where is my Factory Kyocera Hydro?  Where is Class A Licence? I Passed both In Indiana and Also California 100! Peter Don't make me cross you heart.
Lazman217
Labels: Priority-3
Sign in to add a comment