| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 DeleteArray(reinterpret_cast<const char*>(p->value)); | 36 DeleteArray(reinterpret_cast<const char*>(p->value)); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 const char* StringsStorage::GetCopy(const char* src) { | 41 const char* StringsStorage::GetCopy(const char* src) { |
| 42 int len = static_cast<int>(strlen(src)); | 42 int len = static_cast<int>(strlen(src)); |
| 43 HashMap::Entry* entry = GetEntry(src, len); | 43 HashMap::Entry* entry = GetEntry(src, len); |
| 44 if (entry->value == NULL) { | 44 if (entry->value == NULL) { |
| 45 Vector<char> dst = Vector<char>::New(len + 1); | 45 Vector<char> dst = Vector<char>::New(len + 1); |
| 46 OS::StrNCpy(dst, src, len); | 46 StrNCpy(dst, src, len); |
| 47 dst[len] = '\0'; | 47 dst[len] = '\0'; |
| 48 entry->key = dst.start(); | 48 entry->key = dst.start(); |
| 49 entry->value = entry->key; | 49 entry->value = entry->key; |
| 50 } | 50 } |
| 51 return reinterpret_cast<const char*>(entry->value); | 51 return reinterpret_cast<const char*>(entry->value); |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 const char* StringsStorage::GetFormatted(const char* format, ...) { | 55 const char* StringsStorage::GetFormatted(const char* format, ...) { |
| 56 va_list args; | 56 va_list args; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 entry->value = str; | 69 entry->value = str; |
| 70 } else { | 70 } else { |
| 71 DeleteArray(str); | 71 DeleteArray(str); |
| 72 } | 72 } |
| 73 return reinterpret_cast<const char*>(entry->value); | 73 return reinterpret_cast<const char*>(entry->value); |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { | 77 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { |
| 78 Vector<char> str = Vector<char>::New(1024); | 78 Vector<char> str = Vector<char>::New(1024); |
| 79 int len = OS::VSNPrintF(str, format, args); | 79 int len = VSNPrintF(str, format, args); |
| 80 if (len == -1) { | 80 if (len == -1) { |
| 81 DeleteArray(str.start()); | 81 DeleteArray(str.start()); |
| 82 return GetCopy(format); | 82 return GetCopy(format); |
| 83 } | 83 } |
| 84 return AddOrDisposeString(str.start(), len); | 84 return AddOrDisposeString(str.start(), len); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 const char* StringsStorage::GetName(Name* name) { | 88 const char* StringsStorage::GetName(Name* name) { |
| 89 if (name->IsString()) { | 89 if (name->IsString()) { |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 case OTHER: | 670 case OTHER: |
| 671 case EXTERNAL: | 671 case EXTERNAL: |
| 672 return program_entry_; | 672 return program_entry_; |
| 673 case IDLE: | 673 case IDLE: |
| 674 return idle_entry_; | 674 return idle_entry_; |
| 675 default: return NULL; | 675 default: return NULL; |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 | 678 |
| 679 } } // namespace v8::internal | 679 } } // namespace v8::internal |
| OLD | NEW |