OSDN Git Service

Change Ti::Agent collection from vector to List
authorAlex Light <allight@google.com>
Wed, 29 Mar 2017 17:40:15 +0000 (10:40 -0700)
committerAlex Light <allight@google.com>
Wed, 29 Mar 2017 17:40:15 +0000 (10:40 -0700)
We want these to be in a list to avoid the need for moving them
around, which would introduce the need to perform annoying accounting.

Test: ./test.py --host -j40
Bug: 36716572
Bug: 31455788
Change-Id: Ie16523f4e7d79934fa7844fb9b9a26e125cfa9eb

cmdline/cmdline_types.h
runtime/parsed_options.cc
runtime/runtime.h
runtime/runtime_options.def
test/900-hello-plugin/expected.txt
test/900-hello-plugin/load_unload.cc
test/900-hello-plugin/run

index 71c4e95..cd19fa4 100644 (file)
@@ -401,19 +401,19 @@ struct CmdlineType<std::vector<Plugin>> : CmdlineTypeParser<std::vector<Plugin>>
 };
 
 template <>
-struct CmdlineType<std::vector<ti::Agent>> : CmdlineTypeParser<std::vector<ti::Agent>> {
+struct CmdlineType<std::list<ti::Agent>> : CmdlineTypeParser<std::list<ti::Agent>> {
   Result Parse(const std::string& args) {
-    assert(false && "Use AppendValues() for an Agent vector type");
-    return Result::Failure("Unconditional failure: Agent vector must be appended: " + args);
+    assert(false && "Use AppendValues() for an Agent list type");
+    return Result::Failure("Unconditional failure: Agent list must be appended: " + args);
   }
 
   Result ParseAndAppend(const std::string& args,
-                        std::vector<ti::Agent>& existing_value) {
+                        std::list<ti::Agent>& existing_value) {
     existing_value.emplace_back(args);
     return Result::SuccessNoValue();
   }
 
-  static const char* Name() { return "std::vector<ti::Agent>"; }
+  static const char* Name() { return "std::list<ti::Agent>"; }
 };
 
 template <>
index 4d787db..0784e59 100644 (file)
@@ -96,7 +96,7 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize
       //     .WithType<std::vector<ti::Agent>>().AppendValues()
       //     .IntoKey(M::AgentLib)
       .Define("-agentpath:_")
-          .WithType<std::vector<ti::Agent>>().AppendValues()
+          .WithType<std::list<ti::Agent>>().AppendValues()
           .IntoKey(M::AgentPath)
       .Define("-Xms_")
           .WithType<MemoryKiB>()
index d244a9b..92feabb 100644 (file)
@@ -733,7 +733,7 @@ class Runtime {
   std::string class_path_string_;
   std::vector<std::string> properties_;
 
-  std::vector<ti::Agent> agents_;
+  std::list<ti::Agent> agents_;
   std::vector<Plugin> plugins_;
 
   // The default stack size for managed threads created by the runtime.
index e68a1b2..16190cd 100644 (file)
@@ -120,8 +120,8 @@ RUNTIME_OPTIONS_KEY (Unit,                NoDexFileFallback)
 RUNTIME_OPTIONS_KEY (std::string,         CpuAbiList)
 RUNTIME_OPTIONS_KEY (std::string,         Fingerprint)
 RUNTIME_OPTIONS_KEY (ExperimentalFlags,   Experimental,     ExperimentalFlags::kNone) // -Xexperimental:{...}
-RUNTIME_OPTIONS_KEY (std::vector<ti::Agent>,         AgentLib)  // -agentlib:<libname>=<options>
-RUNTIME_OPTIONS_KEY (std::vector<ti::Agent>,         AgentPath)  // -agentpath:<libname>=<options>
+RUNTIME_OPTIONS_KEY (std::list<ti::Agent>,         AgentLib)  // -agentlib:<libname>=<options>
+RUNTIME_OPTIONS_KEY (std::list<ti::Agent>,         AgentPath)  // -agentpath:<libname>=<options>
 RUNTIME_OPTIONS_KEY (std::vector<Plugin>,            Plugins)  // -Xplugin:<library>
 
 // Not parse-able from command line, but can be provided explicitly.
index 43db31c..c160f65 100644 (file)
@@ -3,6 +3,8 @@ Agent_OnLoad called with options "test_900"
 GetEnvHandler called in test 900
 GetEnvHandler called with version 0x900fffff
 GetEnv returned '900' environment!
+Agent_OnLoad called with options "test_900_round_2"
 Hello, world!
 Agent_OnUnload called
+Agent_OnUnload called
 ArtPlugin_Deinitialize called in test 900
index a38cc3d..290997a 100644 (file)
@@ -52,6 +52,9 @@ extern "C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm,
                                                char* options,
                                                void* reserved ATTRIBUTE_UNUSED) {
   printf("Agent_OnLoad called with options \"%s\"\n", options);
+  if (strcmp("test_900_round_2", options) == 0) {
+    return 0;
+  }
   uintptr_t env = 0;
   jint res = vm->GetEnv(reinterpret_cast<void**>(&env), TEST_900_ENV_VERSION_NUMBER);
   if (res != JNI_OK) {
index 50835f8..c633f6d 100755 (executable)
@@ -19,4 +19,5 @@ if  [[ "$@" == *"-O"* ]]; then
   plugin=libartagent.so
 fi
 ./default-run "$@" --runtime-option -agentpath:${plugin}=test_900 \
+                   --runtime-option -agentpath:${plugin}=test_900_round_2 \
                    --android-runtime-option -Xplugin:${plugin}