Bug 143247 - Object.preventExtensions/seal/freeze makes code much slower
Summary: Object.preventExtensions/seal/freeze makes code much slower
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks: 160479
  Show dependency treegraph
 
Reported: 2015-03-30 18:39 PDT by Elliott Sprehn
Modified: 2016-08-02 17:02 PDT (History)
13 users (show)

See Also:


Attachments
work in progress (16.61 KB, patch)
2016-07-17 17:51 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (22.60 KB, patch)
2016-07-17 18:41 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (29.25 KB, patch)
2016-07-17 18:43 PDT, Filip Pizlo
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews106 for mac-yosemite-wk2 (836.09 KB, application/zip)
2016-07-17 19:49 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews114 for mac-yosemite (1.54 MB, application/zip)
2016-07-17 19:52 PDT, Build Bot
no flags Details
the patch (29.57 KB, patch)
2016-07-17 21:05 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
performance (79.15 KB, text/plain)
2016-07-17 22:05 PDT, Filip Pizlo
no flags Details
the patch (29.56 KB, patch)
2016-07-17 22:06 PDT, Filip Pizlo
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Sprehn 2015-03-30 18:39:48 PDT
If you have

class Foo {
  constructor() {
    this.property = 1;
    Object.preventExtensions(this);
  }
}

calling new Foo() seems to be 2-3x slower than doing so without the call to preventExtensions. This is not the case in v8 or Firefox. This pattern is really nice since it catches bad assignments and typos in code.
Comment 1 Filip Pizlo 2016-07-17 17:51:16 PDT
Created attachment 283875 [details]
work in progress
Comment 2 Filip Pizlo 2016-07-17 18:41:05 PDT
Created attachment 283877 [details]
the patch
Comment 3 Filip Pizlo 2016-07-17 18:43:52 PDT
Created attachment 283878 [details]
the patch

The previous patch didn't include the LayoutTests additions.  I'm still testing this, but so far it appears to work like a charm.
Comment 4 Filip Pizlo 2016-07-17 18:45:14 PDT
Comment on attachment 283878 [details]
the patch

I'm seeing crashes.  I'll put up a better patch once I figure out what those are all about.
Comment 5 Build Bot 2016-07-17 19:49:00 PDT
Comment on attachment 283878 [details]
the patch

Attachment 283878 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1699149

New failing tests:
js/preventExtensions.html
Comment 6 Build Bot 2016-07-17 19:49:05 PDT
Created attachment 283879 [details]
Archive of layout-test-results from ews106 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 7 Build Bot 2016-07-17 19:52:43 PDT
Comment on attachment 283878 [details]
the patch

Attachment 283878 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1699142

New failing tests:
js/preventExtensions.html
Comment 8 Build Bot 2016-07-17 19:52:47 PDT
Created attachment 283880 [details]
Archive of layout-test-results from ews114 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 9 Filip Pizlo 2016-07-17 21:05:53 PDT
Created attachment 283882 [details]
the patch

Fixed the test failure.
Comment 10 Filip Pizlo 2016-07-17 22:05:51 PDT
Created attachment 283883 [details]
performance
Comment 11 Filip Pizlo 2016-07-17 22:06:23 PDT
Created attachment 283884 [details]
the patch

Included perf data.
Comment 12 Michael Saboff 2016-07-18 10:41:36 PDT
Comment on attachment 283884 [details]
the patch

r=me
Comment 13 Filip Pizlo 2016-07-18 13:13:59 PDT
Landed in https://trac.webkit.org/changeset/203368
Comment 14 Keith Miller 2016-08-02 16:57:32 PDT
Looks like this breaks some test262 tests.

Specifically:

JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-2.js
JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-3.js
JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-4.js

Which can be run with:

jsc JSTests/test262/harness/assert.js JSTests/test262/harness/sta.js JSTests/test262/harness/propertyHelper.js <testFile>
Comment 15 Filip Pizlo 2016-08-02 17:02:57 PDT
(In reply to comment #14)
> Looks like this breaks some test262 tests.
> 
> Specifically:
> 
> JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-2.js
> JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-3.js
> JSTests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-4.js
> 
> Which can be run with:
> 
> jsc JSTests/test262/harness/assert.js JSTests/test262/harness/sta.js
> JSTests/test262/harness/propertyHelper.js <testFile>

Filed: https://bugs.webkit.org/show_bug.cgi?id=160479