Revision: 9354
Author: fschnei...@chromium.org
Date: Wed Sep 21 01:47:07 2011
Log: Merge r9337 to the 3.4 branch.
Fix a bug with uninitialized const variables in the optimizing compiler.
BUG=96989
Original code review: http://codereview.chromium.org/7974009/
Review URL: http://codereview.chromium.org/7983030
http://code.google.com/p/v8/source/detail?r=9354
Added:
/branches/3.4/test/mjsunit/compiler/regress-96989.js
Modified:
/branches/3.4/src/hydrogen.cc
/branches/3.4/src/hydrogen.h
/branches/3.4/src/version.cc
=======================================
--- /dev/null
+++ /branches/3.4/test/mjsunit/compiler/regress-96989.js Wed Sep 21
01:47:07 2011
@@ -0,0 +1,43 @@
+// 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.
+
+
+// Flags: --allow-natives-syntax
+
+// Test correct handling of uninitialized const.
+
+function test() {
+ for (var i = 41; i < 42; i++) {
+ var c = t ^ i;
+ }
+ const t;
+ return c;
+}
+
+for (var i=0; i<10; i++) test();
+%OptimizeFunctionOnNextCall(test);
+assertEquals(41, test());
=======================================
--- /branches/3.4/src/hydrogen.cc Sun Sep 11 23:47:01 2011
+++ /branches/3.4/src/hydrogen.cc Wed Sep 21 01:47:07 2011
@@ -836,7 +836,7 @@
}
-bool HGraph::CheckPhis() {
+bool HGraph::CheckArgumentsPhiUses() {
int block_count = blocks_.length();
for (int i = 0; i < block_count; ++i) {
for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
@@ -849,13 +849,11 @@
}
-bool HGraph::CollectPhis() {
+bool HGraph::CheckConstPhiUses() {
int block_count = blocks_.length();
- phi_list_ = new ZoneList<HPhi*>(block_count);
for (int i = 0; i < block_count; ++i) {
for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
HPhi* phi = blocks_[i]->phis()->at(j);
- phi_list_->Add(phi);
// Check for the hole value (from an uninitialized const).
for (int k = 0; k < phi->OperandCount(); k++) {
if (phi->OperandAt(k) == GetConstantHole()) return false;
@@ -864,6 +862,18 @@
}
return true;
}
+
+
+void HGraph::CollectPhis() {
+ int block_count = blocks_.length();
+ phi_list_ = new ZoneList<HPhi*>(block_count);
+ for (int i = 0; i < block_count; ++i) {
+ for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
+ HPhi* phi = blocks_[i]->phis()->at(j);
+ phi_list_->Add(phi);
+ }
+ }
+}
void HGraph::InferTypes(ZoneList<HValue*>* worklist) {
@@ -2304,16 +2314,17 @@
graph()->OrderBlocks();
graph()->AssignDominators();
- graph()->EliminateRedundantPhis();
- if (!graph()->CheckPhis()) {
- Bailout("Unsupported phi use of arguments object");
+ if (!graph()->CheckConstPhiUses()) {
+ Bailout("Unsupported phi use of const variable");
return NULL;
}
- if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis();
- if (!graph()->CollectPhis()) {
- Bailout("Unsupported phi use of uninitialized constant");
+ graph()->EliminateRedundantPhis();
+ if (!graph()->CheckArgumentsPhiUses()) {
+ Bailout("Unsupported phi use of arguments");
return NULL;
}
+ if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis();
+ graph()->CollectPhis();
HInferRepresentation rep(graph());
rep.Analyze();
=======================================
--- /branches/3.4/src/hydrogen.h Thu Aug 11 09:03:29 2011
+++ /branches/3.4/src/hydrogen.h Wed Sep 21 01:47:07 2011
@@ -242,11 +242,13 @@
// Returns false if there are phi-uses of the arguments-object
// which are not supported by the optimizing compiler.
- bool CheckPhis();
-
- // Returns false if there are phi-uses of hole values comming
- // from uninitialized consts.
- bool CollectPhis();
+ bool CheckArgumentsPhiUses();
+
+ // Returns false if there are phi-uses of an uninitialized const
+ // which are not supported by the optimizing compiler.
+ bool CheckConstPhiUses();
+
+ void CollectPhis();
Handle<Code> Compile(CompilationInfo* info);
=======================================
--- /branches/3.4/src/version.cc Tue Sep 20 04:32:40 2011
+++ /branches/3.4/src/version.cc Wed Sep 21 01:47:07 2011
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 4
#define BUILD_NUMBER 14
-#define PATCH_LEVEL 22
+#define PATCH_LEVEL 23
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev