Revision: 16644
Author:   [email protected]
Date:     Wed Sep 11 10:52:20 2013 UTC
Log:      performChange no longer takes a |receiver| argument.

The spec omits the receiver arg with the idea arrow functions with lexical | this| will obviate the need for it.

BUG=
[email protected]

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

Patch from Rafael Weinstein <[email protected]>.
http://code.google.com/p/v8/source/detail?r=16644

Modified:
 /branches/bleeding_edge/src/object-observe.js
 /branches/bleeding_edge/test/mjsunit/harmony/object-observe.js

=======================================
--- /branches/bleeding_edge/src/object-observe.js Tue Sep 10 18:13:54 2013 UTC +++ /branches/bleeding_edge/src/object-observe.js Wed Sep 11 10:52:20 2013 UTC
@@ -466,7 +466,7 @@
   ObjectInfoEnqueueChangeRecord(objectInfo, newRecord);
 }

-function ObjectNotifierPerformChange(changeType, changeFn, receiver) {
+function ObjectNotifierPerformChange(changeType, changeFn) {
   if (!IS_SPEC_OBJECT(this))
     throw MakeTypeError("called_on_non_object", ["performChange"]);

@@ -479,15 +479,9 @@
   if (!IS_SPEC_FUNCTION(changeFn))
     throw MakeTypeError("observe_perform_non_function");

-  if (IS_NULL_OR_UNDEFINED(receiver)) {
-    receiver = %GetDefaultReceiver(changeFn) || receiver;
- } else if (!IS_SPEC_OBJECT(receiver) && %IsClassicModeFunction(changeFn)) {
-    receiver = ToObject(receiver);
-  }
-
   ObjectInfoAddPerformingType(objectInfo, changeType);
   try {
-    %_CallFunction(receiver, changeFn);
+    %_CallFunction(void 0, changeFn);
   } finally {
     ObjectInfoRemovePerformingType(objectInfo, changeType);
   }
@@ -520,7 +514,7 @@
   %MoveArrayContents(callbackInfo, delivered);

   try {
-    %Call(void 0, delivered, callback);
+    %_CallFunction(void 0, delivered, callback);
   } catch (ex) {}
   return true;
 }
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/object-observe.js Wed Aug 7 18:45:41 2013 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/object-observe.js Wed Sep 11 10:52:20 2013 UTC
@@ -145,13 +145,8 @@
assertThrows(function() { notifier.performChange(undefined, function(){}); }, TypeError); assertThrows(function() { notifier.performChange('foo', undefined); }, TypeError); assertThrows(function() { notifier.performChange('foo', 'bar'); }, TypeError);
-var testSelf = {};
 notifier.performChange('foo', function() {
-  assertTrue(testSelf === this);
-}, testSelf);
-var self = this;
-notifier.performChange('foo', function() {
-  assertTrue(self === this);
+  assertEquals(undefined, this);
 });

 var notify = notifier.notify;
@@ -400,10 +395,11 @@
   increment: function(amount) {
     var notifier = Object.getNotifier(this);

+    var self = this;
     notifier.performChange(Thingy.INCREMENT, function() {
-      this.a += amount;
-      this.b += amount;
-    }, this);
+      self.a += amount;
+      self.b += amount;
+    });

     notifier.notify({
       object: this,
@@ -415,10 +411,11 @@
   multiply: function(amount) {
     var notifier = Object.getNotifier(this);

+    var self = this;
     notifier.performChange(Thingy.MULTIPLY, function() {
-      this.a *= amount;
-      this.b *= amount;
-    }, this);
+      self.a *= amount;
+      self.b *= amount;
+    });

     notifier.notify({
       object: this,
@@ -430,10 +427,11 @@
   incrementAndMultiply: function(incAmount, multAmount) {
     var notifier = Object.getNotifier(this);

+    var self = this;
     notifier.performChange(Thingy.INCREMENT_AND_MULTIPLY, function() {
-      this.increment(incAmount);
-      this.multiply(multAmount);
-    }, this);
+      self.increment(incAmount);
+      self.multiply(multAmount);
+    });

     notifier.notify({
       object: this,
@@ -505,10 +503,11 @@
     if (!n)
       return;
     var notifier = Object.getNotifier(this);
+    var self = this;
     notifier.performChange(RecursiveThingy.MULTIPLY_FIRST_N, function() {
-      this[n-1] = this[n-1]*amount;
-      this.multiplyFirstN(amount, n-1);
-    }, this);
+      self[n-1] = self[n-1]*amount;
+      self.multiplyFirstN(amount, n-1);
+    });

     notifier.notify({
       object: this,
@@ -557,18 +556,19 @@

   shuffle: function() {
     var notifier = Object.getNotifier(this);
+    var self = this;
     notifier.performChange(DeckSuit.SHUFFLE, function() {
-      this.reverse();
-      this.sort(function() { return Math.random()* 2 - 1; });
-      var cut = this.splice(0, 6);
-      Array.prototype.push.apply(this, cut);
-      this.reverse();
-      this.sort(function() { return Math.random()* 2 - 1; });
-      var cut = this.splice(0, 6);
-      Array.prototype.push.apply(this, cut);
-      this.reverse();
-      this.sort(function() { return Math.random()* 2 - 1; });
-    }, this);
+      self.reverse();
+      self.sort(function() { return Math.random()* 2 - 1; });
+      var cut = self.splice(0, 6);
+      Array.prototype.push.apply(self, cut);
+      self.reverse();
+      self.sort(function() { return Math.random()* 2 - 1; });
+      var cut = self.splice(0, 6);
+      Array.prototype.push.apply(self, cut);
+      self.reverse();
+      self.sort(function() { return Math.random()* 2 - 1; });
+    });

     notifier.notify({
       object: this,

--
--
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/groups/opt_out.

Reply via email to