Skip to content

Commit a6eb2cd

Browse files
liamappelbecommit-bot@chromium.org
authored andcommitted
[vm] Support for simarm_x64
Third sub-CL of https://dart-review.googlesource.com/c/sdk/+/100644 The first was here https://dart-review.googlesource.com/c/sdk/+/103487 The second was here https://dart-review.googlesource.com/c/sdk/+/104286 This is the last major CL to support simarm_x64. Now that the other two CLs have put the required infrastructure in place, this CL actually adds the new mode.. Bug: #36839 Change-Id: Ie2f850bf33544f2462f37854e762191c78b1bde6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105500 Commit-Queue: Liam Appelbe <liama@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
1 parent 3b81c65 commit a6eb2cd

File tree

15 files changed

+253
-26
lines changed

15 files changed

+253
-26
lines changed

pkg/vm/tool/precompiler2

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,18 @@ fi
8787

8888
export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
8989
BIN_DIR="$OUT_DIR/$DART_CONFIGURATION"
90+
DART_BINARY="$BIN_DIR"/dart
91+
PLAT_DIR=$(echo ${BIN_DIR} | sed -e 's/SIMARM_X64$/SIMARM/')
92+
93+
PREBUILT_DART_BINARY="tools/sdks/dart-sdk/bin/dart"
94+
if [ -x "$PREBUILT_DART_BINARY" ]; then
95+
DART_BINARY=$PREBUILT_DART_BINARY
96+
fi
9097

9198
# Step 1: Generate Kernel binary from the input Dart source.
92-
"$BIN_DIR"/dart \
99+
"$DART_BINARY" \
93100
"${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" \
94-
--platform "${BIN_DIR}/vm_platform_strong.dill" \
101+
--platform "${PLAT_DIR}/vm_platform_strong.dill" \
95102
--aot \
96103
"${GEN_KERNEL_OPTIONS[@]}" \
97104
$PACKAGES \

runtime/platform/globals.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,16 @@ typedef simd128_value_t fpu_register_t;
337337
#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64)
338338
#if !defined(ARCH_IS_64_BIT)
339339
#error Mismatched Host/Target architectures.
340-
#endif
340+
#endif // !defined(ARCH_IS_64_BIT)
341341
#elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM)
342-
#if !defined(ARCH_IS_32_BIT)
342+
#if defined(HOST_ARCH_X64) && defined(TARGET_ARCH_ARM)
343+
// This is simarm_x64, which is the only case where host/target architecture
344+
// mismatch is allowed.
345+
#define IS_SIMARM_X64 1
346+
#elif !defined(ARCH_IS_32_BIT)
343347
#error Mismatched Host/Target architectures.
344-
#endif
345-
#endif
348+
#endif // !defined(ARCH_IS_32_BIT)
349+
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM)
346350

347351
// Determine whether we will be using the simulator.
348352
#if defined(TARGET_ARCH_IA32)
@@ -351,8 +355,11 @@ typedef simd128_value_t fpu_register_t;
351355
// No simulator used.
352356
#elif defined(TARGET_ARCH_ARM)
353357
#if !defined(HOST_ARCH_ARM)
358+
#define TARGET_HOST_MISMATCH 1
359+
#if !defined(IS_SIMARM_X64)
354360
#define USING_SIMULATOR 1
355361
#endif
362+
#endif
356363

357364
#elif defined(TARGET_ARCH_ARM64)
358365
#if !defined(HOST_ARCH_ARM64)
@@ -366,6 +373,12 @@ typedef simd128_value_t fpu_register_t;
366373
#error Unknown architecture.
367374
#endif
368375

376+
#if defined(ARCH_IS_32_BIT) || defined(IS_SIMARM_X64)
377+
#define TARGET_ARCH_IS_32_BIT 1
378+
#elif defined(ARCH_IS_64_BIT)
379+
#define TARGET_ARCH_IS_64_BIT 1
380+
#endif
381+
369382
// Determine whether HOST_ARCH equals TARGET_ARCH.
370383
#if defined(HOST_ARCH_ARM) && defined(TARGET_ARCH_ARM)
371384
#define HOST_ARCH_EQUALS_TARGET_ARCH 1

