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

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

Powered by Google App Engine
This is Rietveld 408576698