Revision: 3274
Author: [email protected]
Date: Wed Nov 11 01:55:05 2009
Log: Push bleeding_edge revision  3267 to trunk.

This fixes bailouts for inline constructor generation.
Review URL: http://codereview.chromium.org/390012
http://code.google.com/p/v8/source/detail?r=3274

Added:
  /trunk/test/mjsunit/regress/regress-502.js
Modified:
  /trunk/src/ast.h
  /trunk/src/codegen.cc
  /trunk/src/compiler.cc
  /trunk/src/objects-debug.cc
  /trunk/src/objects-inl.h
  /trunk/src/objects.cc
  /trunk/src/objects.h
  /trunk/src/parser.cc
  /trunk/src/version.cc

=======================================
--- /dev/null
+++ /trunk/test/mjsunit/regress/regress-502.js  Wed Nov 11 01:55:05 2009
@@ -0,0 +1,38 @@
+// Copyright 2009 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.
+
+// Regression test for http://code.google.com/p/v8/issues/detail?id=502.
+//
+// Test that we do not generate an inlined version of the constructor
+// function C.
+
+var X = 'x';
+function C() { this[X] = 42; }
+var a = new C();
+var b = new C();
+assertEquals(42, a.x);
+assertEquals(42, b.x);
=======================================
--- /trunk/src/ast.h    Thu Oct 29 07:46:49 2009
+++ /trunk/src/ast.h    Wed Nov 11 01:55:05 2009
@@ -1263,7 +1263,6 @@
                    ZoneList<Statement*>* body,
                    int materialized_literal_count,
                    int expected_property_count,
-                  bool has_only_this_property_assignments,
                    bool has_only_simple_this_property_assignments,
                    Handle<FixedArray> this_property_assignments,
                    int num_parameters,
@@ -1275,7 +1274,6 @@
          body_(body),
          materialized_literal_count_(materialized_literal_count),
          expected_property_count_(expected_property_count),
-         
has_only_this_property_assignments_(has_only_this_property_assignments),
          has_only_simple_this_property_assignments_(
              has_only_simple_this_property_assignments),
          this_property_assignments_(this_property_assignments),
@@ -1307,9 +1305,6 @@

    int materialized_literal_count() { return materialized_literal_count_; }
    int expected_property_count() { return expected_property_count_; }
-  bool has_only_this_property_assignments() {
-      return has_only_this_property_assignments_;
-  }
    bool has_only_simple_this_property_assignments() {
        return has_only_simple_this_property_assignments_;
    }
@@ -1341,7 +1336,6 @@
    ZoneList<Statement*>* body_;
    int materialized_literal_count_;
    int expected_property_count_;
-  bool has_only_this_property_assignments_;
    bool has_only_simple_this_property_assignments_;
    Handle<FixedArray> this_property_assignments_;
    int num_parameters_;
=======================================
--- /trunk/src/codegen.cc       Thu Oct 29 07:46:49 2009
+++ /trunk/src/codegen.cc       Wed Nov 11 01:55:05 2009
@@ -268,7 +268,6 @@
    fun->shared()->set_is_toplevel(is_toplevel);
    fun->shared()->set_inferred_name(*lit->inferred_name());
    fun->shared()->SetThisPropertyAssignmentsInfo(
-      lit->has_only_this_property_assignments(),
        lit->has_only_simple_this_property_assignments(),
        *lit->this_property_assignments());
  }
=======================================
--- /trunk/src/compiler.cc      Thu Oct 29 07:46:49 2009
+++ /trunk/src/compiler.cc      Wed Nov 11 01:55:05 2009
@@ -452,7 +452,6 @@
    // Set the optimication hints after performing lazy compilation, as  
these are
    // not set when the function is set up as a lazily compiled function.
    shared->SetThisPropertyAssignmentsInfo(
-      lit->has_only_this_property_assignments(),
        lit->has_only_simple_this_property_assignments(),
        *lit->this_property_assignments());

=======================================
--- /trunk/src/objects-debug.cc Thu Oct 29 07:46:49 2009
+++ /trunk/src/objects-debug.cc Wed Nov 11 01:55:05 2009
@@ -796,8 +796,6 @@
    PrintF("\n - debug info = ");
    debug_info()->ShortPrint();
    PrintF("\n - length = %d", length());
-  PrintF("\n - has_only_this_property_assignments = %d",
-         has_only_this_property_assignments());
    PrintF("\n - has_only_simple_this_property_assignments = %d",
           has_only_simple_this_property_assignments());
    PrintF("\n - this_property_assignments = ");
=======================================
--- /trunk/src/objects-inl.h    Thu Oct 29 07:46:49 2009
+++ /trunk/src/objects-inl.h    Wed Nov 11 01:55:05 2009
@@ -2532,9 +2532,6 @@
                 kIsExpressionBit)
  BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
                 kIsTopLevelBit)
-BOOL_GETTER(SharedFunctionInfo, compiler_hints,
-            has_only_this_property_assignments,
-            kHasOnlyThisPropertyAssignments)
  BOOL_GETTER(SharedFunctionInfo, compiler_hints,
              has_only_simple_this_property_assignments,
              kHasOnlySimpleThisPropertyAssignments)
=======================================
--- /trunk/src/objects.cc       Wed Oct 28 07:53:37 2009
+++ /trunk/src/objects.cc       Wed Nov 11 01:55:05 2009
@@ -4921,12 +4921,8 @@


  void SharedFunctionInfo::SetThisPropertyAssignmentsInfo(
-    bool only_this_property_assignments,
      bool only_simple_this_property_assignments,
      FixedArray* assignments) {
-  set_compiler_hints(BooleanBit::set(compiler_hints(),
-                                     kHasOnlyThisPropertyAssignments,
-                                     only_this_property_assignments));
    set_compiler_hints(BooleanBit::set(compiler_hints(),
                                       kHasOnlySimpleThisPropertyAssignments,
                                        
only_simple_this_property_assignments));
@@ -4936,9 +4932,6 @@


  void SharedFunctionInfo::ClearThisPropertyAssignmentsInfo() {
-  set_compiler_hints(BooleanBit::set(compiler_hints(),
-                                     kHasOnlyThisPropertyAssignments,
-                                     false));
    set_compiler_hints(BooleanBit::set(compiler_hints(),
                                       kHasOnlySimpleThisPropertyAssignments,
                                       false));
=======================================
--- /trunk/src/objects.h        Thu Oct 29 07:46:49 2009
+++ /trunk/src/objects.h        Wed Nov 11 01:55:05 2009
@@ -3371,17 +3371,12 @@

    // Add information on assignments of the form this.x = ...;
    void SetThisPropertyAssignmentsInfo(
-      bool has_only_this_property_assignments,
        bool has_only_simple_this_property_assignments,
        FixedArray* this_property_assignments);

    // Clear information on assignments of the form this.x = ...;
    void ClearThisPropertyAssignmentsInfo();

-  // Indicate that this function only consists of assignments of the form
-  // this.x = ...;.
-  inline bool has_only_this_property_assignments();
-
    // Indicate that this function only consists of assignments of the form
    // this.x = y; where y is either a constant or refers to an argument.
    inline bool has_only_simple_this_property_assignments();
@@ -3464,8 +3459,7 @@
    static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1);

    // Bit positions in compiler_hints.
-  static const int kHasOnlyThisPropertyAssignments = 0;
-  static const int kHasOnlySimpleThisPropertyAssignments = 1;
+  static const int kHasOnlySimpleThisPropertyAssignments = 0;

    DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
  };
=======================================
--- /trunk/src/parser.cc        Fri Oct 16 04:48:38 2009
+++ /trunk/src/parser.cc        Wed Nov 11 01:55:05 2009
@@ -676,17 +676,12 @@
    int materialized_literal_count() { return materialized_literal_count_; }

    void SetThisPropertyAssignmentInfo(
-      bool only_this_property_assignments,
        bool only_simple_this_property_assignments,
        Handle<FixedArray> this_property_assignments) {
-    only_this_property_assignments_ = only_this_property_assignments;
      only_simple_this_property_assignments_ =
          only_simple_this_property_assignments;
      this_property_assignments_ = this_property_assignments;
    }
-  bool only_this_property_assignments() {
-    return only_this_property_assignments_;
-  }
    bool only_simple_this_property_assignments() {
      return only_simple_this_property_assignments_;
    }
@@ -705,7 +700,6 @@
    // Properties count estimation.
    int expected_property_count_;

-  bool only_this_property_assignments_;
    bool only_simple_this_property_assignments_;
    Handle<FixedArray> this_property_assignments_;

@@ -720,7 +714,6 @@
  TemporaryScope::TemporaryScope(Parser* parser)
    : materialized_literal_count_(0),
      expected_property_count_(0),
-    only_this_property_assignments_(false),
      only_simple_this_property_assignments_(false),
      this_property_assignments_(Factory::empty_fixed_array()),
      parser_(parser),
@@ -1227,7 +1220,6 @@
            body.elements(),
            temp_scope.materialized_literal_count(),
            temp_scope.expected_property_count(),
-          temp_scope.only_this_property_assignments(),
            temp_scope.only_simple_this_property_assignments(),
            temp_scope.this_property_assignments(),
            0,
