Revision: 21173
Author:   [email protected]
Date:     Tue May  6 14:48:34 2014 UTC
Log:      Re^3-land "Ship promises and weak collections"

[email protected]
BUG=

Review URL: https://codereview.chromium.org/266243003
http://code.google.com/p/v8/source/detail?r=21173

Added:
 /branches/bleeding_edge/test/mjsunit/es6/microtask-delivery.js
Deleted:
 /branches/bleeding_edge/test/mjsunit/harmony/microtask-delivery.js
Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/promise.js
 /branches/bleeding_edge/test/cctest/test-api.cc
 /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc
 /branches/bleeding_edge/test/mjsunit/debug-script.js
 /branches/bleeding_edge/test/mjsunit/es6/promises.js
 /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2034.js
 /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2156.js
 /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2829.js
 /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js
 /branches/bleeding_edge/test/mjsunit/es7/object-observe.js
 /branches/bleeding_edge/test/mjsunit/harmony/collections.js
 /branches/bleeding_edge/test/mjsunit/harmony/private.js
 /branches/bleeding_edge/test/mjsunit/harmony/proxies-hash.js
/branches/bleeding_edge/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js
 /branches/bleeding_edge/test/mjsunit/harmony/symbols.js
 /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-350864.js
 /branches/bleeding_edge/test/promises-aplus/promises-aplus.status
 /branches/bleeding_edge/test/webkit/webkit.status
 /branches/bleeding_edge/tools/gyp/v8.gyp

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/es6/microtask-delivery.js Tue May 6 14:48:34 2014 UTC
@@ -0,0 +1,168 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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: --allow-natives-syntax
+
+var ordering = [];
+function reset() {
+  ordering = [];
+}
+
+function assertArrayValues(expected, actual) {
+  assertEquals(expected.length, actual.length);
+  for (var i = 0; i < expected.length; i++) {
+    assertEquals(expected[i], actual[i]);
+  }
+}
+
+function assertOrdering(expected) {
+  %RunMicrotasks();
+  assertArrayValues(expected, ordering);
+}
+
+function newPromise(id, fn) {
+  var r;
+  var t = 1;
+  var promise = new Promise(function(resolve) {
+    r = resolve;
+    if (fn) fn();
+  });
+
+  var next = promise.then(function(value) {
+    ordering.push('p' + id);
+    return value;
+  });
+
+  return {
+    resolve: r,
+    then: function(fn) {
+      next = next.then(function(value) {
+        ordering.push('p' + id + ':' + t++);
+        return fn ? fn(value) : value;
+      });
+
+      return this;
+    }
+  };
+}
+
+function newObserver(id, fn, obj) {
+  var observer = {
+    value: 1,
+    recordCounts: []
+  };
+
+  Object.observe(observer, function(records) {
+    ordering.push('o' + id);
+    observer.recordCounts.push(records.length);
+    if (fn) fn();
+  });
+
+  return observer;
+}
+
+
+(function PromiseThens() {
+  reset();
+
+  var p1 = newPromise(1).then();
+  var p2 = newPromise(2).then();
+
+  p1.resolve();
+  p2.resolve();
+
+  assertOrdering(['p1', 'p2', 'p1:1', 'p2:1']);
+})();
+
+
+(function ObserversBatch() {
+  reset();
+
+  var p1 = newPromise(1);
+  var p2 = newPromise(2);
+  var p3 = newPromise(3);
+
+  var ob1 = newObserver(1);
+  var ob2 = newObserver(2, function() {
+    ob3.value++;
+    p3.resolve();
+    ob1.value++;
+  });
+  var ob3 = newObserver(3);
+
+  p1.resolve();
+  ob1.value++;
+  p2.resolve();
+  ob2.value++;
+
+  assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1', 'o3', 'p3']);
+  assertArrayValues([1, 1], ob1.recordCounts);
+  assertArrayValues([1], ob2.recordCounts);
+  assertArrayValues([1], ob3.recordCounts);
+})();
+
+
+(function ObserversGetAllRecords() {
+  reset();
+
+  var p1 = newPromise(1);
+  var p2 = newPromise(2);
+  var ob1 = newObserver(1, function() {
+    ob2.value++;
+  });
+  var ob2 = newObserver(2);
+
+  p1.resolve();
+  ob1.value++;
+  p2.resolve();
+  ob2.value++;
+
+  assertOrdering(['p1', 'o1', 'o2', 'p2']);
+  assertArrayValues([1], ob1.recordCounts);
+  assertArrayValues([2], ob2.recordCounts);
+})();
+
+
+(function NewObserverDeliveryGetsNewMicrotask() {
+  reset();
+
+  var p1 = newPromise(1);
+  var p2 = newPromise(2);
+  var ob1 = newObserver(1);
+  var ob2 = newObserver(2, function() {
+    ob1.value++;
+  });
+
+  p1.resolve();
+  ob1.value++;
+  p2.resolve();
+  ob2.value++;
+
+  assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1']);
+  assertArrayValues([1, 1], ob1.recordCounts);
+  assertArrayValues([1], ob2.recordCounts);
+})();
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/microtask-delivery.js Mon Mar 31 12:40:32 2014 UTC
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (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-observation --harmony-promises --allow-natives-syntax
-
-var ordering = [];
-function reset() {
-  ordering = [];
-}
-
-function assertArrayValues(expected, actual) {
-  assertEquals(expected.length, actual.length);
-  for (var i = 0; i < expected.length; i++) {
-    assertEquals(expected[i], actual[i]);
-  }
-}
-
-function assertOrdering(expected) {
-  %RunMicrotasks();
-  assertArrayValues(expected, ordering);
-}
-
-function newPromise(id, fn) {
-  var r;
-  var t = 1;
-  var promise = new Promise(function(resolve) {
-    r = resolve;
-    if (fn) fn();
-  });
-
-  var next = promise.then(function(value) {
-    ordering.push('p' + id);
-    return value;
-  });
-
-  return {
-    resolve: r,
-    then: function(fn) {
-      next = next.then(function(value) {
-        ordering.push('p' + id + ':' + t++);
-        return fn ? fn(value) : value;
-      });
-
-      return this;
-    }
-  };
-}
-
-function newObserver(id, fn, obj) {
-  var observer = {
-    value: 1,
-    recordCounts: []
-  };
-
-  Object.observe(observer, function(records) {
-    ordering.push('o' + id);
-    observer.recordCounts.push(records.length);
-    if (fn) fn();
-  });
-
-  return observer;
-}
-
-
-(function PromiseThens() {
-  reset();
-
-  var p1 = newPromise(1).then();
-  var p2 = newPromise(2).then();
-
-  p1.resolve();
-  p2.resolve();
-
-  assertOrdering(['p1', 'p2', 'p1:1', 'p2:1']);
-})();
-
-
-(function ObserversBatch() {
-  reset();
-
-  var p1 = newPromise(1);
-  var p2 = newPromise(2);
-  var p3 = newPromise(3);
-
-  var ob1 = newObserver(1);
-  var ob2 = newObserver(2, function() {
-    ob3.value++;
-    p3.resolve();
-    ob1.value++;
-  });
-  var ob3 = newObserver(3);
-
-  p1.resolve();
-  ob1.value++;
-  p2.resolve();
-  ob2.value++;
-
-  assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1', 'o3', 'p3']);
-  assertArrayValues([1, 1], ob1.recordCounts);
-  assertArrayValues([1], ob2.recordCounts);
-  assertArrayValues([1], ob3.recordCounts);
-})();
-
-
-(function ObserversGetAllRecords() {
-  reset();
-
-  var p1 = newPromise(1);
-  var p2 = newPromise(2);
-  var ob1 = newObserver(1, function() {
-    ob2.value++;
-  });
-  var ob2 = newObserver(2);
-
-  p1.resolve();
-  ob1.value++;
-  p2.resolve();
-  ob2.value++;
-
-  assertOrdering(['p1', 'o1', 'o2', 'p2']);
-  assertArrayValues([1], ob1.recordCounts);
-  assertArrayValues([2], ob2.recordCounts);
-})();
-
-
-(function NewObserverDeliveryGetsNewMicrotask() {
-  reset();
-
-  var p1 = newPromise(1);
-  var p2 = newPromise(2);
-  var ob1 = newObserver(1);
-  var ob2 = newObserver(2, function() {
-    ob1.value++;
-  });
-
-  p1.resolve();
-  ob1.value++;
-  p2.resolve();
-  ob2.value++;
-
-  assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1']);
-  assertArrayValues([1, 1], ob1.recordCounts);
-  assertArrayValues([1], ob2.recordCounts);
-})();
=======================================
--- /branches/bleeding_edge/src/api.cc  Tue May  6 13:06:12 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Tue May  6 14:48:34 2014 UTC
@@ -5769,7 +5769,7 @@

 bool Value::IsPromise() const {
   i::Handle<i::Object> val = Utils::OpenHandle(this);
-  if (!i::FLAG_harmony_promises || !val->IsJSObject()) return false;
+  if (!val->IsJSObject()) return false;
   i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(val);
   i::Isolate* isolate = obj->GetIsolate();
   LOG_API(isolate, "IsPromise");
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon May  5 18:27:57 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Tue May  6 14:48:34 2014 UTC
@@ -121,7 +121,7 @@
 void Bootstrapper::TearDown() {
   if (delete_these_non_arrays_on_tear_down_ != NULL) {
     int len = delete_these_non_arrays_on_tear_down_->length();
- ASSERT(len < 20); // Don't use this mechanism for unbounded allocations. + ASSERT(len < 24); // Don't use this mechanism for unbounded allocations.
     for (int i = 0; i < len; i++) {
       delete delete_these_non_arrays_on_tear_down_->at(i);
       delete_these_non_arrays_on_tear_down_->at(i) = NULL;
@@ -1077,6 +1077,18 @@
             Builtins::kIllegal, true, true);
     native_context()->set_data_view_fun(*data_view_fun);
   }
+
+  {  // -- W e a k M a p
+    InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
+                    isolate->initial_object_prototype(),
+                    Builtins::kIllegal, true, true);
+  }
+
+  {  // -- W e a k S e t
+    InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
+                    isolate->initial_object_prototype(),
+                    Builtins::kIllegal, true, true);
+  }

   {  // --- arguments_boilerplate_
     // Make sure we can recognize argument objects at runtime.
@@ -1335,19 +1347,6 @@
       native_context()->set_map_iterator_map(*map);
     }
   }
