The following is the design in my mind
We can find that Object.defineProperty is frequently called in some realistic frameworks such as Ember.js.
Object.defineProperty is typically used in the following form.
Object.defineProperty(object, name, {
// property descriptor object
});
If we can create Object.defineProperty's prologue in JS, we can encourage Object Allocation Sinking to sink the above property descriptor object.
My design is simple. We already have some bytecodes like op_define_data_property / op_define_accessor_property.
So, let's add bytecode intrinsic for them and wrap them with JS function.
function defineProperty(object, name, descriptor) {
// Retrieve necessary values.
var enumerable = descriptor.enumerable;
...
// And call intrinsics.
if (accessor property)
@defineAccessorProperty(...);
else
@defineDataProperty(...);
....
}
(In reply to Yusuke Suzuki from comment #1)
> The following is the design in my mind
>
> We can find that Object.defineProperty is frequently called in some
> realistic frameworks such as Ember.js.
> Object.defineProperty is typically used in the following form.
>
> Object.defineProperty(object, name, {
> // property descriptor object
> });
>
> If we can create Object.defineProperty's prologue in JS, we can encourage
> Object Allocation Sinking to sink the above property descriptor object.
> My design is simple. We already have some bytecodes like
> op_define_data_property / op_define_accessor_property.
> So, let's add bytecode intrinsic for them and wrap them with JS function.
>
> function defineProperty(object, name, descriptor) {
> // Retrieve necessary values.
> var enumerable = descriptor.enumerable;
> ...
> // And call intrinsics.
> if (accessor property)
> @defineAccessorProperty(...);
> else
> @defineDataProperty(...);
> ....
> }
At that time, we need extra carefully construct this defineProperty function to be inlined.
Created attachment 315616[details]
WIP - It starts
RFC here. It is just starting the implementation.
This implementation isn't spec compliant and I'm thinking create intrinsic functions to verify if the descriptor has some property without user observable behavior, otherwise it will be classified as escaped object if we use "in" operation.
I'm also in doubt if there is another case where the user-observable behavior can be captured other than proxies case, because according the spec[1], ToPropertyDescriptor operation is called.
The fast case I'm planing here is when we have "Object.defineProperty(a, "foo", {/* descriptor */})" and descriptor is a JS Object allocated in DFG with "NewObject".
[1]-https://tc39.github.io/ecma262/#sec-object.defineproperty
Attachment 315616[details] did not pass style-queue:
ERROR: Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:827: One line control clauses should not use braces. [whitespace/braces] [4]
Total errors found: 1 in 13 files
If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 315620[details]
Archive of layout-test-results from ews114 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 315621[details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Created attachment 315625[details]
Archive of layout-test-results from ews125 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Created attachment 315626[details]
Archive of layout-test-results from ews100 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 317382[details]
RFC - Patch proposal
It's a WIP. Not all test passing, but I would like to get feedback in the Path I'm following here. I'm not 100% sure if the Machinery into FTL analysis are right.
The main idea into FTL is that since the descriptor allocation won't exist, I need to check the presence of properties from structure.
Also, I think that fast path rule should allow just descriptors with prototype === Object. Otherwise it should fall to slow path, since we can have proxies into prototype chain.
Created attachment 322642[details]
Benchmarks
These are the results of current benchmarks. I can see some regressions on "regexp-prototype-*-observable-side-effects" and "string-prototype-*-observable-side-effects", but as the function is called 4 times in each test, there is no JIT and we can't benefit from it.
Created attachment 322697[details]
Archive of layout-test-results from ews112 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322727[details]
Archive of layout-test-results from ews101 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322743[details]
Archive of layout-test-results from ews102 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322749[details]
Archive of layout-test-results from ews112 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322751[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Created attachment 322754[details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Created attachment 322826[details]
Archive of layout-test-results from ews102 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322827[details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Created attachment 322831[details]
Archive of layout-test-results from ews115 for mac-elcapitan
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Created attachment 322832[details]
Archive of layout-test-results from ews125 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Created attachment 322846[details]
Archive of layout-test-results from ews124 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
2017-07-16 12:05 PDT, Caio Lima
2017-07-16 12:26 PDT, Caio Lima
2017-07-16 13:22 PDT, Build Bot
2017-07-16 13:32 PDT, Build Bot
2017-07-16 13:56 PDT, Build Bot
2017-07-16 14:01 PDT, Build Bot
2017-08-06 13:13 PDT, Caio Lima
2017-10-04 02:14 PDT, Caio Lima
2017-10-04 02:20 PDT, Caio Lima
2017-10-04 11:44 PDT, Build Bot
2017-10-04 14:24 PDT, Build Bot
2017-10-04 16:12 PDT, Caio Lima
2017-10-04 16:57 PDT, Build Bot
2017-10-04 17:40 PDT, Build Bot
2017-10-04 17:47 PDT, Build Bot
2017-10-04 18:11 PDT, Build Bot
2017-10-05 04:34 PDT, Caio Lima
2017-10-05 05:19 PDT, Build Bot
2017-10-05 05:26 PDT, Build Bot
2017-10-05 05:51 PDT, Build Bot
2017-10-05 06:10 PDT, Build Bot
2017-10-05 08:31 PDT, Caio Lima
buildbot: commit-queue-
2017-10-05 10:04 PDT, Build Bot