runtime/vm/clustered_snapshot.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,8 @@ class RODataSerializationCluster : public SerializationCluster {
18781878
}
18791879
uint32_t offset = s->GetDataOffset(object);
18801880
s->TraceDataOffset(offset);
1881-
ASSERT(Utils::IsAligned(offset, kObjectAlignment));
1881+
ASSERT(Utils::IsAligned(
1882+
offset, compiler::target::ObjectAlignment::kObjectAlignment));
18821883
ASSERT(offset > running_offset);
18831884
s->WriteUnsigned((offset - running_offset) >>
18841885
compiler::target::ObjectAlignment::kObjectAlignmentLog2);

runtime/vm/compiler/assembler/disassembler_arm.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,12 +1500,15 @@ void Disassembler::DecodeInstruction(char* hex_buffer,
15001500
}
15011501

15021502
*object = NULL;
1503+
// TODO(36839): Make DecodeLoadObjectFromPoolOrThread work on simarm_x64.
1504+
#if !defined(IS_SIMARM_X64)
15031505
if (!code.IsNull()) {
15041506
*object = &Object::Handle();
15051507
if (!DecodeLoadObjectFromPoolOrThread(pc, code, *object)) {
15061508
*object = NULL;
15071509
}
15081510
}
1511+
#endif // !defined(IS_SIMARM_X64)
15091512
}
15101513

15111514
#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)

runtime/vm/compiler/backend/block_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BlockBuilder : public ValueObject {
3030

3131
template <typename T>
3232
T* AddDefinition(T* def) {
33-
def->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index());
33+
flow_graph_->AllocateSSAIndexes(def);
3434
AddInstruction(def);
3535
return def;
3636
}

