VM: Replace dart --noopt with new binary target dart_noopt.

This allows us to exclude precompiler related code from the standalone
JIT VM, and only have the precompiler included in dart_noopt and dart_no_snapshot
(which is used to generate precompiled snapshots)

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1661703002 .
This commit is contained in:
Florian Schneider 2016-02-02 17:51:15 -08:00
parent e1baa6cf21
commit 0f48690061
9 changed files with 199 additions and 27 deletions

View file

@ -25,6 +25,7 @@
'type': 'none',
'dependencies': [
'runtime/dart-runtime.gyp:dart',
'runtime/dart-runtime.gyp:dart_noopt',
'runtime/dart-runtime.gyp:dart_precompiled_runtime',
'runtime/dart-runtime.gyp:dart_no_snapshot',
'runtime/dart-runtime.gyp:run_vm_tests',

View file

@ -366,6 +366,7 @@
'defines': [
'DART_SHARED_LIB',
'DART_NO_SNAPSHOT',
'DART_PRECOMPILER',
],
},
{
@ -627,6 +628,64 @@
},
},
},
{
# dart binary with a snapshot of corelibs built in and support for testing
# precompilation (aka --noopt)
'target_name': 'dart_noopt',
'type': 'executable',
'dependencies': [
'libdart_noopt',
'libdart_builtin',
'libdart_io',
'build_observatory#host',
'generate_snapshot_file#host',
'generate_resources_cc_file#host',
'generate_observatory_assets_cc_file#host',
],
'include_dirs': [
'..',
'../../third_party/', # Zlib
],
'sources': [
'main.cc',
'builtin_common.cc',
'builtin_natives.cc',
'builtin_nolib.cc',
'builtin.h',
'io_natives.h',
'vmservice_impl.cc',
'vmservice_impl.h',
'<(snapshot_cc_file)',
'<(resources_cc_file)',
'<(observatory_assets_cc_file)',
],
'defines': [
'DART_PRECOMPILER',
],
'conditions': [
['OS=="win"', {
'link_settings': {
'libraries': [ '-lws2_32.lib', '-lRpcrt4.lib', '-lwinmm.lib' ],
},
# Generate an import library on Windows, by exporting a function.
# Extensions use this import library to link to the API in dart.exe.
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [ '/EXPORT:Dart_True' ],
},
},
}],
],
'configurations': {
'Dart_Linux_Base': {
# Have the linker add all symbols to the dynamic symbol table
# so that extensions can look them up dynamically in the binary.
'ldflags': [
'-rdynamic',
],
},
},
},
{
# dart binary for running precompiled snapshots without the compiler.
'target_name': 'dart_precompiled_runtime',
@ -760,6 +819,10 @@
'<(observatory_assets_cc_file)',
'snapshot_empty.cc',
],
'defines': [
'DART_NO_SNAPSHOT',
'DART_PRECOMPILER',
],
'conditions': [
['OS=="win"', {
'link_settings': {

View file

@ -343,19 +343,6 @@ static bool ProcessRunPrecompiledSnapshotOption(
}
static bool ProcessNooptOption(
const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
if (*arg != '\0') {
return false;
}
has_noopt = true;
vm_options->AddArgument("--precompilation");
return true;
}
static bool ProcessScriptSnapshotOptionHelper(const char* filename,
bool* snapshot_option) {
*snapshot_option = false;
@ -487,7 +474,6 @@ static struct {
{ "--compile_all", ProcessCompileAllOption },
{ "--enable-vm-service", ProcessEnableVmServiceOption },
{ "--gen-precompiled-snapshot", ProcessGenPrecompiledSnapshotOption },
{ "--noopt", ProcessNooptOption },
{ "--observe", ProcessObserveOption },
{ "--run-precompiled-snapshot", ProcessRunPrecompiledSnapshotOption },
{ "--shutdown", ProcessShutdownOption },
@ -1460,6 +1446,16 @@ void main(int argc, char** argv) {
vm_options.AddArgument("--load_deferred_eagerly");
}
#if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT)
// Always set --precompilation with dart_noopt, unless already set by these
// command line options.
if (!has_gen_precompiled_snapshot &&
!has_run_precompiled_snapshot) {
has_noopt = true;
vm_options.AddArgument("--precompilation");
}
#endif
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
// Start event handler.

View file

@ -17,6 +17,7 @@
'libdart_deps': ['libdart_lib_nosnapshot', 'libdart_lib',
'libdart_vm_nosnapshot', 'libdart_vm',
'libdart_vm_noopt',
'libdart_vm_precompiled_runtime',
'libdouble_conversion',],
},
@ -55,6 +56,41 @@
],
},
},
{
'target_name': 'libdart_noopt',
'type': 'static_library',
'dependencies': [
'libdart_lib',
'libdart_vm_noopt',
'libdouble_conversion',
'generate_version_cc_file#host',
],
'include_dirs': [
'.',
],
'sources': [
'include/dart_api.h',
'include/dart_mirrors_api.h',
'include/dart_native_api.h',
'include/dart_tools_api.h',
'vm/dart_api_impl.cc',
'vm/debugger_api_impl.cc',
'vm/mirrors_api_impl.cc',
'vm/native_api_impl.cc',
'vm/version.h',
'<(version_cc_file)',
],
'defines': [
# The only effect of DART_SHARED_LIB is to export the Dart API entries.
'DART_SHARED_LIB',
'DART_PRECOMPILER',
],
'direct_dependent_settings': {
'include_dirs': [
'include',
],
},
},
{
'target_name': 'libdart_precompiled_runtime',
'type': 'static_library',

View file

@ -5919,7 +5919,7 @@ DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
}
#if defined(DART_PRECOMPILED_RUNTIME)
#if !defined(DART_PRECOMPILER)
DART_EXPORT Dart_Handle Dart_Precompile(
Dart_QualifiedFunctionName entry_points[],
@ -5940,7 +5940,7 @@ DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshot(
return 0;
}
#else // DART_PRECOMPILED_RUNTIME
#else // DART_PRECOMPILER
DART_EXPORT Dart_Handle Dart_Precompile(
Dart_QualifiedFunctionName entry_points[],
@ -6014,7 +6014,7 @@ DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshot(
return Api::Success();
}
#endif // DART_PRECOMPILED_RUNTIME
#endif // DART_PRECOMPILER
DART_EXPORT bool Dart_IsRunningPrecompiledCode() {

View file

@ -158,6 +158,69 @@
},
}]],
},
{
'target_name': 'libdart_vm_noopt',
'type': 'static_library',
'toolsets':['host', 'target'],
'includes': [
'vm_sources.gypi',
'../platform/platform_headers.gypi',
'../platform/platform_sources.gypi',
],
'sources/': [
# Exclude all _test.[cc|h] files.
['exclude', '_test\\.(cc|h)$'],
],
'include_dirs': [
'..',
],
'defines': [
'DART_PRECOMPILER',
],
'conditions': [
['OS=="linux"', {
'link_settings': {
'libraries': [
'-lpthread',
'-lrt',
'-ldl',
],
},
}],
['OS=="android" and _toolset=="host"', {
'link_settings': {
'libraries': [
'-lpthread',
'-lrt',
'-ldl',
],
},
}],
['OS=="win"', {
'sources/' : [
['exclude', 'gdbjit.cc'],
],
}],
['dart_vtune_support==0', {
'sources/' : [
['exclude', 'vtune\\.(cc|h)$'],
],
}],
['dart_vtune_support==1', {
'include_dirs': ['<(dart_vtune_root)/include'],
'defines': ['DART_VTUNE_SUPPORT'],
'link_settings': {
'conditions': [
['OS=="linux"', {
'libraries': ['-ljitprofiling'],
}],
['OS=="win"', {
'libraries': ['-ljitprofiling.lib'],
}],
],
},
}]],
},
{
'target_name': 'libdart_vm_nosnapshot',
'type': 'static_library',
@ -176,6 +239,7 @@
],
'defines': [
'DART_NO_SNAPSHOT',
'DART_PRECOMPILER',
],
'conditions': [
['OS=="linux"', {

View file

@ -61,7 +61,6 @@ abstract class CompilerConfiguration {
bool useSdk = configuration['use_sdk'];
bool isCsp = configuration['csp'];
bool useCps = configuration['cps_ir'];
bool useNoopt = configuration['noopt'];
switch (compiler) {
case 'dart2analyzer':
@ -80,7 +79,7 @@ abstract class CompilerConfiguration {
case 'none':
return new NoneCompilerConfiguration(
isDebug: isDebug, isChecked: isChecked,
isHostChecked: isHostChecked, useSdk: useSdk, useNoopt: useNoopt);
isHostChecked: isHostChecked, useSdk: useSdk);
default:
throw "Unknown compiler '$compiler'";
}
@ -142,17 +141,15 @@ abstract class CompilerConfiguration {
/// The "none" compiler.
class NoneCompilerConfiguration extends CompilerConfiguration {
final bool useNoopt;
NoneCompilerConfiguration({
bool isDebug,
bool isChecked,
bool isHostChecked,
bool useSdk,
bool useNoopt})
bool useSdk})
: super._subclass(
isDebug: isDebug, isChecked: isChecked,
isHostChecked: isHostChecked, useSdk: useSdk), useNoopt = useNoopt;
isHostChecked: isHostChecked, useSdk: useSdk);
bool get hasCompiler => false;
@ -169,9 +166,6 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
args.add('--enable_asserts');
args.add('--enable_type_checks');
}
if (useNoopt) {
args.add('--noopt');
}
return args
..addAll(vmOptions)
..addAll(sharedOptions)

View file

@ -218,8 +218,11 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
if (script != null && type != 'application/dart') {
throw "Dart VM cannot run files of type '$type'.";
}
String executable = suite.configuration['noopt']
? suite.dartVmNooptBinaryFileName
: suite.dartVmBinaryFileName;
return <Command>[commandBuilder.getVmCommand(
suite.dartVmBinaryFileName, arguments, environmentOverrides)];
executable, arguments, environmentOverrides)];
}
}

View file

@ -212,6 +212,21 @@ abstract class TestSuite {
return dartExecutable;
}
String get dartVmNooptBinaryFileName {
// Controlled by user with the option "--dart".
String dartExecutable = configuration['dart'];
if (dartExecutable == '') {
String suffix = executableBinarySuffix;
dartExecutable = useSdk
? '$buildDir/dart-sdk/bin/dart_noopt$suffix'
: '$buildDir/dart_noopt$suffix';
}
TestUtils.ensureExists(dartExecutable, configuration);
return dartExecutable;
}
String get dartPrecompiledBinaryFileName {
// Controlled by user with the option "--dart_precompiled".
String dartExecutable = configuration['dart_precompiled'];