Commit 2a37ab79 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Fixed inlining of constant values

Use CopyToRepresentation to elide HForceRepresentation of HConstant

BUG=v8:3529
LOG=y
R=bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23397 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f5af44f4
......@@ -1512,17 +1512,8 @@ HInstruction* HForceRepresentation::New(Zone* zone, HValue* context,
HValue* value, Representation representation) {
if (FLAG_fold_constants && value->IsConstant()) {
HConstant* c = HConstant::cast(value);
if (c->HasNumberValue()) {
double double_res = c->DoubleValue();
if (representation.IsDouble()) {
return HConstant::New(zone, context, double_res);
} else if (representation.CanContainDouble(double_res)) {
return HConstant::New(zone, context,
static_cast<int32_t>(double_res),
representation);
}
}
c = c->CopyToRepresentation(representation, zone);
if (c != NULL) return c;
}
return new(zone) HForceRepresentation(value, representation);
}
......
......@@ -13,18 +13,6 @@
namespace v8 {
namespace internal {
inline bool Representation::CanContainDouble(double value) {
if (IsDouble() || is_more_general_than(Representation::Double())) {
return true;
}
if (IsInt32Double(value)) {
if (IsInteger32()) return true;
if (IsSmi()) return Smi::IsValid(static_cast<int32_t>(value));
}
return false;
}
Representation Representation::FromType(Type* type) {
DisallowHeapAllocation no_allocation;
if (type->Is(Type::None())) return Representation::None();
......
......@@ -122,8 +122,6 @@ class Representation {
return other.is_more_general_than(*this) || other.Equals(*this);
}
bool CanContainDouble(double value);
Representation generalize(Representation other) {
if (other.fits_into(*this)) return *this;
if (other.is_more_general_than(*this)) return other;
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Test push double as tagged.
var a = [{}];
function f(a) {
a.push(Infinity);
}
f(a);
f(a);
f(a);
%OptimizeFunctionOnNextCall(f);
f(a);
assertEquals([{}, Infinity, Infinity, Infinity, Infinity], a);
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