runtime/vm/compiler/backend/il.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,7 @@ Definition* UnboxInt32Instr::Canonicalize(FlowGraph* flow_graph) {
31973197

31983198
ConstantInstr* c = value()->definition()->AsConstant();
31993199
if ((c != NULL) && c->value().IsSmi()) {
3200-
if (!is_truncating() && (kSmiBits > 32)) {
3200+
if (!is_truncating()) {
32013201
// Check that constant fits into 32-bit integer.
32023202
const int64_t value = static_cast<int64_t>(Smi::Cast(c->value()).Value());
32033203
if (!Utils::IsInt(32, value)) {

runtime/vm/compiler/backend/type_propagator.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,11 @@ CompileType ConstantInstr::ComputeType() const {
10881088

10891089
intptr_t cid = value().GetClassId();
10901090

1091+
if (cid == kSmiCid && !compiler::target::IsSmi(Smi::Cast(value()).Value())) {
1092+
return CompileType::Create(kMintCid,
1093+
AbstractType::ZoneHandle(Type::MintType()));
1094+
}
1095+
10911096
if ((cid != kTypeArgumentsCid) && value().IsInstance()) {
10921097
// Allocate in old-space since this may be invoked from the
10931098
// background compiler.

runtime/vm/cpu_arm.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "vm/object.h"
1616
#include "vm/simulator.h"
1717

18-
#if !defined(USING_SIMULATOR)
18+
#if !defined(TARGET_HOST_MISMATCH)
1919
#include <sys/syscall.h> /* NOLINT */
2020
#include <unistd.h> /* NOLINT */
2121
#endif
@@ -81,7 +81,7 @@ DEFINE_FLAG(bool,
8181
"Use integer division instruction if supported");
8282
#endif
8383

84-
#if defined(USING_SIMULATOR)
84+
#if defined(TARGET_HOST_MISMATCH)
8585
#if defined(TARGET_ARCH_ARM_5TE) || defined(TARGET_OS_ANDROID) \
8686
|| defined(TARGET_OS_IOS)
8787
DEFINE_FLAG(bool, sim_use_hardfp, false, "Use the hardfp ABI.");
@@ -96,7 +96,7 @@ void CPU::FlushICache(uword start, uword size) {
9696
UNREACHABLE();
9797
#endif
9898

99-
#if !defined(USING_SIMULATOR) && !HOST_OS_IOS
99+
#if !defined(TARGET_HOST_MISMATCH) && HOST_ARCH_ARM && !HOST_OS_IOS
100100
// Nothing to do. Flushing no instructions.
101101
if (size == 0) {
102102
return;
@@ -120,9 +120,9 @@ void CPU::FlushICache(uword start, uword size) {
120120

121121
const char* CPU::Id() {
122122
return
123-
#if defined(USING_SIMULATOR)
123+
#if defined(TARGET_HOST_MISMATCH)
124124
"sim"
125-
#endif // defined(USING_SIMULATOR)
125+
#endif // defined(TARGET_HOST_MISMATCH)
126126
"arm";
127127
}
128128

@@ -137,7 +137,7 @@ intptr_t HostCPUFeatures::store_pc_read_offset_ = 8;
137137
bool HostCPUFeatures::initialized_ = false;
138138
#endif
139139

140-
#if !defined(USING_SIMULATOR)
140+
#if !defined(TARGET_HOST_MISMATCH)
141141
#if HOST_OS_IOS
142142
void HostCPUFeatures::Init() {
143143
// TODO(24743): Actually check the CPU features and fail if we're missing
@@ -292,7 +292,7 @@ void HostCPUFeatures::Cleanup() {
292292
hardware_ = NULL;
293293
CpuInfo::Cleanup();
294294
}
295-
#endif // !defined(USING_SIMULATOR)
295+
#endif // !defined(TARGET_HOST_MISMATCH)
296296

297297
} // namespace dart
298298

runtime/vm/dart.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ReadOnlyHandles {
8787
};
8888

8989
static void CheckOffsets() {
90+
#if !defined(IS_SIMARM_X64)
9091
// These offsets are embedded in precompiled instructions. We need the
9192
// compiler and the runtime to agree.
9293
bool ok = true;
@@ -124,6 +125,7 @@ static void CheckOffsets() {
124125
#undef CHECK_RANGE
125126
#undef CHECK_CONSTANT
126127
#undef CHECK_OFFSET
128+
#endif // !defined(IS_SIMARM_X64)
127129
}
128130

129131
char* Dart::Init(const uint8_t* vm_isolate_snapshot,

runtime/vm/datastream.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,21 @@ class WriteStream : public ValueObject {
391391
current_ += len;
392392
}
393393

394+
void WriteTargetWord(uword value) {
395+
#if defined(IS_SIMARM_X64)
396+
RELEASE_ASSERT(Utils::IsInt(32, static_cast<word>(value)));
397+
const intptr_t len = sizeof(uint32_t);
398+
if ((end_ - current_) < len) {
399+
Resize(len);
400+
}
401+
ASSERT((end_ - current_) >= len);
402+
*reinterpret_cast<uint32_t*>(current_) = static_cast<uint32_t>(value);
403+
current_ += len;
404+
#else // defined(IS_SIMARM_X64)
405+
WriteWord(value);
406+
#endif // defined(IS_SIMARM_X64)
407+
}
408+
394409
void Print(const char* format, ...) {
395410
va_list args;
396411
va_start(args, format);
@@ -430,6 +445,17 @@ class WriteStream : public ValueObject {
430445
WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
431446
}
432447

448+
template <typename T>
449+
void WriteFixed(T value) {
450+
const intptr_t len = sizeof(T);
451+
if ((end_ - current_) < len) {
452+
Resize(len);
453+
}
454+
ASSERT((end_ - current_) >= len);
455+
*reinterpret_cast<T*>(current_) = static_cast<T>(value);
456+
current_ += len;
457+
}
458+
433459
private:
434460
DART_FORCE_INLINE void WriteByte(uint8_t value) {
435461
if (current_ >= end_) {

0 commit comments

Comments
 (0)