Reviewers: rossberg,

Description:
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.

Please review this at https://codereview.chromium.org/1257063003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+52, -8 lines):
  M BUILD.gn
  M src/bootstrapper.cc
  M src/flag-definitions.h
  A src/harmony-object-observe.js
  M src/object-observe.js
  M test/mjsunit/array-push7.js
  M test/mjsunit/es6/debug-stepin-microtasks.js
  M test/mjsunit/es6/microtask-delivery.js
  M test/mjsunit/es6/regress/regress-3750.js
  M test/mjsunit/es7/object-observe.js
  M test/mjsunit/es7/object-observe-debug-event.js
  M test/mjsunit/es7/object-observe-runtime.js
  M test/mjsunit/harmony/regress/regress-405844.js
  M test/mjsunit/harmony/regress/regress-observe-empty-double-array.js
  M test/mjsunit/migrations.js
  M test/mjsunit/regress/regress-3315.js
  M test/mjsunit/regress/regress-356589.js
  M test/mjsunit/regress/regress-417709a.js
  M test/mjsunit/regress/regress-observe-map-cache.js
  M tools/gyp/v8.gyp


Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index d194d63256cdeecbe177cc13719aa865f08d91b3..622c45a29c6ae9853db9d4e60c2f6622e75875ae 100644
--- a/BUILD.gn
+++ b/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"
   ]
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index a0d62827cfd2b061b6e2b0b144a99e491bcaa9a8..bec30f67726668434bb1998525c7ed600302660e 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1858,6 +1858,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)
@@ -1893,6 +1894,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)
@@ -2580,6 +2582,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};
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index acc7edaa6eb1a638fdf71bd370d063d224823395..b5e212b5a24155d04b4f4f90d9c3fc9c1df69109 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -210,6 +210,7 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
 #define HARMONY_SHIPPING(V)                                             \
   V(harmony_arrow_functions, "harmony arrow functions")                 \
   V(harmony_computed_property_names, "harmony computed property names") \
+  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")                         \
Index: src/harmony-object-observe.js
diff --git a/src/harmony-object-observe.js b/src/harmony-object-observe.js
new file mode 100644
index 0000000000000000000000000000000000000000..8644d91adc40f7e018d28594b83784ee33cce6cb
--- /dev/null
+++ b/src/harmony-object-observe.js
@@ -0,0 +1,16 @@
+// 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);
+utils.InstallFunctions($observeNotifierPrototype, DONT_ENUM,
+                       $observeNotifierMethods);
+
+})
Index: src/object-observe.js
diff --git a/src/object-observe.js b/src/object-observe.js
index 56859a1c97ba9f7729c2b8fb821c6142d6fdb7f1..d065f4654d6c5ade0cf0b937753be72f965f1d84 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -9,6 +9,11 @@ var $observeEndPerformSplice;
 var $observeNativeObjectObserve;
 var $observeNativeObjectGetNotifier;
 var $observeNativeObjectNotifierPerformChange;
+var $observeNotifierPrototype;
+
+var $observeObjectMethods;
+var $observeArrayMethods;
+var $observeNotifierMethods;

 (function(global, utils) {

@@ -676,20 +681,20 @@ function ObserveMicrotaskRunner() {

 // -------------------------------------------------------------------

-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
+$observeObjectMethods = [
   "deliverChangeRecords", ObjectDeliverChangeRecords,
   "getNotifier", ObjectGetNotifier,
   "observe", ObjectObserve,
   "unobserve", ObjectUnobserve
-]);
-utils.InstallFunctions(GlobalArray, DONT_ENUM, [
+];
+$observeArrayMethods = [
   "observe", ArrayObserve,
   "unobserve", ArrayUnobserve
-]);
-utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
+];
+$observeNotifierMethods = [
   "notify", ObjectNotifierNotify,
   "performChange", ObjectNotifierPerformChange
-]);
+];

 $observeNotifyChange = NotifyChange;
 $observeEnqueueSpliceRecord = EnqueueSpliceRecord;
@@ -698,5 +703,6 @@ $observeEndPerformSplice = EndPerformSplice;
 $observeNativeObjectObserve = NativeObjectObserve;
 $observeNativeObjectGetNotifier = NativeObjectGetNotifier;
$observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange;
+$observeNotifierPrototype = notifierPrototype;

 })
Index: test/mjsunit/array-push7.js
diff --git a/test/mjsunit/array-push7.js b/test/mjsunit/array-push7.js
index b45a739d70b99c266b57cd0d1be07bc3a3041060..68c3a2a76e986dab91e0c6ccca987f35e68dd2da 100644
--- a/test/mjsunit/array-push7.js
+++ b/test/mjsunit/array-push7.js
@@ -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;
Index: test/mjsunit/es6/debug-stepin-microtasks.js
diff --git a/test/mjsunit/es6/debug-stepin-microtasks.js b/test/mjsunit/es6/debug-stepin-microtasks.js index 8dbdb3457ab8e6828e3adc9b4f6cfb5caf2fd05d..98510ff52be153373b1fa29624377c17c823b33e 100644
--- a/test/mjsunit/es6/debug-stepin-microtasks.js
+++ b/test/mjsunit/es6/debug-stepin-microtasks.js
@@ -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
Index: test/mjsunit/es6/microtask-delivery.js
diff --git a/test/mjsunit/es6/microtask-delivery.js b/test/mjsunit/es6/microtask-delivery.js index f74385e63565d9da5c5618ad1d55d833220789c9..01b971ddc0cb9c7ef3da42a0437ae4e937519948 100644
--- a/test/mjsunit/es6/microtask-delivery.js
+++ b/test/mjsunit/es6/microtask-delivery.js
@@ -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 = [];
Index: test/mjsunit/es6/regress/regress-3750.js
diff --git a/test/mjsunit/es6/regress/regress-3750.js b/test/mjsunit/es6/regress/regress-3750.js index a425def2b751c90d08e8df6352ba0b6a9e3a70fa..10509bff51d724ee2ae2280e3be394b54b4d7db8 100644
--- a/test/mjsunit/es6/regress/regress-3750.js
+++ b/test/mjsunit/es6/regress/regress-3750.js
@@ -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 { }
Index: test/mjsunit/es7/object-observe-debug-event.js
diff --git a/test/mjsunit/es7/object-observe-debug-event.js b/test/mjsunit/es7/object-observe-debug-event.js index ed627642cc0018e3b2e8a2318a2f5e246c4f0022..06123b8dc2796b492696de37e840432c7af4a545 100644
--- a/test/mjsunit/es7/object-observe-debug-event.js
+++ b/test/mjsunit/es7/object-observe-debug-event.js
@@ -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;
Index: test/mjsunit/es7/object-observe-runtime.js
diff --git a/test/mjsunit/es7/object-observe-runtime.js b/test/mjsunit/es7/object-observe-runtime.js index 769cd1b2969e67d097e537315a6fa97913185d6c..1a07141af663fafd2d177deebadeb6e55f88d84c 100644
--- a/test/mjsunit/es7/object-observe-runtime.js
+++ b/test/mjsunit/es7/object-observe-runtime.js
@@ -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
Index: test/mjsunit/es7/object-observe.js
diff --git a/test/mjsunit/es7/object-observe.js b/test/mjsunit/es7/object-observe.js index b2853c40484fc7cfd215885d2016f6c4325b3401..5a252a3745d08b946cc0444dd4b2ffe9c70423d5 100644
--- a/test/mjsunit/es7/object-observe.js
+++ b/test/mjsunit/es7/object-observe.js
@@ -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 = [];
Index: test/mjsunit/harmony/regress/regress-405844.js
diff --git a/test/mjsunit/harmony/regress/regress-405844.js b/test/mjsunit/harmony/regress/regress-405844.js index fbe7310d7966385cd22d9e975c0b5cbedb05e22d..3d3561f7a55fdd6681ff503652711899a4a52862 100644
--- a/test/mjsunit/harmony/regress/regress-405844.js
+++ b/test/mjsunit/harmony/regress/regress-405844.js
@@ -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);
Index: test/mjsunit/harmony/regress/regress-observe-empty-double-array.js
diff --git a/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js b/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js index 301ece70fef5156af1f53eeb98573f24afc2a611..1460889f45a3a97b6c54734b70de461ef373b544 100644
--- a/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js
+++ b/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js
@@ -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.
Index: test/mjsunit/migrations.js
diff --git a/test/mjsunit/migrations.js b/test/mjsunit/migrations.js
index 288bc610312edc2c6ae7eeaf4cabbeb5d794463e..a18d884059baf40cc59294bbef5ed921b0bc20f0 100644
--- a/test/mjsunit/migrations.js
+++ b/test/mjsunit/migrations.js
@@ -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')();
Index: test/mjsunit/regress/regress-3315.js
diff --git a/test/mjsunit/regress/regress-3315.js b/test/mjsunit/regress/regress-3315.js index a1105e28488971dca2a930db92f22b8cde26866d..bfd7df29b844c3e2f893dbe7736d6bce59caee49 100644
--- a/test/mjsunit/regress/regress-3315.js
+++ b/test/mjsunit/regress/regress-3315.js
@@ -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;
Index: test/mjsunit/regress/regress-356589.js
diff --git a/test/mjsunit/regress/regress-356589.js b/test/mjsunit/regress/regress-356589.js index f93c5456407e6f1a433aa2c63d84f0749489a19b..a47f51bac1bf7541ad42ed8af8b2f285ebea0196 100644
--- a/test/mjsunit/regress/regress-356589.js
+++ b/test/mjsunit/regress/regress-356589.js
@@ -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'];
Index: test/mjsunit/regress/regress-417709a.js
diff --git a/test/mjsunit/regress/regress-417709a.js b/test/mjsunit/regress/regress-417709a.js index d210c10429ad2a49d8df3436f054dca82d7583bd..5500be2cf0fce5409661152ab845a0214891e122 100644
--- a/test/mjsunit/regress/regress-417709a.js
+++ b/test/mjsunit/regress/regress-417709a.js
@@ -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 = [];
Index: test/mjsunit/regress/regress-observe-map-cache.js
diff --git a/test/mjsunit/regress/regress-observe-map-cache.js b/test/mjsunit/regress/regress-observe-map-cache.js index 4c7a7e3e973d12cde43caaa64b11f6f08cef3dcc..c71759c0cc04d2430b247c65d641b17b62f590f4 100644
--- a/test/mjsunit/regress/regress-observe-map-cache.js
+++ b/test/mjsunit/regress/regress-observe-map-cache.js
@@ -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() {
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index acae8077f533e03b0ea46334bdefd7058033249b..19231d82bf957dbf35d9e66d05b01f6d62997454 100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1813,6 +1813,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',
         ],


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to