25 мар. 2014 г.

Chrome 33: null !== null (sometimes)

Если в Chrome 33 посмотреть в консоль на страничках http://jsfiddle.net/u42Xm/1/ и http://jsfiddle.net/u42Xm/2/ то увидим интересную картину: условие null === null не выполняется 26440 раз из 50000 проходов цикла. Баг оптимизатора?

5 мар. 2014 г.

Эффективность реализации алгоритма reflow (layout) в браузерах

Реализация shadow DOM была удалена из кода WebKit, чтобы переписать её заново в отдельной ветке. По замыслу авторов это должно позволить

  1. избавиться от устаревшего кода, который много раз менялся вместе с изменениями спеки
  2. контролировать влияние на производительность (постепенные изменения кода в течение нескольких лет дали в итоге замедление времени загрузки страницы на 5%, но измерить результат было сложно, теперь сравнивать производительность разных веток кода будет проще)
> The old implementation on trunk resulted in 5% overall slowdown in the page load time but we didn't quantify that until we removed the feature entirely last year.  That's probably because the feature was added over years as a pile of small changesets each of which introduced immeasurably small performance regressions.  Development in a branch allows a faithful performance comparison between the two.
> JSC team has been utilizing SVN branches to work on Concurrent JIT, Generational GC, FTL, etc... to quantity the total performance cost and benefit of each feature, and it has been working very well as far as I could tell.

4 мар. 2014 г.

Порядок перечисления в for-in и Object.keys()

ECMAScript Language Specification Edition 3 (ECMA-262-3):

  • 4.3.3 Object
    An object is a member of the type Object. It is an unordered collection of properties each of which contains a primitive value, object, or function.
  • 12.6.4 The for-in Statement
    The mechanics of enumerating the properties (get the name of the next property ... that doesn't have the DontEnum attribute) is implementation dependent.
ECMAScript Language Specification Edition 5.1 (ECMA-262-5.1):
  • 8.6 The Object Type
    An Object is a collection of properties.
  • 12.6.4 The for-in Statement
    The mechanics and order of enumerating the properties (let P be the name of the next property of obj whose [[Enumerable]] attribute is true) is not specified.
  • 15.2.3.14 Object.keys ( O )
    If an implementation defines a specific order of enumeration for the for-in statement, that same enumeration order must be used in step 5 of this algorithm.