Commit 6c83b7d6 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Support double allocations when folding allocation.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15839 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3c0483af
...@@ -3267,12 +3267,9 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, ...@@ -3267,12 +3267,9 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator_size = dominator_allocate_instr->size(); HValue* dominator_size = dominator_allocate_instr->size();
HValue* current_size = size(); HValue* current_size = size();
// We can just fold allocations that are guaranteed in new space. // We can just fold allocations that are guaranteed in new space.
// TODO(hpayer): Support double aligned allocations.
// TODO(hpayer): Add support for non-constant allocation in dominator. // TODO(hpayer): Add support for non-constant allocation in dominator.
if (!GuaranteedInNewSpace() || MustAllocateDoubleAligned() || if (!GuaranteedInNewSpace() || !current_size->IsInteger32Constant() ||
!current_size->IsInteger32Constant() ||
!dominator_allocate_instr->GuaranteedInNewSpace() || !dominator_allocate_instr->GuaranteedInNewSpace() ||
dominator_allocate_instr->MustAllocateDoubleAligned() ||
!dominator_size->IsInteger32Constant()) { !dominator_size->IsInteger32Constant()) {
if (FLAG_trace_allocation_folding) { if (FLAG_trace_allocation_folding) {
PrintF("#%d (%s) cannot fold into #%d (%s)\n", PrintF("#%d (%s) cannot fold into #%d (%s)\n",
...@@ -3287,6 +3284,17 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, ...@@ -3287,6 +3284,17 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
int32_t current_size_constant = int32_t current_size_constant =
HConstant::cast(current_size)->GetInteger32Constant(); HConstant::cast(current_size)->GetInteger32Constant();
int32_t new_dominator_size = dominator_size_constant + current_size_constant; int32_t new_dominator_size = dominator_size_constant + current_size_constant;
if (MustAllocateDoubleAligned()) {
if (!dominator_allocate_instr->MustAllocateDoubleAligned()) {
dominator_allocate_instr->SetFlags(HAllocate::ALLOCATE_DOUBLE_ALIGNED);
}
if ((dominator_size_constant & kDoubleAlignmentMask) != 0) {
dominator_size_constant += kDoubleSize / 2;
new_dominator_size += kDoubleSize / 2;
}
}
if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) {
if (FLAG_trace_allocation_folding) { if (FLAG_trace_allocation_folding) {
PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n",
......
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --nouse-osr // Flags: --allow-natives-syntax --nouse-osr --expose-gc
// Test loop barrier when folding allocations.
function f() { function f() {
var elem1 = [1,2,3]; var elem1 = [1,2,3];
for (var i=0; i < 100000; i++) { for (var i=0; i < 100000; i++) {
...@@ -39,8 +42,38 @@ f(); f(); f(); ...@@ -39,8 +42,38 @@ f(); f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
var result = f(); var result = f();
for (var i=0; i < 100000; i++) { gc();
var bar = [1];
}
assertEquals(result[2], 3); assertEquals(result[2], 3);
// Test allocation folding of doubles.
function doubles() {
var elem1 = [1.1, 1.2];
var elem2 = [2.1, 2.2];
return elem2;
}
doubles(); doubles(); doubles();
%OptimizeFunctionOnNextCall(doubles);
var result = doubles();
gc();
assertEquals(result[1], 2.2);
// Test allocation folding of doubles into non-doubles.
function doubles_int() {
var elem1 = [2, 3];
var elem2 = [2.1, 3.1];
return elem2;
}
doubles_int(); doubles_int(); doubles_int();
%OptimizeFunctionOnNextCall(doubles_int);
var result = doubles_int();
gc();
assertEquals(result[1], 3.1);
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