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 int current_pattern = 0; |
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 if (map == *pattern.find_[current_pattern]) { |
10516 info->set_target_object(replace_with); | 10516 info->set_target_object(*pattern.replace_[current_pattern]); |
10517 return; | 10517 if (++current_pattern == pattern.count_) return; |
10518 } | |
10519 } | 10518 } |
10520 } | 10519 } |
10521 } | 10520 } |
10522 UNREACHABLE(); | 10521 UNREACHABLE(); |
10523 } | 10522 } |
10524 | 10523 |
10525 | 10524 |
10526 void Code::FindAllMaps(MapHandleList* maps) { | 10525 void Code::FindAllMaps(MapHandleList* maps) { |
10527 ASSERT(is_inline_cache_stub()); | 10526 ASSERT(is_inline_cache_stub()); |
10528 DisallowHeapAllocation no_allocation; | 10527 DisallowHeapAllocation no_allocation; |
(...skipping 14 matching lines...) Expand all Loading... |
10543 RelocInfo* info = it.rinfo(); | 10542 RelocInfo* info = it.rinfo(); |
10544 Object* object = info->target_object(); | 10543 Object* object = info->target_object(); |
10545 if (object->IsMap()) { | 10544 if (object->IsMap()) { |
10546 Handle<Map> map(Map::cast(object)); | 10545 Handle<Map> map(Map::cast(object)); |
10547 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate())); | 10546 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate())); |
10548 } | 10547 } |
10549 } | 10548 } |
10550 } | 10549 } |
10551 | 10550 |
10552 | 10551 |
10553 void Code::ReplaceFirstMap(Map* replace_with) { | |
10554 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); | |
10555 } | |
10556 | |
10557 | |
10558 Code* Code::FindFirstHandler() { | 10552 Code* Code::FindFirstHandler() { |
10559 ASSERT(is_inline_cache_stub()); | 10553 ASSERT(is_inline_cache_stub()); |
10560 DisallowHeapAllocation no_allocation; | 10554 DisallowHeapAllocation no_allocation; |
10561 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 10555 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
10562 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10556 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10563 RelocInfo* info = it.rinfo(); | 10557 RelocInfo* info = it.rinfo(); |
10564 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); | 10558 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); |
10565 if (code->kind() == Code::HANDLER) return code; | 10559 if (code->kind() == Code::HANDLER) return code; |
10566 } | 10560 } |
10567 return NULL; | 10561 return NULL; |
(...skipping 25 matching lines...) Expand all Loading... |
10593 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10587 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10594 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10588 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10595 RelocInfo* info = it.rinfo(); | 10589 RelocInfo* info = it.rinfo(); |
10596 Object* object = info->target_object(); | 10590 Object* object = info->target_object(); |
10597 if (object->IsName()) return Name::cast(object); | 10591 if (object->IsName()) return Name::cast(object); |
10598 } | 10592 } |
10599 return NULL; | 10593 return NULL; |
10600 } | 10594 } |
10601 | 10595 |
10602 | 10596 |
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() { | 10597 void Code::ClearInlineCaches() { |
10619 ClearInlineCaches(NULL); | 10598 ClearInlineCaches(NULL); |
10620 } | 10599 } |
10621 | 10600 |
10622 | 10601 |
10623 void Code::ClearInlineCaches(Code::Kind kind) { | 10602 void Code::ClearInlineCaches(Code::Kind kind) { |
10624 ClearInlineCaches(&kind); | 10603 ClearInlineCaches(&kind); |
10625 } | 10604 } |
10626 | 10605 |
10627 | 10606 |
(...skipping 5855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16483 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16462 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16484 static const char* error_messages_[] = { | 16463 static const char* error_messages_[] = { |
16485 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16464 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16486 }; | 16465 }; |
16487 #undef ERROR_MESSAGES_TEXTS | 16466 #undef ERROR_MESSAGES_TEXTS |
16488 return error_messages_[reason]; | 16467 return error_messages_[reason]; |
16489 } | 16468 } |
16490 | 16469 |
16491 | 16470 |
16492 } } // namespace v8::internal | 16471 } } // namespace v8::internal |
OLD | NEW |