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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 2480793002: clang-format runtime/bin (Closed)
Patch Set: Created 4 years, 1 month 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 05452ae26dffa59dbc800927030c40596ac31866..17acc09fcd58da6d6c0b6ad2c5f1da1933aa995e 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -140,8 +140,8 @@ static bool ProcessEnvironmentOption(const char* arg) {
name[name_len] = '\0';
value = strdup(equals_pos + 1);
}
- HashMap::Entry* entry = environment->Lookup(
- GetHashmapKeyFromString(name), HashMap::StringHash(name), true);
+ HashMap::Entry* entry = environment->Lookup(GetHashmapKeyFromString(name),
+ HashMap::StringHash(name), true);
ASSERT(entry != NULL); // Lookup adds an entry if key not found.
entry->value = value;
return true;
@@ -162,10 +162,9 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
name_chars[utf8_len] = '\0';
const char* value = NULL;
if (environment != NULL) {
- HashMap::Entry* entry = environment->Lookup(
- GetHashmapKeyFromString(name_chars),
- HashMap::StringHash(name_chars),
- false);
+ HashMap::Entry* entry =
+ environment->Lookup(GetHashmapKeyFromString(name_chars),
+ HashMap::StringHash(name_chars), false);
if (entry != NULL) {
value = reinterpret_cast<char*>(entry->value);
}
@@ -180,7 +179,6 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
}
-
static const char* ProcessOption(const char* option, const char* name) {
const intptr_t length = strlen(name);
if (strncmp(option, name, length) == 0) {
@@ -311,10 +309,8 @@ static int ParseArguments(int argc,
ProcessInstructionsBlobOption(argv[i]) ||
ProcessRodataBlobOption(argv[i]) ||
ProcessEmbedderEntryPointsManifestOption(argv[i]) ||
- ProcessURLmappingOption(argv[i]) ||
- ProcessPackageRootOption(argv[i]) ||
- ProcessPackagesOption(argv[i]) ||
- ProcessEnvironmentOption(argv[i])) {
+ ProcessURLmappingOption(argv[i]) || ProcessPackageRootOption(argv[i]) ||
+ ProcessPackagesOption(argv[i]) || ProcessEnvironmentOption(argv[i])) {
i += 1;
continue;
}
@@ -333,8 +329,9 @@ static int ParseArguments(int argc,
// Verify consistency of arguments.
if ((commandline_package_root != NULL) &&
(commandline_packages_file != NULL)) {
- Log::PrintErr("Specifying both a packages directory and a packages "
- "file is invalid.\n");
+ Log::PrintErr(
+ "Specifying both a packages directory and a packages "
+ "file is invalid.\n");
return -1;
}
@@ -349,25 +346,24 @@ static int ParseArguments(int argc,
}
bool precompiled_as_assembly = assembly_filename != NULL;
- bool precompiled_as_blobs = (instructions_blob_filename != NULL) ||
- (rodata_blob_filename != NULL);
+ bool precompiled_as_blobs =
+ (instructions_blob_filename != NULL) || (rodata_blob_filename != NULL);
if (precompiled_as_assembly && precompiled_as_blobs) {
Log::PrintErr(
- "Cannot request a precompiled snapshot simultaneously as "
- "assembly (--assembly=<output.file>) and as blobs "
- "(--instructions-blob=<output.file> and "
- "--rodata-blob=<output.file>)\n\n");
+ "Cannot request a precompiled snapshot simultaneously as "
+ "assembly (--assembly=<output.file>) and as blobs "
+ "(--instructions-blob=<output.file> and "
+ "--rodata-blob=<output.file>)\n\n");
return -1;
}
if ((instructions_blob_filename != NULL) != (rodata_blob_filename != NULL)) {
Log::PrintErr(
- "Requesting a precompiled snapshot as blobs requires both "
- "(--instructions-blob=<output.file> and "
- "--rodata-blob=<output.file>)\n\n");
+ "Requesting a precompiled snapshot as blobs requires both "
+ "(--instructions-blob=<output.file> and "
+ "--rodata-blob=<output.file>)\n\n");
return -1;
}
- if (IsSnapshottingForPrecompilation() &&
- (entry_points_files->count() == 0)) {
+ if (IsSnapshottingForPrecompilation() && (entry_points_files->count() == 0)) {
Log::PrintErr(
"Specifying an instructions snapshot filename indicates precompilation"
". But no embedder entry points manifest was specified.\n\n");
@@ -434,9 +430,8 @@ static Dart_Handle LoadUrlContents(const char* uri_string) {
UriResolverIsolateScope scope;
Dart_Handle resolved_uri = Dart_NewStringFromCString(uri_string);
- Dart_Handle result = Loader::LoadUrlContents(resolved_uri,
- &payload,
- &payload_length);
+ Dart_Handle result =
+ Loader::LoadUrlContents(resolved_uri, &payload, &payload_length);
if (Dart_IsError(result)) {
failed = true;
result_string = strdup(Dart_GetError(result));
@@ -475,8 +470,8 @@ static Dart_Handle ResolveUriInWorkingDirectory(const char* script_uri) {
}
}
- Dart_Handle result = failed ? Dart_NewApiError(result_string) :
- DartUtils::NewString(result_string);
+ Dart_Handle result = failed ? Dart_NewApiError(result_string)
+ : DartUtils::NewString(result_string);
free(result_string);
return result;
}
@@ -491,7 +486,7 @@ static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
}
// Now load the contents of the specified uri.
const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri);
- Dart_Handle source = LoadUrlContents(resolved_uri_string);
+ Dart_Handle source = LoadUrlContents(resolved_uri_string);
if (Dart_IsError(source)) {
return source;
@@ -526,8 +521,8 @@ static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
return Dart_NewApiError("accessing library url failed");
}
const char* library_url_string = DartUtils::GetStringValue(library_url);
- const char* mapped_library_url_string = DartUtils::MapLibraryUrl(
- library_url_string);
+ const char* mapped_library_url_string =
+ DartUtils::MapLibraryUrl(library_url_string);
if (mapped_library_url_string != NULL) {
library_url = ResolveUriInWorkingDirectory(mapped_library_url_string);
library_url_string = DartUtils::GetStringValue(library_url);
@@ -565,7 +560,8 @@ static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
// Special case for parting sources of a builtin library.
if (tag == Dart_kSourceTag) {
return Dart_LoadSource(library, url, Dart_Null(),
- Builtin::PartSource(libraryBuiltinId, url_string), 0, 0);
+ Builtin::PartSource(libraryBuiltinId, url_string),
+ 0, 0);
}
ASSERT(tag == Dart_kImportTag);
return DartUtils::NewError("Unable to import '%s' ", url_string);
@@ -580,7 +576,7 @@ static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
}
}
const char* resolved_uri_string = DartUtils::GetStringValue(resolved_url);
- Dart_Handle source = LoadUrlContents(resolved_uri_string);
+ Dart_Handle source = LoadUrlContents(resolved_uri_string);
if (Dart_IsError(source)) {
return source;
}
@@ -608,6 +604,7 @@ static Dart_Handle LoadGenericSnapshotCreationScript(
}
+// clang-format off
static void PrintUsage() {
Log::PrintErr(
"Usage: \n"
@@ -669,6 +666,7 @@ static void PrintUsage() {
" points into Dart code from the C API. \n"
"\n");
}
+// clang-format on
static void VerifyLoaded(Dart_Handle library) {
@@ -698,7 +696,7 @@ static Dart_NativeFunction StubNativeLookup(Dart_Handle name,
static const uint8_t* StubNativeSymbol(Dart_NativeFunction nf) {
- return reinterpret_cast<const uint8_t *>(StubNativeFunctionName);
+ return reinterpret_cast<const uint8_t*>(StubNativeFunctionName);
}
@@ -715,20 +713,15 @@ static void SetupStubNativeResolver(size_t lib_index,
static const uint32_t kLoadBufferMaxSize = 128;
char* load_buffer =
reinterpret_cast<char*>(calloc(kLoadBufferMaxSize, sizeof(char)));
- snprintf(load_buffer,
- kLoadBufferMaxSize,
- "import '%s';",
+ snprintf(load_buffer, kLoadBufferMaxSize, "import '%s';",
DartUtils::GetStringValue(library_string));
Dart_Handle script_handle = Dart_NewStringFromCString(load_buffer);
memset(load_buffer, 0, kLoadBufferMaxSize);
- snprintf(load_buffer,
- kLoadBufferMaxSize,
- "dart:_snapshot_%zu",
- lib_index);
+ snprintf(load_buffer, kLoadBufferMaxSize, "dart:_snapshot_%zu", lib_index);
Dart_Handle script_url = Dart_NewStringFromCString(load_buffer);
free(load_buffer);
- Dart_Handle loaded = Dart_LoadLibrary(script_url, Dart_Null(),
- script_handle, 0, 0);
+ Dart_Handle loaded =
+ Dart_LoadLibrary(script_url, Dart_Null(), script_handle, 0, 0);
DART_CHECK_VALID(loaded);
// Do a fresh lookup
@@ -736,9 +729,8 @@ static void SetupStubNativeResolver(size_t lib_index,
}
DART_CHECK_VALID(library);
- Dart_Handle result = Dart_SetNativeResolver(library,
- &StubNativeLookup,
- &StubNativeSymbol);
+ Dart_Handle result =
+ Dart_SetNativeResolver(library, &StubNativeLookup, &StubNativeSymbol);
DART_CHECK_VALID(result);
}
@@ -768,7 +760,6 @@ static void ImportNativeEntryPointLibrariesIntoRoot(
static void SetupStubNativeResolversForPrecompilation(
const Dart_QualifiedFunctionName* entries) {
-
if (entries == NULL) {
return;
}
@@ -787,7 +778,7 @@ static void SetupStubNativeResolversForPrecompilation(
}
-static void CleanupEntryPointItem(const Dart_QualifiedFunctionName *entry) {
+static void CleanupEntryPointItem(const Dart_QualifiedFunctionName* entry) {
if (entry == NULL) {
return;
}
@@ -848,7 +839,9 @@ const char* ParseEntryNameForIndex(uint8_t index) {
static bool ParseEntryPointsManifestSingleLine(
- const char* line, Dart_QualifiedFunctionName* entry, char** error) {
+ const char* line,
+ Dart_QualifiedFunctionName* entry,
+ char** error) {
bool success = true;
size_t offset = 0;
for (uint8_t i = 0; i < 3; i++) {
@@ -1017,20 +1010,15 @@ static void CreateAndWriteSnapshot() {
intptr_t isolate_size = 0;
// First create a snapshot.
- result = Dart_CreateSnapshot(&vm_isolate_buffer,
- &vm_isolate_size,
- &isolate_buffer,
- &isolate_size);
+ result = Dart_CreateSnapshot(&vm_isolate_buffer, &vm_isolate_size,
+ &isolate_buffer, &isolate_size);
CHECK_RESULT(result);
// Now write the vm isolate and isolate snapshots out to the
// specified file and exit.
- WriteSnapshotFile(vm_isolate_snapshot_filename,
- vm_isolate_buffer,
+ WriteSnapshotFile(vm_isolate_snapshot_filename, vm_isolate_buffer,
vm_isolate_size);
- WriteSnapshotFile(isolate_snapshot_filename,
- isolate_buffer,
- isolate_size);
+ WriteSnapshotFile(isolate_snapshot_filename, isolate_buffer, isolate_size);
Dart_ExitScope();
// Shutdown the isolate.
@@ -1055,9 +1043,7 @@ static void CreateAndWritePrecompiledSnapshot(
result = Dart_CreatePrecompiledSnapshotAssembly(&assembly_buffer,
&assembly_size);
CHECK_RESULT(result);
- WriteSnapshotFile(assembly_filename,
- assembly_buffer,
- assembly_size);
+ WriteSnapshotFile(assembly_filename, assembly_buffer, assembly_size);
} else {
uint8_t* vm_isolate_buffer = NULL;
intptr_t vm_isolate_size = 0;
@@ -1067,26 +1053,17 @@ static void CreateAndWritePrecompiledSnapshot(
intptr_t instructions_blob_size = 0;
uint8_t* rodata_blob_buffer = NULL;
intptr_t rodata_blob_size = 0;
- result = Dart_CreatePrecompiledSnapshotBlob(&vm_isolate_buffer,
- &vm_isolate_size,
- &isolate_buffer,
- &isolate_size,
- &instructions_blob_buffer,
- &instructions_blob_size,
- &rodata_blob_buffer,
- &rodata_blob_size);
+ result = Dart_CreatePrecompiledSnapshotBlob(
+ &vm_isolate_buffer, &vm_isolate_size, &isolate_buffer, &isolate_size,
+ &instructions_blob_buffer, &instructions_blob_size, &rodata_blob_buffer,
+ &rodata_blob_size);
CHECK_RESULT(result);
- WriteSnapshotFile(vm_isolate_snapshot_filename,
- vm_isolate_buffer,
+ WriteSnapshotFile(vm_isolate_snapshot_filename, vm_isolate_buffer,
vm_isolate_size);
- WriteSnapshotFile(isolate_snapshot_filename,
- isolate_buffer,
- isolate_size);
- WriteSnapshotFile(instructions_blob_filename,
- instructions_blob_buffer,
+ WriteSnapshotFile(isolate_snapshot_filename, isolate_buffer, isolate_size);
+ WriteSnapshotFile(instructions_blob_filename, instructions_blob_buffer,
instructions_blob_size);
- WriteSnapshotFile(rodata_blob_filename,
- rodata_blob_buffer,
+ WriteSnapshotFile(rodata_blob_filename, rodata_blob_buffer,
rodata_blob_size);
}
@@ -1136,16 +1113,11 @@ static Dart_Isolate CreateServiceIsolate(const char* script_uri,
Dart_IsolateFlags* flags,
void* data,
char** error) {
- IsolateData* isolate_data = new IsolateData(script_uri,
- package_root,
- package_config);
+ IsolateData* isolate_data =
+ new IsolateData(script_uri, package_root, package_config);
Dart_Isolate isolate = NULL;
- isolate = Dart_CreateIsolate(script_uri,
- main,
- NULL,
- NULL,
- isolate_data,
- error);
+ isolate =
+ Dart_CreateIsolate(script_uri, main, NULL, NULL, isolate_data, error);
if (isolate == NULL) {
Log::PrintErr("Error: Could not create service isolate");
@@ -1168,9 +1140,7 @@ static Dart_Isolate CreateServiceIsolate(const char* script_uri,
CHECK_RESULT(result);
ASSERT(Dart_IsServiceIsolate(isolate));
// Load embedder specific bits and return. Will not start http server.
- if (!VmService::Setup("127.0.0.1",
- -1,
- false /* running_precompiled */,
+ if (!VmService::Setup("127.0.0.1", -1, false /* running_precompiled */,
false /* server dev mode */)) {
*error = strdup(VmService::GetErrorMessage());
return NULL;
@@ -1194,10 +1164,7 @@ int main(int argc, char** argv) {
entry_points_files = &entry_points_files_array;
// Parse command line arguments.
- if (ParseArguments(argc,
- argv,
- &vm_options,
- &app_script_name) < 0) {
+ if (ParseArguments(argc, argv, &vm_options, &app_script_name) < 0) {
PrintUsage();
return 255;
}
@@ -1249,11 +1216,10 @@ int main(int argc, char** argv) {
return 255;
}
- IsolateData* isolate_data = new IsolateData(NULL,
- commandline_package_root,
+ IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
commandline_packages_file);
- Dart_Isolate isolate = Dart_CreateIsolate(
- NULL, NULL, NULL, NULL, isolate_data, &error);
+ Dart_Isolate isolate =
+ Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
if (isolate == NULL) {
Log::PrintErr("Error: %s", error);
free(error);
@@ -1300,8 +1266,8 @@ int main(int argc, char** argv) {
// Now we create an isolate into which we load all the code that needs to
// be in the snapshot.
isolate_data = new IsolateData(NULL, NULL, NULL);
- if (Dart_CreateIsolate(
- NULL, NULL, NULL, NULL, isolate_data, &error) == NULL) {
+ if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error) ==
+ NULL) {
fprintf(stderr, "%s", error);
free(error);
exit(255);
« 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