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

Side by Side Diff: src/mark-compact.cc

Issue 101853003: Cache optimized code for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 candidate = next_candidate; 1060 candidate = next_candidate;
1061 } 1061 }
1062 1062
1063 shared_function_info_candidates_head_ = NULL; 1063 shared_function_info_candidates_head_ = NULL;
1064 } 1064 }
1065 1065
1066 1066
1067 void CodeFlusher::ProcessOptimizedCodeMaps() { 1067 void CodeFlusher::ProcessOptimizedCodeMaps() {
1068 static const int kEntriesStart = SharedFunctionInfo::kEntriesStart; 1068 static const int kEntriesStart = SharedFunctionInfo::kEntriesStart;
1069 static const int kEntryLength = SharedFunctionInfo::kEntryLength; 1069 static const int kEntryLength = SharedFunctionInfo::kEntryLength;
1070 static const int kContextOffset = 0; 1070 static const int kContextOffset = SharedFunctionInfo::kContextOffset;
titzer 2013/12/16 11:59:34 Duplicated constants for code shortitude below. Pr
1071 static const int kCodeOffset = 1; 1071 static const int kCodeOffset = SharedFunctionInfo::kCachedCodeOffset;
1072 static const int kLiteralsOffset = 2; 1072 static const int kLiteralsOffset = SharedFunctionInfo::kLiteralsOffset;
1073 STATIC_ASSERT(kEntryLength == 3); 1073 static const int kOsrAstIdOffset = SharedFunctionInfo::kOsrAstIdOffset;
1074 STATIC_ASSERT(kEntryLength == 4);
1074 1075
1075 SharedFunctionInfo* holder = optimized_code_map_holder_head_; 1076 SharedFunctionInfo* holder = optimized_code_map_holder_head_;
1076 SharedFunctionInfo* next_holder; 1077 SharedFunctionInfo* next_holder;
1077 while (holder != NULL) { 1078 while (holder != NULL) {
1078 next_holder = GetNextCodeMap(holder); 1079 next_holder = GetNextCodeMap(holder);
1079 ClearNextCodeMap(holder); 1080 ClearNextCodeMap(holder);
1080 1081
1081 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); 1082 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map());
1082 int new_length = kEntriesStart; 1083 int new_length = kEntriesStart;
1083 int old_length = code_map->length(); 1084 int old_length = code_map->length();
1084 for (int i = kEntriesStart; i < old_length; i += kEntryLength) { 1085 for (int i = kEntriesStart; i < old_length; i += kEntryLength) {
1085 Code* code = Code::cast(code_map->get(i + kCodeOffset)); 1086 Code* code = Code::cast(code_map->get(i + kCodeOffset));
1086 MarkBit code_mark = Marking::MarkBitFrom(code); 1087 MarkBit code_mark = Marking::MarkBitFrom(code);
1087 if (!code_mark.Get()) { 1088 if (!code_mark.Get()) {
1088 continue; 1089 continue;
1089 } 1090 }
1090 1091
1091 // Update and record the context slot in the optimized code map. 1092 // Update and record the context slot in the optimized code map.
1092 Object** context_slot = HeapObject::RawField(code_map, 1093 Object** context_slot = HeapObject::RawField(code_map,
titzer 2013/12/16 11:59:34 Ack, this code is horrible; can we please extract
1093 FixedArray::OffsetOfElementAt(new_length)); 1094 FixedArray::OffsetOfElementAt(new_length));
1094 code_map->set(new_length++, code_map->get(i + kContextOffset)); 1095 code_map->set(new_length++, code_map->get(i + kContextOffset));
1095 ASSERT(Marking::IsBlack( 1096 ASSERT(Marking::IsBlack(
1096 Marking::MarkBitFrom(HeapObject::cast(*context_slot)))); 1097 Marking::MarkBitFrom(HeapObject::cast(*context_slot))));
1097 isolate_->heap()->mark_compact_collector()-> 1098 isolate_->heap()->mark_compact_collector()->
1098 RecordSlot(context_slot, context_slot, *context_slot); 1099 RecordSlot(context_slot, context_slot, *context_slot);
1099 1100
1100 // Update and record the code slot in the optimized code map. 1101 // Update and record the code slot in the optimized code map.
1101 Object** code_slot = HeapObject::RawField(code_map, 1102 Object** code_slot = HeapObject::RawField(code_map,
1102 FixedArray::OffsetOfElementAt(new_length)); 1103 FixedArray::OffsetOfElementAt(new_length));
1103 code_map->set(new_length++, code_map->get(i + kCodeOffset)); 1104 code_map->set(new_length++, code_map->get(i + kCodeOffset));
1104 ASSERT(Marking::IsBlack( 1105 ASSERT(Marking::IsBlack(
1105 Marking::MarkBitFrom(HeapObject::cast(*code_slot)))); 1106 Marking::MarkBitFrom(HeapObject::cast(*code_slot))));
1106 isolate_->heap()->mark_compact_collector()-> 1107 isolate_->heap()->mark_compact_collector()->
1107 RecordSlot(code_slot, code_slot, *code_slot); 1108 RecordSlot(code_slot, code_slot, *code_slot);
1108 1109
1109 // Update and record the literals slot in the optimized code map. 1110 // Update and record the literals slot in the optimized code map.
1110 Object** literals_slot = HeapObject::RawField(code_map, 1111 Object** literals_slot = HeapObject::RawField(code_map,
1111 FixedArray::OffsetOfElementAt(new_length)); 1112 FixedArray::OffsetOfElementAt(new_length));
1112 code_map->set(new_length++, code_map->get(i + kLiteralsOffset)); 1113 code_map->set(new_length++, code_map->get(i + kLiteralsOffset));
1113 ASSERT(Marking::IsBlack( 1114 ASSERT(Marking::IsBlack(
1114 Marking::MarkBitFrom(HeapObject::cast(*literals_slot)))); 1115 Marking::MarkBitFrom(HeapObject::cast(*literals_slot))));
1115 isolate_->heap()->mark_compact_collector()-> 1116 isolate_->heap()->mark_compact_collector()->
1116 RecordSlot(literals_slot, literals_slot, *literals_slot); 1117 RecordSlot(literals_slot, literals_slot, *literals_slot);
1118
1119 // Update OSR AST id. No write barrier necessary for a smi.
1120 ASSERT(code_map->get(i + kOsrAstIdOffset)->IsSmi());
1121 code_map->set(new_length++, code_map->get(i + kOsrAstIdOffset));
1117 } 1122 }
1118 1123
1119 // Trim the optimized code map if entries have been removed. 1124 // Trim the optimized code map if entries have been removed.
1120 if (new_length < old_length) { 1125 if (new_length < old_length) {
1121 holder->TrimOptimizedCodeMap(old_length - new_length); 1126 holder->TrimOptimizedCodeMap(old_length - new_length);
1122 } 1127 }
1123 1128
1124 holder = next_holder; 1129 holder = next_holder;
1125 } 1130 }
1126 1131
(...skipping 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4363 while (buffer != NULL) { 4368 while (buffer != NULL) {
4364 SlotsBuffer* next_buffer = buffer->next(); 4369 SlotsBuffer* next_buffer = buffer->next();
4365 DeallocateBuffer(buffer); 4370 DeallocateBuffer(buffer);
4366 buffer = next_buffer; 4371 buffer = next_buffer;
4367 } 4372 }
4368 *buffer_address = NULL; 4373 *buffer_address = NULL;
4369 } 4374 }
4370 4375
4371 4376
4372 } } // namespace v8::internal 4377 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/objects.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698