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

Side by Side Diff: src/objects.cc

Issue 16782004: Reland "Enable map dependency to in-flight compilation info." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: The fix. 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11073 matching lines...) Expand 10 before | Expand all | Expand 10 after
11084 11084
11085 11085
11086 void Map::ZapPrototypeTransitions() { 11086 void Map::ZapPrototypeTransitions() {
11087 FixedArray* proto_transitions = GetPrototypeTransitions(); 11087 FixedArray* proto_transitions = GetPrototypeTransitions();
11088 MemsetPointer(proto_transitions->data_start(), 11088 MemsetPointer(proto_transitions->data_start(),
11089 GetHeap()->the_hole_value(), 11089 GetHeap()->the_hole_value(),
11090 proto_transitions->length()); 11090 proto_transitions->length());
11091 } 11091 }
11092 11092
11093 11093
11094 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group,
11095 CompilationInfo* info) {
11096 Handle<DependentCode> dep(dependent_code());
11097 Handle<DependentCode> codes =
11098 DependentCode::Insert(dep, group, info->object_wrapper());
11099 if (*codes != dependent_code()) set_dependent_code(*codes);
11100 info->dependent_maps(group)->Add(Handle<Map>(this), info->zone());
11101 }
11102
11103
11104 void Map::AddDependentCode(DependentCode::DependencyGroup group,
11105 Handle<Code> code) {
11106 Handle<DependentCode> codes = DependentCode::Insert(
11107 Handle<DependentCode>(dependent_code()), group, code);
11108 if (*codes != dependent_code()) set_dependent_code(*codes);
11109 }
11110
11111
11094 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { 11112 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) {
11095 Recompute(entries); 11113 Recompute(entries);
11096 } 11114 }
11097 11115
11098 11116
11099 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { 11117 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) {
11100 start_indexes_[0] = 0; 11118 start_indexes_[0] = 0;
11101 for (int g = 1; g <= kGroupCount; g++) { 11119 for (int g = 1; g <= kGroupCount; g++) {
11102 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); 11120 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1));
11103 start_indexes_[g] = start_indexes_[g - 1] + count; 11121 start_indexes_[g] = start_indexes_[g - 1] + count;
11104 } 11122 }
11105 } 11123 }
11106 11124
11107 11125
11108 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, 11126 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
11109 DependencyGroup group, 11127 DependencyGroup group,
11110 Handle<Code> value) { 11128 Handle<Object> object) {
11111 GroupStartIndexes starts(*entries); 11129 GroupStartIndexes starts(*entries);
11112 int start = starts.at(group); 11130 int start = starts.at(group);
11113 int end = starts.at(group + 1); 11131 int end = starts.at(group + 1);
11114 int number_of_entries = starts.number_of_entries(); 11132 int number_of_entries = starts.number_of_entries();
11115 if (start < end && entries->code_at(end - 1) == *value) { 11133 if (start < end && entries->object_at(end - 1) == *object) {
11116 // Do not append the code if it is already in the array. 11134 // Do not append the compilation info if it is already in the array.
11117 // It is sufficient to just check only the last element because 11135 // It is sufficient to just check only the last element because
11118 // we process embedded maps of an optimized code in one batch. 11136 // we process embedded maps of an optimized code in one batch.
11119 return entries; 11137 return entries;
11120 } 11138 }
11121 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { 11139 if (entries->length() < kCodesStartIndex + number_of_entries + 1) {
11122 Factory* factory = entries->GetIsolate()->factory(); 11140 Factory* factory = entries->GetIsolate()->factory();
11123 int capacity = kCodesStartIndex + number_of_entries + 1; 11141 int capacity = kCodesStartIndex + number_of_entries + 1;
11124 if (capacity > 5) capacity = capacity * 5 / 4; 11142 if (capacity > 5) capacity = capacity * 5 / 4;
11125 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( 11143 Handle<DependentCode> new_entries = Handle<DependentCode>::cast(
11126 factory->CopySizeFixedArray(entries, capacity)); 11144 factory->CopySizeFixedArray(entries, capacity));
11127 // The number of codes can change after GC. 11145 // The number of codes can change after GC.
11128 starts.Recompute(*entries); 11146 starts.Recompute(*entries);
11129 start = starts.at(group); 11147 start = starts.at(group);
11130 end = starts.at(group + 1); 11148 end = starts.at(group + 1);
11131 number_of_entries = starts.number_of_entries(); 11149 number_of_entries = starts.number_of_entries();
11132 for (int i = 0; i < number_of_entries; i++) { 11150 for (int i = 0; i < number_of_entries; i++) {
11133 entries->clear_code_at(i); 11151 entries->clear_at(i);
11134 } 11152 }
11135 // If the old fixed array was empty, we need to reset counters of the 11153 // If the old fixed array was empty, we need to reset counters of the
11136 // new array. 11154 // new array.
11137 if (number_of_entries == 0) { 11155 if (number_of_entries == 0) {
11138 for (int g = 0; g < kGroupCount; g++) { 11156 for (int g = 0; g < kGroupCount; g++) {
11139 new_entries->set_number_of_entries(static_cast<DependencyGroup>(g), 0); 11157 new_entries->set_number_of_entries(static_cast<DependencyGroup>(g), 0);
11140 } 11158 }
11141 } 11159 }
11142 entries = new_entries; 11160 entries = new_entries;
11143 } 11161 }
11144 entries->ExtendGroup(group); 11162 entries->ExtendGroup(group);
11145 entries->set_code_at(end, *value); 11163 entries->set_object_at(end, *object);
11146 entries->set_number_of_entries(group, end + 1 - start); 11164 entries->set_number_of_entries(group, end + 1 - start);
11147 return entries; 11165 return entries;
11148 } 11166 }
11149 11167
11150 11168
11169 void DependentCode::UpdateToFinishedCode(DependencyGroup group,
11170 CompilationInfo* info,
11171 Code* code) {
11172 DisallowHeapAllocation no_gc;
11173 AllowDeferredHandleDereference get_object_wrapper;
11174 Foreign* info_wrapper = *info->object_wrapper();
11175 GroupStartIndexes starts(this);
11176 int start = starts.at(group);
11177 int end = starts.at(group + 1);
11178 for (int i = start; i < end; i++) {
11179 if (object_at(i) == info_wrapper) {
11180 set_object_at(i, code);
11181 break;
11182 }
11183 }
11184
11185 #ifdef DEBUG
11186 for (int i = start; i < end; i++) {
11187 ASSERT(is_code_at(i) || compilation_info_at(i) != info);
11188 }
11189 #endif
11190 }
11191
11192
11193 void DependentCode::RemoveCompilationInfo(DependentCode::DependencyGroup group,
11194 CompilationInfo* info) {
11195 DisallowHeapAllocation no_allocation;
11196 AllowDeferredHandleDereference get_object_wrapper;
11197 Foreign* info_wrapper = *info->object_wrapper();
11198 GroupStartIndexes starts(this);
11199 int start = starts.at(group);
11200 int end = starts.at(group + 1);
11201 // Find compilation info wrapper.
11202 int info_pos = -1;
11203 for (int i = start; i < end; i++) {
11204 if (object_at(i) == info_wrapper) {
11205 info_pos = i;
11206 break;
11207 }
11208 }
11209 if (info_pos == -1) return; // Not found.
11210 int gap = info_pos;
11211 // Use the last of each group to fill the gap in the previous group.
11212 for (int i = group; i < kGroupCount; i++) {
11213 int last_of_group = starts.at(i + 1) - 1;
11214 ASSERT(last_of_group >= gap);
11215 if (last_of_group == gap) continue;
11216 copy(last_of_group, gap);
11217 gap = last_of_group;
11218 }
11219 ASSERT(gap == starts.number_of_entries() - 1);
11220 clear_at(gap); // Clear last gap.
11221 set_number_of_entries(group, end - start - 1);
11222
11223 #ifdef DEBUG
11224 for (int i = start; i < end - 1; i++) {
11225 ASSERT(is_code_at(i) || compilation_info_at(i) != info);
11226 }
11227 #endif
11228 }
11229
11230
11151 bool DependentCode::Contains(DependencyGroup group, Code* code) { 11231 bool DependentCode::Contains(DependencyGroup group, Code* code) {
11152 GroupStartIndexes starts(this); 11232 GroupStartIndexes starts(this);
11153 int number_of_entries = starts.at(kGroupCount); 11233 int number_of_entries = starts.number_of_entries();
11154 for (int i = 0; i < number_of_entries; i++) { 11234 for (int i = 0; i < number_of_entries; i++) {
11155 if (code_at(i) == code) return true; 11235 if (object_at(i) == code) return true;
11156 } 11236 }
11157 return false; 11237 return false;
11158 } 11238 }
11159 11239
11160 11240
11161 class DeoptimizeDependentCodeFilter : public OptimizedFunctionFilter { 11241 class DeoptimizeDependentCodeFilter : public OptimizedFunctionFilter {
11162 public: 11242 public:
11163 virtual bool TakeFunction(JSFunction* function) { 11243 virtual bool TakeFunction(JSFunction* function) {
11164 return function->code()->marked_for_deoptimization(); 11244 return function->code()->marked_for_deoptimization();
11165 } 11245 }
11166 }; 11246 };
11167 11247
11168 11248
11169 void DependentCode::DeoptimizeDependentCodeGroup( 11249 void DependentCode::DeoptimizeDependentCodeGroup(
11170 Isolate* isolate, 11250 Isolate* isolate,
11171 DependentCode::DependencyGroup group) { 11251 DependentCode::DependencyGroup group) {
11172 DisallowHeapAllocation no_allocation_scope; 11252 DisallowHeapAllocation no_allocation_scope;
11173 DependentCode::GroupStartIndexes starts(this); 11253 DependentCode::GroupStartIndexes starts(this);
11174 int start = starts.at(group); 11254 int start = starts.at(group);
11175 int end = starts.at(group + 1); 11255 int end = starts.at(group + 1);
11176 int number_of_entries = starts.at(DependentCode::kGroupCount); 11256 int code_entries = starts.number_of_entries();
11177 if (start == end) return; 11257 if (start == end) return;
11178 for (int i = start; i < end; i++) { 11258 for (int i = start; i < end; i++) {
11179 Code* code = code_at(i); 11259 if (is_code_at(i)) {
11180 code->set_marked_for_deoptimization(true); 11260 Code* code = code_at(i);
11261 code->set_marked_for_deoptimization(true);
11262 } else {
11263 CompilationInfo* info = compilation_info_at(i);
11264 info->AbortDueToDependentMap();
11265 }
11181 } 11266 }
11182 // Compact the array by moving all subsequent groups to fill in the new holes. 11267 // Compact the array by moving all subsequent groups to fill in the new holes.
11183 for (int src = end, dst = start; src < number_of_entries; src++, dst++) { 11268 for (int src = end, dst = start; src < code_entries; src++, dst++) {
11184 set_code_at(dst, code_at(src)); 11269 copy(src, dst);
11185 } 11270 }
11186 // Now the holes are at the end of the array, zap them for heap-verifier. 11271 // Now the holes are at the end of the array, zap them for heap-verifier.
11187 int removed = end - start; 11272 int removed = end - start;
11188 for (int i = number_of_entries - removed; i < number_of_entries; i++) { 11273 for (int i = code_entries - removed; i < code_entries; i++) {
11189 clear_code_at(i); 11274 clear_at(i);
11190 } 11275 }
11191 set_number_of_entries(group, 0); 11276 set_number_of_entries(group, 0);
11192 DeoptimizeDependentCodeFilter filter; 11277 DeoptimizeDependentCodeFilter filter;
11193 Deoptimizer::DeoptimizeAllFunctionsWith(isolate, &filter); 11278 Deoptimizer::DeoptimizeAllFunctionsWith(isolate, &filter);
11194 } 11279 }
11195 11280
11196 11281
11197 MaybeObject* JSReceiver::SetPrototype(Object* value, 11282 MaybeObject* JSReceiver::SetPrototype(Object* value,
11198 bool skip_hidden_prototypes) { 11283 bool skip_hidden_prototypes) {
11199 #ifdef DEBUG 11284 #ifdef DEBUG
(...skipping 4504 matching lines...) Expand 10 before | Expand all | Expand 10 after
15704 15789
15705 15790
15706 void JSTypedArray::Neuter() { 15791 void JSTypedArray::Neuter() {
15707 set_byte_offset(Smi::FromInt(0)); 15792 set_byte_offset(Smi::FromInt(0));
15708 set_byte_length(Smi::FromInt(0)); 15793 set_byte_length(Smi::FromInt(0));
15709 set_length(Smi::FromInt(0)); 15794 set_length(Smi::FromInt(0));
15710 set_elements(GetHeap()->EmptyExternalArrayForMap(map())); 15795 set_elements(GetHeap()->EmptyExternalArrayForMap(map()));
15711 } 15796 }
15712 15797
15713 } } // namespace v8::internal 15798 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698