Replace the --platform vm_option with --kernel-binaries option.

This new flag value specifies the directory in which the VM should look
up the platform.dill file. A future change will require the VM to load
another kernel binary from disk. This binary will also live in the same
directory that --kernel-binaries specifies. This way, we avoid adding a
different flag for each of the different binaries.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2933203004 .
This commit is contained in:
Siva Chandra 2017-06-16 12:22:28 -07:00
parent 93a02bf8f9
commit bac83e0973
4 changed files with 35 additions and 23 deletions

View file

@ -5,12 +5,16 @@
#include "bin/dfe.h"
#include "bin/dartutils.h"
#include "bin/error_exit.h"
#include "bin/file.h"
#include "vm/kernel.h"
namespace dart {
namespace bin {
const char kPlatformBinaryName[] = "platform.dill";
DFE::DFE()
: frontend_filename_(NULL),
platform_binary_filename_(NULL),
@ -19,13 +23,29 @@ DFE::DFE()
DFE::~DFE() {
frontend_filename_ = NULL;
platform_binary_filename_ = NULL;
if (platform_binary_filename_ != NULL) {
delete platform_binary_filename_;
platform_binary_filename_ = NULL;
}
if (kernel_platform_ != NULL) {
delete reinterpret_cast<kernel::Program*>(kernel_platform_);
kernel_platform_ = NULL;
}
kernel_platform_ = NULL;
}
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);
}
Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) {
ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate));
// First check if the URL points to a Kernel IR file in which case we
@ -85,15 +105,7 @@ void* DFE::CompileAndReadScript(const char* script_uri,
void* DFE::ReadPlatform() {
const uint8_t* buffer = NULL;
intptr_t buffer_length = -1;
bool result =
TryReadKernelFile(platform_binary_filename_, &buffer, &buffer_length);
if (result) {
kernel_platform_ = Dart_ReadKernelBinary(buffer, buffer_length);
return kernel_platform_;
}
return NULL;
return kernel_platform_ = ReadScript(platform_binary_filename_);
}

View file

@ -25,9 +25,9 @@ class DFE {
const char* platform_binary_filename() const {
return platform_binary_filename_;
}
void set_platform_binary_filename(const char* name) {
platform_binary_filename_ = name;
}
void SetKernelBinaries(const char* name);
bool UsePlatformBinary() const { return platform_binary_filename_ != NULL; }
void* kernel_platform() const { return kernel_platform_; }
@ -66,7 +66,7 @@ class DFE {
intptr_t* kernel_ir_size);
const char* frontend_filename_;
const char* platform_binary_filename_;
char* platform_binary_filename_;
void* kernel_platform_;
DISALLOW_COPY_AND_ASSIGN(DFE);

View file

@ -381,13 +381,13 @@ static bool ProcessFrontendOption(const char* filename,
}
static bool ProcessPlatformOption(const char* filename,
CommandLineOptions* vm_options) {
ASSERT(filename != NULL);
if (filename[0] == '\0') {
static bool ProcessKernelBinariesOption(const char* dirname,
CommandLineOptions* vm_options) {
ASSERT(dirname != NULL);
if (dirname[0] == '\0') {
return false;
}
dfe.set_platform_binary_filename(filename);
dfe.SetKernelBinaries(dirname);
return true;
}
#endif
@ -616,7 +616,7 @@ static struct {
{"--parse_all", ProcessParseAllOption},
#if !defined(DART_PRECOMPILED_RUNTIME)
{"--dfe=", ProcessFrontendOption},
{"--platform=", ProcessPlatformOption},
{"--kernel-binaries=", ProcessKernelBinariesOption},
#endif
{"--enable-vm-service", ProcessEnableVmServiceOption},
{"--disable-service-origin-check", ProcessDisableServiceOriginCheckOption},

View file

@ -198,7 +198,7 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
List<String> args = [];
if (useDfe) {
args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot');
args.add('--platform=${buildDir}/patched_sdk/platform.dill');
args.add('--kernel-binaries=${buildDir}/patched_sdk');
}
if (isChecked) {
args.add('--enable_asserts');
@ -608,7 +608,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
var args = <String>[];
if (useDfe) {
args.add('--dfe=utils/kernel-service/kernel-service.dart');
args.add('--platform=${buildDir}/patched_sdk/platform.dill');
args.add('--kernel-binaries=${buildDir}/patched_sdk');
}
args.add("--snapshot-kind=app-aot");
if (useBlobs) {