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

Unified Diff: runtime/bin/gen_snapshot.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/filter_unsupported.cc ('k') | runtime/bin/hashmap_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index e815265deb62b0caa68c51500f1a7cb4f17346a4..2a7d3247eb75c0dd30fa5ecc24c838c3182481a1 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -25,9 +25,9 @@
#include "include/dart_api.h"
#include "include/dart_tools_api.h"
-#include "platform/hashmap.h"
#include "platform/globals.h"
#include "platform/growable_array.h"
+#include "platform/hashmap.h"
namespace dart {
namespace bin {
@@ -57,13 +57,11 @@ static const int kErrorExitCode = 255;
exit(exit_code); \
}
-
// The core snapshot to use when creating isolates. Normally NULL, but loaded
// from a file when creating script snapshots.
const uint8_t* isolate_snapshot_data = NULL;
const uint8_t* isolate_snapshot_instructions = NULL;
-
// Global state that indicates whether a snapshot is to be created and
// if so which file to write the snapshot into.
enum SnapshotKind {
@@ -84,7 +82,6 @@ static bool dependencies_only = false;
static bool print_dependencies = false;
static const char* dependencies_filename = NULL;
-
// Value of the --load-compilation-trace flag.
// (This pointer points into an argv buffer and does not need to be
// free'd.)
@@ -100,7 +97,6 @@ static const char* commandline_package_root = NULL;
// free'd.)
static const char* commandline_packages_file = NULL;
-
// Global state which contains a pointer to the script name for which
// a snapshot needs to be created (NULL would result in the creation
// of a generic snapshot that contains only the corelibs).
@@ -118,7 +114,6 @@ static bool IsValidFlag(const char* name,
(strncmp(name, prefix, prefix_length) == 0));
}
-
// The environment provided through the command line using -D options.
static dart::HashMap* environment = NULL;
@@ -171,7 +166,6 @@ static bool ProcessEnvironmentOption(const char* arg) {
return true;
}
-
static Dart_Handle EnvironmentCallback(Dart_Handle name) {
uint8_t* utf8_array;
intptr_t utf8_len;
@@ -202,7 +196,6 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
return result;
}
-
static const char* ProcessOption(const char* option, const char* name) {
const intptr_t length = strlen(name);
if (strncmp(option, name, length) == 0) {
@@ -211,7 +204,6 @@ static const char* ProcessOption(const char* option, const char* name) {
return NULL;
}
-
static bool ProcessSnapshotKindOption(const char* option) {
const char* kind = ProcessOption(option, "--snapshot_kind=");
if (kind == NULL) {
@@ -243,7 +235,6 @@ static bool ProcessSnapshotKindOption(const char* option) {
return false;
}
-
static bool ProcessVmSnapshotDataOption(const char* option) {
const char* name = ProcessOption(option, "--vm_snapshot_data=");
if (name == NULL) {
@@ -256,7 +247,6 @@ static bool ProcessVmSnapshotDataOption(const char* option) {
return false;
}
-
static bool ProcessVmSnapshotInstructionsOption(const char* option) {
const char* name = ProcessOption(option, "--vm_snapshot_instructions=");
if (name == NULL) {
@@ -269,7 +259,6 @@ static bool ProcessVmSnapshotInstructionsOption(const char* option) {
return false;
}
-
static bool ProcessIsolateSnapshotDataOption(const char* option) {
const char* name = ProcessOption(option, "--isolate_snapshot_data=");
if (name == NULL) {
@@ -282,7 +271,6 @@ static bool ProcessIsolateSnapshotDataOption(const char* option) {
return false;
}
-
static bool ProcessIsolateSnapshotInstructionsOption(const char* option) {
const char* name = ProcessOption(option, "--isolate_snapshot_instructions=");
if (name == NULL) {
@@ -295,7 +283,6 @@ static bool ProcessIsolateSnapshotInstructionsOption(const char* option) {
return false;
}
-
static bool ProcessAssemblyOption(const char* option) {
const char* name = ProcessOption(option, "--assembly=");
if (name != NULL) {
@@ -305,7 +292,6 @@ static bool ProcessAssemblyOption(const char* option) {
return false;
}
-
static bool ProcessScriptSnapshotOption(const char* option) {
const char* name = ProcessOption(option, "--script_snapshot=");
if (name == NULL) {
@@ -318,7 +304,6 @@ static bool ProcessScriptSnapshotOption(const char* option) {
return false;
}
-
static bool ProcessDependenciesOption(const char* option) {
const char* name = ProcessOption(option, "--dependencies=");
if (name != NULL) {
@@ -328,7 +313,6 @@ static bool ProcessDependenciesOption(const char* option) {
return false;
}
-
static bool ProcessDependenciesOnlyOption(const char* option) {
const char* name = ProcessOption(option, "--dependencies_only");
if (name == NULL) {
@@ -365,7 +349,6 @@ static bool ProcessEmbedderEntryPointsManifestOption(const char* option) {
return false;
}
-
static bool ProcessLoadCompilationTraceOption(const char* option) {
const char* name = ProcessOption(option, "--load_compilation_trace=");
if (name == NULL) {
@@ -378,7 +361,6 @@ static bool ProcessLoadCompilationTraceOption(const char* option) {
return false;
}
-
static bool ProcessPackageRootOption(const char* option) {
const char* name = ProcessOption(option, "--package_root=");
if (name == NULL) {
@@ -391,7 +373,6 @@ static bool ProcessPackageRootOption(const char* option) {
return false;
}
-
static bool ProcessPackagesOption(const char* option) {
const char* name = ProcessOption(option, "--packages=");
if (name != NULL) {
@@ -401,7 +382,6 @@ static bool ProcessPackagesOption(const char* option) {
return false;
}
-
static bool ProcessURLmappingOption(const char* option) {
const char* mapping = ProcessOption(option, "--url_mapping=");
if (mapping == NULL) {
@@ -414,12 +394,10 @@ static bool ProcessURLmappingOption(const char* option) {
return false;
}
-
static bool IsSnapshottingForPrecompilation() {
return (snapshot_kind == kAppAOTBlobs) || (snapshot_kind == kAppAOTAssembly);
}
-
// Parse out the command line arguments. Returns -1 if the arguments
// are incorrect, 0 otherwise.
static int ParseArguments(int argc,
@@ -545,7 +523,6 @@ static int ParseArguments(int argc,
return 0;
}
-
static void WriteFile(const char* filename,
const uint8_t* buffer,
const intptr_t size) {
@@ -565,7 +542,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) {
@@ -585,7 +561,6 @@ static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) {
file->Release();
}
-
class UriResolverIsolateScope {
public:
UriResolverIsolateScope() {
@@ -611,10 +586,8 @@ class UriResolverIsolateScope {
DISALLOW_COPY_AND_ASSIGN(UriResolverIsolateScope);
};
-
Dart_Isolate UriResolverIsolateScope::isolate = NULL;
-
static void AddDependency(const char* uri_string) {
IsolateData* isolate_data =
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
@@ -624,7 +597,6 @@ static void AddDependency(const char* uri_string) {
}
}
-
static Dart_Handle LoadUrlContents(const char* uri_string) {
bool failed = false;
char* error_string = NULL;
@@ -656,7 +628,6 @@ static Dart_Handle LoadUrlContents(const char* uri_string) {
return result;
}
-
static Dart_Handle ResolveUriInWorkingDirectory(const char* script_uri) {
bool failed = false;
char* result_string = NULL;
@@ -682,7 +653,6 @@ static Dart_Handle ResolveUriInWorkingDirectory(const char* script_uri) {
return result;
}
-
static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
// First resolve the specified script uri with respect to the original
// working directory.
@@ -704,7 +674,6 @@ static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
}
}
-
static Builtin::BuiltinLibraryId BuiltinId(const char* url) {
if (DartUtils::IsDartBuiltinLibURL(url)) {
return Builtin::kBuiltinLibrary;
@@ -715,7 +684,6 @@ static Builtin::BuiltinLibraryId BuiltinId(const char* url) {
return Builtin::kInvalidLibrary;
}
-
// Generates a depfile like gcc -M -MF. Must be consumable by Ninja.
class DependenciesFileWriter : public ValueObject {
public:
@@ -816,7 +784,6 @@ class DependenciesFileWriter : public ValueObject {
bool success_;
};
-
static void CreateAndWriteDependenciesFile() {
IsolateData* isolate_data =
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
@@ -861,7 +828,6 @@ static void CreateAndWriteDependenciesFile() {
isolate_data->set_dependencies(NULL);
}
-
static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
Dart_Handle library,
Dart_Handle url) {
@@ -940,7 +906,6 @@ static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
}
}
-
static Dart_Handle LoadGenericSnapshotCreationScript(
Builtin::BuiltinLibraryId id) {
Dart_Handle source = Builtin::Source(id);
@@ -955,7 +920,6 @@ static Dart_Handle LoadGenericSnapshotCreationScript(
return lib;
}
-
// clang-format off
static void PrintUsage() {
Log::PrintErr(
@@ -1030,29 +994,24 @@ static void PrintUsage() {
}
// clang-format on
-
static const char StubNativeFunctionName[] = "StubNativeFunction";
-
void StubNativeFunction(Dart_NativeArguments arguments) {
// This is a stub function for the resolver
Dart_SetReturnValue(
arguments, Dart_NewApiError("<EMBEDDER DID NOT SETUP NATIVE RESOLVER>"));
}
-
static Dart_NativeFunction StubNativeLookup(Dart_Handle name,
int argument_count,
bool* auto_setup_scope) {
return &StubNativeFunction;
}
-
static const uint8_t* StubNativeSymbol(Dart_NativeFunction nf) {
return reinterpret_cast<const uint8_t*>(StubNativeFunctionName);
}
-
static void SetupStubNativeResolver(size_t lib_index,
const Dart_QualifiedFunctionName* entry) {
// TODO(24686): Remove this.
@@ -1087,7 +1046,6 @@ static void SetupStubNativeResolver(size_t lib_index,
DART_CHECK_VALID(result);
}
-
// Iterate over all libraries and setup the stub native lookup. This must be
// run after |SetupStubNativeResolversForPrecompilation| because the former
// loads some libraries.
@@ -1108,7 +1066,6 @@ static void SetupStubNativeResolvers() {
}
}
-
static void ImportNativeEntryPointLibrariesIntoRoot(
const Dart_QualifiedFunctionName* entries) {
if (entries == NULL) {
@@ -1131,7 +1088,6 @@ static void ImportNativeEntryPointLibrariesIntoRoot(
}
}
-
static void SetupStubNativeResolversForPrecompilation(
const Dart_QualifiedFunctionName* entries) {
if (entries == NULL) {
@@ -1151,7 +1107,6 @@ static void SetupStubNativeResolversForPrecompilation(
}
}
-
static void CleanupEntryPointItem(const Dart_QualifiedFunctionName* entry) {
if (entry == NULL) {
return;
@@ -1164,7 +1119,6 @@ static void CleanupEntryPointItem(const Dart_QualifiedFunctionName* entry) {
free(const_cast<char*>(entry->function_name));
}
-
static void CleanupEntryPointsCollection(Dart_QualifiedFunctionName* entries) {
if (entries == NULL) {
return;
@@ -1181,7 +1135,6 @@ static void CleanupEntryPointsCollection(Dart_QualifiedFunctionName* entries) {
free(entries);
}
-
char* ParserErrorStringCreate(const char* format, ...) {
static const size_t kErrorBufferSize = 256;
@@ -1196,7 +1149,6 @@ char* ParserErrorStringCreate(const char* format, ...) {
return error_buffer;
}
-
const char* ParseEntryNameForIndex(uint8_t index) {
switch (index) {
case 0:
@@ -1211,7 +1163,6 @@ const char* ParseEntryNameForIndex(uint8_t index) {
return NULL;
}
-
static bool ParseEntryPointsManifestSingleLine(
const char* line,
Dart_QualifiedFunctionName* entry,
@@ -1267,7 +1218,6 @@ static bool ParseEntryPointsManifestSingleLine(
return success;
}
-
int64_t ParseEntryPointsManifestLines(FILE* file,
Dart_QualifiedFunctionName* collection) {
int64_t entries = 0;
@@ -1311,7 +1261,6 @@ int64_t ParseEntryPointsManifestLines(FILE* file,
return entries;
}
-
static Dart_QualifiedFunctionName* ParseEntryPointsManifestFiles() {
// Total number of entries across all manifest files.
int64_t entry_count = 0;
@@ -1363,7 +1312,6 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestFiles() {
return entries;
}
-
static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
Dart_QualifiedFunctionName* entries = ParseEntryPointsManifestFiles();
if ((entries == NULL) && IsSnapshottingForPrecompilation()) {
@@ -1374,7 +1322,6 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
return entries;
}
-
static void LoadCompilationTrace() {
if ((load_compilation_trace_filename != NULL) &&
(snapshot_kind == kCoreJIT)) {
@@ -1386,7 +1333,6 @@ static void LoadCompilationTrace() {
}
}
-
static void CreateAndWriteCoreSnapshot() {
ASSERT(snapshot_kind == kCore);
ASSERT(vm_snapshot_data_filename != NULL);
@@ -1418,7 +1364,6 @@ static void CreateAndWriteCoreSnapshot() {
}
}
-
static void CreateAndWriteCoreJITSnapshot() {
ASSERT(snapshot_kind == kCoreJIT);
ASSERT(vm_snapshot_data_filename != NULL);
@@ -1458,7 +1403,6 @@ static void CreateAndWriteCoreJITSnapshot() {
isolate_snapshot_instructions_size);
}
-
static void CreateAndWriteScriptSnapshot() {
ASSERT(snapshot_kind == kScript);
ASSERT(script_snapshot_filename != NULL);
@@ -1473,7 +1417,6 @@ static void CreateAndWriteScriptSnapshot() {
WriteFile(script_snapshot_filename, buffer, size);
}
-
static void CreateAndWritePrecompiledSnapshot(
Dart_QualifiedFunctionName* standalone_entry_points) {
ASSERT(IsSnapshottingForPrecompilation());
@@ -1526,7 +1469,6 @@ static void CreateAndWritePrecompiledSnapshot(
}
}
-
static void SetupForUriResolution() {
// Set up the library tag handler for this isolate.
Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
@@ -1542,7 +1484,6 @@ static void SetupForUriResolution() {
CHECK_RESULT(library);
}
-
static void SetupForGenericSnapshotCreation() {
SetupForUriResolution();
@@ -1558,7 +1499,6 @@ static void SetupForGenericSnapshotCreation() {
}
}
-
static Dart_Isolate CreateServiceIsolate(const char* script_uri,
const char* main,
const char* package_root,
@@ -1605,7 +1545,6 @@ static Dart_Isolate CreateServiceIsolate(const char* script_uri,
return isolate;
}
-
static MappedMemory* MapFile(const char* filename,
File::MapType type,
const uint8_t** buffer) {
@@ -1630,7 +1569,6 @@ static MappedMemory* MapFile(const char* filename,
return mapping;
}
-
int main(int argc, char** argv) {
const int EXTRA_VM_ARGUMENTS = 2;
CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
« no previous file with comments | « runtime/bin/filter_unsupported.cc ('k') | runtime/bin/hashmap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698