-
-  if (FLAG_harmony_weak_collections) {
-    {  // -- W e a k M a p
- InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
-                      isolate()->initial_object_prototype(),
-                      Builtins::kIllegal, true, true);
-    }
-    {  // -- W e a k S e t
- InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
-                      isolate()->initial_object_prototype(),
-                      Builtins::kIllegal, true, true);
-    }
-  }

   if (FLAG_harmony_generators) {
// Create generator meta-objects and install them on the builtins object.
@@ -1536,6 +1535,7 @@
 void Genesis::InstallNativeFunctions() {
   HandleScope scope(isolate());
   INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
+
   INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
   INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
   INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun);
@@ -1543,6 +1543,7 @@
   INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
   INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
   INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
+
   INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
   INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
   INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
@@ -1551,6 +1552,14 @@
   INSTALL_NATIVE(JSObject, "functionCache", function_cache);
   INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
                  to_complete_property_descriptor);
+
+  INSTALL_NATIVE(JSFunction, "IsPromise", is_promise);
+  INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
+  INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
+  INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
+  INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain);
+  INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch);
+
   INSTALL_NATIVE(JSFunction, "NotifyChange", observers_notify_change);
INSTALL_NATIVE(JSFunction, "EnqueueSpliceRecord", observers_enqueue_splice);
   INSTALL_NATIVE(JSFunction, "BeginPerformSplice",
@@ -1570,15 +1579,6 @@
   INSTALL_NATIVE(JSFunction, "RunMicrotasks", run_microtasks);
   INSTALL_NATIVE(JSFunction, "EnqueueMicrotask", enqueue_microtask);

-  if (FLAG_harmony_promises) {
-    INSTALL_NATIVE(JSFunction, "IsPromise", is_promise);
-    INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
-    INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
-    INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
-    INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain);
-    INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch);
-  }
-
   if (FLAG_harmony_proxies) {
     INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
     INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
@@ -1999,8 +1999,6 @@
     INSTALL_EXPERIMENTAL_NATIVE(i, symbols, "symbol.js")
     INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js")
     INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection.js")
-    INSTALL_EXPERIMENTAL_NATIVE(i, weak_collections, "weak_collection.js")
-    INSTALL_EXPERIMENTAL_NATIVE(i, promises, "promise.js")
     INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
     INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js")
     INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Tue May 6 09:28:08 2014 UTC +++ /branches/bleeding_edge/src/flag-definitions.h Tue May 6 14:48:34 2014 UTC
@@ -152,12 +152,9 @@
             "enable harmony modules (implies block scoping)")
 DEFINE_bool(harmony_symbols, false,
             "enable harmony symbols (a.k.a. private names)")
