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}
This commit is contained in:
parent
890c4d9dc6
commit
2e4efcfac2
1
BUILD.gn
1
BUILD.gn
@ -313,6 +313,7 @@ action("js2c_experimental") {
|
||||
"src/harmony-reflect.js",
|
||||
"src/harmony-spread.js",
|
||||
"src/harmony-object.js",
|
||||
"src/harmony-object-observe.js",
|
||||
"src/harmony-sharedarraybuffer.js",
|
||||
"src/harmony-simd.js"
|
||||
]
|
||||
|
@ -1851,6 +1851,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
|
||||
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_sharedarraybuffer)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics)
|
||||
@ -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_destructuring)
|
||||
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_atomics)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_new_target)
|
||||
@ -2573,6 +2575,8 @@ bool Genesis::InstallExperimentalNatives() {
|
||||
static const char* harmony_destructuring_natives[] = {nullptr};
|
||||
static const char* harmony_object_natives[] = {"native harmony-object.js",
|
||||
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_sharedarraybuffer_natives[] = {
|
||||
"native harmony-sharedarraybuffer.js", NULL};
|
||||
|
@ -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_computed_property_names, "harmony computed property names") \
|
||||
V(harmony_new_target, "harmony new.target") \
|
||||
V(harmony_object_observe, "harmony Object.observe") \
|
||||
V(harmony_spreadcalls, "harmony spread-calls") \
|
||||
V(harmony_spread_arrays, "harmony spread in array literals") \
|
||||
V(harmony_unicode, "harmony unicode escapes") \
|
||||
|
14
src/harmony-object-observe.js
Normal file
14
src/harmony-object-observe.js
Normal file
@ -0,0 +1,14 @@
|
||||
// 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;
|
||||
var $observeNativeObjectGetNotifier;
|
||||
var $observeNativeObjectNotifierPerformChange;
|
||||
|
||||
var $observeObjectMethods;
|
||||
var $observeArrayMethods;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
"use strict";
|
||||
@ -676,21 +679,30 @@ function ObserveMicrotaskRunner() {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
"deliverChangeRecords", ObjectDeliverChangeRecords,
|
||||
"getNotifier", ObjectGetNotifier,
|
||||
"observe", ObjectObserve,
|
||||
"unobserve", ObjectUnobserve
|
||||
]);
|
||||
utils.InstallFunctions(GlobalArray, DONT_ENUM, [
|
||||
"observe", ArrayObserve,
|
||||
"unobserve", ArrayUnobserve
|
||||
]);
|
||||
utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
|
||||
"notify", ObjectNotifierNotify,
|
||||
"performChange", ObjectNotifierPerformChange
|
||||
]);
|
||||
|
||||
$observeObjectMethods = [
|
||||
"deliverChangeRecords", ObjectDeliverChangeRecords,
|
||||
"getNotifier", ObjectGetNotifier,
|
||||
"observe", ObjectObserve,
|
||||
"unobserve", ObjectUnobserve
|
||||
];
|
||||
$observeArrayMethods = [
|
||||
"observe", ArrayObserve,
|
||||
"unobserve", ArrayUnobserve
|
||||
];
|
||||
|
||||
// TODO(adamk): Figure out why this prototype removal has to
|
||||
// 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;
|
||||
$observeEnqueueSpliceRecord = EnqueueSpliceRecord;
|
||||
$observeBeginPerformSplice = BeginPerformSplice;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
var v = 0;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax --expose-debug-as debug
|
||||
|
||||
Debug = debug.Debug
|
||||
|
@ -25,6 +25,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
var ordering = [];
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright 2014 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.
|
||||
//
|
||||
// Flags: --harmony-object-observe
|
||||
|
||||
'use strict';
|
||||
class Example { }
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --expose-debug-as debug
|
||||
|
||||
Debug = debug.Debug;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
// These tests are meant to ensure that that the Object.observe runtime
|
||||
|
@ -25,7 +25,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// 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
|
||||
|
||||
var allObservers = [];
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Flags: --harmony-proxies
|
||||
// Flags: --harmony-proxies --harmony-object-observe
|
||||
|
||||
var proxy = Proxy.create({ fix: function() { return {}; } });
|
||||
Object.preventExtensions(proxy);
|
||||
|
@ -25,6 +25,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax
|
||||
//
|
||||
// Test passes if it does not crash.
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-ayle license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax --track-fields --expose-gc
|
||||
|
||||
var global = Function('return this')();
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright 2014 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.
|
||||
//
|
||||
// Flags: --harmony-object-observe
|
||||
|
||||
var indexZeroCallCount = 0;
|
||||
var indexOneCallCount = 0;
|
||||
|
@ -25,6 +25,8 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// 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
|
||||
|
||||
arr = ['a', 'b', 'c', 'd'];
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --stack-size=100
|
||||
|
||||
var a = [];
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-object-observe
|
||||
// Flags: --allow-natives-syntax --enable-slow-asserts
|
||||
|
||||
function f() {
|
||||
|
@ -1821,6 +1821,7 @@
|
||||
'../../src/harmony-reflect.js',
|
||||
'../../src/harmony-spread.js',
|
||||
'../../src/harmony-object.js',
|
||||
'../../src/harmony-object-observe.js',
|
||||
'../../src/harmony-sharedarraybuffer.js',
|
||||
'../../src/harmony-simd.js',
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user