[vm] Add a stub simx64.

This allows building gen_snapshot with host=arm64, target=x64.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/103386
Change-Id: I478cc0917462896de9b598455d2ed68401323b50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252962
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2022-07-29 18:11:01 +00:00 committed by Commit Bot
parent fb3d3e8802
commit 4f7bb16cc5
10 changed files with 199 additions and 5 deletions

View file

@ -578,6 +578,8 @@ class Architecture extends NamedEnum {
static const ia32 = Architecture._('ia32');
static const x64 = Architecture._('x64');
static const x64c = Architecture._('x64c');
static const simx64 = Architecture._('simx64');
static const simx64c = Architecture._('simx64c');
static const arm = Architecture._('arm');
// ignore: constant_identifier_names
static const arm_x64 = Architecture._('arm_x64');
@ -597,6 +599,8 @@ class Architecture extends NamedEnum {
ia32,
x64,
x64c,
simx64,
simx64c,
arm,
arm_x64,
arm64,

View file

@ -1005,6 +1005,8 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
switch (_configuration.architecture) {
case Architecture.x64:
case Architecture.x64c:
case Architecture.simx64:
case Architecture.simx64c:
ccFlags = "-m64";
break;
case Architecture.simarm64:

View file

@ -40,6 +40,7 @@ bool HostCPUFeatures::abm_supported_ = false;
bool HostCPUFeatures::initialized_ = false;
#endif
#if !defined(USING_SIMULATOR)
void HostCPUFeatures::Init() {
CpuInfo::Init();
hardware_ = CpuInfo::GetCpuModel();
@ -63,6 +64,31 @@ void HostCPUFeatures::Cleanup() {
CpuInfo::Cleanup();
}
#else // !defined(USING_SIMULATOR)
void HostCPUFeatures::Init() {
CpuInfo::Init();
hardware_ = CpuInfo::GetCpuModel();
sse4_1_supported_ = false;
popcnt_supported_ = false;
abm_supported_ = false;
#if defined(DEBUG)
initialized_ = true;
#endif
}
void HostCPUFeatures::Cleanup() {
DEBUG_ASSERT(initialized_);
#if defined(DEBUG)
initialized_ = false;
#endif
ASSERT(hardware_ != NULL);
free(const_cast<char*>(hardware_));
hardware_ = NULL;
CpuInfo::Cleanup();
}
#endif // !defined(USING_SIMULATOR)
} // namespace dart
#endif // defined TARGET_ARCH_X64

View file

@ -8,8 +8,10 @@
#include "vm/globals.h"
#if defined(USING_SIMULATOR)
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
#if defined(TARGET_ARCH_IA32)
#error Simulator not implemented.
#elif defined(TARGET_ARCH_X64)
#include "vm/simulator_x64.h"
#elif defined(TARGET_ARCH_ARM)
#include "vm/simulator_arm.h"
#elif defined(TARGET_ARCH_ARM64)

View file

@ -0,0 +1,72 @@
// Copyright (c) 2022, 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.
#include <setjmp.h> // NOLINT
#include <stdlib.h>
#include "vm/globals.h"
#if defined(TARGET_ARCH_X64)
// Only build the simulator if not compiling for real X64 hardware.
#if defined(USING_SIMULATOR)
#include "vm/simulator.h"
#include "vm/heap/safepoint.h"
#include "vm/isolate.h"
namespace dart {
// Get the active Simulator for the current isolate.
Simulator* Simulator::Current() {
Isolate* isolate = Isolate::Current();
Simulator* simulator = isolate->simulator();
if (simulator == NULL) {
NoSafepointScope no_safepoint;
simulator = new Simulator();
isolate->set_simulator(simulator);
}
return simulator;
}
void Simulator::Init() {}
Simulator::Simulator() {}
Simulator::~Simulator() {
Isolate* isolate = Isolate::Current();
if (isolate != NULL) {
isolate->set_simulator(NULL);
}
}
int64_t Simulator::Call(int64_t entry,
int64_t parameter0,
int64_t parameter1,
int64_t parameter2,
int64_t parameter3,
bool fp_return,
bool fp_args) {
UNIMPLEMENTED();
}
void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) {
UNIMPLEMENTED();
}
uword Simulator::RedirectExternalReference(uword function,
CallKind call_kind,
int argument_count) {
return 0;
}
uword Simulator::FunctionForRedirect(uword redirect) {
return 0;
}
} // namespace dart
#endif // !defined(USING_SIMULATOR)
#endif // defined TARGET_ARCH_RISCV

View file

@ -0,0 +1,76 @@
// Copyright (c) 2022, 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.
#ifndef RUNTIME_VM_SIMULATOR_X64_H_
#define RUNTIME_VM_SIMULATOR_X64_H_
#ifndef RUNTIME_VM_SIMULATOR_H_
#error Do not include simulator_x64.h directly; use simulator.h.
#endif
#include "vm/constants.h"
#include "vm/random.h"
namespace dart {
class Thread;
class Simulator {
public:
static const uword kSimulatorStackUnderflowSize = 64;
Simulator();
~Simulator();
static Simulator* Current();
int64_t Call(int64_t entry,
int64_t parameter0,
int64_t parameter1,
int64_t parameter2,
int64_t parameter3,
bool fp_return = false,
bool fp_args = false);
// Runtime and native call support.
enum CallKind {
kRuntimeCall,
kLeafRuntimeCall,
kLeafFloatRuntimeCall,
kNativeCallWrapper
};
static uword RedirectExternalReference(uword function,
CallKind call_kind,
int argument_count);
static uword FunctionForRedirect(uword redirect);
void JumpToFrame(uword pc, uword sp, uword fp, Thread* thread);
uint64_t get_register(Register rs) const { return 0; }
uint64_t get_pc() const { return 0; }
uint64_t get_sp() const { return 0; }
uint64_t get_fp() const { return 0; }
uint64_t get_lr() const { return 0; }
// High address.
uword stack_base() const { return 0; }
// Limit for StackOverflowError.
uword overflow_stack_limit() const { return 0; }
// Low address.
uword stack_limit() const { return 0; }
// Accessor to the instruction counter.
uint64_t get_icount() const { return 0; }
// Call on program start.
static void Init();
private:
DISALLOW_COPY_AND_ASSIGN(Simulator);
};
} // namespace dart
#endif // RUNTIME_VM_SIMULATOR_X64_H_

View file

@ -301,6 +301,8 @@ vm_sources = [
"simulator_arm64.h",
"simulator_riscv.cc",
"simulator_riscv.h",
"simulator_x64.cc",
"simulator_x64.h",
"snapshot.cc",
"snapshot.h",
"source_report.cc",

View file

@ -1337,6 +1337,14 @@
"gen_snapshot"
]
},
{
"name": "build dart (cross x64)",
"script": "tools/build.py",
"arguments": [
"--arch=simx64",
"gen_snapshot"
]
},
{
"name": "vm nnbd tests in weak mode with asserts",
"arguments": [

View file

@ -82,8 +82,8 @@ def HostCpuForArch(arch):
# - using a host architecture with a different word size (supports only AOT and only 32-bit target on 64-bit host)
if arch in ['ia32']:
candidates = ['x86']
elif arch in ['x64', 'x64c']:
candidates = ['x64']
elif arch in ['x64', 'x64c', 'simx64', 'simx64c']:
candidates = ['x64', 'arm64']
elif arch in ['arm', 'simarm']:
candidates = ['arm', 'x86', 'riscv32', 'arm64', 'x64', 'riscv64']
elif arch in ['arm64', 'arm64c', 'simarm64', 'simarm64c']:
@ -124,7 +124,7 @@ def TargetCpuForArch(arch, target_os):
# Simulators
if arch in ['simarm_x64', 'simriscv32_x64']:
return 'x64'
elif arch in ['simarm_arm64', 'simriscv32_arm64']:
elif arch in ['simarm_arm64', 'simriscv32_arm64', 'simx64', 'simx64c']:
return 'arm64'
elif arch in ['simarm_riscv64', 'simriscv32_riscv64']:
return 'riscv64'
@ -149,7 +149,7 @@ def TargetCpuForArch(arch, target_os):
def DartTargetCpuForArch(arch):
if arch in ['ia32']:
return 'ia32'
if arch in ['x64', 'x64c']:
if arch in ['x64', 'x64c', 'simx64', 'simx64c']:
return 'x64'
if arch in [
'arm', 'simarm', 'simarm_x64', 'arm_x64', 'simarm_arm64',

View file

@ -77,6 +77,8 @@ ARCH_FAMILY = {
'simarm64c': 'ia32',
'simriscv32': 'ia32',
'simriscv64': 'ia32',
'simx64': 'arm',
'simx64c': 'arm',
'riscv32': 'riscv',
'riscv64': 'riscv',
}