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

Side by Side Diff: src/objects.cc

Issue 16542003: Enable map dependency to in-flight compilation info. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: put transition maps and initial maps dependency into a separate CL Created 7 years, 6 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 11072 matching lines...) Expand 10 before | Expand all | Expand 10 after
11083 11083
11084 11084
11085 void Map::ZapPrototypeTransitions() { 11085 void Map::ZapPrototypeTransitions() {
11086 FixedArray* proto_transitions = GetPrototypeTransitions(); 11086 FixedArray* proto_transitions = GetPrototypeTransitions();
11087 MemsetPointer(proto_transitions->data_start(), 11087 MemsetPointer(proto_transitions->data_start(),
11088 GetHeap()->the_hole_value(), 11088 GetHeap()->the_hole_value(),
11089 proto_transitions->length()); 11089 proto_transitions->length());
11090 } 11090 }
11091 11091
11092 11092
11093 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group,
11094 CompilationInfo* info) {
11095 Handle<DependentCode> codes = DependentCode::Insert(
11096 Handle<DependentCode>(dependent_code()), group, info->object_wrapper());
11097 if (*codes != dependent_code()) set_dependent_code(*codes);
11098 info->dependent_maps(group)->Add(Handle<Map>(this), info->zone());
ulan 2013/06/07 13:21:29 Note that this can add duplicate maps into depende
11099 }
11100
11101
11102 void Map::AddDependentCode(DependentCode::DependencyGroup group,
11103 Handle<Code> code) {
11104 Handle<DependentCode> codes = DependentCode::Insert(
11105 Handle<DependentCode>(dependent_code()), group, code);
11106 if (*codes != dependent_code()) set_dependent_code(*codes);
11107 }
11108
11109
11093 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { 11110 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) {
11094 Recompute(entries); 11111 Recompute(entries);
11095 } 11112 }
11096 11113
11097 11114
11098 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { 11115 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) {
11099 start_indexes_[0] = 0; 11116 start_indexes_[0] = 0;
11100 for (int g = 1; g <= kGroupCount; g++) { 11117 for (int g = 1; g <= kGroupCount; g++) {
11101 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); 11118 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1));
11102 start_indexes_[g] = start_indexes_[g - 1] + count; 11119 start_indexes_[g] = start_indexes_[g - 1] + count;
11103 } 11120 }
11104 } 11121 }
11105 11122
11106 11123
11107 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, 11124 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
11108 DependencyGroup group, 11125 DependencyGroup group,
11109 Handle<Code> value) { 11126 Handle<Object> object) {
11110 GroupStartIndexes starts(*entries); 11127 GroupStartIndexes starts(*entries);
11111 int start = starts.at(group); 11128 int start = starts.at(group);
11112 int end = starts.at(group + 1); 11129 int end = starts.at(group + 1);
11113 int number_of_entries = starts.number_of_entries(); 11130 int number_of_entries = starts.number_of_entries();
11114 if (start < end && entries->code_at(end - 1) == *value) { 11131 if (start < end && entries->object_at(end - 1) == *object) {
11115 // Do not append the code if it is already in the array. 11132 // Do not append the compilation info if it is already in the array.
11116 // It is sufficient to just check only the last element because 11133 // It is sufficient to just check only the last element because
11117 // we process embedded maps of an optimized code in one batch. 11134 // we process embedded maps of an optimized code in one batch.
11118 return entries; 11135 return entries;
11119 } 11136 }
11120 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { 11137 if (entries->length() < kCodesStartIndex + number_of_entries + 1) {
11121 Factory* factory = entries->GetIsolate()->factory(); 11138 Factory* factory = entries->GetIsolate()->factory();
11122 int capacity = kCodesStartIndex + number_of_entries + 1; 11139 int capacity = kCodesStartIndex + number_of_entries + 1;
11123 if (capacity > 5) capacity = capacity * 5 / 4; 11140 if (capacity > 5) capacity = capacity * 5 / 4;
11124 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( 11141 Handle<DependentCode> new_entries = Handle<DependentCode>::cast(
11125 factory->CopySizeFixedArray(entries, capacity)); 11142 factory->CopySizeFixedArray(entries, capacity));
11126 // The number of codes can change after GC. 11143 // The number of codes can change after GC.
11127 starts.Recompute(*entries); 11144 starts.Recompute(*entries);
11128 start = starts.at(group); 11145 start = starts.at(group);
11129 end = starts.at(group + 1); 11146 end = starts.at(group + 1);
11130 number_of_entries = starts.number_of_entries(); 11147 number_of_entries = starts.number_of_entries();
11131 for (int i = 0; i < number_of_entries; i++) { 11148 for (int i = 0; i < number_of_entries; i++) {
11132 entries->clear_code_at(i); 11149 entries->clear_at(i);
11133 } 11150 }
11134 // If the old fixed array was empty, we need to reset counters of the 11151 // If the old fixed array was empty, we need to reset counters of the
11135 // new array. 11152 // new array.
11136 if (number_of_entries == 0) { 11153 if (number_of_entries == 0) {
11137 for (int g = 0; g < kGroupCount; g++) { 11154 for (int g = 0; g < kGroupCount; g++) {
11138 new_entries->set_number_of_entries(static_cast<DependencyGroup>(g), 0); 11155 new_entries->set_number_of_entries(static_cast<DependencyGroup>(g), 0);
11139 } 11156 }
11140 } 11157 }
11141 entries = new_entries; 11158 entries = new_entries;
11142 } 11159 }
11143 entries->ExtendGroup(group); 11160 entries->ExtendGroup(group);
11144 entries->set_code_at(end, *value); 11161 entries->set_object_at(end, *object);
11145 entries->set_number_of_entries(group, end + 1 - start); 11162 entries->set_number_of_entries(group, end + 1 - start);
11146 return entries; 11163 return entries;
11147 } 11164 }
11148 11165
11149 11166
11167 void DependentCode::UpdateToFinishedCode(DependencyGroup group,
11168 CompilationInfo* info,
11169 Code* code) {
11170 DisallowHeapAllocation no_gc;
11171 AllowDeferredHandleDereference get_object_wrapper;
11172 Foreign* info_wrapper = *info->object_wrapper();
11173 GroupStartIndexes starts(this);
11174 int start = starts.at(group);
11175 int end = starts.at(group + 1);
11176 for (int i = start; i < end; i++) {
11177 if (object_at(i) == info_wrapper) {
11178 set_object_at(i, code);
11179 break;
11180 }
11181 }
11182
11183 #ifdef DEBUG
11184 for (int i = start; i < end; i++) {
11185 ASSERT(is_code_at(i) || compilation_info_at(i) != info);
11186 }
11187 #endif
11188 }
11189
11190
11191 void DependentCode::RemoveCompilationInfo(DependentCode::DependencyGroup group,
11192 CompilationInfo* info) {
11193 DisallowHeapAllocation no_allocation;
11194 AllowDeferredHandleDereference get_object_wrapper;
11195 Foreign* info_wrapper = *info->object_wrapper();
11196 GroupStartIndexes starts(this);
11197 int start = starts.at(group);
11198 int end = starts.at(group + 1);
11199 // Find compilation info wrapper.
11200 int info_pos = -1;
11201 for (int i = start; i < end; i++) {
11202 if (object_at(i) == info_wrapper) {
11203 info_pos = i;
11204 break;
11205 }
11206 }
11207 if (info_pos == -1) return; // Not found.
11208 int gap = info_pos;
11209 // Use the last of each group to fill the gap in the previous group.
11210 for (int i = group; i < kGroupCount; i++) {
11211 int last_of_group = starts.at(group + 1) - 1;
11212 ASSERT(last_of_group >= gap);
11213 if (last_of_group == gap) continue;
11214 copy(last_of_group, gap);
11215 gap = last_of_group;
11216 }
11217 clear_at(gap); // Clear last gap.
11218 set_number_of_entries(group, end - start - 1);
11219
11220 #ifdef DEBUG
11221 for (int i = start; i < end - 1; i++) {
11222 ASSERT(is_code_at(i) || compilation_info_at(i) != info);
11223 }
11224 #endif
11225 }
11226
11227
11150 bool DependentCode::Contains(DependencyGroup group, Code* code) { 11228 bool DependentCode::Contains(DependencyGroup group, Code* code) {
11151 GroupStartIndexes starts(this); 11229 GroupStartIndexes starts(this);
11152 int number_of_entries = starts.at(kGroupCount); 11230 int number_of_entries = starts.number_of_code_entries();
11153 for (int i = 0; i < number_of_entries; i++) { 11231 for (int i = 0; i < number_of_entries; i++) {
11154 if (code_at(i) == code) return true; 11232 if (object_at(i) == code) return true;
11155 } 11233 }
11156 return false; 11234 return false;
11157 } 11235 }
11158 11236
11159 11237
11160 class DeoptimizeDependentCodeFilter : public OptimizedFunctionFilter { 11238 class DeoptimizeDependentCodeFilter : public OptimizedFunctionFilter {
11161 public: 11239 public:
11162 virtual bool TakeFunction(JSFunction* function) { 11240 virtual bool TakeFunction(JSFunction* function) {
11163 return function->code()->marked_for_deoptimization(); 11241 return function->code()->marked_for_deoptimization();
11164 } 11242 }
11165 }; 11243 };
11166 11244
11167 11245
11168 void DependentCode::DeoptimizeDependentCodeGroup( 11246 void DependentCode::DeoptimizeDependentCodeGroup(
11169 Isolate* isolate, 11247 Isolate* isolate,
11170 DependentCode::DependencyGroup group) { 11248 DependentCode::DependencyGroup group) {
11171 DisallowHeapAllocation no_allocation_scope; 11249 DisallowHeapAllocation no_allocation_scope;
11172 DependentCode::GroupStartIndexes starts(this); 11250 DependentCode::GroupStartIndexes starts(this);
11173 int start = starts.at(group); 11251 int start = starts.at(group);
11174 int end = starts.at(group + 1); 11252 int end = starts.at(group + 1);
11175 int number_of_entries = starts.at(DependentCode::kGroupCount); 11253 int code_entries = starts.number_of_code_entries();
11176 if (start == end) return; 11254 if (start == end) return;
11177 for (int i = start; i < end; i++) { 11255 for (int i = start; i < end; i++) {
11178 Code* code = code_at(i); 11256 if (is_code_at(i)) {
11179 code->set_marked_for_deoptimization(true); 11257 Code* code = code_at(i);
11258 code->set_marked_for_deoptimization(true);
11259 } else {
11260 CompilationInfo* info = compilation_info_at(i);
11261 info->AbortDueToDependentMap();
11262 }
11180 } 11263 }
11181 // Compact the array by moving all subsequent groups to fill in the new holes. 11264 // Compact the array by moving all subsequent groups to fill in the new holes.
11182 for (int src = end, dst = start; src < number_of_entries; src++, dst++) { 11265 for (int src = end, dst = start; src < code_entries; src++, dst++) {
11183 set_code_at(dst, code_at(src)); 11266 copy(src, dst);
11184 } 11267 }
11185 // Now the holes are at the end of the array, zap them for heap-verifier. 11268 // Now the holes are at the end of the array, zap them for heap-verifier.
11186 int removed = end - start; 11269 int removed = end - start;
11187 for (int i = number_of_entries - removed; i < number_of_entries; i++) { 11270 for (int i = code_entries - removed; i < code_entries; i++) {
11188 clear_code_at(i); 11271 clear_at(i);
11189 } 11272 }
11190 set_number_of_entries(group, 0); 11273 set_number_of_entries(group, 0);
11191 DeoptimizeDependentCodeFilter filter; 11274 DeoptimizeDependentCodeFilter filter;
11192 Deoptimizer::DeoptimizeAllFunctionsWith(isolate, &filter); 11275 Deoptimizer::DeoptimizeAllFunctionsWith(isolate, &filter);
11193 } 11276 }
11194 11277
11195 11278
11196 MaybeObject* JSReceiver::SetPrototype(Object* value, 11279 MaybeObject* JSReceiver::SetPrototype(Object* value,
11197 bool skip_hidden_prototypes) { 11280 bool skip_hidden_prototypes) {
11198 #ifdef DEBUG 11281 #ifdef DEBUG
(...skipping 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after
15688 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15771 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15689 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15772 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15690 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15773 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15691 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15774 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15692 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15775 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15693 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15776 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15694 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15777 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15695 } 15778 }
15696 15779
15697 } } // namespace v8::internal 15780 } } // namespace v8::internal
OLDNEW
« src/compiler.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698