Revision: 6904
Author: [email protected]
Date: Tue Feb 22 09:20:25 2011
Log: Fix for bug http://code.google.com/p/v8/issues/detail?id=1176.

Review URL: http://codereview.chromium.org/6469083/
http://code.google.com/p/v8/source/detail?r=6904

Added:
 /branches/bleeding_edge/test/mjsunit/regress/regress-1176.js
Modified:
 /branches/bleeding_edge/src/arm/codegen-arm.cc
 /branches/bleeding_edge/src/arm/full-codegen-arm.cc
 /branches/bleeding_edge/src/ia32/codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
 /branches/bleeding_edge/src/x64/codegen-x64.cc
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc
 /branches/bleeding_edge/test/mjsunit/strict-mode.js

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-1176.js Tue Feb 22 09:20:25 2011
@@ -0,0 +1,33 @@
+// Copyright 2011 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.
+
+"use strict";
+function strict_delete_this() {
+  // "delete this" is allowed in strict mode.
+  delete this;
+}
+strict_delete_this();
=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.cc      Mon Feb 14 15:41:47 2011
+++ /branches/bleeding_edge/src/arm/codegen-arm.cc      Tue Feb 22 09:20:25 2011
@@ -5850,8 +5850,8 @@

     } else if (variable != NULL) {
       // Delete of an unqualified identifier is disallowed in strict mode
-      // so this code can only be reached in non-strict mode.
-      ASSERT(strict_mode_flag() == kNonStrictMode);
+      // but "delete this" is.
+      ASSERT(strict_mode_flag() == kNonStrictMode || variable->is_this());
       Slot* slot = variable->AsSlot();
       if (variable->is_global()) {
         LoadGlobal();
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Mon Feb 21 08:49:39 2011 +++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Tue Feb 22 09:20:25 2011
@@ -3373,8 +3373,8 @@
         }
       } else if (var != NULL) {
         // Delete of an unqualified identifier is disallowed in strict mode
-        // so this code can only be reached in non-strict mode.
-        ASSERT(strict_mode_flag() == kNonStrictMode);
+        // but "delete this" is.
+        ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
         if (var->is_global()) {
           __ ldr(r2, GlobalObjectOperand());
           __ mov(r1, Operand(var->name()));
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Mon Feb 14 15:41:47 2011 +++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Tue Feb 22 09:20:25 2011
@@ -8234,8 +8234,8 @@
Variable* variable = node->expression()->AsVariableProxy()->AsVariable();
     if (variable != NULL) {
       // Delete of an unqualified identifier is disallowed in strict mode
-      // so this code can only be reached in non-strict mode.
-      ASSERT(strict_mode_flag() == kNonStrictMode);
+      // but "delete this" is.
+      ASSERT(strict_mode_flag() == kNonStrictMode || variable->is_this());
       Slot* slot = variable->AsSlot();
       if (variable->is_global()) {
         LoadGlobal();
@@ -8244,7 +8244,6 @@
         Result answer = frame_->InvokeBuiltin(Builtins::DELETE,
                                               CALL_FUNCTION, 3);
         frame_->Push(&answer);
-        return;

       } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
         // Call the runtime to delete from the context holding the named
@@ -8255,13 +8254,11 @@
         frame_->EmitPush(Immediate(variable->name()));
Result answer = frame_->CallRuntime(Runtime::kDeleteContextSlot, 2);
         frame_->Push(&answer);
-        return;
-      }
-
-      // Default: Result of deleting non-global, not dynamically
-      // introduced variables is false.
-      frame_->Push(Factory::false_value());
-
+      } else {
+        // Default: Result of deleting non-global, not dynamically
+        // introduced variables is false.
+        frame_->Push(Factory::false_value());
+      }
     } else {
       // Default: Result of deleting expressions is true.
       Load(node->expression());  // may have side-effects
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Mon Feb 21 08:49:39 2011 +++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Tue Feb 22 09:20:25 2011
@@ -3743,8 +3743,8 @@
         }
       } else if (var != NULL) {
         // Delete of an unqualified identifier is disallowed in strict mode
-        // so this code can only be reached in non-strict mode.
-        ASSERT(strict_mode_flag() == kNonStrictMode);
+        // but "delete this" is.
+        ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
         if (var->is_global()) {
           __ push(GlobalObjectOperand());
           __ push(Immediate(var->name()));
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc      Mon Feb 14 15:41:47 2011
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc      Tue Feb 22 09:20:25 2011
@@ -7239,8 +7239,8 @@
Variable* variable = node->expression()->AsVariableProxy()->AsVariable();
     if (variable != NULL) {
       // Delete of an unqualified identifier is disallowed in strict mode
-      // so this code can only be reached in non-strict mode.
-      ASSERT(strict_mode_flag() == kNonStrictMode);
+      // but "delete this" is.
+      ASSERT(strict_mode_flag() == kNonStrictMode || variable->is_this());
       Slot* slot = variable->AsSlot();
       if (variable->is_global()) {
         LoadGlobal();
@@ -7249,7 +7249,6 @@
         Result answer = frame_->InvokeBuiltin(Builtins::DELETE,
                                               CALL_FUNCTION, 3);
         frame_->Push(&answer);
-        return;

       } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
         // Call the runtime to delete from the context holding the named
@@ -7260,13 +7259,11 @@
         frame_->EmitPush(variable->name());
Result answer = frame_->CallRuntime(Runtime::kDeleteContextSlot, 2);
         frame_->Push(&answer);
-        return;
-      }
-
-      // Default: Result of deleting non-global, not dynamically
-      // introduced variables is false.
-      frame_->Push(Factory::false_value());
-
+      } else {
+        // Default: Result of deleting non-global, not dynamically
+        // introduced variables is false.
+        frame_->Push(Factory::false_value());
+      }
     } else {
       // Default: Result of deleting expressions is true.
       Load(node->expression());  // may have side-effects
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Mon Feb 21 08:49:39 2011 +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Tue Feb 22 09:20:25 2011
@@ -3075,8 +3075,8 @@
         }
       } else if (var != NULL) {
         // Delete of an unqualified identifier is disallowed in strict mode
-        // so this code can only be reached in non-strict mode.
-        ASSERT(strict_mode_flag() == kNonStrictMode);
+        // but "delete this" is.
+        ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
         if (var->is_global()) {
           __ push(GlobalObjectOperand());
           __ Push(var->name());
=======================================
--- /branches/bleeding_edge/test/mjsunit/strict-mode.js Mon Feb 21 16:39:21 2011 +++ /branches/bleeding_edge/test/mjsunit/strict-mode.js Tue Feb 22 09:20:25 2011
@@ -291,6 +291,13 @@
                 SyntaxError);
 CheckStrictMode("var variable; delete variable;", SyntaxError);

+(function TestStrictDelete() {
+  "use strict";
+  // "delete this" is allowed in strict mode and should work.
+  function strict_delete() { delete this; }
+  strict_delete();
+})();
+
// Prefix unary operators other than delete, ++, -- are valid in strict mode
 (function StrictModeUnaryOperators() {
   "use strict";

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to