Commit 2e4efcfa authored by adamk's avatar adamk Committed by Commit bot

Add a --harmony-object-observe runtime flag (on by default)

To avoid tanking context startup performance, only the actual installation of the
JS-exposed API is flag-guarded. The remainder of the implementation still
resides in the snapshot.

Review URL: https://codereview.chromium.org/1257063003

Cr-Commit-Position: refs/heads/master@{#30017}
parent 890c4d9d
...@@ -313,6 +313,7 @@ action("js2c_experimental") { ...@@ -313,6 +313,7 @@ action("js2c_experimental") {
"src/harmony-reflect.js", "src/harmony-reflect.js",
"src/harmony-spread.js", "src/harmony-spread.js",
"src/harmony-object.js", "src/harmony-object.js",
"src/harmony-object-observe.js",
"src/harmony-sharedarraybuffer.js", "src/harmony-sharedarraybuffer.js",
"src/harmony-simd.js" "src/harmony-simd.js"
] ]
......
...@@ -1851,6 +1851,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) ...@@ -1851,6 +1851,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object_observe)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics)
...@@ -1886,6 +1887,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) ...@@ -1886,6 +1887,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_new_target) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_new_target)
...@@ -2573,6 +2575,8 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -2573,6 +2575,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_destructuring_natives[] = {nullptr}; static const char* harmony_destructuring_natives[] = {nullptr};
static const char* harmony_object_natives[] = {"native harmony-object.js", static const char* harmony_object_natives[] = {"native harmony-object.js",
NULL}; NULL};
static const char* harmony_object_observe_natives[] = {
"native harmony-object-observe.js", nullptr};
static const char* harmony_spread_arrays_natives[] = {nullptr}; static const char* harmony_spread_arrays_natives[] = {nullptr};
static const char* harmony_sharedarraybuffer_natives[] = { static const char* harmony_sharedarraybuffer_natives[] = {
"native harmony-sharedarraybuffer.js", NULL}; "native harmony-sharedarraybuffer.js", NULL};
......
...@@ -210,6 +210,7 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode") ...@@ -210,6 +210,7 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
V(harmony_arrow_functions, "harmony arrow functions") \ V(harmony_arrow_functions, "harmony arrow functions") \
V(harmony_computed_property_names, "harmony computed property names") \ V(harmony_computed_property_names, "harmony computed property names") \
V(harmony_new_target, "harmony new.target") \ V(harmony_new_target, "harmony new.target") \
V(harmony_object_observe, "harmony Object.observe") \
V(harmony_spreadcalls, "harmony spread-calls") \ V(harmony_spreadcalls, "harmony spread-calls") \
V(harmony_spread_arrays, "harmony spread in array literals") \ V(harmony_spread_arrays, "harmony spread in array literals") \
V(harmony_unicode, "harmony unicode escapes") \ V(harmony_unicode, "harmony unicode escapes") \
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
utils.InstallFunctions(global.Object, DONT_ENUM, $observeObjectMethods);
utils.InstallFunctions(global.Array, DONT_ENUM, $observeArrayMethods);
})
...@@ -10,6 +10,9 @@ var $observeNativeObjectObserve; ...@@ -10,6 +10,9 @@ var $observeNativeObjectObserve;
var $observeNativeObjectGetNotifier; var $observeNativeObjectGetNotifier;
var $observeNativeObjectNotifierPerformChange; var $observeNativeObjectNotifierPerformChange;
var $observeObjectMethods;
var $observeArrayMethods;
(function(global, utils) { (function(global, utils) {
"use strict"; "use strict";
...@@ -676,20 +679,29 @@ function ObserveMicrotaskRunner() { ...@@ -676,20 +679,29 @@ function ObserveMicrotaskRunner() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
utils.InstallFunctions(GlobalObject, DONT_ENUM, [ utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange
]);
$observeObjectMethods = [
"deliverChangeRecords", ObjectDeliverChangeRecords, "deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier, "getNotifier", ObjectGetNotifier,
"observe", ObjectObserve, "observe", ObjectObserve,
"unobserve", ObjectUnobserve "unobserve", ObjectUnobserve
]); ];
utils.InstallFunctions(GlobalArray, DONT_ENUM, [ $observeArrayMethods = [
"observe", ArrayObserve, "observe", ArrayObserve,
"unobserve", ArrayUnobserve "unobserve", ArrayUnobserve
]); ];
utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify, // TODO(adamk): Figure out why this prototype removal has to
"performChange", ObjectNotifierPerformChange // happen as part of initial snapshotting.
]); var removePrototypeFn = function(f, i) {
if (i % 2 === 1) %FunctionRemovePrototype(f);
};
$observeObjectMethods.forEach(removePrototypeFn);
$observeArrayMethods.forEach(removePrototypeFn);
$observeNotifyChange = NotifyChange; $observeNotifyChange = NotifyChange;
$observeEnqueueSpliceRecord = EnqueueSpliceRecord; $observeEnqueueSpliceRecord = EnqueueSpliceRecord;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
var v = 0; var v = 0;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax --expose-debug-as debug // Flags: --allow-natives-syntax --expose-debug-as debug
Debug = debug.Debug Debug = debug.Debug
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
var ordering = []; var ordering = [];
......
// Copyright 2014 the V8 project authors. All rights reserved. // Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
//
// Flags: --harmony-object-observe
'use strict'; 'use strict';
class Example { } class Example { }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --expose-debug-as debug // Flags: --expose-debug-as debug
Debug = debug.Debug; Debug = debug.Debug;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
// These tests are meant to ensure that that the Object.observe runtime // These tests are meant to ensure that that the Object.observe runtime
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-proxies // Flags: --harmony-proxies --harmony-object-observe
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
var allObservers = []; var allObservers = [];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Flags: --harmony-proxies // Flags: --harmony-proxies --harmony-object-observe
var proxy = Proxy.create({ fix: function() { return {}; } }); var proxy = Proxy.create({ fix: function() { return {}; } });
Object.preventExtensions(proxy); Object.preventExtensions(proxy);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
// //
// Test passes if it does not crash. // Test passes if it does not crash.
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-ayle license that can be // Use of this source code is governed by a BSD-ayle license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax --track-fields --expose-gc // Flags: --allow-natives-syntax --track-fields --expose-gc
var global = Function('return this')(); var global = Function('return this')();
......
// Copyright 2014 the V8 project authors. All rights reserved. // Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
//
// Flags: --harmony-object-observe
var indexZeroCallCount = 0; var indexZeroCallCount = 0;
var indexOneCallCount = 0; var indexOneCallCount = 0;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-object-observe
// This test passes if it does not crash in debug mode // This test passes if it does not crash in debug mode
arr = ['a', 'b', 'c', 'd']; arr = ['a', 'b', 'c', 'd'];
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --stack-size=100 // Flags: --stack-size=100
var a = []; var a = [];
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-object-observe
// Flags: --allow-natives-syntax --enable-slow-asserts // Flags: --allow-natives-syntax --enable-slow-asserts
function f() { function f() {
......
...@@ -1821,6 +1821,7 @@ ...@@ -1821,6 +1821,7 @@
'../../src/harmony-reflect.js', '../../src/harmony-reflect.js',
'../../src/harmony-spread.js', '../../src/harmony-spread.js',
'../../src/harmony-object.js', '../../src/harmony-object.js',
'../../src/harmony-object-observe.js',
'../../src/harmony-sharedarraybuffer.js', '../../src/harmony-sharedarraybuffer.js',
'../../src/harmony-simd.js', '../../src/harmony-simd.js',
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment