| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_VM_BENCHMARK_TEST_H_ | 5 #ifndef RUNTIME_VM_BENCHMARK_TEST_H_ |
| 6 #define RUNTIME_VM_BENCHMARK_TEST_H_ | 6 #define RUNTIME_VM_BENCHMARK_TEST_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| 11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 12 #include "vm/heap.h" | 12 #include "vm/heap.h" |
| 13 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
| 14 #include "vm/malloc_hooks.h" | |
| 15 #include "vm/object.h" | 14 #include "vm/object.h" |
| 16 #include "vm/zone.h" | 15 #include "vm/zone.h" |
| 17 | 16 |
| 18 namespace dart { | 17 namespace dart { |
| 19 | 18 |
| 20 DECLARE_FLAG(int, code_heap_size); | 19 DECLARE_FLAG(int, code_heap_size); |
| 21 DECLARE_FLAG(int, old_gen_growth_space_ratio); | 20 DECLARE_FLAG(int, old_gen_growth_space_ratio); |
| 22 | 21 |
| 23 namespace bin { | 22 namespace bin { |
| 24 // Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. | 23 // Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. |
| 25 extern const uint8_t* vm_snapshot_data; | 24 extern const uint8_t* vm_snapshot_data; |
| 26 extern const uint8_t* vm_snapshot_instructions; | 25 extern const uint8_t* vm_snapshot_instructions; |
| 27 extern const uint8_t* core_isolate_snapshot_data; | 26 extern const uint8_t* core_isolate_snapshot_data; |
| 28 extern const uint8_t* core_isolate_snapshot_instructions; | 27 extern const uint8_t* core_isolate_snapshot_instructions; |
| 29 } | 28 } |
| 30 | 29 |
| 31 // The BENCHMARK macros are used for benchmarking a specific functionality | 30 // The BENCHMARK macros are used for benchmarking a specific functionality |
| 32 // of the VM. | 31 // of the VM. |
| 33 #define BENCHMARK_HELPER(name, kind) \ | 32 #define BENCHMARK_HELPER(name, kind) \ |
| 34 void Dart_Benchmark##name(Benchmark* benchmark); \ | 33 void Dart_Benchmark##name(Benchmark* benchmark); \ |
| 35 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ | 34 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ |
| 36 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, \ | 35 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, \ |
| 37 Thread* thread); \ | 36 Thread* thread); \ |
| 38 void Dart_Benchmark##name(Benchmark* benchmark) { \ | 37 void Dart_Benchmark##name(Benchmark* benchmark) { \ |
| 39 bool __stack_trace_collection_enabled__ = \ | |
| 40 MallocHooks::stack_trace_collection_enabled(); \ | |
| 41 MallocHooks::set_stack_trace_collection_enabled(false); \ | |
| 42 FLAG_old_gen_growth_space_ratio = 100; \ | 38 FLAG_old_gen_growth_space_ratio = 100; \ |
| 43 BenchmarkIsolateScope __isolate__(benchmark); \ | 39 BenchmarkIsolateScope __isolate__(benchmark); \ |
| 44 Thread* __thread__ = Thread::Current(); \ | 40 Thread* __thread__ = Thread::Current(); \ |
| 45 ASSERT(__thread__->isolate() == benchmark->isolate()); \ | 41 ASSERT(__thread__->isolate() == benchmark->isolate()); \ |
| 46 StackZone __zone__(__thread__); \ | 42 StackZone __zone__(__thread__); \ |
| 47 HandleScope __hs__(__thread__); \ | 43 HandleScope __hs__(__thread__); \ |
| 48 Dart_BenchmarkHelper##name(benchmark, __thread__); \ | 44 Dart_BenchmarkHelper##name(benchmark, __thread__); \ |
| 49 MallocHooks::set_stack_trace_collection_enabled( \ | |
| 50 __stack_trace_collection_enabled__); \ | |
| 51 } \ | 45 } \ |
| 52 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, Thread* thread) | 46 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, Thread* thread) |
| 53 | 47 |
| 54 #define BENCHMARK(name) BENCHMARK_HELPER(name, "RunTime") | 48 #define BENCHMARK(name) BENCHMARK_HELPER(name, "RunTime") |
| 55 #define BENCHMARK_SIZE(name) BENCHMARK_HELPER(name, "CodeSize") | 49 #define BENCHMARK_SIZE(name) BENCHMARK_HELPER(name, "CodeSize") |
| 56 #define BENCHMARK_MEMORY(name) BENCHMARK_HELPER(name, "MemoryUse") | 50 #define BENCHMARK_MEMORY(name) BENCHMARK_HELPER(name, "MemoryUse") |
| 57 | 51 |
| 58 inline Dart_Handle NewString(const char* str) { | 52 inline Dart_Handle NewString(const char* str) { |
| 59 return Dart_NewStringFromCString(str); | 53 return Dart_NewStringFromCString(str); |
| 60 } | 54 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 123 |
| 130 private: | 124 private: |
| 131 Benchmark* benchmark_; | 125 Benchmark* benchmark_; |
| 132 | 126 |
| 133 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); | 127 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); |
| 134 }; | 128 }; |
| 135 | 129 |
| 136 } // namespace dart | 130 } // namespace dart |
| 137 | 131 |
| 138 #endif // RUNTIME_VM_BENCHMARK_TEST_H_ | 132 #endif // RUNTIME_VM_BENCHMARK_TEST_H_ |
| OLD | NEW |