Index: runtime/bin/main.cc |
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
index 7a1ef37f8fb338acb6840202c633925cb519926f..17e6234b05db499a0754cac7fc6038798a2ba73b 100644 |
--- a/runtime/bin/main.cc |
+++ b/runtime/bin/main.cc |
@@ -123,6 +123,9 @@ static bool parse_all = false; |
// of assembly/shared libraries for precompilation. |
static bool use_blobs = false; |
+// Global flag is used to indicate that we want to obfuscate identifiers. |
+static bool obfuscate = 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; |
@@ -378,6 +381,16 @@ static bool ProcessUseBlobsOption(const char* arg, |
return true; |
} |
+static bool ProcessObfuscateOption(const char* arg, |
+ CommandLineOptions* vm_options) { |
+ ASSERT(arg != NULL); |
+ if (*arg != '\0') { |
+ return false; |
+ } |
+ obfuscate = true; |
+ return true; |
+} |
+ |
static bool ProcessSnapshotFilenameOption(const char* filename, |
CommandLineOptions* vm_options) { |
snapshot_filename = filename; |
@@ -587,6 +600,7 @@ static struct { |
{"--snapshot-kind=", ProcessSnapshotKindOption}, |
{"--snapshot-depfile=", ProcessSnapshotDepsFilenameOption}, |
{"--use-blobs", ProcessUseBlobsOption}, |
+ {"--obfuscate", ProcessObfuscateOption}, |
{"--save-compilation-trace=", ProcessSaveCompilationTraceOption}, |
{"--load-compilation-trace=", ProcessLoadCompilationTraceOption}, |
{"--save-feedback=", ProcessSaveFeedbackOption}, |
@@ -1414,6 +1428,46 @@ static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) { |
file->Release(); |
} |
+static Dart_QualifiedFunctionName standalone_entry_points[] = { |
+ {"dart:_builtin", "::", "_getPrintClosure"}, |
+ {"dart:_builtin", "::", "_getUriBaseClosure"}, |
+ {"dart:_builtin", "::", "_libraryFilePath"}, |
+ {"dart:_builtin", "::", "_resolveInWorkingDirectory"}, |
+ {"dart:_builtin", "::", "_setPackageRoot"}, |
+ {"dart:_builtin", "::", "_setPackagesMap"}, |
+ {"dart:_builtin", "::", "_setWorkingDirectory"}, |
+ {"dart:async", "::", "_setScheduleImmediateClosure"}, |
+ {"dart:io", "::", "_getWatchSignalInternal"}, |
+ {"dart:io", "::", "_makeDatagram"}, |
+ {"dart:io", "::", "_makeUint8ListView"}, |
+ {"dart:io", "::", "_setupHooks"}, |
+ {"dart:io", "CertificateException", "CertificateException."}, |
+ {"dart:io", "Directory", "Directory."}, |
+ {"dart:io", "File", "File."}, |
+ {"dart:io", "FileSystemException", "FileSystemException."}, |
+ {"dart:io", "HandshakeException", "HandshakeException."}, |
+ {"dart:io", "Link", "Link."}, |
+ {"dart:io", "OSError", "OSError."}, |
+ {"dart:io", "TlsException", "TlsException."}, |
+ {"dart:io", "X509Certificate", "X509Certificate._"}, |
+ {"dart:io", "_ExternalBuffer", "get:end"}, |
+ {"dart:io", "_ExternalBuffer", "get:start"}, |
+ {"dart:io", "_ExternalBuffer", "set:data"}, |
+ {"dart:io", "_ExternalBuffer", "set:end"}, |
+ {"dart:io", "_ExternalBuffer", "set:start"}, |
+ {"dart:io", "_Platform", "set:_nativeScript"}, |
+ {"dart:io", "_ProcessStartStatus", "set:_errorCode"}, |
+ {"dart:io", "_ProcessStartStatus", "set:_errorMessage"}, |
+ {"dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE"}, |
+ {"dart:io", "_SecureFilterImpl", "get:SIZE"}, |
+ {"dart:io", "_SecureFilterImpl", "get:buffers"}, |
+ {"dart:isolate", "::", "_getIsolateScheduleImmediateClosure"}, |
+ {"dart:isolate", "::", "_setupHooks"}, |
+ {"dart:isolate", "::", "_startMainIsolate"}, |
+ {"dart:vmservice_io", "::", "main"}, |
+ {NULL, NULL, NULL} // Must be terminated with NULL entries. |
+}; |
+ |
bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { |
// Call CreateIsolateAndSetup which creates an isolate and loads up |
// the specified application script. |
@@ -1421,9 +1475,17 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { |
bool is_main_isolate = true; |
int exit_code = 0; |
char* isolate_name = BuildIsolateName(script_name, "main"); |
+ Dart_IsolateFlags flags; |
+ Dart_IsolateFlagsInitialize(&flags); |
+ |
+ if (gen_snapshot_kind == kAppAOT) { |
+ flags.obfuscate = obfuscate; |
+ flags.entry_points = standalone_entry_points; |
+ } |
+ |
Dart_Isolate isolate = CreateIsolateAndSetupHelper( |
is_main_isolate, script_name, "main", commandline_package_root, |
- commandline_packages_file, NULL, &error, &exit_code); |
+ commandline_packages_file, &flags, &error, &exit_code); |
if (isolate == NULL) { |
delete[] isolate_name; |
Log::PrintErr("%s\n", error); |
@@ -1497,46 +1559,6 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { |
} |
if (gen_snapshot_kind == kAppAOT) { |
- Dart_QualifiedFunctionName standalone_entry_points[] = { |
- {"dart:_builtin", "::", "_getPrintClosure"}, |
- {"dart:_builtin", "::", "_getUriBaseClosure"}, |
- {"dart:_builtin", "::", "_libraryFilePath"}, |
- {"dart:_builtin", "::", "_resolveInWorkingDirectory"}, |
- {"dart:_builtin", "::", "_setPackageRoot"}, |
- {"dart:_builtin", "::", "_setPackagesMap"}, |
- {"dart:_builtin", "::", "_setWorkingDirectory"}, |
- {"dart:async", "::", "_setScheduleImmediateClosure"}, |
- {"dart:io", "::", "_getWatchSignalInternal"}, |
- {"dart:io", "::", "_makeDatagram"}, |
- {"dart:io", "::", "_makeUint8ListView"}, |
- {"dart:io", "::", "_setupHooks"}, |
- {"dart:io", "CertificateException", "CertificateException."}, |
- {"dart:io", "Directory", "Directory."}, |
- {"dart:io", "File", "File."}, |
- {"dart:io", "FileSystemException", "FileSystemException."}, |
- {"dart:io", "HandshakeException", "HandshakeException."}, |
- {"dart:io", "Link", "Link."}, |
- {"dart:io", "OSError", "OSError."}, |
- {"dart:io", "TlsException", "TlsException."}, |
- {"dart:io", "X509Certificate", "X509Certificate._"}, |
- {"dart:io", "_ExternalBuffer", "get:end"}, |
- {"dart:io", "_ExternalBuffer", "get:start"}, |
- {"dart:io", "_ExternalBuffer", "set:data"}, |
- {"dart:io", "_ExternalBuffer", "set:end"}, |
- {"dart:io", "_ExternalBuffer", "set:start"}, |
- {"dart:io", "_Platform", "set:_nativeScript"}, |
- {"dart:io", "_ProcessStartStatus", "set:_errorCode"}, |
- {"dart:io", "_ProcessStartStatus", "set:_errorMessage"}, |
- {"dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE"}, |
- {"dart:io", "_SecureFilterImpl", "get:SIZE"}, |
- {"dart:io", "_SecureFilterImpl", "get:buffers"}, |
- {"dart:isolate", "::", "_getIsolateScheduleImmediateClosure"}, |
- {"dart:isolate", "::", "_setupHooks"}, |
- {"dart:isolate", "::", "_startMainIsolate"}, |
- {"dart:vmservice_io", "::", "main"}, |
- {NULL, NULL, NULL} // Must be terminated with NULL entries. |
- }; |
- |
uint8_t* feedback_buffer = NULL; |
intptr_t feedback_length = 0; |
if (load_feedback_filename != NULL) { |