mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:50:11 +00:00
[VM] Pass --strong down to DFE isolate
Bug: https://github.com/dart-lang/sdk/issues/31147 Change-Id: Id8dbdadc1f69213604572efc815d45675d49734e Reviewed-on: https://dart-review.googlesource.com/15883 Commit-Queue: Vyacheslav Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
ae2d84e51e
commit
0fe889dbd7
|
@ -13,10 +13,12 @@ namespace dart {
|
|||
namespace bin {
|
||||
|
||||
const char kPlatformBinaryName[] = "vm_platform.dill";
|
||||
const char kPlatformStrongBinaryName[] = "vm_platform_strong.dill";
|
||||
const char kVMServiceIOBinaryName[] = "vmservice_io.dill";
|
||||
|
||||
DFE::DFE()
|
||||
: frontend_filename_(NULL),
|
||||
kernel_binaries_path_(NULL),
|
||||
platform_binary_filename_(NULL),
|
||||
vmservice_io_binary_filename_(NULL),
|
||||
kernel_platform_(NULL),
|
||||
|
@ -25,10 +27,14 @@ DFE::DFE()
|
|||
DFE::~DFE() {
|
||||
frontend_filename_ = NULL;
|
||||
|
||||
if (platform_binary_filename_ != NULL) {
|
||||
delete platform_binary_filename_;
|
||||
platform_binary_filename_ = NULL;
|
||||
}
|
||||
free(kernel_binaries_path_);
|
||||
kernel_binaries_path_ = NULL;
|
||||
|
||||
free(platform_binary_filename_);
|
||||
platform_binary_filename_ = NULL;
|
||||
|
||||
free(vmservice_io_binary_filename_);
|
||||
vmservice_io_binary_filename_ = NULL;
|
||||
|
||||
if (kernel_platform_ != NULL) {
|
||||
delete reinterpret_cast<kernel::Program*>(kernel_platform_);
|
||||
|
@ -37,19 +43,19 @@ DFE::~DFE() {
|
|||
}
|
||||
|
||||
void DFE::SetKernelBinaries(const char* name) {
|
||||
intptr_t len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(),
|
||||
kPlatformBinaryName) +
|
||||
1;
|
||||
platform_binary_filename_ = new char[len];
|
||||
snprintf(platform_binary_filename_, len, "%s%s%s", name,
|
||||
File::PathSeparator(), kPlatformBinaryName);
|
||||
kernel_binaries_path_ = strdup(name);
|
||||
vmservice_io_binary_filename_ =
|
||||
OS::SCreate(/*zone=*/NULL, "%s%s%s", name, File::PathSeparator(),
|
||||
kVMServiceIOBinaryName);
|
||||
}
|
||||
|
||||
len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(),
|
||||
kVMServiceIOBinaryName) +
|
||||
1;
|
||||
vmservice_io_binary_filename_ = new char[len];
|
||||
snprintf(vmservice_io_binary_filename_, len, "%s%s%s", name,
|
||||
File::PathSeparator(), kVMServiceIOBinaryName);
|
||||
const char* DFE::GetPlatformBinaryFilename() {
|
||||
if (platform_binary_filename_ == NULL) {
|
||||
platform_binary_filename_ = OS::SCreate(
|
||||
/*zone=*/NULL, "%s%s%s", kernel_binaries_path_, File::PathSeparator(),
|
||||
FLAG_strong ? kPlatformStrongBinaryName : kPlatformBinaryName);
|
||||
}
|
||||
return platform_binary_filename_;
|
||||
}
|
||||
|
||||
static void ReleaseFetchedBytes(uint8_t* buffer) {
|
||||
|
@ -71,7 +77,7 @@ Dart_Handle DFE::ReadKernelBinary(Dart_Isolate isolate,
|
|||
// TODO(aam): When Frontend is ready, VM should be passing vm_outline.dill
|
||||
// instead of vm_platform.dill to Frontend for compilation.
|
||||
Dart_KernelCompilationResult kresult =
|
||||
Dart_CompileToKernel(url_string, platform_binary_filename_);
|
||||
Dart_CompileToKernel(url_string, GetPlatformBinaryFilename());
|
||||
if (kresult.status != Dart_KernelCompilationStatus_Ok) {
|
||||
return Dart_NewApiError(kresult.error);
|
||||
}
|
||||
|
@ -90,7 +96,7 @@ void* DFE::CompileAndReadScript(const char* script_uri,
|
|||
// TODO(aam): When Frontend is ready, VM should be passing vm_outline.dill
|
||||
// instead of vm_platform.dill to Frontend for compilation.
|
||||
Dart_KernelCompilationResult result =
|
||||
Dart_CompileToKernel(script_uri, platform_binary_filename_);
|
||||
Dart_CompileToKernel(script_uri, GetPlatformBinaryFilename());
|
||||
switch (result.status) {
|
||||
case Dart_KernelCompilationStatus_Ok:
|
||||
return Dart_ReadKernelBinary(result.kernel, result.kernel_size,
|
||||
|
@ -111,8 +117,8 @@ void* DFE::CompileAndReadScript(const char* script_uri,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void* DFE::ReadPlatform() const {
|
||||
return ReadScript(platform_binary_filename_);
|
||||
void* DFE::ReadPlatform() {
|
||||
return ReadScript(GetPlatformBinaryFilename());
|
||||
}
|
||||
|
||||
void* DFE::ReadVMServiceIO() const {
|
||||
|
|
|
@ -22,13 +22,11 @@ class DFE {
|
|||
void set_frontend_filename(const char* name) { frontend_filename_ = name; }
|
||||
bool UseDartFrontend() const { return frontend_filename_ != NULL; }
|
||||
|
||||
const char* platform_binary_filename() const {
|
||||
return platform_binary_filename_;
|
||||
}
|
||||
const char* GetPlatformBinaryFilename();
|
||||
|
||||
void SetKernelBinaries(const char* name);
|
||||
|
||||
bool UsePlatformBinary() const { return platform_binary_filename_ != NULL; }
|
||||
bool UsePlatformBinary() const { return kernel_binaries_path_ != NULL; }
|
||||
|
||||
void* kernel_platform() const { return kernel_platform_; }
|
||||
void set_kernel_platform(void* kernel_platform) {
|
||||
|
@ -54,7 +52,7 @@ class DFE {
|
|||
|
||||
// Reads the platform kernel file.
|
||||
// Returns an in memory kernel representation of the platform kernel file.
|
||||
void* ReadPlatform() const;
|
||||
void* ReadPlatform();
|
||||
|
||||
// Reads the vmservice_io kernel file.
|
||||
// Returns the in memory representation of the vmservice_io kernel file.
|
||||
|
@ -76,6 +74,7 @@ class DFE {
|
|||
intptr_t* kernel_ir_size) const;
|
||||
|
||||
const char* frontend_filename_;
|
||||
char* kernel_binaries_path_;
|
||||
char* platform_binary_filename_;
|
||||
char* vmservice_io_binary_filename_;
|
||||
void* kernel_platform_;
|
||||
|
|
|
@ -1073,6 +1073,10 @@ void main(int argc, char** argv) {
|
|||
Process::SetExitHook(SnapshotOnExitHook);
|
||||
}
|
||||
|
||||
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
|
||||
// Note: must read platform only *after* VM flags are parsed because
|
||||
// they might affect how the platform is loaded.
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
// If a kernel platform binary file is specified, read it. This
|
||||
// step will become redundant once we have the snapshot version
|
||||
|
@ -1087,8 +1091,6 @@ void main(int argc, char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
|
||||
// Start event handler.
|
||||
TimerUtils::InitOnce();
|
||||
EventHandler::Start();
|
||||
|
|
|
@ -331,6 +331,10 @@ class KernelCompilationRequest : public ValueObject {
|
|||
dart_incremental.type = Dart_CObject_kBool;
|
||||
dart_incremental.value.as_bool = incremental_compile;
|
||||
|
||||
Dart_CObject dart_strong;
|
||||
dart_strong.type = Dart_CObject_kBool;
|
||||
dart_strong.value.as_bool = FLAG_strong;
|
||||
|
||||
// TODO(aam): Assert that isolate exists once we move CompileAndReadScript
|
||||
// compilation logic out of CreateIsolateAndSetupHelper and into
|
||||
// IsolateSetupHelper in main.cc.
|
||||
|
@ -347,17 +351,22 @@ class KernelCompilationRequest : public ValueObject {
|
|||
Dart_CObject message;
|
||||
message.type = Dart_CObject_kArray;
|
||||
|
||||
intptr_t message_len = 6;
|
||||
Dart_CObject files;
|
||||
if (source_files_count != 0) {
|
||||
files = BuildFilesPairs(source_files_count, source_files);
|
||||
message_len++;
|
||||
} else {
|
||||
files.type = Dart_CObject_kNull;
|
||||
}
|
||||
Dart_CObject* message_arr[] = {
|
||||
&tag, &send_port, &uri, &dart_platform_kernel, &dart_incremental,
|
||||
&isolate_id, &files};
|
||||
Dart_CObject* message_arr[] = {&tag,
|
||||
&send_port,
|
||||
&uri,
|
||||
&dart_platform_kernel,
|
||||
&dart_incremental,
|
||||
&dart_strong,
|
||||
&isolate_id,
|
||||
&files};
|
||||
message.value.as_array.values = message_arr;
|
||||
message.value.as_array.length = message_len;
|
||||
message.value.as_array.length = ARRAY_SIZE(message_arr);
|
||||
// Send the message.
|
||||
Dart_PostCObject(kernel_port, &message);
|
||||
|
||||
|
|
|
@ -39,15 +39,15 @@ import 'package:kernel/target/targets.dart' show TargetFlags;
|
|||
import 'package:kernel/target/vm.dart' show VmTarget;
|
||||
|
||||
const bool verbose = const bool.fromEnvironment('DFE_VERBOSE');
|
||||
const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE');
|
||||
|
||||
abstract class Compiler {
|
||||
final FileSystem fileSystem;
|
||||
final bool strongMode;
|
||||
final List<String> errors = new List<String>();
|
||||
|
||||
CompilerOptions options;
|
||||
|
||||
Compiler(this.fileSystem, Uri platformKernel) {
|
||||
Compiler(this.fileSystem, Uri platformKernel, {this.strongMode: false}) {
|
||||
Uri packagesUri = (Platform.packageConfig != null)
|
||||
? Uri.parse(Platform.packageConfig)
|
||||
: null;
|
||||
|
@ -57,6 +57,7 @@ abstract class Compiler {
|
|||
print("DFE: packagesUri: ${packagesUri}");
|
||||
print("DFE: Platform.resolvedExecutable: ${Platform.resolvedExecutable}");
|
||||
print("DFE: platformKernel: ${platformKernel}");
|
||||
print("DFE: strongMode: ${strongMode}");
|
||||
}
|
||||
|
||||
options = new CompilerOptions()
|
||||
|
@ -82,8 +83,9 @@ abstract class Compiler {
|
|||
class IncrementalCompiler extends Compiler {
|
||||
IncrementalKernelGenerator generator;
|
||||
|
||||
IncrementalCompiler(FileSystem fileSystem, Uri platformKernel)
|
||||
: super(fileSystem, platformKernel);
|
||||
IncrementalCompiler(FileSystem fileSystem, Uri platformKernel,
|
||||
{strongMode: false})
|
||||
: super(fileSystem, platformKernel, strongMode: strongMode);
|
||||
|
||||
@override
|
||||
Future<Program> compile(Uri script) async {
|
||||
|
@ -104,9 +106,9 @@ class IncrementalCompiler extends Compiler {
|
|||
class SingleShotCompiler extends Compiler {
|
||||
final bool requireMain;
|
||||
|
||||
SingleShotCompiler(
|
||||
FileSystem fileSystem, Uri platformKernel, this.requireMain)
|
||||
: super(fileSystem, platformKernel);
|
||||
SingleShotCompiler(FileSystem fileSystem, Uri platformKernel,
|
||||
{this.requireMain: false, strongMode: false})
|
||||
: super(fileSystem, platformKernel, strongMode: strongMode);
|
||||
|
||||
@override
|
||||
Future<Program> compile(Uri script) async {
|
||||
|
@ -119,7 +121,8 @@ class SingleShotCompiler extends Compiler {
|
|||
final Map<int, Compiler> isolateCompilers = new Map<int, Compiler>();
|
||||
|
||||
Future<Compiler> lookupOrBuildNewIncrementalCompiler(
|
||||
int isolateId, List sourceFiles, Uri platformKernel) async {
|
||||
int isolateId, List sourceFiles, Uri platformKernel,
|
||||
{strongMode: false}) async {
|
||||
IncrementalCompiler compiler;
|
||||
if (isolateCompilers.containsKey(isolateId)) {
|
||||
compiler = isolateCompilers[isolateId];
|
||||
|
@ -142,7 +145,8 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(
|
|||
// destroyed when corresponding isolate is shut down. To achieve that kernel
|
||||
// isolate needs to receive a message indicating that particular
|
||||
// isolate was shut down. Message should be handled here in this script.
|
||||
compiler = new IncrementalCompiler(fileSystem, platformKernel);
|
||||
compiler = new IncrementalCompiler(fileSystem, platformKernel,
|
||||
strongMode: strongMode);
|
||||
isolateCompilers[isolateId] = compiler;
|
||||
}
|
||||
return compiler;
|
||||
|
@ -165,8 +169,9 @@ Future _processLoadRequest(request) async {
|
|||
'vm_platform.dill');
|
||||
|
||||
final bool incremental = request[4];
|
||||
|
||||
final List sourceFiles = request.length > 6 ? request[6] : null;
|
||||
final bool strong = request[5];
|
||||
final int isolateId = request[6];
|
||||
final List sourceFiles = request[7];
|
||||
|
||||
Compiler compiler;
|
||||
// TODO(aam): There should be no need to have an option to choose
|
||||
|
@ -174,15 +179,14 @@ Future _processLoadRequest(request) async {
|
|||
// compiler as its functionality is a super set of the other one. We need to
|
||||
// watch the performance though.
|
||||
if (incremental) {
|
||||
final int isolateId = request[5];
|
||||
compiler = await lookupOrBuildNewIncrementalCompiler(
|
||||
isolateId, sourceFiles, platformKernel);
|
||||
} else {
|
||||
final FileSystem fileSystem = sourceFiles == null
|
||||
? PhysicalFileSystem.instance
|
||||
: _buildFileSystem(sourceFiles);
|
||||
compiler = new SingleShotCompiler(
|
||||
fileSystem, platformKernel, sourceFiles == null /* requireMain */);
|
||||
compiler = new SingleShotCompiler(fileSystem, platformKernel,
|
||||
requireMain: sourceFiles == null, strongMode: strong);
|
||||
}
|
||||
|
||||
CompilationResult result;
|
||||
|
@ -265,7 +269,9 @@ train(String scriptUri) {
|
|||
scriptUri,
|
||||
null /* platformKernel */,
|
||||
false /* incremental */,
|
||||
1 /* isolateId chosen randomly */
|
||||
false /* strong */,
|
||||
1 /* isolateId chosen randomly */,
|
||||
null /* source files */
|
||||
];
|
||||
_processLoadRequest(request);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue