Slow access of global variables

VERIFIED DUPLICATE of bug 169559

Status

()

Core
Security
VERIFIED DUPLICATE of bug 169559
15 years ago
15 years ago

People

(Reporter: Tim Powell, Assigned: Mitchell Stoltz (not reading bugmail))

Tracking

({perf})

Trunk
x86
Windows 95
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
Accessing a JavaScript global variable is extremely slow in Mozilla 1.3. I don't
understand why this is. The slowest is to use global variables outside a
function, which I would imagine is quite common. Global variables are about 3
times slower than local variables in a function. Globals in functions in IE are
also somewhat slower, but only about 1.5 times slower than its local variables.
(Reporter)

Comment 1

15 years ago
Created attachment 119586 [details]
Testcase comparing local and global variables in loops

I'm using this testcase to compare performance. Here's the results on the same
computer (Pentium II 300MHz, 364M RAM):

Mozilla 1.3: Local: 770ms  Global: 2310ms  Global not Function: 3960ms
   MS IE5.5: Local: 880ms  Global: 1430ms  Global not Function: 2190ms
(Reporter)

Comment 2

15 years ago
Note that the testcase may load somewhat slowly initially because it tests
globals outside a function when the page loads. Click the test button to test
local and global variables in functions.
Summary: Slow access of global variables → Slow access of global variables

Comment 3

15 years ago
This is due to DOM security checks on global variables. That is,
Mozilla does a security check on every global variable access;
IE does not.

Reassigning to Security:General to see if this cost can be mitigated
in any way, and cc'ing jst -
Assignee: rogerl → mstoltz
Component: JavaScript Engine → Security: General
QA Contact: pschwartau → carosendahl

Comment 4

15 years ago
Actually, this bug is a duplicate of bug 169559. Tim, you will be
cc'ed on that one so you can follow progress on this issue -

*** This bug has been marked as a duplicate of 169559 ***
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE

Comment 5

15 years ago
v
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.