WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 30942
Use pointers instead of copies to pass GregorianDateTime objects around
https://bugs.webkit.org/show_bug.cgi?id=30942
Summary
Use pointers instead of copies to pass GregorianDateTime objects around
Geoffrey Garen
Reported
2009-10-29 18:56:19 PDT
Created
attachment 42168
[details]
patch patch coming.
Attachments
patch
(22.54 KB, patch)
2009-10-29 18:56 PDT
,
Geoffrey Garen
levin
: review-
Details
Formatted Diff
Diff
patch2
(22.95 KB, patch)
2009-10-30 14:28 PDT
,
Geoffrey Garen
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
David Levin
Comment 1
2009-10-29 21:12:24 PDT
Comment on
attachment 42168
[details]
patch This seemed to be intent on preserving the current behavior, but doing it in a more efficient manner, so I reviewed it with that in mind.
> Index: JavaScriptCore/ChangeLog
Please add a link to the bug.
> + (JSC::dateProtoFuncGetYear): Renamed getGregorianDateTime to gregorianDateTime, > + since it no longer has an out parameter. Uses NULL to indicate invalid dates.
Since 0 is used in the code instead of NULL, nice to do the same thing here.
> Index: JavaScriptCore/runtime/DateInstance.cpp > +const GregorianDateTime* DateInstance::gregorianDateTime(ExecState* exec, bool outputIsUTC) const
> + return &m_data->m_cachedGregorianDateTimeUTC; > } else {
Since there is now a return at the end of the "if", the "else" should be removed.
> Index: JavaScriptCore/runtime/DatePrototype.cpp > JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) > @@ -454,13 +454,13 @@ JSValue JSC_HOST_CALL dateProtoFuncToISO > + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, outputIsUTC);
fwiw, in other places, you changed the name from t to gregorianDateTime.
> JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) > @@ -830,16 +830,19 @@ static JSValue setNewValueFromTimeArgs(E > + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, inputIsUTC);
fwiw, in other places, you changed the name from t to gregorianDateTime.
> + if (!t) > + return jsNaN(exec);
This doesn't look right to me and appears to be change in behavior. In other similar places, it does this: JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; It seems like this case isn't covered by current layout tests, so it would be nice to expand them to hit it.
> @@ -857,26 +860,27 @@ static JSValue setNewValueFromDateArgs(E > + if (numArgsToUse == 3 && isnan(milli)) { > - // Based on ECMA 262 15.9.5.40 - .41 (set[UTC]FullYear) > - // the time must be reset to +0 if it is NaN.
You're removing this comment. Do you think it is no longer valuable?
> + JSValue result = jsNumber(exec, 0); > + thisDateObj->setInternalValue(result); > + return result; > }
> + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, inputIsUTC); > + if (!t) > + return jsNaN(exec);
This doesn't look right to me and appears to be change in behavior. In other similar places, it does this: JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; It seems like this case isn't covered by current layout tests, so it would be nice to expand them to hit it.
Geoffrey Garen
Comment 2
2009-10-30 14:28:34 PDT
> > Index: JavaScriptCore/ChangeLog > > Please add a link to the bug.
Fixed.
> > > + (JSC::dateProtoFuncGetYear): Renamed getGregorianDateTime to gregorianDateTime, > > + since it no longer has an out parameter. Uses NULL to indicate invalid dates. > > Since 0 is used in the code instead of NULL, nice to do the same thing here.
Fixed.
> > Index: JavaScriptCore/runtime/DateInstance.cpp > > +const GregorianDateTime* DateInstance::gregorianDateTime(ExecState* exec, bool outputIsUTC) const > > > + return &m_data->m_cachedGregorianDateTimeUTC; > > } else { > > Since there is now a return at the end of the "if", the "else" should be > removed.
Fixed.
> > JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) > > @@ -454,13 +454,13 @@ JSValue JSC_HOST_CALL dateProtoFuncToISO > > + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, outputIsUTC); > > fwiw, in other places, you changed the name from t to gregorianDateTime. > > > > JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) > > @@ -830,16 +830,19 @@ static JSValue setNewValueFromTimeArgs(E > > + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, inputIsUTC); > > fwiw, in other places, you changed the name from t to gregorianDateTime.
"gregorianDateTime" is not an option, since it would conflict with the local name gregorianDateTime. I changed these cases to "other" to match the style of how a copy constructor indicates the object being copied.
> > + if (!t) > > + return jsNaN(exec); > > This doesn't look right to me and appears to be change in behavior. In other > similar places, it does this: > JSValue result = jsNaN(exec); > thisDateObj->setInternalValue(result); > return result;
No change in behavior. If gregorianDateTime returns 0, it indicates that the object's internal value is already NaN, so there's no need to set it to NaN. The new code is the same, just less verbose.
> > @@ -857,26 +860,27 @@ static JSValue setNewValueFromDateArgs(E > > + if (numArgsToUse == 3 && isnan(milli)) { > > - // Based on ECMA 262 15.9.5.40 - .41 (set[UTC]FullYear) > > - // the time must be reset to +0 if it is NaN. > > You're removing this comment. Do you think it is no longer valuable?
The original KJS developers had a habit of commenting most lines of code with the section of the ECMA spec that pertained to them. We've been moving away from that style, since it just clutters the code.
> > + const GregorianDateTime* t = thisDateObj->gregorianDateTime(exec, inputIsUTC); > > + if (!t) > > + return jsNaN(exec); > > This doesn't look right to me and appears to be change in behavior. In other > similar places, it does this: > JSValue result = jsNaN(exec); > thisDateObj->setInternalValue(result); > return result;
Same as above. I'll post a new patch with the fixes in place.
Geoffrey Garen
Comment 3
2009-10-30 14:28:59 PDT
Created
attachment 42235
[details]
patch2
Darin Adler
Comment 4
2009-10-30 14:46:09 PDT
Comment on
attachment 42235
[details]
patch2 r=me Generally we should never be typing "WTF::" anywhere except for the "using WTF::<name>" in the WTF headers. It looks like we’re not following that guideline (created by Maciej) in the code you’re modifying or the code you’re adding.
Geoffrey Garen
Comment 5
2009-10-30 15:23:54 PDT
Committed revision 50359 with some WTF's removed.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug