 Chromium Code Reviews
 Chromium Code Reviews Issue 2944433003:
  [kernel] Add TokenPosition to AllocateObject, fix some cc tests  (Closed)
    
  
    Issue 2944433003:
  [kernel] Add TokenPosition to AllocateObject, fix some cc tests  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/profiler_service.h" | 5 #include "vm/profiler_service.h" | 
| 6 | 6 | 
| 7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" | 
| 8 #include "vm/hash_map.h" | 8 #include "vm/hash_map.h" | 
| 9 #include "vm/log.h" | 9 #include "vm/log.h" | 
| 10 #include "vm/malloc_hooks.h" | 10 #include "vm/malloc_hooks.h" | 
| (...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2671 if (function.IsNull()) { | 2671 if (function.IsNull()) { | 
| 2672 // No function. | 2672 // No function. | 
| 2673 return NULL; | 2673 return NULL; | 
| 2674 } | 2674 } | 
| 2675 Zone* zone = Thread::Current()->zone(); | 2675 Zone* zone = Thread::Current()->zone(); | 
| 2676 const Script& script = Script::Handle(zone, function.script()); | 2676 const Script& script = Script::Handle(zone, function.script()); | 
| 2677 if (script.IsNull()) { | 2677 if (script.IsNull()) { | 
| 2678 // No script. | 2678 // No script. | 
| 2679 return NULL; | 2679 return NULL; | 
| 2680 } | 2680 } | 
| 2681 const TokenStream& token_stream = TokenStream::Handle(zone, script.tokens()); | |
| 2682 if (token_stream.IsNull()) { | |
| 2683 // No token position. | |
| 2684 return NULL; | |
| 2685 } | |
| 2686 ProfileFunctionSourcePosition pfsp(TokenPosition::kNoSource); | 2681 ProfileFunctionSourcePosition pfsp(TokenPosition::kNoSource); | 
| 2687 if (!func->GetSinglePosition(&pfsp)) { | 2682 if (!func->GetSinglePosition(&pfsp)) { | 
| 2688 // Not exactly one source position. | 2683 // Not exactly one source position. | 
| 2689 return NULL; | 2684 return NULL; | 
| 2690 } | 2685 } | 
| 2691 TokenPosition token_pos = pfsp.token_pos(); | 2686 TokenPosition token_pos = pfsp.token_pos(); | 
| 2692 if (!token_pos.IsSourcePosition()) { | 2687 if (!token_pos.IsSourcePosition()) { | 
| 2693 // Not a location in a script. | 2688 // Not a location in a script. | 
| 2694 return NULL; | 2689 return NULL; | 
| 2695 } | 2690 } | 
| 2696 if (token_pos.IsSynthetic()) { | 2691 if (token_pos.IsSynthetic()) { | 
| 2697 token_pos = token_pos.FromSynthetic(); | 2692 token_pos = token_pos.FromSynthetic(); | 
| 2698 } | 2693 } | 
| 2699 TokenStream::Iterator iterator(zone, token_stream, token_pos); | 2694 | 
| 2700 const String& str = String::Handle(zone, iterator.CurrentLiteral()); | 2695 if (script.kind() == RawScript::kKernelTag) { | 
| 
Vyacheslav Egorov (Google)
2017/06/16 11:09:18
Please update CL description to include descriptio
 
jensj
2017/06/16 11:39:07
"fix some cc tests" isn't descriptive enough?
 
Kevin Millikin (Google)
2017/06/21 06:50:43
I would probably factor out the common code from t
 | |
| 2701 if (str.IsNull()) { | 2696 intptr_t line = 0, column = 0, token_len = 0; | 
| 2702 return NULL; | 2697 script.GetTokenLocation(token_pos, &line, &column, &token_len); | 
| 2698 const String& str = String::Handle( | |
| 2699 zone, script.GetSnippet(line, column, line, column + token_len)); | |
| 2700 if (str.IsNull()) { | |
| 2701 return NULL; | |
| 2702 } | |
| 2703 return str.ToCString(); | |
| 2704 } else { | |
| 2705 const TokenStream& token_stream = | |
| 2706 TokenStream::Handle(zone, script.tokens()); | |
| 2707 if (token_stream.IsNull()) { | |
| 2708 // No token position. | |
| 2709 return NULL; | |
| 2710 } | |
| 2711 TokenStream::Iterator iterator(zone, token_stream, token_pos); | |
| 2712 const String& str = String::Handle(zone, iterator.CurrentLiteral()); | |
| 2713 if (str.IsNull()) { | |
| 2714 return NULL; | |
| 2715 } | |
| 2716 return str.ToCString(); | |
| 2703 } | 2717 } | 
| 2704 return str.ToCString(); | |
| 2705 } | 2718 } | 
| 2706 | 2719 | 
| 2707 bool ProfileTrieWalker::Down() { | 2720 bool ProfileTrieWalker::Down() { | 
| 2708 if ((current_ == NULL) || (current_->NumChildren() == 0)) { | 2721 if ((current_ == NULL) || (current_->NumChildren() == 0)) { | 
| 2709 return false; | 2722 return false; | 
| 2710 } | 2723 } | 
| 2711 parent_ = current_; | 2724 parent_ = current_; | 
| 2712 current_ = current_->At(0); | 2725 current_ = current_->At(0); | 
| 2713 return true; | 2726 return true; | 
| 2714 } | 2727 } | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2878 // Disable thread interrupts while processing the buffer. | 2891 // Disable thread interrupts while processing the buffer. | 
| 2879 DisableThreadInterruptsScope dtis(thread); | 2892 DisableThreadInterruptsScope dtis(thread); | 
| 2880 | 2893 | 
| 2881 ClearProfileVisitor clear_profile(isolate); | 2894 ClearProfileVisitor clear_profile(isolate); | 
| 2882 sample_buffer->VisitSamples(&clear_profile); | 2895 sample_buffer->VisitSamples(&clear_profile); | 
| 2883 } | 2896 } | 
| 2884 | 2897 | 
| 2885 #endif // !PRODUCT | 2898 #endif // !PRODUCT | 
| 2886 | 2899 | 
| 2887 } // namespace dart | 2900 } // namespace dart | 
| OLD | NEW |