Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: runtime/bin/main.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/lockers.h ('k') | runtime/bin/platform.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index cbe38ef74c80f16fe16e762e02b70a61778c33de..7337d57969328a763215d111e542b3c9b70ede37 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -2,9 +2,9 @@
// 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
#include "include/dart_api.h"
#include "include/dart_tools_api.h"
@@ -114,31 +114,25 @@ static const char* commandline_package_root = NULL;
// free'd.)
static const char* commandline_packages_file = NULL;
-
// Global flag that is used to indicate that we want to compile all the
// dart functions and not run anything.
static bool compile_all = false;
static bool parse_all = false;
-
// Global flag that is used to indicate that we want to use blobs/mmap instead
// of assembly/shared libraries for precompilation.
static bool use_blobs = false;
-
// Global flag that is used to indicate that we want to trace resolution of
// URIs and the loading of libraries, parts and scripts.
static bool trace_loading = false;
-
static char* app_script_uri = NULL;
static const uint8_t* app_isolate_snapshot_data = NULL;
static const uint8_t* app_isolate_snapshot_instructions = NULL;
-
static Dart_Isolate main_isolate = NULL;
-
static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost";
static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
// VM Service options.
@@ -150,7 +144,6 @@ static int vm_service_server_port = -1;
// checks are disabled.
static bool vm_service_dev_mode = false;
-
// The environment provided through the command line using -D options.
static dart::HashMap* environment = NULL;
@@ -162,7 +155,6 @@ static bool IsValidFlag(const char* name,
(strncmp(name, prefix, prefix_length) == 0));
}
-
static bool version_option = false;
static bool ProcessVersionOption(const char* arg,
CommandLineOptions* vm_options) {
@@ -173,7 +165,6 @@ static bool ProcessVersionOption(const char* arg,
return true;
}
-
static bool help_option = false;
static bool ProcessHelpOption(const char* arg, CommandLineOptions* vm_options) {
if (*arg != '\0') {
@@ -183,7 +174,6 @@ static bool ProcessHelpOption(const char* arg, CommandLineOptions* vm_options) {
return true;
}
-
static bool verbose_option = false;
static bool ProcessVerboseOption(const char* arg,
CommandLineOptions* vm_options) {
@@ -194,7 +184,6 @@ static bool ProcessVerboseOption(const char* arg,
return true;
}
-
static bool ProcessPackageRootOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -205,7 +194,6 @@ static bool ProcessPackageRootOption(const char* arg,
return true;
}
-
static bool ProcessPackagesOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -216,7 +204,6 @@ static bool ProcessPackagesOption(const char* arg,
return true;
}
-
static bool ProcessSaveCompilationTraceOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -227,7 +214,6 @@ static bool ProcessSaveCompilationTraceOption(const char* arg,
return true;
}
-
static bool ProcessLoadCompilationTraceOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -238,7 +224,6 @@ static bool ProcessLoadCompilationTraceOption(const char* arg,
return true;
}
-
static bool ProcessSaveFeedbackOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -249,7 +234,6 @@ static bool ProcessSaveFeedbackOption(const char* arg,
return true;
}
-
static bool ProcessLoadFeedbackOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -260,12 +244,10 @@ static bool ProcessLoadFeedbackOption(const char* arg,
return true;
}
-
static void* GetHashmapKeyFromString(char* key) {
return reinterpret_cast<void*>(key);
}
-
static bool ExtractPortAndAddress(const char* option_value,
int* out_port,
const char** out_ip,
@@ -302,7 +284,6 @@ static bool ExtractPortAndAddress(const char* option_value,
return true;
}
-
static bool ProcessEnvironmentOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -345,7 +326,6 @@ static bool ProcessEnvironmentOption(const char* arg,
return true;
}
-
static bool ProcessCompileAllOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -356,7 +336,6 @@ static bool ProcessCompileAllOption(const char* arg,
return true;
}
-
static bool ProcessParseAllOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -367,7 +346,6 @@ static bool ProcessParseAllOption(const char* arg,
return true;
}
-
#if !defined(DART_PRECOMPILED_RUNTIME)
static bool ProcessFrontendOption(const char* filename,
CommandLineOptions* vm_options) {
@@ -380,7 +358,6 @@ static bool ProcessFrontendOption(const char* filename,
return true;
}
-
static bool ProcessKernelBinariesOption(const char* dirname,
CommandLineOptions* vm_options) {
ASSERT(dirname != NULL);
@@ -392,7 +369,6 @@ static bool ProcessKernelBinariesOption(const char* dirname,
}
#endif
-
static bool ProcessUseBlobsOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -403,7 +379,6 @@ static bool ProcessUseBlobsOption(const char* arg,
return true;
}
-
static bool ProcessSnapshotFilenameOption(const char* filename,
CommandLineOptions* vm_options) {
snapshot_filename = filename;
@@ -413,7 +388,6 @@ static bool ProcessSnapshotFilenameOption(const char* filename,
return true;
}
-
static bool ProcessSnapshotKindOption(const char* kind,
CommandLineOptions* vm_options) {
if (strcmp(kind, "script") == 0) {
@@ -433,14 +407,12 @@ static bool ProcessSnapshotKindOption(const char* kind,
return false;
}
-
static bool ProcessSnapshotDepsFilenameOption(const char* filename,
CommandLineOptions* vm_options) {
snapshot_deps_filename = filename;
return true;
}
-
static bool ProcessEnableVmServiceOption(const char* option_value,
CommandLineOptions* vm_options) {
ASSERT(option_value != NULL);
@@ -457,7 +429,6 @@ static bool ProcessEnableVmServiceOption(const char* option_value,
return true;
}
-
static bool ProcessDisableServiceOriginCheckOption(
const char* option_value,
CommandLineOptions* vm_options) {
@@ -469,7 +440,6 @@ static bool ProcessDisableServiceOriginCheckOption(
return true;
}
-
static bool ProcessObserveOption(const char* option_value,
CommandLineOptions* vm_options) {
ASSERT(option_value != NULL);
@@ -490,7 +460,6 @@ static bool ProcessObserveOption(const char* option_value,
return true;
}
-
static bool ProcessTraceLoadingOption(const char* arg,
CommandLineOptions* vm_options) {
if (*arg != '\0') {
@@ -500,7 +469,6 @@ static bool ProcessTraceLoadingOption(const char* arg,
return true;
}
-
static bool ProcessHotReloadTestModeOption(const char* arg,
CommandLineOptions* vm_options) {
if (*arg != '\0') {
@@ -521,7 +489,6 @@ static bool ProcessHotReloadTestModeOption(const char* arg,
return true;
}
-
static bool ProcessHotReloadRollbackTestModeOption(
const char* arg,
CommandLineOptions* vm_options) {
@@ -541,7 +508,6 @@ static bool ProcessHotReloadRollbackTestModeOption(
return true;
}
-
extern bool short_socket_read;
extern bool short_socket_write;
@@ -552,14 +518,12 @@ static bool ProcessShortSocketReadOption(const char* arg,
return true;
}
-
static bool ProcessShortSocketWriteOption(const char* arg,
CommandLineOptions* vm_options) {
short_socket_write = true;
return true;
}
-
extern const char* commandline_root_certs_file;
extern const char* commandline_root_certs_cache;
@@ -579,7 +543,6 @@ static bool ProcessRootCertsFileOption(const char* arg,
return true;
}
-
static bool ProcessRootCertsCacheOption(const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
@@ -596,7 +559,6 @@ static bool ProcessRootCertsCacheOption(const char* arg,
return true;
}
-
static struct {
const char* option_name;
bool (*process)(const char* option, CommandLineOptions* vm_options);
@@ -638,7 +600,6 @@ static struct {
{"--root-certs-cache=", ProcessRootCertsCacheOption},
{NULL, NULL}};
-
static bool ProcessMainOptions(const char* option,
CommandLineOptions* vm_options) {
int i = 0;
@@ -657,7 +618,6 @@ static bool ProcessMainOptions(const char* option,
return false;
}
-
// Parse out the command line arguments. Returns -1 if the arguments
// are incorrect, 0 otherwise.
static int ParseArguments(int argc,
@@ -774,7 +734,6 @@ static int ParseArguments(int argc,
return 0;
}
-
static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) {
int options_count = options->count();
Dart_Handle dart_arguments = Dart_NewList(options_count);
@@ -794,7 +753,6 @@ static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) {
return dart_arguments;
}
-
static Dart_Handle EnvironmentCallback(Dart_Handle name) {
uint8_t* utf8_array;
intptr_t utf8_len;
@@ -825,7 +783,6 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
return result;
}
-
#define SAVE_ERROR_AND_EXIT(result) \
*error = strdup(Dart_GetError(result)); \
if (Dart_IsCompilationError(result)) { \
@@ -839,20 +796,17 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
Dart_ShutdownIsolate(); \
return NULL;
-
#define CHECK_RESULT(result) \
if (Dart_IsError(result)) { \
SAVE_ERROR_AND_EXIT(result); \
}
-
#define CHECK_RESULT_CLEANUP(result, cleanup) \
if (Dart_IsError(result)) { \
delete (cleanup); \
SAVE_ERROR_AND_EXIT(result); \
}
-
static void SnapshotOnExitHook(int64_t exit_code) {
if (Dart_CurrentIsolate() != main_isolate) {
Log::PrintErr(
@@ -866,7 +820,6 @@ static void SnapshotOnExitHook(int64_t exit_code) {
}
}
-
static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
bool is_main_isolate,
const char* script_uri,
@@ -972,7 +925,6 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
return isolate;
}
-
#if !defined(DART_PRECOMPILED_RUNTIME)
// Returns newly created Kernel Isolate on success, NULL on failure.
// For now we only support the kernel isolate coming up from an
@@ -1024,7 +976,6 @@ static Dart_Isolate CreateAndSetupKernelIsolate(const char* main,
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
-
// Returns newly created Service Isolate on success, NULL on failure.
// For now we only support the service isolate coming up from sources
// which are compiled by the VM parser.
@@ -1104,7 +1055,6 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
return isolate;
}
-
// Returns newly created Isolate on success, NULL on failure.
static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
const char* script_uri,
@@ -1193,7 +1143,6 @@ static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
#undef CHECK_RESULT
-
static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
const char* main,
const char* package_root,
@@ -1229,12 +1178,10 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
&exit_code);
}
-
static void PrintVersion() {
Log::PrintErr("Dart VM version: %s\n", Dart_VersionString());
}
-
// clang-format off
static void PrintUsage() {
Log::PrintErr(
@@ -1329,7 +1276,6 @@ static void PrintUsage() {
}
// clang-format on
-
char* BuildIsolateName(const char* script_name, const char* func_name) {
// Skip past any slashes in the script name.
const char* last_slash = strrchr(script_name, '/');
@@ -1345,23 +1291,19 @@ char* BuildIsolateName(const char* script_name, const char* func_name) {
return buffer;
}
-
static void OnIsolateShutdown(void* callback_data) {
IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
isolate_data->OnIsolateShutdown();
}
-
static void DeleteIsolateData(void* callback_data) {
IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
delete isolate_data;
}
-
static const char* kStdoutStreamId = "Stdout";
static const char* kStderrStreamId = "Stderr";
-
static bool ServiceStreamListenCallback(const char* stream_id) {
if (strcmp(stream_id, kStdoutStreamId) == 0) {
SetCaptureStdout(true);
@@ -1373,7 +1315,6 @@ static bool ServiceStreamListenCallback(const char* stream_id) {
return false;
}
-
static void ServiceStreamCancelCallback(const char* stream_id) {
if (strcmp(stream_id, kStdoutStreamId) == 0) {
SetCaptureStdout(false);
@@ -1382,7 +1323,6 @@ static void ServiceStreamCancelCallback(const char* stream_id) {
}
}
-
static bool FileModifiedCallback(const char* url, int64_t since) {
if (strncmp(url, "file:///", 8) == 0) {
// If it isn't a file on local disk, we don't know if it has been
@@ -1398,7 +1338,6 @@ static bool FileModifiedCallback(const char* url, int64_t since) {
return modified;
}
-
static void GenerateAppAOTSnapshot() {
if (use_blobs) {
Snapshot::GenerateAppAOTAsBlobs(snapshot_filename);
@@ -1407,7 +1346,6 @@ static void GenerateAppAOTSnapshot() {
}
}
-
#define CHECK_RESULT(result) \
if (Dart_IsError(result)) { \
const int exit_code = Dart_IsCompilationError(result) \
@@ -1416,7 +1354,6 @@ static void GenerateAppAOTSnapshot() {
ErrorExit(exit_code, "%s\n", Dart_GetError(result)); \
}
-
static void WriteFile(const char* filename,
const uint8_t* buffer,
const intptr_t size) {
@@ -1430,7 +1367,6 @@ static void WriteFile(const char* filename,
file->Release();
}
-
static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) {
File* file = File::Open(filename, File::kRead);
if (file == NULL) {
@@ -1444,7 +1380,6 @@ static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) {
file->Release();
}
-
bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
// Call CreateIsolateAndSetup which creates an isolate and loads up
// the specified application script.
@@ -1492,8 +1427,8 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
result = Dart_LibraryImportLibrary(isolate_data->builtin_lib(), root_lib,
Dart_Null());
if ((gen_snapshot_kind == kAppAOT) || (gen_snapshot_kind == kAppJIT)) {
- // Load the embedder's portion of the VM service's Dart code so it will
- // be included in the app snapshot.
+// Load the embedder's portion of the VM service's Dart code so it will
+// be included in the app snapshot.
#if defined(DART_PRECOMPILED_RUNTIME)
if (!VmService::LoadForGenPrecompiled(NULL)) {
#else
@@ -1699,13 +1634,11 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
#undef CHECK_RESULT
-
// Observatory assets are only needed in the regular dart binary.
#if !defined(DART_PRECOMPILER) && !defined(NO_OBSERVATORY)
extern unsigned int observatory_assets_archive_len;
extern const uint8_t* observatory_assets_archive;
-
// |input| is assumed to be a gzipped stream.
// This function allocates the output buffer in the C heap and the caller
// is responsible for freeing it.
@@ -1771,7 +1704,6 @@ void Decompress(const uint8_t* input,
inflateEnd(&strm);
}
-
Dart_Handle GetVMServiceAssetsArchiveCallback() {
uint8_t* decompressed = NULL;
unsigned int decompressed_len = 0;
@@ -1787,7 +1719,6 @@ Dart_Handle GetVMServiceAssetsArchiveCallback() {
static Dart_GetVMServiceAssetsArchive GetVMServiceAssetsArchiveCallback = NULL;
#endif // !defined(DART_PRECOMPILER)
-
void main(int argc, char** argv) {
char* script_name;
const int EXTRA_VM_ARGUMENTS = 8;
« no previous file with comments | « runtime/bin/lockers.h ('k') | runtime/bin/platform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698