Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects.cc

Issue 188783003: Make maps in monomorphic IC stubs weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Move the head of dependent IC to dependent code Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11517 matching lines...) Expand 10 before | Expand all | Expand 10 after
11528 11528
11529 11529
11530 void Map::AddDependentCode(DependentCode::DependencyGroup group, 11530 void Map::AddDependentCode(DependentCode::DependencyGroup group,
11531 Handle<Code> code) { 11531 Handle<Code> code) {
11532 Handle<DependentCode> codes = DependentCode::Insert( 11532 Handle<DependentCode> codes = DependentCode::Insert(
11533 Handle<DependentCode>(dependent_code()), group, code); 11533 Handle<DependentCode>(dependent_code()), group, code);
11534 if (*codes != dependent_code()) set_dependent_code(*codes); 11534 if (*codes != dependent_code()) set_dependent_code(*codes);
11535 } 11535 }
11536 11536
11537 11537
11538 void Map::AddDependentIC(Handle<Code> stub) {
11539 ASSERT(stub->next_code_link()->IsUndefined());
11540 int n = dependent_code()->number_of_entries(DependentCode::kWeakICGroup);
11541 if (n == 0) {
11542 // Slow path: insert the head of the list with possible heap allocation.
11543 AddDependentCode(DependentCode::kWeakICGroup, stub);
11544 } else {
11545 // Fast path: link the stub to the existing head of the list without any
11546 // heap allocation.
11547 ASSERT(n == 1);
11548 dependent_code()->AddToDependentICList(stub);
11549 }
11550 }
11551
11552
11538 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { 11553 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) {
11539 Recompute(entries); 11554 Recompute(entries);
11540 } 11555 }
11541 11556
11542 11557
11543 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { 11558 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) {
11544 start_indexes_[0] = 0; 11559 start_indexes_[0] = 0;
11545 for (int g = 1; g <= kGroupCount; g++) { 11560 for (int g = 1; g <= kGroupCount; g++) {
11546 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); 11561 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1));
11547 start_indexes_[g] = start_indexes_[g - 1] + count; 11562 start_indexes_[g] = start_indexes_[g - 1] + count;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
11658 set_number_of_entries(group, end - start - 1); 11673 set_number_of_entries(group, end - start - 1);
11659 11674
11660 #ifdef DEBUG 11675 #ifdef DEBUG
11661 for (int i = start; i < end - 1; i++) { 11676 for (int i = start; i < end - 1; i++) {
11662 ASSERT(is_code_at(i) || compilation_info_at(i) != info); 11677 ASSERT(is_code_at(i) || compilation_info_at(i) != info);
11663 } 11678 }
11664 #endif 11679 #endif
11665 } 11680 }
11666 11681
11667 11682
11683 static bool CodeListContains(Object* head, Code* code) {
11684 while (!head->IsUndefined()) {
11685 if (head == code) return true;
11686 head = Code::cast(head)->next_code_link();
11687 }
11688 return false;
11689 }
11690
11691
11668 bool DependentCode::Contains(DependencyGroup group, Code* code) { 11692 bool DependentCode::Contains(DependencyGroup group, Code* code) {
11669 GroupStartIndexes starts(this); 11693 GroupStartIndexes starts(this);
11670 int start = starts.at(group); 11694 int start = starts.at(group);
11671 int end = starts.at(group + 1); 11695 int end = starts.at(group + 1);
11696 if (group == kWeakICGroup) {
11697 return CodeListContains(object_at(start), code);
11698 }
11672 for (int i = start; i < end; i++) { 11699 for (int i = start; i < end; i++) {
11673 if (object_at(i) == code) return true; 11700 if (object_at(i) == code) return true;
11674 } 11701 }
11675 return false; 11702 return false;
11676 } 11703 }
11677 11704
11678 11705
11679 bool DependentCode::MarkCodeForDeoptimization( 11706 bool DependentCode::MarkCodeForDeoptimization(
11680 Isolate* isolate, 11707 Isolate* isolate,
11681 DependentCode::DependencyGroup group) { 11708 DependentCode::DependencyGroup group) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
11718 Isolate* isolate, 11745 Isolate* isolate,
11719 DependentCode::DependencyGroup group) { 11746 DependentCode::DependencyGroup group) {
11720 ASSERT(AllowCodeDependencyChange::IsAllowed()); 11747 ASSERT(AllowCodeDependencyChange::IsAllowed());
11721 DisallowHeapAllocation no_allocation_scope; 11748 DisallowHeapAllocation no_allocation_scope;
11722 bool marked = MarkCodeForDeoptimization(isolate, group); 11749 bool marked = MarkCodeForDeoptimization(isolate, group);
11723 11750
11724 if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate); 11751 if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate);
11725 } 11752 }
11726 11753
11727 11754
11755 void DependentCode::AddToDependentICList(Handle<Code> stub) {
11756 DisallowHeapAllocation no_heap_allocation;
11757 GroupStartIndexes starts(this);
11758 int i = starts.at(kWeakICGroup);
11759 stub->set_next_code_link(object_at(i));
11760 set_object_at(i, *stub);
11761 }
11762
11763
11728 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object, 11764 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
11729 Handle<Object> value, 11765 Handle<Object> value,
11730 bool skip_hidden_prototypes) { 11766 bool skip_hidden_prototypes) {
11731 #ifdef DEBUG 11767 #ifdef DEBUG
11732 int size = object->Size(); 11768 int size = object->Size();
11733 #endif 11769 #endif
11734 11770
11735 Isolate* isolate = object->GetIsolate(); 11771 Isolate* isolate = object->GetIsolate();
11736 Heap* heap = isolate->heap(); 11772 Heap* heap = isolate->heap();
11737 // Silently ignore the change if value is not a JSObject or null. 11773 // Silently ignore the change if value is not a JSObject or null.
(...skipping 4723 matching lines...) Expand 10 before | Expand all | Expand 10 after
16461 #define ERROR_MESSAGES_TEXTS(C, T) T, 16497 #define ERROR_MESSAGES_TEXTS(C, T) T,
16462 static const char* error_messages_[] = { 16498 static const char* error_messages_[] = {
16463 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16499 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16464 }; 16500 };
16465 #undef ERROR_MESSAGES_TEXTS 16501 #undef ERROR_MESSAGES_TEXTS
16466 return error_messages_[reason]; 16502 return error_messages_[reason];
16467 } 16503 }
16468 16504
16469 16505
16470 } } // namespace v8::internal 16506 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698