Closed Bug 771742 Opened 13 years ago Closed 13 years ago

Refactor many of the Date methods to be implemented in separate methods (not in single utility functions), using the spec algorithms

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

Attachments

(5 files)

The current NonGenericMethodGuard idiom is awkward and doesn't read very naturally. It asks for a JSClass* even when the method in question might need to accept objects (this values, more generally) that are of multiple classes. It also results in weird function-pointer-passing behaviors that aren't easy to use, or to understand on the implementation side. We're introducing a new system to address this, which will take a test function (that says if a value is an acceptable this) and an implementation function (which will perform the implemented function's semantics, knowing that the this value passed the test). To do this we need to refactor some of the existing method-guard code, which currently has to pass along the function pointer for recursive invocation, and which can't really be adapted to the new form. This bug will hold patches to do this refactoring. (The actual method guard idiom change more generally will be a separate bug.)
The existing Date.prototype.* code makes a bunch of assumptions about the exact way we implement stuff now -- that NaNs won't enter, that if they do they'll propagate nicely, and so on. So there's a little more work being done in this patch than in the code before it. But it's very little -- think more isNaN or ToInteger computations -- and should be negligible overall, and it'll allow us to implement the spec algorithms as the spec states them.
Attachment #639901 - Flags: review?(luke)
Comment on attachment 639901 [details] [diff] [review] Preliminary reorganization of various Date spec methods/constants Review of attachment 639901 [details] [diff] [review]: ----------------------------------------------------------------- Nice ::: js/src/jsdate.cpp @@ -189,5 @@ > -/* math here has to be f.p, because we need > - * floor((1968 - 1969) / 4) == -1 > - */ > -#define DayFromYear(y) (365 * ((y)-1970) + floor(((y)-1969)/4.0) \ > - - floor(((y)-1901)/100.0) + floor(((y)-1601)/400.0)) But it was so readable before!
Attachment #639901 - Flags: review?(luke) → review+
Comment on attachment 639902 [details] [diff] [review] Implement the Date.prototype.set<time component> methods in spec terms, without using date_makeTime Mmmm, Waldo-style spec comments; good stuff.
Attachment #639902 - Flags: review?(luke) → review+
Comment on attachment 639903 [details] [diff] [review] Same thing for Date.prototype.set<day/month/year duration>, without date_makeDate Review of attachment 639903 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsdate.cpp @@ -2127,5 @@ > - SetDateToNaN(cx, thisObj, &args.rval()); > - return true; > - } > - > - unsigned numNums = Min(args.length(), maxargs); I'm gonna miss numNums.
Attachment #639903 - Flags: review?(luke) → review+
Attachment #639904 - Flags: review?(luke) → review+
Comment on attachment 639907 [details] [diff] [review] Date.prototype.to{ISO,GMT}String refactoring No /* Step 1 */ comments?
Attachment #639907 - Flags: review?(luke) → review+
Target Milestone: --- → mozilla16
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: