IonMonkey: Constant boundscheck bailouts on setelem

RESOLVED FIXED in mozilla25

Status

()

defect
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: h4writer, Assigned: h4writer)

Tracking

(Blocks 1 bug)

unspecified
mozilla25
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Small testcase:

var obj = {}
fun = function(index, value)
{
  for(var i=0; i<4000; i++)
    i -= 0.1;

  obj[index] = value;
}
for (var i=0; i<20; i++)
{
  var rnd = Math.floor(Math.random() * 3000);
  fun(rnd, true);
}

Constant bailing on obj[index] = value;

The object is annotated being sparse, but we don't do anything with it. So I copied the same logic as we have for getelem (to check for sparse + boundscheck failure). This solves the issue.
(Assignee)

Comment 1

6 years ago
Posted patch bug899051-boundscheck (obsolete) — Splinter Review
Assignee: general → hv1989
Attachment #782547 - Flags: review?(bhackett1024)
(Assignee)

Updated

6 years ago
Blocks: 897962
(Assignee)

Comment 2

6 years ago
Updated to tip. There were some unrelated changes
Attachment #782547 - Attachment is obsolete: true
Attachment #782547 - Flags: review?(bhackett1024)
Attachment #782555 - Flags: review?(bhackett1024)
Attachment #782555 - Flags: review?(bhackett1024) → review+

Comment 3

6 years ago
This change really improves the performance a lot in some situations.
I've changed the test-script a bit to make it a "benchmark-script".
For the function I tested in 0 A.D. there was no improvement, so there must be still another bug.


Modified testscript:
--------------------
var obj = {}

fun = function(index, value)
{
	for(var i=0; i<4000; i++)
		i -= 0.1;

	obj[index] = value;
}

var startTime = elapsed();
for (var i=0; i<10000; i++)
{
	var rnd = Math.floor(Math.random() * 20000);
	var value = false;
	if (rnd%500 === 0)
		value = true;
	fun(rnd, value);
}
var endTime = elapsed();
var timeElapsed = endTime - startTime;
print("time: " + timeElapsed);


Debug mode without patch (in microseconds):
-------------------------------------------
time: 12117303
time: 12030396
time: 12008570
-----------------
Average: 12052090


Debug mode with patch (in microseconds):
----------------------------------------
time: 309777
time: 308813
time: 307613
---------------
Average: 308734

Debug mode: now only takes 1/39 of the time


Release without patch (in microseconds):
----------------------------------------
time: 796801
time: 822047
time: 795438
---------------
Average: 804762


Release mode with patch (in microseconds):
------------------------------------------
time: 160410
time: 160823
time: 160517
---------------
Average: 160583

Release mode: now only takes 1/5 of the time
(Assignee)

Updated

6 years ago
Depends on: 899572
https://hg.mozilla.org/mozilla-central/rev/d2e6989ff928
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.