Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 98c13ba

Browse files
victoragnezcommit-bot@chromium.org
authored andcommitted
[vm/precomp] Reduce arm-32 code size in BoxInt64Instr
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>
1 parent 37b6b86 commit 98c13ba

15 files changed

+418
-219
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Test case that tests boxing mint
6+
7+
// VMOptions=--shared-slow-path-triggers-gc
8+
9+
import 'dart:typed_data';
10+
import 'package:expect/expect.dart';
11+
12+
final l = Uint64List(10);
13+
int sum = 0;
14+
15+
foobar() {
16+
for (int i = 0; i < l.length; ++i) {
17+
sum += l[i];
18+
}
19+
Expect.equals(sum, 1481763717120);
20+
}
21+
22+
main() {
23+
for (int i = 0; i < 10; i++) {
24+
l[i] = (i + 30) << 32;
25+
}
26+
foobar();
27+
}

runtime/vm/compiler/backend/flow_graph_compiler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ class FlowGraphCompiler : public ValueObject {
770770
// locations of values in the slow path call.
771771
Environment* SlowPathEnvironmentFor(Instruction* inst,
772772
intptr_t num_slow_path_args) {
773+
if (inst->env() == nullptr && is_optimizing()) {
774+
if (pending_deoptimization_env_ == nullptr) {
775+
return nullptr;
776+
}
777+
return SlowPathEnvironmentFor(pending_deoptimization_env_, inst->locs(),
778+
num_slow_path_args);
779+
}
773780
return SlowPathEnvironmentFor(inst->env(), inst->locs(),
774781
num_slow_path_args);
775782
}

runtime/vm/compiler/backend/il_arm.cc

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "vm/compiler/backend/locations.h"
1313
#include "vm/compiler/backend/locations_helpers.h"
1414
#include "vm/compiler/backend/range_analysis.h"
15+
#include "vm/compiler/compiler_state.h"
1516
#include "vm/compiler/jit/compiler.h"
1617
#include "vm/cpu.h"
1718
#include "vm/dart_entry.h"
@@ -4592,16 +4593,18 @@ LocationSummary* BoxInt64Instr::MakeLocationSummary(Zone* zone,
45924593
bool opt) const {
45934594
const intptr_t kNumInputs = 1;
45944595
const intptr_t kNumTemps = ValueFitsSmi() ? 0 : 1;
4595-
LocationSummary* summary = new (zone)
4596-
LocationSummary(zone, kNumInputs, kNumTemps,
4597-
ValueFitsSmi() ? LocationSummary::kNoCall
4598-
: LocationSummary::kCallOnSlowPath);
4596+
LocationSummary* summary = new (zone) LocationSummary(
4597+
zone, kNumInputs, kNumTemps,
4598+
ValueFitsSmi() ? LocationSummary::kNoCall
4599+
: (SlowPathSharingSupported(opt)
4600+
? LocationSummary::kCallOnSharedSlowPath
4601+
: LocationSummary::kCallOnSlowPath));
45994602
summary->set_in(0, Location::Pair(Location::RequiresRegister(),
46004603
Location::RequiresRegister()));
46014604
if (!ValueFitsSmi()) {
4602-
summary->set_temp(0, Location::RequiresRegister());
4605+
summary->set_temp(0, Location::RegisterLocation(R1));
46034606
}
4604-
summary->set_out(0, Location::RequiresRegister());
4607+
summary->set_out(0, Location::RegisterLocation(R0));
46054608
return summary;
46064609
}
46074610

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

4629-
BoxAllocationSlowPath::Allocate(compiler, this, compiler->mint_class(),
4630-
out_reg, tmp);
4632+
if (compiler->intrinsic_mode()) {
4633+
__ TryAllocate(compiler->mint_class(),
4634+
compiler->intrinsic_slow_path_label(), out_reg, tmp);
4635+
} else {
4636+
if (locs()->call_on_shared_slow_path()) {
4637+
const bool live_fpu_regs =
4638+
locs()->live_registers()->FpuRegisterCount() > 0;
4639+
__ ldr(
4640+
TMP,
4641+
compiler::Address(
4642+
THR,
4643+
live_fpu_regs
4644+
? compiler::target::Thread::
4645+
allocate_mint_with_fpu_regs_entry_point_offset()
4646+
: compiler::target::Thread::
4647+
allocate_mint_without_fpu_regs_entry_point_offset()));
4648+
__ blx(TMP);
4649+
4650+
ASSERT(!locs()->live_registers()->ContainsRegister(R0));
4651+
auto extended_env = compiler->SlowPathEnvironmentFor(this, 0);
4652+
compiler->EmitCallsiteMetadata(token_pos(), DeoptId::kNone,
4653+
RawPcDescriptors::kOther, locs(),
4654+
extended_env);
4655+
} else {
4656+
BoxAllocationSlowPath::Allocate(compiler, this, compiler->mint_class(),
4657+
out_reg, tmp);
4658+
}
4659+
}
4660+
46314661
__ StoreToOffset(kWord, value_lo, out_reg,
46324662
compiler::target::Mint::value_offset() - kHeapObjectTag);
46334663
__ StoreToOffset(kWord, value_hi, out_reg,

runtime/vm/compiler/runtime_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ class Thread : public AllStatic {
650650
static word monomorphic_miss_entry_offset();
651651
static word write_barrier_wrappers_thread_offset(Register regno);
652652
static word array_write_barrier_entry_point_offset();
653+
static word allocate_mint_with_fpu_regs_entry_point_offset();
654+
static word allocate_mint_without_fpu_regs_entry_point_offset();
653655
static word write_barrier_entry_point_offset();
654656
static word vm_tag_offset();
655657
static uword vm_tag_compiled_id();
@@ -692,6 +694,8 @@ class Thread : public AllStatic {
692694
static word stack_overflow_shared_with_fpu_regs_stub_offset();
693695
static word lazy_deopt_from_return_stub_offset();
694696
static word lazy_deopt_from_throw_stub_offset();
697+
static word allocate_mint_with_fpu_regs_stub_offset();
698+
static word allocate_mint_without_fpu_regs_stub_offset();
695699
static word optimize_stub_offset();
696700
static word deoptimize_stub_offset();
697701
static word enter_safepoint_stub_offset();

0 commit comments

Comments
 (0)