Commit a2553124 authored by titzer@chromium.org's avatar titzer@chromium.org

Handle misaligned loads and stores in load elimination. Do not track...

Handle misaligned loads and stores in load elimination. Do not track misaligned loads and be conservative about invalidating misaligned stores. Add more tests for number conversion to string (NumberToStringStub exhibits misaligned loads)

BUG=v8:2934
R=bmeurer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17294 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b453e6ac
......@@ -212,7 +212,7 @@ class HLoadEliminationTable : public ZoneObject {
// instruction is redundant. Otherwise, return {instr}.
HValue* store(HStoreNamedField* instr) {
int field = FieldOf(instr->access());
if (field < 0) return instr;
if (field < 0) return KillIfMisaligned(instr);
HValue* object = instr->object()->ActualValue();
HValue* value = instr->value();
......@@ -250,6 +250,38 @@ class HLoadEliminationTable : public ZoneObject {
}
}
// Kill all entries aliasing the given store.
void KillStore(HStoreNamedField* s) {
int field = FieldOf(s->access());
if (field >= 0) {
KillFieldInternal(s->object()->ActualValue(), field, s->value());
} else {
KillIfMisaligned(s);
}
}
// Kill multiple entries in the case of a misaligned store.
HValue* KillIfMisaligned(HStoreNamedField* instr) {
HObjectAccess access = instr->access();
if (access.IsInobject()) {
int offset = access.offset();
if ((offset % kPointerSize) != 0) {
// Kill the field containing the first word of the access.
HValue* object = instr->object()->ActualValue();
int field = offset / kPointerSize;
KillFieldInternal(object, field, NULL);
// Kill the next field in case of overlap.
int size = kPointerSize;
if (access.representation().IsByte()) size = 1;
else if (access.representation().IsInteger32()) size = 4;
int next_field = (offset + size - 1) / kPointerSize;
if (next_field != field) KillFieldInternal(object, next_field, NULL);
}
}
return instr;
}
// Find an entry for the given object and field pair.
HFieldApproximation* Find(HValue* object, int field) {
// Search for a field approximation for this object.
......@@ -347,7 +379,8 @@ class HLoadEliminationTable : public ZoneObject {
// Compute the field index for the given in-object offset; -1 if not tracked.
int FieldOf(int offset) {
if (offset >= kMaxTrackedFields * kPointerSize) return -1;
ASSERT((offset % kPointerSize) == 0); // Assume aligned accesses.
// TODO(titzer): track misaligned loads in a separate list?
if ((offset % kPointerSize) != 0) return -1; // Ignore misaligned accesses.
return offset / kPointerSize;
}
......@@ -430,11 +463,7 @@ class HLoadEliminationEffects : public ZoneObject {
// Kill non-agreeing fields for each store contained in these effects.
for (int i = 0; i < stores_.length(); i++) {
HStoreNamedField* s = stores_[i];
int field = table->FieldOf(s->access());
if (field >= 0) {
table->KillFieldInternal(s->object()->ActualValue(), field, s->value());
}
table->KillStore(stores_[i]);
}
}
......
// Copyright 2013 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.
function add(a, b) {
return a + b;
}
function testToString(a, b) {
assertEquals(a, b.toString());
assertEquals(a, "" + b);
assertEquals(a, add("", b));
assertEquals("yes" + a, add("yes", b));
}
testToString("NaN", (NaN));
testToString("Infinity", (1/0));
testToString("-Infinity", (-1/0));
testToString("0", (0));
testToString("9", (9));
testToString("90", (90));
testToString("90.12", (90.12));
testToString("0.1", (0.1));
testToString("0.01", (0.01));
testToString("0.0123", (0.0123));
testToString("111111111111111110000", (111111111111111111111));
testToString("1.1111111111111111e+21", (1111111111111111111111));
testToString("1.1111111111111111e+22", (11111111111111111111111));
testToString("0.00001", (0.00001));
testToString("0.000001", (0.000001));
testToString("1e-7", (0.0000001));
testToString("1.2e-7", (0.00000012));
testToString("1.23e-7", (0.000000123));
testToString("1e-8", (0.00000001));
testToString("1.2e-8", (0.000000012));
testToString("1.23e-8", (0.0000000123));
testToString("0", (-0));
testToString("-9", (-9));
testToString("-90", (-90));
testToString("-90.12", (-90.12));
testToString("-0.1", (-0.1));
testToString("-0.01", (-0.01));
testToString("-0.0123", (-0.0123));
testToString("-111111111111111110000", (-111111111111111111111));
testToString("-1.1111111111111111e+21", (-1111111111111111111111));
testToString("-1.1111111111111111e+22", (-11111111111111111111111));
testToString("-0.00001", (-0.00001));
testToString("-0.000001", (-0.000001));
testToString("-1e-7", (-0.0000001));
testToString("-1.2e-7", (-0.00000012));
testToString("-1.23e-7", (-0.000000123));
testToString("-1e-8", (-0.00000001));
testToString("-1.2e-8", (-0.000000012));
testToString("-1.23e-8", (-0.0000000123));
testToString("1000", (1000));
testToString("0.00001", (0.00001));
testToString("1000000000000000100", (1000000000000000128));
testToString("1e+21", (1000000000000000012800));
testToString("-1e+21", (-1000000000000000012800));
testToString("1e-7", (0.0000001));
testToString("-1e-7", (-0.0000001));
testToString("1.0000000000000001e+21", (1000000000000000128000));
testToString("0.000001", (0.000001));
testToString("1e-7", (0.0000001));
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment