Review Request: KJS: Implement Object.GetOwnPropertyDescriptor & Object.DefineProperty

Bernd Buschinski b.buschinski at googlemail.com
Mon Apr 9 21:23:28 BST 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/104515/
-----------------------------------------------------------

(Updated April 9, 2012, 8:23 p.m.)


Review request for kdelibs.


Changes
-------

Changed Array to use Object instead of Pointer to Objects.

This gives a 100ms speed boost compared to the Pointer version.
Overall its ~100ms slower than the original kjs 4.8.2, but that is expected as this version really checks for attributes.
So every put/delete/enum is really checked, a version without check is always faster.

Tested with sunspider 1.0 (latest svn trunk), both version run about 10 times (x10runs = 100).


I also tested virtual putDirect vs. non-virtual putDirect (only performancewise), the avg performance loss was 14ms (after 10 x 10 runs = 100 sunspider 1.0 runs).
Anyway it does not seems like it is a very critical performance loss.


testregress showed a tiny/typo difference with max Array Index, this is fixed in this version. Now no difference when using
./testregression.shell --js --noxvfb ~/khtmltests/regression/
compared to the orginal kde 4.8.2 kjs


Description
-------

KJS: Implement Object.GetOwnPropertyDescriptor & Object.DefineProperty

This is a pretty big patch, to get Object.defineProperty perfect for ecmascript (for all tests that only use implemented stuff, all test that use Object.create for example will fail, as its not implemented)

PropertyDescriptor:
Necessary for collectiong data, this introduce new CommonIdentifiers.h, this might requiere to rebuild khtml against new kjs, otherwise it might cause weird crashes (at least for me)


object.h:
Beside from adding new getPropertyDescriptor & getOwnPropertyDescriptor & defineOwnProperty, the important changes are making
getPropertyAttributes, put/get/remove-Direct virtual.
Why do I need that?
Because put checks if the prototype already has property XYZ and uses it. Now imagine an array that got a setter-only property via a prototype. DefineProperty would try to use put, which uses the prototype property and it would fail. So all custom-data classes like Array need to implement/use put/get/remove-Direct.


object.cpp:
currently put on a setter-only property would always throw an exception, this is only correct for strict-mode, as we currently do not check for strict-mode it would make more sense to change it to default not throwing an exception.


array.cpp/h:
The old Array implementation did not store attributes for array indexes, I rewrote it to also store the attributes.
+ Bonus: also fix getOwnPropertyNames, as we now store attributes.
+ use new attributes, reject put/delete/enum if set

function.cpp (Arguments)
changed the default attributes how parameter are stored, according to ECMA 10.6.11.b


Rest is "just" the defineProperty implementation


Diffs (updated)
-----

  kjs/CMakeLists.txt 1188064 
  kjs/CommonIdentifiers.h 8ee40e8 
  kjs/array_instance.h 3f2b630 
  kjs/array_instance.cpp fe9b8b4 
  kjs/function.h 3757fe8 
  kjs/function.cpp 5f39ae6 
  kjs/object.h 047c242 
  kjs/object.cpp c19122f 
  kjs/object_object.cpp 986f03f 
  kjs/operations.h f8a28c8 
  kjs/operations.cpp d4c0066 

Diff: http://git.reviewboard.kde.org/r/104515/diff/


Testing
-------

ecmascript & daily surfing

used valgrind on many array testcases to check for possible memleaks


Thanks,

Bernd Buschinski

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20120409/d7936cc0/attachment.htm>


More information about the kde-core-devel mailing list