Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 10483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10494 return (result != NULL) ? AllocationSite::cast(result) : NULL; | 10494 return (result != NULL) ? AllocationSite::cast(result) : NULL; |
| 10495 } | 10495 } |
| 10496 | 10496 |
| 10497 | 10497 |
| 10498 Map* Code::FindFirstMap() { | 10498 Map* Code::FindFirstMap() { |
| 10499 Object* result = FindNthObject(1, GetHeap()->meta_map()); | 10499 Object* result = FindNthObject(1, GetHeap()->meta_map()); |
| 10500 return (result != NULL) ? Map::cast(result) : NULL; | 10500 return (result != NULL) ? Map::cast(result) : NULL; |
| 10501 } | 10501 } |
| 10502 | 10502 |
| 10503 | 10503 |
| 10504 void Code::ReplaceNthObject(int n, | 10504 void Code::FindAndReplace(const FindAndReplacePattern& pattern) { |
| 10505 Map* match_map, | |
| 10506 Object* replace_with) { | |
| 10507 ASSERT(is_inline_cache_stub() || is_handler()); | 10505 ASSERT(is_inline_cache_stub() || is_handler()); |
| 10508 DisallowHeapAllocation no_allocation; | 10506 DisallowHeapAllocation no_allocation; |
| 10509 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10507 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
| 10508 STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32); | |
| 10509 unsigned remaining_set = (1u << pattern.count_) - 1; | |
| 10510 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10510 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10511 RelocInfo* info = it.rinfo(); | 10511 RelocInfo* info = it.rinfo(); |
| 10512 Object* object = info->target_object(); | 10512 Object* object = info->target_object(); |
| 10513 if (object->IsHeapObject()) { | 10513 if (object->IsHeapObject()) { |
| 10514 if (HeapObject::cast(object)->map() == match_map) { | 10514 Map* map = HeapObject::cast(object)->map(); |
| 10515 if (--n == 0) { | 10515 for (int i = 0; i < pattern.count_; i++) { |
| 10516 info->set_target_object(replace_with); | 10516 if (((remaining_set >> i) & 1) && map == *pattern.find_[i]) { |
| 10517 return; | 10517 info->set_target_object(*pattern.replace_[i]); |
| 10518 remaining_set ^= 1u << i; | |
| 10519 if (!remaining_set) return; | |
| 10518 } | 10520 } |
| 10519 } | 10521 } |
|
Toon Verwaest
2014/03/17 09:40:14
Why don't we just introduce an invariant that the
ulan
2014/03/17 13:43:31
Good idea, turned that into O(m) and added comment
| |
| 10520 } | 10522 } |
| 10521 } | 10523 } |
| 10522 UNREACHABLE(); | 10524 UNREACHABLE(); |
| 10523 } | 10525 } |
| 10524 | 10526 |
| 10525 | 10527 |
| 10526 void Code::FindAllMaps(MapHandleList* maps) { | 10528 void Code::FindAllMaps(MapHandleList* maps) { |
| 10527 ASSERT(is_inline_cache_stub()); | 10529 ASSERT(is_inline_cache_stub()); |
| 10528 DisallowHeapAllocation no_allocation; | 10530 DisallowHeapAllocation no_allocation; |
| 10529 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10531 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10543 RelocInfo* info = it.rinfo(); | 10545 RelocInfo* info = it.rinfo(); |
| 10544 Object* object = info->target_object(); | 10546 Object* object = info->target_object(); |
| 10545 if (object->IsMap()) { | 10547 if (object->IsMap()) { |
| 10546 Handle<Map> map(Map::cast(object)); | 10548 Handle<Map> map(Map::cast(object)); |
| 10547 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate())); | 10549 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate())); |
| 10548 } | 10550 } |
| 10549 } | 10551 } |
| 10550 } | 10552 } |
| 10551 | 10553 |
| 10552 | 10554 |
| 10553 void Code::ReplaceFirstMap(Map* replace_with) { | |
| 10554 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); | |
| 10555 } | |
| 10556 | |
| 10557 | |
| 10558 Code* Code::FindFirstHandler() { | 10555 Code* Code::FindFirstHandler() { |
| 10559 ASSERT(is_inline_cache_stub()); | 10556 ASSERT(is_inline_cache_stub()); |
| 10560 DisallowHeapAllocation no_allocation; | 10557 DisallowHeapAllocation no_allocation; |
| 10561 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 10558 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
| 10562 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10559 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10563 RelocInfo* info = it.rinfo(); | 10560 RelocInfo* info = it.rinfo(); |
| 10564 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); | 10561 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); |
| 10565 if (code->kind() == Code::HANDLER) return code; | 10562 if (code->kind() == Code::HANDLER) return code; |
| 10566 } | 10563 } |
| 10567 return NULL; | 10564 return NULL; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 10593 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10590 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
| 10594 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10591 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10595 RelocInfo* info = it.rinfo(); | 10592 RelocInfo* info = it.rinfo(); |
| 10596 Object* object = info->target_object(); | 10593 Object* object = info->target_object(); |
| 10597 if (object->IsName()) return Name::cast(object); | 10594 if (object->IsName()) return Name::cast(object); |
| 10598 } | 10595 } |
| 10599 return NULL; | 10596 return NULL; |
| 10600 } | 10597 } |
| 10601 | 10598 |
| 10602 | 10599 |
| 10603 void Code::ReplaceNthCell(int n, Cell* replace_with) { | |
| 10604 ASSERT(is_inline_cache_stub()); | |
| 10605 DisallowHeapAllocation no_allocation; | |
| 10606 int mask = RelocInfo::ModeMask(RelocInfo::CELL); | |
| 10607 for (RelocIterator it(this, mask); !it.done(); it.next()) { | |
| 10608 RelocInfo* info = it.rinfo(); | |
| 10609 if (--n == 0) { | |
| 10610 info->set_target_cell(replace_with); | |
| 10611 return; | |
| 10612 } | |
| 10613 } | |
| 10614 UNREACHABLE(); | |
| 10615 } | |
| 10616 | |
| 10617 | |
| 10618 void Code::ClearInlineCaches() { | 10600 void Code::ClearInlineCaches() { |
| 10619 ClearInlineCaches(NULL); | 10601 ClearInlineCaches(NULL); |
| 10620 } | 10602 } |
| 10621 | 10603 |
| 10622 | 10604 |
| 10623 void Code::ClearInlineCaches(Code::Kind kind) { | 10605 void Code::ClearInlineCaches(Code::Kind kind) { |
| 10624 ClearInlineCaches(&kind); | 10606 ClearInlineCaches(&kind); |
| 10625 } | 10607 } |
| 10626 | 10608 |
| 10627 | 10609 |
| (...skipping 5852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16480 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16462 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16481 static const char* error_messages_[] = { | 16463 static const char* error_messages_[] = { |
| 16482 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16464 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16483 }; | 16465 }; |
| 16484 #undef ERROR_MESSAGES_TEXTS | 16466 #undef ERROR_MESSAGES_TEXTS |
| 16485 return error_messages_[reason]; | 16467 return error_messages_[reason]; |
| 16486 } | 16468 } |
| 16487 | 16469 |
| 16488 | 16470 |
| 16489 } } // namespace v8::internal | 16471 } } // namespace v8::internal |
| OLD | NEW |