Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index f79dc5898e4a4257805531e7bea40532558d4d01..059e009f66ae529a30182d029979f391bdabc219 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -5812,10 +5812,19 @@ bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, |
| // name of a function in it, and replacing ':' by '_' to make sure the |
| // constructed name is a valid C++ identifier for debugging purpose. |
| // Set 'chars' to allocated buffer and return number of written characters. |
| -static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, |
| - char** chars, |
| - intptr_t reserve_len, |
| - bool with_lib) { |
| + |
| +enum QualifiedFunctionLibKind { |
| + kQualifiedFunctionLibKindLibUrl, |
| + kQualifiedFunctionLibKindLibName |
| +}; |
| + |
| + |
| +static intptr_t ConstructFunctionFullyQualifiedCString( |
| + const Function& function, |
| + char** chars, |
| + intptr_t reserve_len, |
| + bool with_lib, |
| + QualifiedFunctionLibKind lib_kind = kQualifiedFunctionLibKindLibUrl) { |
|
siva
2014/08/20 20:40:09
instead of a default value for the param why not j
Cutch
2014/08/20 20:43:40
Done.
|
| const char* name = String::Handle(function.name()).ToCString(); |
| const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; |
| reserve_len += OS::SNPrint(NULL, 0, function_format, name); |
| @@ -5831,7 +5840,16 @@ static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, |
| const char* library_name = NULL; |
| const char* lib_class_format = NULL; |
| if (with_lib) { |
| - library_name = String::Handle(library.url()).ToCString(); |
| + switch (lib_kind) { |
| + case kQualifiedFunctionLibKindLibUrl: |
| + library_name = String::Handle(library.url()).ToCString(); |
| + break; |
| + case kQualifiedFunctionLibKindLibName: |
| + library_name = String::Handle(library.name()).ToCString(); |
| + break; |
| + default: |
| + UNIMPLEMENTED(); |
|
siva
2014/08/20 20:40:09
UNREACHABLE() instead of unimplemented?
Cutch
2014/08/20 20:43:41
Done.
|
| + } |
| ASSERT(library_name != NULL); |
| lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; |
| } else { |
| @@ -5848,7 +5866,8 @@ static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, |
| written = ConstructFunctionFullyQualifiedCString(parent, |
| chars, |
| reserve_len, |
| - with_lib); |
| + with_lib, |
| + lib_kind); |
| } |
| ASSERT(*chars != NULL); |
| char* next = *chars + written; |
| @@ -5870,6 +5889,14 @@ const char* Function::ToFullyQualifiedCString() const { |
| } |
| +const char* Function::ToLibNamePrefixedQualifiedCString() const { |
| + char* chars = NULL; |
| + ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true, |
| + kQualifiedFunctionLibKindLibName); |
| + return chars; |
| +} |
| + |
| + |
| const char* Function::ToQualifiedCString() const { |
| char* chars = NULL; |
| ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false); |
| @@ -12009,9 +12036,10 @@ RawCode* Code::FinalizeCode(const char* name, |
| RawCode* Code::FinalizeCode(const Function& function, |
| Assembler* assembler, |
| bool optimized) { |
| - // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| + // Calling ToLibNamePrefixedQualifiedCString is very expensive, |
| + // try to avoid it. |
| if (CodeObservers::AreActive()) { |
| - return FinalizeCode(function.ToFullyQualifiedCString(), |
| + return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), |
| assembler, |
| optimized); |
| } else { |