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

Side by Side Diff: runtime/vm/benchmark_test.h

Issue 2622053002: Refactor snapshots pieces to include a section for loading instructions into the heap of a regular … (Closed)
Patch Set: . Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « runtime/tools/create_snapshot_bin.py ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/object.h" 14 #include "vm/object.h"
15 #include "vm/zone.h" 15 #include "vm/zone.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DECLARE_FLAG(int, code_heap_size); 19 DECLARE_FLAG(int, code_heap_size);
20 DECLARE_FLAG(int, old_gen_growth_space_ratio); 20 DECLARE_FLAG(int, old_gen_growth_space_ratio);
21 21
22 namespace bin { 22 namespace bin {
23 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we 23 // Snapshot pieces if we link in a snapshot, otherwise initialized to NULL.
24 // link in a snapshot otherwise it is initialized to NULL. 24 extern const uint8_t* vm_snapshot_data;
25 extern const uint8_t* vm_isolate_snapshot_buffer; 25 extern const uint8_t* vm_snapshot_instructions;
26 26 extern const uint8_t* core_isolate_snapshot_data;
27 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a 27 extern const uint8_t* core_isolate_snapshot_instructions;
28 // snapshot otherwise it is initialized to NULL.
29 extern const uint8_t* core_isolate_snapshot_buffer;
30 } 28 }
31 29
32 // The BENCHMARK macros are used for benchmarking a specific functionality 30 // The BENCHMARK macros are used for benchmarking a specific functionality
33 // of the VM. 31 // of the VM.
34 #define BENCHMARK_HELPER(name, kind) \ 32 #define BENCHMARK_HELPER(name, kind) \
35 void Dart_Benchmark##name(Benchmark* benchmark); \ 33 void Dart_Benchmark##name(Benchmark* benchmark); \
36 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ 34 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \
37 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, \ 35 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, \
38 Thread* thread); \ 36 Thread* thread); \
39 void Dart_Benchmark##name(Benchmark* benchmark) { \ 37 void Dart_Benchmark##name(Benchmark* benchmark) { \
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 tail_ = this; 73 tail_ = this;
76 } 74 }
77 75
78 // Accessors. 76 // Accessors.
79 const char* name() const { return name_; } 77 const char* name() const { return name_; }
80 const char* score_kind() const { return score_kind_; } 78 const char* score_kind() const { return score_kind_; }
81 void set_score(int64_t value) { score_ = value; } 79 void set_score(int64_t value) { score_ = value; }
82 int64_t score() const { return score_; } 80 int64_t score() const { return score_; }
83 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); } 81 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
84 82
85 Dart_Isolate CreateIsolate(const uint8_t* buffer); 83 Dart_Isolate CreateIsolate(const uint8_t* snapshot_data,
84 const uint8_t* snapshot_instructions);
86 85
87 void Run() { (*run_)(this); } 86 void Run() { (*run_)(this); }
88 void RunBenchmark(); 87 void RunBenchmark();
89 88
90 static void RunAll(const char* executable); 89 static void RunAll(const char* executable);
91 static void SetExecutable(const char* arg) { executable_ = arg; } 90 static void SetExecutable(const char* arg) { executable_ = arg; }
92 static const char* Executable() { return executable_; } 91 static const char* Executable() { return executable_; }
93 92
94 private: 93 private:
95 static Benchmark* first_; 94 static Benchmark* first_;
96 static Benchmark* tail_; 95 static Benchmark* tail_;
97 static const char* executable_; 96 static const char* executable_;
98 97
99 RunEntry* const run_; 98 RunEntry* const run_;
100 const char* name_; 99 const char* name_;
101 const char* score_kind_; 100 const char* score_kind_;
102 int64_t score_; 101 int64_t score_;
103 Dart_Isolate isolate_; 102 Dart_Isolate isolate_;
104 Benchmark* next_; 103 Benchmark* next_;
105 104
106 DISALLOW_COPY_AND_ASSIGN(Benchmark); 105 DISALLOW_COPY_AND_ASSIGN(Benchmark);
107 }; 106 };
108 107
109 108
110 class BenchmarkIsolateScope { 109 class BenchmarkIsolateScope {
111 public: 110 public:
112 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { 111 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) {
113 benchmark_->CreateIsolate(bin::core_isolate_snapshot_buffer); 112 benchmark_->CreateIsolate(bin::core_isolate_snapshot_data,
113 bin::core_isolate_snapshot_instructions);
114 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. 114 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks.
115 } 115 }
116 ~BenchmarkIsolateScope() { 116 ~BenchmarkIsolateScope() {
117 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 117 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
118 ASSERT(benchmark_->isolate() == Isolate::Current()); 118 ASSERT(benchmark_->isolate() == Isolate::Current());
119 Dart_ShutdownIsolate(); 119 Dart_ShutdownIsolate();
120 benchmark_ = NULL; 120 benchmark_ = NULL;
121 } 121 }
122 Benchmark* benchmark() const { return benchmark_; } 122 Benchmark* benchmark() const { return benchmark_; }
123 123
124 private: 124 private:
125 Benchmark* benchmark_; 125 Benchmark* benchmark_;
126 126
127 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); 127 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope);
128 }; 128 };
129 129
130 } // namespace dart 130 } // namespace dart
131 131
132 #endif // RUNTIME_VM_BENCHMARK_TEST_H_ 132 #endif // RUNTIME_VM_BENCHMARK_TEST_H_
OLDNEW
« no previous file with comments | « runtime/tools/create_snapshot_bin.py ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698