-DEFINE_bool(harmony_promises, false, "enable harmony promises")
 DEFINE_bool(harmony_proxies, false, "enable harmony proxies")
 DEFINE_bool(harmony_collections, false,
- "enable harmony collections (sets, maps, weak sets, weak maps)")
-DEFINE_bool(harmony_weak_collections, false,
-            "enable only harmony weak collections (weak sets and maps)")
+            "enable harmony collections (sets, maps)")
 DEFINE_bool(harmony_generators, false, "enable harmony generators")
 DEFINE_bool(harmony_iteration, false, "enable harmony iteration (for-of)")
 DEFINE_bool(harmony_numeric_literals, false,
@@ -177,14 +174,10 @@
 DEFINE_implication(harmony, harmony_numeric_literals)
 DEFINE_implication(harmony, harmony_strings)
 DEFINE_implication(harmony, harmony_arrays)
-DEFINE_implication(harmony_collections, harmony_weak_collections)
-DEFINE_implication(harmony_promises, harmony_weak_collections)
 DEFINE_implication(harmony_modules, harmony_scoping)

 DEFINE_implication(harmony, es_staging)
 DEFINE_implication(es_staging, harmony_maths)
-DEFINE_implication(es_staging, harmony_promises)
-DEFINE_implication(es_staging, harmony_weak_collections)

 // Flags for experimental implementation features.
 DEFINE_bool(packed_arrays, true, "optimizes arrays that have no holes")
=======================================
--- /branches/bleeding_edge/src/promise.js      Fri May  2 08:00:47 2014 UTC
+++ /branches/bleeding_edge/src/promise.js      Tue May  6 14:48:34 2014 UTC
@@ -10,7 +10,22 @@
 // var $WeakMap = global.WeakMap


-var $Promise = Promise;
+var $Promise = function Promise(resolver) {
+  if (resolver === promiseRaw) return;
+  if (!%_IsConstructCall()) throw MakeTypeError('not_a_promise', [this]);
+  if (!IS_SPEC_FUNCTION(resolver))
+    throw MakeTypeError('resolver_not_a_function', [resolver]);
+  var promise = PromiseInit(this);
+  try {
+    %DebugPromiseHandlePrologue(function() { return promise });
+    resolver(function(x) { PromiseResolve(promise, x) },
+             function(r) { PromiseReject(promise, r) });
+  } catch (e) {
+    PromiseReject(promise, e);
+  } finally {
+    %DebugPromiseHandleEpilogue();
+  }
+}


 //-------------------------------------------------------------------
@@ -27,23 +42,6 @@
 function IsPromise(x) {
   return IS_SPEC_OBJECT(x) && %HasLocalProperty(x, promiseStatus);
 }
-
-function Promise(resolver) {
-  if (resolver === promiseRaw) return;
-  if (!%_IsConstructCall()) throw MakeTypeError('not_a_promise', [this]);
-  if (typeof resolver !== 'function')
-    throw MakeTypeError('resolver_not_a_function', [resolver]);
-  var promise = PromiseInit(this);
-  try {
-    %DebugPromiseHandlePrologue(function() { return promise });
-    resolver(function(x) { PromiseResolve(promise, x) },
-             function(r) { PromiseReject(promise, r) });
-  } catch (e) {
-    PromiseReject(promise, e);
-  } finally {
-    %DebugPromiseHandleEpilogue();
-  }
-}

 function PromiseSet(promise, status, value, onResolve, onReject) {
   SET_PRIVATE(promise, promiseStatus, status);
@@ -78,7 +76,7 @@
 function PromiseNopResolver() {}

 function PromiseCreate() {
-  return new Promise(PromiseNopResolver)
+  return new $Promise(PromiseNopResolver)
 }


@@ -87,7 +85,7 @@
 function PromiseDeferred() {
   if (this === $Promise) {
     // Optimized case, avoid extra closure.
-    var promise = PromiseInit(new Promise(promiseRaw));
+    var promise = PromiseInit(new $Promise(promiseRaw));
     return {
       promise: promise,
       resolve: function(x) { PromiseResolve(promise, x) },
@@ -106,7 +104,7 @@
 function PromiseResolved(x) {
   if (this === $Promise) {
     // Optimized case, avoid extra closure.
-    return PromiseSet(new Promise(promiseRaw), +1, x);
+    return PromiseSet(new $Promise(promiseRaw), +1, x);
   } else {
     return new this(function(resolve, reject) { resolve(x) });
   }
@@ -115,7 +113,7 @@
 function PromiseRejected(r) {
   if (this === $Promise) {
     // Optimized case, avoid extra closure.
-    return PromiseSet(new Promise(promiseRaw), -1, r);
+    return PromiseSet(new $Promise(promiseRaw), -1, r);
   } else {
     return new this(function(resolve, reject) { reject(r) });
   }
@@ -190,10 +188,8 @@
 // Multi-unwrapped chaining with thenable coercion.

 function PromiseThen(onResolve, onReject) {
-  onResolve =
-    IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
-  onReject =
-    IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
+ onResolve = IS_SPEC_FUNCTION(onResolve) ? onResolve : PromiseIdResolveHandler; + onReject = IS_SPEC_FUNCTION(onReject) ? onReject : PromiseIdRejectHandler;
   var that = this;
   var constructor = this.constructor;
   return %_CallFunction(
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue May 6 13:06:12 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Tue May 6 14:48:34 2014 UTC
@@ -22338,8 +22338,6 @@


 TEST(Promises) {
-  i::FLAG_harmony_promises = true;
-
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
   v8::HandleScope scope(isolate);
=======================================
--- /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc Tue May 6 13:06:12 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc Tue May 6 14:48:34 2014 UTC
@@ -36,7 +36,6 @@
 class HarmonyIsolate {
  public:
   HarmonyIsolate() {
-    i::FLAG_harmony_promises = true;
     isolate_ = Isolate::New();
     isolate_->Enter();
   }
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-script.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/debug-script.js Tue May 6 14:48:34 2014 UTC
@@ -59,7 +59,7 @@
 }

 // This has to be updated if the number of native scripts change.
-assertTrue(named_native_count == 17 || named_native_count == 18);
+assertTrue(named_native_count == 19 || named_native_count == 20);
 // Only the 'gc' extension is loaded.
 assertEquals(1, extension_count);
 // This script and mjsunit.js has been loaded.  If using d8, d8 loads
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/promises.js Mon Apr 28 15:57:25 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/promises.js Tue May 6 14:48:34 2014 UTC
@@ -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-promises --allow-natives-syntax
+// Flags: --allow-natives-syntax

 var asyncAssertsExpected = 0;

@@ -396,6 +396,30 @@
   assertAsyncRan()
 })();

+(function() {
+  var deferred = Promise.defer()
+  var p1 = deferred.promise
+  var p2 = p1.then(1, 2)
+  p2.then(
+    function(x) { assertAsync(x === 5, "then/resolve-non-function") },
+    assertUnreachable
+  )
+  deferred.resolve(5)
+  assertAsyncRan()
+})();
+
+(function() {
+  var deferred = Promise.defer()
+  var p1 = deferred.promise
+  var p2 = p1.then(1, 2)
+  p2.then(
+    assertUnreachable,
+    function(x) { assertAsync(x === 5, "then/reject-non-function") }
+  )
+  deferred.reject(5)
+  assertAsyncRan()
+})();
+
 (function() {
   var deferred = Promise.defer()
   var p1 = deferred.promise
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2034.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2034.js Tue May 6 14:48:34 2014 UTC
@@ -25,8 +25,6 @@
 // (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-weak-collections
-
 var key = {};
 var map = new WeakMap;
 Object.preventExtensions(key);
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2156.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2156.js Tue May 6 14:48:34 2014 UTC
@@ -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: --allow-natives-syntax --harmony-weak-collections
+// Flags: --allow-natives-syntax

 var key1 = {};
 var key2 = {};
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2829.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/regress/regress-2829.js Tue May 6 14:48:34 2014 UTC
@@ -25,8 +25,6 @@
 // (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-weak-collections
-
 (function test1() {
   var wm1 = new WeakMap();
   wm1.set(Object.prototype, 23);
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js Tue May 6 14:48:34 2014 UTC
@@ -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-weak-collections --expose-gc --allow-natives-syntax
+// Flags: --expose-gc --allow-natives-syntax


 // Note: this test is superseded by harmony/collections.js.
@@ -225,7 +225,7 @@
   assertTrue(C.prototype instanceof Object);
   assertEquals({
     value: {},
-    writable: true,  // TODO(2793): This should be non-writable.
+    writable: false,
     enumerable: false,
     configurable: false
   }, Object.getOwnPropertyDescriptor(C, "prototype"));
=======================================
--- /branches/bleeding_edge/test/mjsunit/es7/object-observe.js Fri May 2 13:55:11 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es7/object-observe.js Tue May 6 14:48:34 2014 UTC
@@ -25,8 +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-observation --harmony-proxies
-// Flags: --harmony-collections --harmony-weak-collections
+// Flags: --harmony-proxies --harmony-collections
 // Flags: --harmony-symbols --allow-natives-syntax

 var allObservers = [];
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/collections.js Thu Apr 17 17:45:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/collections.js Tue May 6 14:48:34 2014 UTC
@@ -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-collections --harmony-weak-collections
+// Flags: --harmony-collections
 // Flags: --expose-gc --allow-natives-syntax


@@ -290,19 +290,20 @@


 // Test prototype property of Set, Map, WeakMap and WeakSet.
-function TestPrototype(C) {
+// TODO(2793): Should all be non-writable, and the extra flag removed.
+function TestPrototype(C, writable) {
   assertTrue(C.prototype instanceof Object);
   assertEquals({
     value: {},
-    writable: true,  // TODO(2793): This should be non-writable.
+    writable: writable,
     enumerable: false,
     configurable: false
   }, Object.getOwnPropertyDescriptor(C, "prototype"));
 }
-TestPrototype(Set);
-TestPrototype(Map);
-TestPrototype(WeakMap);
-TestPrototype(WeakSet);
+TestPrototype(Set, true);
+TestPrototype(Map, true);
+TestPrototype(WeakMap, false);
+TestPrototype(WeakSet, false);


// Test constructor property of the Set, Map, WeakMap and WeakSet prototype.
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/private.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/private.js Tue May 6 14:48:34 2014 UTC
@@ -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-symbols --harmony-collections --harmony-weak-collections
+// Flags: --harmony-symbols --harmony-collections
 // Flags: --expose-gc --allow-natives-syntax

 var symbols = []
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/proxies-hash.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/proxies-hash.js Tue May 6 14:48:34 2014 UTC
@@ -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 --harmony-collections --harmony-weak-collections
+// Flags: --harmony-proxies --harmony-collections


 // Helper.
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/regress/regress-observe-empty-double-array.js Tue May 6 14:48:34 2014 UTC
@@ -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-observation --allow-natives-syntax
+// Flags: --allow-natives-syntax
 //
 // Test passes if it does not crash.

=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/symbols.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/symbols.js Tue May 6 14:48:34 2014 UTC
@@ -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-symbols --harmony-collections --harmony-weak-collections
+// Flags: --harmony-symbols --harmony-collections
 // Flags: --expose-gc --allow-natives-syntax

 var symbols = []
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-350864.js Mon Mar 31 12:40:32 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-350864.js Tue May 6 14:48:34 2014 UTC
@@ -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_symbols --harmony-weak-collections
+// Flags: --harmony-symbols

 var v0 = new WeakMap;
 var v1 = {};
=======================================
--- /branches/bleeding_edge/test/promises-aplus/promises-aplus.status Mon Apr 28 15:57:25 2014 UTC +++ /branches/bleeding_edge/test/promises-aplus/promises-aplus.status Tue May 6 14:48:34 2014 UTC
@@ -28,7 +28,5 @@

 [
 [ALWAYS, {
-  # http://crbug.com/347455
-  '2.2.7': FAIL
 }],  # ALWAYS
 ]
=======================================
--- /branches/bleeding_edge/test/webkit/webkit.status Fri Mar 21 09:28:26 2014 UTC +++ /branches/bleeding_edge/test/webkit/webkit.status Tue May 6 14:48:34 2014 UTC
@@ -30,9 +30,6 @@
   # BUG(237872). TODO(bmeurer): Investigate.
   'string-replacement-outofmemory': [FAIL],

- # TODO(rossberg): Awaiting spec resolution (https://bugs.ecmascript.org/show_bug.cgi?id=2566)
-  'fast/js/Promise-then': [FAIL],
-
##############################################################################
   # Flaky tests.
   # BUG(v8:2989).
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp    Mon Apr 28 09:14:24 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp    Tue May  6 14:48:34 2014 UTC
@@ -1096,6 +1096,8 @@
           '../../src/regexp.js',
           '../../src/arraybuffer.js',
           '../../src/typedarray.js',
+          '../../src/weak_collection.js',
+          '../../src/promise.js',
           '../../src/object-observe.js',
           '../../src/macros.py',
         ],
@@ -1104,8 +1106,6 @@
           '../../src/symbol.js',
           '../../src/proxy.js',
           '../../src/collection.js',
-          '../../src/weak_collection.js',
-          '../../src/promise.js',
           '../../src/generator.js',
           '../../src/array-iterator.js',
           '../../src/harmony-string.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