Skip to content

Commit

Permalink
[vm/precomp] Reduce arm-32 code size in BoxInt64Instr
Browse files Browse the repository at this point in the history
Change-Id: Id544f20493c0baffb154ee1ea235247ddd844a60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127146
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
  • Loading branch information
victoragnez authored and commit-bot@chromium.org committed Dec 10, 2019
1 parent 37b6b86 commit 98c13ba
Show file tree
Hide file tree
Showing 15 changed files with 418 additions and 219 deletions.
27 changes: 27 additions & 0 deletions runtime/tests/vm/dart/arm32_boxmint_test.dart
@@ -0,0 +1,27 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Test case that tests boxing mint

// VMOptions=--shared-slow-path-triggers-gc

import 'dart:typed_data';
import 'package:expect/expect.dart';

final l = Uint64List(10);
int sum = 0;

foobar() {
for (int i = 0; i < l.length; ++i) {
sum += l[i];
}
Expect.equals(sum, 1481763717120);
}

main() {
for (int i = 0; i < 10; i++) {
l[i] = (i + 30) << 32;
}
foobar();
}
7 changes: 7 additions & 0 deletions runtime/vm/compiler/backend/flow_graph_compiler.h
Expand Up @@ -770,6 +770,13 @@ class FlowGraphCompiler : public ValueObject {
// locations of values in the slow path call.
Environment* SlowPathEnvironmentFor(Instruction* inst,
intptr_t num_slow_path_args) {
if (inst->env() == nullptr && is_optimizing()) {
if (pending_deoptimization_env_ == nullptr) {
return nullptr;
}
return SlowPathEnvironmentFor(pending_deoptimization_env_, inst->locs(),
num_slow_path_args);
}
return SlowPathEnvironmentFor(inst->env(), inst->locs(),
num_slow_path_args);
}
Expand Down
46 changes: 38 additions & 8 deletions runtime/vm/compiler/backend/il_arm.cc
Expand Up @@ -12,6 +12,7 @@
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/backend/locations_helpers.h"
#include "vm/compiler/backend/range_analysis.h"
#include "vm/compiler/compiler_state.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/cpu.h"
#include "vm/dart_entry.h"
Expand Down Expand Up @@ -4592,16 +4593,18 @@ LocationSummary* BoxInt64Instr::MakeLocationSummary(Zone* zone,
bool opt) const {
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = ValueFitsSmi() ? 0 : 1;
LocationSummary* summary = new (zone)
LocationSummary(zone, kNumInputs, kNumTemps,
ValueFitsSmi() ? LocationSummary::kNoCall
: LocationSummary::kCallOnSlowPath);
LocationSummary* summary = new (zone) LocationSummary(
zone, kNumInputs, kNumTemps,
ValueFitsSmi() ? LocationSummary::kNoCall
: (SlowPathSharingSupported(opt)
? LocationSummary::kCallOnSharedSlowPath
: LocationSummary::kCallOnSlowPath));
summary->set_in(0, Location::Pair(Location::RequiresRegister(),
Location::RequiresRegister()));
if (!ValueFitsSmi()) {
summary->set_temp(0, Location::RequiresRegister());
summary->set_temp(0, Location::RegisterLocation(R1));
}
summary->set_out(0, Location::RequiresRegister());
summary->set_out(0, Location::RegisterLocation(R0));
return summary;
}

Expand All @@ -4626,8 +4629,35 @@ void BoxInt64Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ cmp(value_hi, compiler::Operand(out_reg, ASR, 31), EQ);
__ b(&done, EQ);

BoxAllocationSlowPath::Allocate(compiler, this, compiler->mint_class(),
out_reg, tmp);
if (compiler->intrinsic_mode()) {
__ TryAllocate(compiler->mint_class(),
compiler->intrinsic_slow_path_label(), out_reg, tmp);
} else {
if (locs()->call_on_shared_slow_path()) {
const bool live_fpu_regs =
locs()->live_registers()->FpuRegisterCount() > 0;
__ ldr(
TMP,
compiler::Address(
THR,
live_fpu_regs
? compiler::target::Thread::
allocate_mint_with_fpu_regs_entry_point_offset()
: compiler::target::Thread::
allocate_mint_without_fpu_regs_entry_point_offset()));
__ blx(TMP);

ASSERT(!locs()->live_registers()->ContainsRegister(R0));
auto extended_env = compiler->SlowPathEnvironmentFor(this, 0);
compiler->EmitCallsiteMetadata(token_pos(), DeoptId::kNone,
RawPcDescriptors::kOther, locs(),
extended_env);
} else {
BoxAllocationSlowPath::Allocate(compiler, this, compiler->mint_class(),
out_reg, tmp);
}
}

__ StoreToOffset(kWord, value_lo, out_reg,
compiler::target::Mint::value_offset() - kHeapObjectTag);
__ StoreToOffset(kWord, value_hi, out_reg,
Expand Down
4 changes: 4 additions & 0 deletions runtime/vm/compiler/runtime_api.h
Expand Up @@ -650,6 +650,8 @@ class Thread : public AllStatic {
static word monomorphic_miss_entry_offset();
static word write_barrier_wrappers_thread_offset(Register regno);
static word array_write_barrier_entry_point_offset();
static word allocate_mint_with_fpu_regs_entry_point_offset();
static word allocate_mint_without_fpu_regs_entry_point_offset();
static word write_barrier_entry_point_offset();
static word vm_tag_offset();
static uword vm_tag_compiled_id();
Expand Down Expand Up @@ -692,6 +694,8 @@ class Thread : public AllStatic {
static word stack_overflow_shared_with_fpu_regs_stub_offset();
static word lazy_deopt_from_return_stub_offset();
static word lazy_deopt_from_throw_stub_offset();
static word allocate_mint_with_fpu_regs_stub_offset();
static word allocate_mint_without_fpu_regs_stub_offset();
static word optimize_stub_offset();
static word deoptimize_stub_offset();
static word enter_safepoint_stub_offset();
Expand Down

0 comments on commit 98c13ba

Please sign in to comment.