| 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/runtime/runtime.h" | 5 #include "src/runtime/runtime.h" |
| 6 | 6 |
| 7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
| 8 #include "src/base/hashmap.h" | 8 #include "src/base/hashmap.h" |
| 9 #include "src/contexts.h" | 9 #include "src/contexts.h" |
| 10 #include "src/handles-inl.h" | 10 #include "src/handles-inl.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 FOR_EACH_INTRINSIC(F) | 54 FOR_EACH_INTRINSIC(F) |
| 55 FOR_EACH_INTRINSIC(I) | 55 FOR_EACH_INTRINSIC(I) |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 #undef I | 58 #undef I |
| 59 #undef F | 59 #undef F |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| 62 | 62 |
| 63 V8_DECLARE_ONCE(initialize_function_name_map_once); | 63 V8_DECLARE_ONCE(initialize_function_name_map_once); |
| 64 static const base::HashMap* kRuntimeFunctionNameMap; | 64 static const base::CustomMatcherHashMap* kRuntimeFunctionNameMap; |
| 65 | 65 |
| 66 struct IntrinsicFunctionIdentifier { | 66 struct IntrinsicFunctionIdentifier { |
| 67 IntrinsicFunctionIdentifier(const unsigned char* data, const int length) | 67 IntrinsicFunctionIdentifier(const unsigned char* data, const int length) |
| 68 : data_(data), length_(length) {} | 68 : data_(data), length_(length) {} |
| 69 | 69 |
| 70 static bool Match(void* key1, void* key2) { | 70 static bool Match(void* key1, void* key2) { |
| 71 const IntrinsicFunctionIdentifier* lhs = | 71 const IntrinsicFunctionIdentifier* lhs = |
| 72 static_cast<IntrinsicFunctionIdentifier*>(key1); | 72 static_cast<IntrinsicFunctionIdentifier*>(key1); |
| 73 const IntrinsicFunctionIdentifier* rhs = | 73 const IntrinsicFunctionIdentifier* rhs = |
| 74 static_cast<IntrinsicFunctionIdentifier*>(key2); | 74 static_cast<IntrinsicFunctionIdentifier*>(key2); |
| 75 if (lhs->length_ != rhs->length_) return false; | 75 if (lhs->length_ != rhs->length_) return false; |
| 76 return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(lhs->data_), | 76 return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(lhs->data_), |
| 77 reinterpret_cast<const uint8_t*>(rhs->data_), | 77 reinterpret_cast<const uint8_t*>(rhs->data_), |
| 78 rhs->length_) == 0; | 78 rhs->length_) == 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 uint32_t Hash() { | 81 uint32_t Hash() { |
| 82 return StringHasher::HashSequentialString<uint8_t>( | 82 return StringHasher::HashSequentialString<uint8_t>( |
| 83 data_, length_, v8::internal::kZeroHashSeed); | 83 data_, length_, v8::internal::kZeroHashSeed); |
| 84 } | 84 } |
| 85 | 85 |
| 86 const unsigned char* data_; | 86 const unsigned char* data_; |
| 87 const int length_; | 87 const int length_; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 void InitializeIntrinsicFunctionNames() { | 90 void InitializeIntrinsicFunctionNames() { |
| 91 base::HashMap* function_name_map = | 91 base::CustomMatcherHashMap* function_name_map = |
| 92 new base::HashMap(IntrinsicFunctionIdentifier::Match); | 92 new base::CustomMatcherHashMap(IntrinsicFunctionIdentifier::Match); |
| 93 for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) { | 93 for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) { |
| 94 const Runtime::Function* function = &kIntrinsicFunctions[i]; | 94 const Runtime::Function* function = &kIntrinsicFunctions[i]; |
| 95 IntrinsicFunctionIdentifier* identifier = new IntrinsicFunctionIdentifier( | 95 IntrinsicFunctionIdentifier* identifier = new IntrinsicFunctionIdentifier( |
| 96 reinterpret_cast<const unsigned char*>(function->name), | 96 reinterpret_cast<const unsigned char*>(function->name), |
| 97 static_cast<int>(strlen(function->name))); | 97 static_cast<int>(strlen(function->name))); |
| 98 base::HashMap::Entry* entry = | 98 base::HashMap::Entry* entry = |
| 99 function_name_map->InsertNew(identifier, identifier->Hash()); | 99 function_name_map->InsertNew(identifier, identifier->Hash()); |
| 100 entry->value = const_cast<Runtime::Function*>(function); | 100 entry->value = const_cast<Runtime::Function*>(function); |
| 101 } | 101 } |
| 102 kRuntimeFunctionNameMap = function_name_map; | 102 kRuntimeFunctionNameMap = function_name_map; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) { | 161 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) { |
| 162 return os << Runtime::FunctionForId(id)->name; | 162 return os << Runtime::FunctionForId(id)->name; |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 } // namespace internal | 166 } // namespace internal |
| 167 } // namespace v8 | 167 } // namespace v8 |
| OLD | NEW |