OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 const int kMaxElementsForLinearSearch = 8; | 1486 const int kMaxElementsForLinearSearch = 8; |
1487 if (StringShape(name).IsSymbol() && nof < kMaxElementsForLinearSearch) { | 1487 if (StringShape(name).IsSymbol() && nof < kMaxElementsForLinearSearch) { |
1488 return LinearSearch(name, nof); | 1488 return LinearSearch(name, nof); |
1489 } | 1489 } |
1490 | 1490 |
1491 // Slow case: perform binary search. | 1491 // Slow case: perform binary search. |
1492 return BinarySearch(name, 0, nof - 1); | 1492 return BinarySearch(name, 0, nof - 1); |
1493 } | 1493 } |
1494 | 1494 |
1495 | 1495 |
| 1496 int DescriptorArray::SearchWithCache(String* name) { |
| 1497 int number = DescriptorLookupCache::Lookup(this, name); |
| 1498 if (number == DescriptorLookupCache::kAbsent) { |
| 1499 number = Search(name); |
| 1500 DescriptorLookupCache::Update(this, name, number); |
| 1501 } |
| 1502 return number; |
| 1503 } |
| 1504 |
| 1505 |
1496 String* DescriptorArray::GetKey(int descriptor_number) { | 1506 String* DescriptorArray::GetKey(int descriptor_number) { |
1497 ASSERT(descriptor_number < number_of_descriptors()); | 1507 ASSERT(descriptor_number < number_of_descriptors()); |
1498 return String::cast(get(ToKeyIndex(descriptor_number))); | 1508 return String::cast(get(ToKeyIndex(descriptor_number))); |
1499 } | 1509 } |
1500 | 1510 |
1501 | 1511 |
1502 Object* DescriptorArray::GetValue(int descriptor_number) { | 1512 Object* DescriptorArray::GetValue(int descriptor_number) { |
1503 ASSERT(descriptor_number < number_of_descriptors()); | 1513 ASSERT(descriptor_number < number_of_descriptors()); |
1504 return GetContentArray()->get(ToValueIndex(descriptor_number)); | 1514 return GetContentArray()->get(ToValueIndex(descriptor_number)); |
1505 } | 1515 } |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3325 #undef WRITE_INT_FIELD | 3335 #undef WRITE_INT_FIELD |
3326 #undef READ_SHORT_FIELD | 3336 #undef READ_SHORT_FIELD |
3327 #undef WRITE_SHORT_FIELD | 3337 #undef WRITE_SHORT_FIELD |
3328 #undef READ_BYTE_FIELD | 3338 #undef READ_BYTE_FIELD |
3329 #undef WRITE_BYTE_FIELD | 3339 #undef WRITE_BYTE_FIELD |
3330 | 3340 |
3331 | 3341 |
3332 } } // namespace v8::internal | 3342 } } // namespace v8::internal |
3333 | 3343 |
3334 #endif // V8_OBJECTS_INL_H_ | 3344 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |