Last Comment Bug 775166 - Remove some ugly optimization in jsarray
: Remove some ugly optimization in jsarray
Status: RESOLVED FIXED
[js:t]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla17
Assigned To: Tom Schuster [:evilpie]
:
: Jason Orendorff [:jorendorff]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-18 10:22 PDT by Tom Schuster [:evilpie]
Modified: 2012-08-25 19:45 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
v1 (6.05 KB, patch)
2012-07-18 10:22 PDT, Tom Schuster [:evilpie]
bhackett1024: review+
Details | Diff | Splinter Review

Description Tom Schuster [:evilpie] 2012-07-18 10:22:51 PDT
Created attachment 643435 [details] [diff] [review]
v1

This seems very premature to optimize, because this is unlikely to really matter. Checking if something is a hole based on whether this index was atomized before seems really ugly.
Comment 1 Brian Hackett (:bhackett) 2012-07-18 13:06:33 PDT
Comment on attachment 643435 [details] [diff] [review]
v1

Review of attachment 643435 [details] [diff] [review]:
-----------------------------------------------------------------

Wow, gross.
Comment 3 Ryan VanderMeulen [:RyanVM] 2012-07-21 14:42:53 PDT
https://hg.mozilla.org/mozilla-central/rev/60b949c0eaef
Comment 4 Jeff Walden [:Waldo] (remove +bmo to email) 2012-08-25 19:45:04 PDT
Comment on attachment 643435 [details] [diff] [review]
v1

Review of attachment 643435 [details] [diff] [review]:
-----------------------------------------------------------------

I was always pretty meh about this ugly, nice to see someone caring more than me enough to remove it.  :-)  A few little comments in passing, while I'm skimming the bugmail backlog.

::: js/src/jsarray.cpp
@@ +260,5 @@
>      return true;
>  }
>  
> +bool
> +DoubleIndexToId(JSContext *cx, double index, jsid *id)

Shouldn't this be static bool?

@@ +261,5 @@
>  }
>  
> +bool
> +DoubleIndexToId(JSContext *cx, double index, jsid *id)
> +{

I think this method can assert that index is finite and a non-negative integer, right?

@@ +262,5 @@
>  
> +bool
> +DoubleIndexToId(JSContext *cx, double index, jsid *id)
> +{
> +    if (index == uint32_t(index))

Tom, if |index|, truncated, isn't a uint32_t, this invokes undefined behavior.  I *think*, if I remember correctly, that this method's only called with integral values, so couldn't you change this test to |index <= JSID_INT_MAX| to avoid this problem?

Note You need to log in before you can comment on or make changes to this bug.