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

Side by Side Diff: runtime/vm/object.cc

Issue 489923002: Tweaks to perf jitdump support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os_linux.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 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5794 matching lines...) Expand 10 before | Expand all | Expand 10 after
5805 } 5805 }
5806 } 5806 }
5807 return true; 5807 return true;
5808 } 5808 }
5809 5809
5810 5810
5811 // Helper allocating a C string buffer in the zone, printing the fully qualified 5811 // Helper allocating a C string buffer in the zone, printing the fully qualified
5812 // name of a function in it, and replacing ':' by '_' to make sure the 5812 // name of a function in it, and replacing ':' by '_' to make sure the
5813 // constructed name is a valid C++ identifier for debugging purpose. 5813 // constructed name is a valid C++ identifier for debugging purpose.
5814 // Set 'chars' to allocated buffer and return number of written characters. 5814 // Set 'chars' to allocated buffer and return number of written characters.
5815 static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, 5815
5816 char** chars, 5816 enum QualifiedFunctionLibKind {
5817 intptr_t reserve_len, 5817 kQualifiedFunctionLibKindLibUrl,
5818 bool with_lib) { 5818 kQualifiedFunctionLibKindLibName
5819 };
5820
5821
5822 static intptr_t ConstructFunctionFullyQualifiedCString(
5823 const Function& function,
5824 char** chars,
5825 intptr_t reserve_len,
5826 bool with_lib,
5827 QualifiedFunctionLibKind lib_kind) {
5819 const char* name = String::Handle(function.name()).ToCString(); 5828 const char* name = String::Handle(function.name()).ToCString();
5820 const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; 5829 const char* function_format = (reserve_len == 0) ? "%s" : "%s_";
5821 reserve_len += OS::SNPrint(NULL, 0, function_format, name); 5830 reserve_len += OS::SNPrint(NULL, 0, function_format, name);
5822 const Function& parent = Function::Handle(function.parent_function()); 5831 const Function& parent = Function::Handle(function.parent_function());
5823 intptr_t written = 0; 5832 intptr_t written = 0;
5824 if (parent.IsNull()) { 5833 if (parent.IsNull()) {
5825 const Class& function_class = Class::Handle(function.Owner()); 5834 const Class& function_class = Class::Handle(function.Owner());
5826 ASSERT(!function_class.IsNull()); 5835 ASSERT(!function_class.IsNull());
5827 const char* class_name = String::Handle(function_class.Name()).ToCString(); 5836 const char* class_name = String::Handle(function_class.Name()).ToCString();
5828 ASSERT(class_name != NULL); 5837 ASSERT(class_name != NULL);
5829 const Library& library = Library::Handle(function_class.library()); 5838 const Library& library = Library::Handle(function_class.library());
5830 ASSERT(!library.IsNull()); 5839 ASSERT(!library.IsNull());
5831 const char* library_name = NULL; 5840 const char* library_name = NULL;
5832 const char* lib_class_format = NULL; 5841 const char* lib_class_format = NULL;
5833 if (with_lib) { 5842 if (with_lib) {
5834 library_name = String::Handle(library.url()).ToCString(); 5843 switch (lib_kind) {
5844 case kQualifiedFunctionLibKindLibUrl:
5845 library_name = String::Handle(library.url()).ToCString();
5846 break;
5847 case kQualifiedFunctionLibKindLibName:
5848 library_name = String::Handle(library.name()).ToCString();
5849 break;
5850 default:
5851 UNREACHABLE();
5852 }
5835 ASSERT(library_name != NULL); 5853 ASSERT(library_name != NULL);
5836 lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; 5854 lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_";
5837 } else { 5855 } else {
5838 library_name = ""; 5856 library_name = "";
5839 lib_class_format = "%s%s."; 5857 lib_class_format = "%s%s.";
5840 } 5858 }
5841 reserve_len += 5859 reserve_len +=
5842 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); 5860 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name);
5843 ASSERT(chars != NULL); 5861 ASSERT(chars != NULL);
5844 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); 5862 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1);
5845 written = OS::SNPrint( 5863 written = OS::SNPrint(
5846 *chars, reserve_len + 1, lib_class_format, library_name, class_name); 5864 *chars, reserve_len + 1, lib_class_format, library_name, class_name);
5847 } else { 5865 } else {
5848 written = ConstructFunctionFullyQualifiedCString(parent, 5866 written = ConstructFunctionFullyQualifiedCString(parent,
5849 chars, 5867 chars,
5850 reserve_len, 5868 reserve_len,
5851 with_lib); 5869 with_lib,
5870 lib_kind);
5852 } 5871 }
5853 ASSERT(*chars != NULL); 5872 ASSERT(*chars != NULL);
5854 char* next = *chars + written; 5873 char* next = *chars + written;
5855 written += OS::SNPrint(next, reserve_len + 1, function_format, name); 5874 written += OS::SNPrint(next, reserve_len + 1, function_format, name);
5856 // Replace ":" with "_". 5875 // Replace ":" with "_".
5857 while (true) { 5876 while (true) {
5858 next = strchr(next, ':'); 5877 next = strchr(next, ':');
5859 if (next == NULL) break; 5878 if (next == NULL) break;
5860 *next = '_'; 5879 *next = '_';
5861 } 5880 }
5862 return written; 5881 return written;
5863 } 5882 }
5864 5883
5865 5884
5866 const char* Function::ToFullyQualifiedCString() const { 5885 const char* Function::ToFullyQualifiedCString() const {
5867 char* chars = NULL; 5886 char* chars = NULL;
5868 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true); 5887 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true,
5888 kQualifiedFunctionLibKindLibUrl);
5889 return chars;
5890 }
5891
5892
5893 const char* Function::ToLibNamePrefixedQualifiedCString() const {
5894 char* chars = NULL;
5895 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true,
5896 kQualifiedFunctionLibKindLibName);
5869 return chars; 5897 return chars;
5870 } 5898 }
5871 5899
5872 5900
5873 const char* Function::ToQualifiedCString() const { 5901 const char* Function::ToQualifiedCString() const {
5874 char* chars = NULL; 5902 char* chars = NULL;
5875 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false); 5903 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false,
5904 kQualifiedFunctionLibKindLibUrl);
5876 return chars; 5905 return chars;
5877 } 5906 }
5878 5907
5879 5908
5880 bool Function::HasCompatibleParametersWith(const Function& other, 5909 bool Function::HasCompatibleParametersWith(const Function& other,
5881 Error* bound_error) const { 5910 Error* bound_error) const {
5882 ASSERT(FLAG_error_on_bad_override); 5911 ASSERT(FLAG_error_on_bad_override);
5883 ASSERT((bound_error != NULL) && bound_error->IsNull()); 5912 ASSERT((bound_error != NULL) && bound_error->IsNull());
5884 // Check that this function's signature type is a subtype of the other 5913 // Check that this function's signature type is a subtype of the other
5885 // function's signature type. 5914 // function's signature type.
(...skipping 6116 matching lines...) Expand 10 before | Expand all | Expand 10 after
12002 } 12031 }
12003 } 12032 }
12004 code.set_comments(assembler->GetCodeComments()); 12033 code.set_comments(assembler->GetCodeComments());
12005 return code.raw(); 12034 return code.raw();
12006 } 12035 }
12007 12036
12008 12037
12009 RawCode* Code::FinalizeCode(const Function& function, 12038 RawCode* Code::FinalizeCode(const Function& function,
12010 Assembler* assembler, 12039 Assembler* assembler,
12011 bool optimized) { 12040 bool optimized) {
12012 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. 12041 // Calling ToLibNamePrefixedQualifiedCString is very expensive,
12042 // try to avoid it.
12013 if (CodeObservers::AreActive()) { 12043 if (CodeObservers::AreActive()) {
12014 return FinalizeCode(function.ToFullyQualifiedCString(), 12044 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(),
12015 assembler, 12045 assembler,
12016 optimized); 12046 optimized);
12017 } else { 12047 } else {
12018 return FinalizeCode("", assembler); 12048 return FinalizeCode("", assembler);
12019 } 12049 }
12020 } 12050 }
12021 12051
12022 12052
12023 // Check if object matches find condition. 12053 // Check if object matches find condition.
12024 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { 12054 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const {
(...skipping 7454 matching lines...) Expand 10 before | Expand all | Expand 10 after
19479 return tag_label.ToCString(); 19509 return tag_label.ToCString();
19480 } 19510 }
19481 19511
19482 19512
19483 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19513 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19484 Instance::PrintJSONImpl(stream, ref); 19514 Instance::PrintJSONImpl(stream, ref);
19485 } 19515 }
19486 19516
19487 19517
19488 } // namespace dart 19518 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698