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

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

Powered by Google App Engine
This is Rietveld 408576698