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

Side by Side Diff: src/hydrogen.cc

Issue 40063002: Bookkeeping for allocation site pretenuring (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase built on site fields in another CL. Created 7 years, 1 month 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 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 2245
2246 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 2246 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
2247 Add<HStoreNamedField>(array, access, empty_fixed_array); 2247 Add<HStoreNamedField>(array, access, empty_fixed_array);
2248 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), 2248 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
2249 length_field); 2249 length_field);
2250 2250
2251 if (mode == TRACK_ALLOCATION_SITE) { 2251 if (mode == TRACK_ALLOCATION_SITE) {
2252 BuildCreateAllocationMemento(array, 2252 BuildCreateAllocationMemento(array,
2253 JSArray::kSize, 2253 JSArray::kSize,
2254 allocation_site_payload); 2254 allocation_site_payload);
2255 if (FLAG_allocation_site_pretenuring) {
2256 // Increment create count
Hannes Payer (out of office) 2013/11/21 20:52:24 Beautify comment.
mvstanton 2013/11/22 11:18:51 Done.
2257 // TODO(mvstanton): move into BuildCreateAllocationMemento when
2258 // constructed arrays also pay attention to pretenuring.
2259 HObjectAccess access =
2260 HObjectAccess::ForAllocationSiteOffset(
2261 AllocationSite::kMementoCreateCountOffset);
2262 HValue* create_info = Add<HLoadNamedField>(allocation_site_payload,
2263 access);
2264 HInstruction* new_create_info = Add<HAdd>(create_info,
2265 graph()->GetConstant1());
2266 HStoreNamedField* store = Add<HStoreNamedField>(allocation_site_payload,
2267 access, new_create_info);
2268 store->SkipWriteBarrier(); // I am writing a smi
Hannes Payer (out of office) 2013/11/21 20:52:24 Move comment in extra line and make it nice.
mvstanton 2013/11/22 11:18:51 Done.
2269 }
2255 } 2270 }
2256 2271
2257 int elements_location = JSArray::kSize; 2272 int elements_location = JSArray::kSize;
2258 if (mode == TRACK_ALLOCATION_SITE) { 2273 if (mode == TRACK_ALLOCATION_SITE) {
2259 elements_location += AllocationMemento::kSize; 2274 elements_location += AllocationMemento::kSize;
2260 } 2275 }
2261 2276
2262 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location); 2277 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location);
2263 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); 2278 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
2264 return static_cast<HInnerAllocatedObject*>(elements); 2279 return static_cast<HInnerAllocatedObject*>(elements);
(...skipping 6938 matching lines...) Expand 10 before | Expand all | Expand 10 after
9203 Handle<JSObject> boilerplate_object, 9218 Handle<JSObject> boilerplate_object,
9204 AllocationSiteContext* site_context) { 9219 AllocationSiteContext* site_context) {
9205 NoObservableSideEffectsScope no_effects(this); 9220 NoObservableSideEffectsScope no_effects(this);
9206 InstanceType instance_type = boilerplate_object->map()->instance_type(); 9221 InstanceType instance_type = boilerplate_object->map()->instance_type();
9207 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); 9222 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
9208 9223
9209 HType type = instance_type == JS_ARRAY_TYPE 9224 HType type = instance_type == JS_ARRAY_TYPE
9210 ? HType::JSArray() : HType::JSObject(); 9225 ? HType::JSArray() : HType::JSObject();
9211 HValue* object_size_constant = Add<HConstant>( 9226 HValue* object_size_constant = Add<HConstant>(
9212 boilerplate_object->map()->instance_size()); 9227 boilerplate_object->map()->instance_size());
9228
9229 // We should pull pre-tenure mode from the allocation site.
9230 // For now, just see what it says, and remark on it if it sez
9231 // we should pretenure. That means the rudimentary counting in the garbage
9232 // collector is having an effect.
9233 PretenureFlag pretenure_flag = isolate()->heap()->GetPretenureMode();
9234 if (FLAG_allocation_site_pretenuring) {
9235 pretenure_flag = site_context->current()->GetPretenureMode()
9236 ? TENURED
9237 : NOT_TENURED;
9238 if (FLAG_trace_track_allocation_sites) {
9239 PrintF("Boilerplate %p %s\n",
9240 static_cast<void*>(*boilerplate_object),
9241 pretenure_flag == TENURED ? "tenured" : "not tenured");
9242 }
9243 }
9244
9213 HInstruction* object = Add<HAllocate>(object_size_constant, type, 9245 HInstruction* object = Add<HAllocate>(object_size_constant, type,
9214 isolate()->heap()->GetPretenureMode(), instance_type); 9246 pretenure_flag, instance_type);
9215 9247
9216 BuildEmitObjectHeader(boilerplate_object, object); 9248 BuildEmitObjectHeader(boilerplate_object, object);
9217 9249
9218 Handle<FixedArrayBase> elements(boilerplate_object->elements()); 9250 Handle<FixedArrayBase> elements(boilerplate_object->elements());
9219 int elements_size = (elements->length() > 0 && 9251 int elements_size = (elements->length() > 0 &&
9220 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? 9252 elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
9221 elements->Size() : 0; 9253 elements->Size() : 0;
9222 9254
9223 HInstruction* object_elements = NULL; 9255 HInstruction* object_elements = NULL;
9224 if (elements_size > 0) { 9256 if (elements_size > 0) {
9225 HValue* object_elements_size = Add<HConstant>(elements_size); 9257 HValue* object_elements_size = Add<HConstant>(elements_size);
9226 if (boilerplate_object->HasFastDoubleElements()) { 9258 if (boilerplate_object->HasFastDoubleElements()) {
9227 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9259 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9228 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); 9260 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE);
9229 } else { 9261 } else {
9230 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9262 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9231 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE); 9263 pretenure_flag, FIXED_ARRAY_TYPE);
9232 } 9264 }
9233 } 9265 }
9234 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 9266 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
9235 9267
9236 // Copy object elements if non-COW. 9268 // Copy object elements if non-COW.
9237 if (object_elements != NULL) { 9269 if (object_elements != NULL) {
9238 BuildEmitElements(boilerplate_object, elements, object_elements, 9270 BuildEmitElements(boilerplate_object, elements, object_elements,
9239 site_context); 9271 site_context);
9240 } 9272 }
9241 9273
9242 // Copy in-object properties. 9274 // Copy in-object properties.
9243 if (boilerplate_object->map()->NumberOfFields() != 0) { 9275 if (boilerplate_object->map()->NumberOfFields() != 0) {
9244 BuildEmitInObjectProperties(boilerplate_object, object, site_context); 9276 BuildEmitInObjectProperties(boilerplate_object, object, site_context,
9277 pretenure_flag);
9245 } 9278 }
9246 return object; 9279 return object;
9247 } 9280 }
9248 9281
9249 9282
9250 void HOptimizedGraphBuilder::BuildEmitObjectHeader( 9283 void HOptimizedGraphBuilder::BuildEmitObjectHeader(
9251 Handle<JSObject> boilerplate_object, 9284 Handle<JSObject> boilerplate_object,
9252 HInstruction* object) { 9285 HInstruction* object) {
9253 ASSERT(boilerplate_object->properties()->length() == 0); 9286 ASSERT(boilerplate_object->properties()->length() == 0);
9254 9287
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
9287 object_elements = Add<HConstant>(elements_field); 9320 object_elements = Add<HConstant>(elements_field);
9288 } 9321 }
9289 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 9322 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9290 object_elements); 9323 object_elements);
9291 } 9324 }
9292 9325
9293 9326
9294 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 9327 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
9295 Handle<JSObject> boilerplate_object, 9328 Handle<JSObject> boilerplate_object,
9296 HInstruction* object, 9329 HInstruction* object,
9297 AllocationSiteContext* site_context) { 9330 AllocationSiteContext* site_context,
9331 PretenureFlag pretenure_flag) {
9298 Handle<DescriptorArray> descriptors( 9332 Handle<DescriptorArray> descriptors(
9299 boilerplate_object->map()->instance_descriptors()); 9333 boilerplate_object->map()->instance_descriptors());
9300 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 9334 int limit = boilerplate_object->map()->NumberOfOwnDescriptors();
9301 9335
9302 int copied_fields = 0; 9336 int copied_fields = 0;
9303 for (int i = 0; i < limit; i++) { 9337 for (int i = 0; i < limit; i++) {
9304 PropertyDetails details = descriptors->GetDetails(i); 9338 PropertyDetails details = descriptors->GetDetails(i);
9305 if (details.type() != FIELD) continue; 9339 if (details.type() != FIELD) continue;
9306 copied_fields++; 9340 copied_fields++;
9307 int index = descriptors->GetFieldIndex(i); 9341 int index = descriptors->GetFieldIndex(i);
(...skipping 15 matching lines...) Expand all
9323 BuildFastLiteral(value_object, site_context); 9357 BuildFastLiteral(value_object, site_context);
9324 site_context->ExitScope(current_site, value_object); 9358 site_context->ExitScope(current_site, value_object);
9325 Add<HStoreNamedField>(object, access, result); 9359 Add<HStoreNamedField>(object, access, result);
9326 } else { 9360 } else {
9327 Representation representation = details.representation(); 9361 Representation representation = details.representation();
9328 HInstruction* value_instruction = Add<HConstant>(value); 9362 HInstruction* value_instruction = Add<HConstant>(value);
9329 9363
9330 if (representation.IsDouble()) { 9364 if (representation.IsDouble()) {
9331 // Allocate a HeapNumber box and store the value into it. 9365 // Allocate a HeapNumber box and store the value into it.
9332 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 9366 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
9333 // TODO(mvstanton): This heap number alloc does not have a corresponding 9367 // This heap number alloc does not have a corresponding
9334 // AllocationSite. That is okay because 9368 // AllocationSite. That is okay because
9335 // 1) it's a child object of another object with a valid allocation site 9369 // 1) it's a child object of another object with a valid allocation site
9336 // 2) we can just use the mode of the parent object for pretenuring 9370 // 2) we can just use the mode of the parent object for pretenuring
9337 // The todo is replace GetPretenureMode() with
9338 // site_context->top()->GetPretenureMode().
9339 HInstruction* double_box = 9371 HInstruction* double_box =
9340 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 9372 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
9341 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE); 9373 pretenure_flag, HEAP_NUMBER_TYPE);
9342 AddStoreMapConstant(double_box, 9374 AddStoreMapConstant(double_box,
9343 isolate()->factory()->heap_number_map()); 9375 isolate()->factory()->heap_number_map());
9344 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 9376 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
9345 value_instruction); 9377 value_instruction);
9346 value_instruction = double_box; 9378 value_instruction = double_box;
9347 } 9379 }
9348 9380
9349 Add<HStoreNamedField>(object, access, value_instruction); 9381 Add<HStoreNamedField>(object, access, value_instruction);
9350 } 9382 }
9351 } 9383 }
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
10670 if (ShouldProduceTraceOutput()) { 10702 if (ShouldProduceTraceOutput()) {
10671 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10703 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10672 } 10704 }
10673 10705
10674 #ifdef DEBUG 10706 #ifdef DEBUG
10675 graph_->Verify(false); // No full verify. 10707 graph_->Verify(false); // No full verify.
10676 #endif 10708 #endif
10677 } 10709 }
10678 10710
10679 } } // namespace v8::internal 10711 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698