@@ -1441,16 +1433,15 @@
  class ThisNamedPropertyAssigmentFinder : public ParserFinder {
   public:
    ThisNamedPropertyAssigmentFinder()
-      : only_this_property_assignments_(true),
-        only_simple_this_property_assignments_(true),
+      : only_simple_this_property_assignments_(true),
          names_(NULL),
          assigned_arguments_(NULL),
          assigned_constants_(NULL) {}

    void Update(Scope* scope, Statement* stat) {
-    // Bail out if function already has non this property assignment
-    // statements.
-    if (!only_this_property_assignments_) {
+    // Bail out if function already has property assignment that are
+    // not simple this property assignments.
+    if (!only_simple_this_property_assignments_) {
        return;
      }

@@ -1459,15 +1450,9 @@
      if (IsThisPropertyAssignment(assignment)) {
        HandleThisPropertyAssignment(scope, assignment);
      } else {
-      only_this_property_assignments_ = false;
        only_simple_this_property_assignments_ = false;
      }
    }
-
-  // Returns whether only statements of the form this.x = ...; was  
encountered.
-  bool only_this_property_assignments() {
-    return only_this_property_assignments_;
-  }

    // Returns whether only statements of the form this.x = y; where y is  
either a
    // constant or a function argument was encountered.
@@ -1524,28 +1509,24 @@
          // Constant assigned.
          Literal* literal = assignment->value()->AsLiteral();
          AssignmentFromConstant(key, literal->handle());
+        return;
        } else if (assignment->value()->AsVariableProxy() != NULL) {
          // Variable assigned.
          Handle<String> name =
              assignment->value()->AsVariableProxy()->name();
          // Check whether the variable assigned matches an argument name.
-        int index = -1;
          for (int i = 0; i < scope->num_parameters(); i++) {
            if (*scope->parameter(i)->name() == *name) {
              // Assigned from function argument.
-            index = i;
-            break;
+            AssignmentFromParameter(key, i);
+            return;
            }
          }
-        if (index != -1) {
-          AssignmentFromParameter(key, index);
-        } else {
-          AssignmentFromSomethingElse(key);
-        }
-      } else {
-        AssignmentFromSomethingElse(key);
        }
      }
+    // It is not a simple "this.x = value;" assignment with a constant
+    // or parameter value.
+    AssignmentFromSomethingElse();
    }

    void AssignmentFromParameter(Handle<String> name, int index) {
@@ -1562,12 +1543,7 @@
      assigned_constants_->Add(value);
    }

-  void AssignmentFromSomethingElse(Handle<String> name) {
-    EnsureAllocation();
-    names_->Add(name);
-    assigned_arguments_->Add(-1);
-    assigned_constants_->Add(Factory::undefined_value());
-
+  void AssignmentFromSomethingElse() {
      // The this assignment is not a simple one.
      only_simple_this_property_assignments_ = false;
    }
@@ -1582,7 +1558,6 @@
      }
    }

-  bool only_this_property_assignments_;
    bool only_simple_this_property_assignments_;
    ZoneStringList* names_;
    ZoneList<int>* assigned_arguments_;
@@ -1623,11 +1598,11 @@

    // Propagate the collected information on this property assignments.
    if (top_scope_->is_function_scope()) {
-    if (this_property_assignment_finder.only_this_property_assignments()) {
+    bool only_simple_this_property_assignments =
+         
this_property_assignment_finder.only_simple_this_property_assignments();
+    if (only_simple_this_property_assignments) {
        temp_scope_->SetThisPropertyAssignmentInfo(
-          this_property_assignment_finder.only_this_property_assignments(),
-          this_property_assignment_finder.
-              only_simple_this_property_assignments(),
+          only_simple_this_property_assignments,
            this_property_assignment_finder.GetThisPropertyAssignments());
      }
    }
@@ -3624,7 +3599,6 @@

      int materialized_literal_count;
      int expected_property_count;
-    bool only_this_property_assignments;
      bool only_simple_this_property_assignments;
      Handle<FixedArray> this_property_assignments;
      if (is_lazily_compiled && pre_data() != NULL) {
@@ -3634,15 +3608,12 @@
        scanner_.SeekForward(end_pos);
        materialized_literal_count = entry.literal_count();
        expected_property_count = entry.property_count();
-      only_this_property_assignments = false;
        only_simple_this_property_assignments = false;
        this_property_assignments = Factory::empty_fixed_array();
      } else {
        ParseSourceElements(&body, Token::RBRACE, CHECK_OK);
        materialized_literal_count = temp_scope.materialized_literal_count();
        expected_property_count = temp_scope.expected_property_count();
-      only_this_property_assignments =
-          temp_scope.only_this_property_assignments();
        only_simple_this_property_assignments =
            temp_scope.only_simple_this_property_assignments();
        this_property_assignments = temp_scope.this_property_assignments();
@@ -3664,7 +3635,6 @@
                              body.elements(),
                              materialized_literal_count,
                              expected_property_count,
-                            only_this_property_assignments,
                              only_simple_this_property_assignments,
                              this_property_assignments,
                              num_parameters,
=======================================
--- /trunk/src/version.cc       Wed Nov 11 01:17:04 2009
+++ /trunk/src/version.cc       Wed Nov 11 01:55:05 2009
@@ -35,7 +35,7 @@
  #define MAJOR_VERSION     1
  #define MINOR_VERSION     3
  #define BUILD_NUMBER      18
-#define PATCH_LEVEL       4
+#define PATCH_LEVEL       5
  #define CANDIDATE_VERSION false

  // Define SONAME to have the SCons build the put a specific SONAME into the

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

Reply via email to