Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/coverage.h" | 5 #include "vm/coverage.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| 11 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 DEFINE_FLAG(charp, coverage_dir, NULL, | 17 DEFINE_FLAG(charp, coverage_dir, NULL, |
| 18 "Enable writing coverage data into specified directory."); | 18 "Enable writing coverage data into specified directory."); |
| 19 | 19 |
| 20 | 20 |
| 21 void CodeCoverage::CompileAndAdd(const Function& function, | 21 void CodeCoverage::CompileAndAdd(const Function& function, |
| 22 const JSONArray& hits_arr) { | 22 const JSONArray& hits_arr) { |
| 23 if (!function.HasCode()) { | 23 if (!function.HasCode()) { |
| 24 if (Compiler::CompileFunction(function) != Error::null()) { | 24 // If the function should not be compiled or if the compilation failed, |
| 25 // then just skip this method. | |
| 26 // TODO(iposva): Maybe we should skip synthesized methods in general too. | |
| 27 if (function.is_abstract() || function.IsRedirectingFactory()) { | |
| 28 return; | |
| 29 } | |
| 30 if (function.IsNonImplicitClosureFunction() && | |
| 31 (function.context_scope() == ContextScope::null())) { | |
| 32 // TODO(iposva): This can arise if we attempt to compile an inner function | |
| 33 // before we have compiled its enclosing function. | |
|
hausner
2013/10/04 16:06:23
Or the enclosing function failed to compile.
Ivan Posva
2013/10/04 20:50:02
Done.
| |
| 34 OS::Print("### Coverage skipped compiling: %s\n", function.ToCString()); | |
| 35 return; | |
| 36 } | |
| 37 const Error& err = Error::Handle(Compiler::CompileFunction(function)); | |
| 38 if (!err.IsNull()) { | |
| 39 OS::Print("### Coverage failed compiling:\n%s\n", err.ToErrorCString()); | |
| 25 return; | 40 return; |
| 26 } | 41 } |
| 27 } | 42 } |
| 28 ASSERT(function.HasCode()); | 43 ASSERT(function.HasCode()); |
| 29 | 44 |
| 30 Isolate* isolate = Isolate::Current(); | 45 Isolate* isolate = Isolate::Current(); |
| 31 // Print the hit counts for all IC datas. | 46 // Print the hit counts for all IC datas. |
| 32 const Script& script = Script::Handle(function.script()); | 47 const Script& script = Script::Handle(function.script()); |
| 33 const Code& code = Code::Handle(function.unoptimized_code()); | 48 const Code& code = Code::Handle(function.unoptimized_code()); |
| 34 const Array& ic_array = Array::Handle(code.ExtractTypeFeedbackArray()); | 49 const Array& ic_array = Array::Handle(code.ExtractTypeFeedbackArray()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 void* file = (*file_open)(filename, true); | 179 void* file = (*file_open)(filename, true); |
| 165 if (file == NULL) { | 180 if (file == NULL) { |
| 166 OS::Print("Failed to write coverage file: %s\n", filename); | 181 OS::Print("Failed to write coverage file: %s\n", filename); |
| 167 return; | 182 return; |
| 168 } | 183 } |
| 169 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file); | 184 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file); |
| 170 (*file_close)(file); | 185 (*file_close)(file); |
| 171 } | 186 } |
| 172 | 187 |
| 173 } // namespace dart | 188 } // namespace dart |
| OLD | NEW |