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 11520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11531 | 11531 |
11532 | 11532 |
11533 void Map::AddDependentCode(DependentCode::DependencyGroup group, | 11533 void Map::AddDependentCode(DependentCode::DependencyGroup group, |
11534 Handle<Code> code) { | 11534 Handle<Code> code) { |
11535 Handle<DependentCode> codes = DependentCode::Insert( | 11535 Handle<DependentCode> codes = DependentCode::Insert( |
11536 Handle<DependentCode>(dependent_code()), group, code); | 11536 Handle<DependentCode>(dependent_code()), group, code); |
11537 if (*codes != dependent_code()) set_dependent_code(*codes); | 11537 if (*codes != dependent_code()) set_dependent_code(*codes); |
11538 } | 11538 } |
11539 | 11539 |
11540 | 11540 |
| 11541 void Map::AddDependentIC(Handle<Code> stub) { |
| 11542 ASSERT(stub->next_code_link()->IsUndefined()); |
| 11543 int n = dependent_code()->number_of_entries(DependentCode::kWeakICGroup); |
| 11544 if (n == 0) { |
| 11545 // Slow path: insert the head of the list with possible heap allocation. |
| 11546 AddDependentCode(DependentCode::kWeakICGroup, stub); |
| 11547 } else { |
| 11548 // Fast path: link the stub to the existing head of the list without any |
| 11549 // heap allocation. |
| 11550 ASSERT(n == 1); |
| 11551 dependent_code()->AddToDependentICList(stub); |
| 11552 } |
| 11553 } |
| 11554 |
| 11555 |
11541 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { | 11556 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { |
11542 Recompute(entries); | 11557 Recompute(entries); |
11543 } | 11558 } |
11544 | 11559 |
11545 | 11560 |
11546 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { | 11561 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { |
11547 start_indexes_[0] = 0; | 11562 start_indexes_[0] = 0; |
11548 for (int g = 1; g <= kGroupCount; g++) { | 11563 for (int g = 1; g <= kGroupCount; g++) { |
11549 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); | 11564 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); |
11550 start_indexes_[g] = start_indexes_[g - 1] + count; | 11565 start_indexes_[g] = start_indexes_[g - 1] + count; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11661 set_number_of_entries(group, end - start - 1); | 11676 set_number_of_entries(group, end - start - 1); |
11662 | 11677 |
11663 #ifdef DEBUG | 11678 #ifdef DEBUG |
11664 for (int i = start; i < end - 1; i++) { | 11679 for (int i = start; i < end - 1; i++) { |
11665 ASSERT(is_code_at(i) || compilation_info_at(i) != info); | 11680 ASSERT(is_code_at(i) || compilation_info_at(i) != info); |
11666 } | 11681 } |
11667 #endif | 11682 #endif |
11668 } | 11683 } |
11669 | 11684 |
11670 | 11685 |
| 11686 static bool CodeListContains(Object* head, Code* code) { |
| 11687 while (!head->IsUndefined()) { |
| 11688 if (head == code) return true; |
| 11689 head = Code::cast(head)->next_code_link(); |
| 11690 } |
| 11691 return false; |
| 11692 } |
| 11693 |
| 11694 |
11671 bool DependentCode::Contains(DependencyGroup group, Code* code) { | 11695 bool DependentCode::Contains(DependencyGroup group, Code* code) { |
11672 GroupStartIndexes starts(this); | 11696 GroupStartIndexes starts(this); |
11673 int start = starts.at(group); | 11697 int start = starts.at(group); |
11674 int end = starts.at(group + 1); | 11698 int end = starts.at(group + 1); |
| 11699 if (group == kWeakICGroup) { |
| 11700 return CodeListContains(object_at(start), code); |
| 11701 } |
11675 for (int i = start; i < end; i++) { | 11702 for (int i = start; i < end; i++) { |
11676 if (object_at(i) == code) return true; | 11703 if (object_at(i) == code) return true; |
11677 } | 11704 } |
11678 return false; | 11705 return false; |
11679 } | 11706 } |
11680 | 11707 |
11681 | 11708 |
11682 bool DependentCode::MarkCodeForDeoptimization( | 11709 bool DependentCode::MarkCodeForDeoptimization( |
11683 Isolate* isolate, | 11710 Isolate* isolate, |
11684 DependentCode::DependencyGroup group) { | 11711 DependentCode::DependencyGroup group) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11721 Isolate* isolate, | 11748 Isolate* isolate, |
11722 DependentCode::DependencyGroup group) { | 11749 DependentCode::DependencyGroup group) { |
11723 ASSERT(AllowCodeDependencyChange::IsAllowed()); | 11750 ASSERT(AllowCodeDependencyChange::IsAllowed()); |
11724 DisallowHeapAllocation no_allocation_scope; | 11751 DisallowHeapAllocation no_allocation_scope; |
11725 bool marked = MarkCodeForDeoptimization(isolate, group); | 11752 bool marked = MarkCodeForDeoptimization(isolate, group); |
11726 | 11753 |
11727 if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate); | 11754 if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate); |
11728 } | 11755 } |
11729 | 11756 |
11730 | 11757 |
| 11758 void DependentCode::AddToDependentICList(Handle<Code> stub) { |
| 11759 DisallowHeapAllocation no_heap_allocation; |
| 11760 GroupStartIndexes starts(this); |
| 11761 int i = starts.at(kWeakICGroup); |
| 11762 stub->set_next_code_link(object_at(i)); |
| 11763 set_object_at(i, *stub); |
| 11764 } |
| 11765 |
| 11766 |
11731 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object, | 11767 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object, |
11732 Handle<Object> value, | 11768 Handle<Object> value, |
11733 bool skip_hidden_prototypes) { | 11769 bool skip_hidden_prototypes) { |
11734 #ifdef DEBUG | 11770 #ifdef DEBUG |
11735 int size = object->Size(); | 11771 int size = object->Size(); |
11736 #endif | 11772 #endif |
11737 | 11773 |
11738 Isolate* isolate = object->GetIsolate(); | 11774 Isolate* isolate = object->GetIsolate(); |
11739 Heap* heap = isolate->heap(); | 11775 Heap* heap = isolate->heap(); |
11740 // Silently ignore the change if value is not a JSObject or null. | 11776 // Silently ignore the change if value is not a JSObject or null. |
(...skipping 4860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16601 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16637 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16602 static const char* error_messages_[] = { | 16638 static const char* error_messages_[] = { |
16603 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16639 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16604 }; | 16640 }; |
16605 #undef ERROR_MESSAGES_TEXTS | 16641 #undef ERROR_MESSAGES_TEXTS |
16606 return error_messages_[reason]; | 16642 return error_messages_[reason]; |
16607 } | 16643 } |
16608 | 16644 |
16609 | 16645 |
16610 } } // namespace v8::internal | 16646 } } // namespace v8::internal |
OLD | NEW |