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

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. 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
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/full-codegen-ia32.cc » ('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 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2233
2234 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 2234 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
2235 Add<HStoreNamedField>(array, access, empty_fixed_array); 2235 Add<HStoreNamedField>(array, access, empty_fixed_array);
2236 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), 2236 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
2237 length_field); 2237 length_field);
2238 2238
2239 if (mode == TRACK_ALLOCATION_SITE) { 2239 if (mode == TRACK_ALLOCATION_SITE) {
2240 BuildCreateAllocationMemento(array, 2240 BuildCreateAllocationMemento(array,
2241 JSArray::kSize, 2241 JSArray::kSize,
2242 allocation_site_payload); 2242 allocation_site_payload);
2243 if (FLAG_allocation_site_pretenuring) {
2244 // TODO(mvstanton): move this code into BuildCreateAllocationMemento when
2245 // constructed arrays also pay attention to pretenuring.
2246 HObjectAccess access =
2247 HObjectAccess::ForAllocationSiteOffset(
2248 AllocationSite::kMementoCreateCountOffset);
2249 HValue* create_info = Add<HLoadNamedField>(allocation_site_payload,
2250 access);
2251 HInstruction* new_create_info = HAdd::New(zone(), context(),
2252 create_info,
2253 graph()->GetConstant1());
2254 new_create_info->ClearFlag(HValue::kCanOverflow);
2255 HStoreNamedField* store = Add<HStoreNamedField>(allocation_site_payload,
2256 access, new_create_info);
2257 // No write barrier needed to store a smi.
2258 store->SkipWriteBarrier();
2259 }
2243 } 2260 }
2244 2261
2245 int elements_location = JSArray::kSize; 2262 int elements_location = JSArray::kSize;
2246 if (mode == TRACK_ALLOCATION_SITE) { 2263 if (mode == TRACK_ALLOCATION_SITE) {
2247 elements_location += AllocationMemento::kSize; 2264 elements_location += AllocationMemento::kSize;
2248 } 2265 }
2249 2266
2250 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location); 2267 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location);
2251 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); 2268 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
2252 return static_cast<HInnerAllocatedObject*>(elements); 2269 return static_cast<HInnerAllocatedObject*>(elements);
(...skipping 7072 matching lines...) Expand 10 before | Expand all | Expand 10 after
9325 Handle<JSObject> boilerplate_object, 9342 Handle<JSObject> boilerplate_object,
9326 AllocationSiteUsageContext* site_context) { 9343 AllocationSiteUsageContext* site_context) {
9327 NoObservableSideEffectsScope no_effects(this); 9344 NoObservableSideEffectsScope no_effects(this);
9328 InstanceType instance_type = boilerplate_object->map()->instance_type(); 9345 InstanceType instance_type = boilerplate_object->map()->instance_type();
9329 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); 9346 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
9330 9347
9331 HType type = instance_type == JS_ARRAY_TYPE 9348 HType type = instance_type == JS_ARRAY_TYPE
9332 ? HType::JSArray() : HType::JSObject(); 9349 ? HType::JSArray() : HType::JSObject();
9333 HValue* object_size_constant = Add<HConstant>( 9350 HValue* object_size_constant = Add<HConstant>(
9334 boilerplate_object->map()->instance_size()); 9351 boilerplate_object->map()->instance_size());
9352
9353 // We should pull pre-tenure mode from the allocation site.
9354 // For now, just see what it says, and remark on it if it sez
9355 // we should pretenure. That means the rudimentary counting in the garbage
9356 // collector is having an effect.
9357 PretenureFlag pretenure_flag = isolate()->heap()->GetPretenureMode();
9358 if (FLAG_allocation_site_pretenuring) {
9359 pretenure_flag = site_context->current()->GetPretenureMode()
9360 ? TENURED
9361 : NOT_TENURED;
9362 if (FLAG_trace_track_allocation_sites) {
9363 PrintF("Hydrogen: AllocationSite %p boilerplate %p %s\n",
9364 static_cast<void*>(*(site_context->current())),
9365 static_cast<void*>(*boilerplate_object),
9366 pretenure_flag == TENURED ? "tenured" : "not tenured");
9367 }
9368 }
9369
9335 HInstruction* object = Add<HAllocate>(object_size_constant, type, 9370 HInstruction* object = Add<HAllocate>(object_size_constant, type,
9336 isolate()->heap()->GetPretenureMode(), instance_type); 9371 pretenure_flag, instance_type);
9337 9372
9338 BuildEmitObjectHeader(boilerplate_object, object); 9373 BuildEmitObjectHeader(boilerplate_object, object);
9339 9374
9340 Handle<FixedArrayBase> elements(boilerplate_object->elements()); 9375 Handle<FixedArrayBase> elements(boilerplate_object->elements());
9341 int elements_size = (elements->length() > 0 && 9376 int elements_size = (elements->length() > 0 &&
9342 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? 9377 elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
9343 elements->Size() : 0; 9378 elements->Size() : 0;
9344 9379
9345 HInstruction* object_elements = NULL; 9380 HInstruction* object_elements = NULL;
9346 if (elements_size > 0) { 9381 if (elements_size > 0) {
9347 HValue* object_elements_size = Add<HConstant>(elements_size); 9382 HValue* object_elements_size = Add<HConstant>(elements_size);
9348 if (boilerplate_object->HasFastDoubleElements()) { 9383 if (boilerplate_object->HasFastDoubleElements()) {
9349 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9384 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9350 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); 9385 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE);
9351 } else { 9386 } else {
9352 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9387 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9353 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE); 9388 pretenure_flag, FIXED_ARRAY_TYPE);
9354 } 9389 }
9355 } 9390 }
9356 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 9391 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
9357 9392
9358 // Copy object elements if non-COW. 9393 // Copy object elements if non-COW.
9359 if (object_elements != NULL) { 9394 if (object_elements != NULL) {
9360 BuildEmitElements(boilerplate_object, elements, object_elements, 9395 BuildEmitElements(boilerplate_object, elements, object_elements,
9361 site_context); 9396 site_context);
9362 } 9397 }
9363 9398
9364 // Copy in-object properties. 9399 // Copy in-object properties.
9365 if (boilerplate_object->map()->NumberOfFields() != 0) { 9400 if (boilerplate_object->map()->NumberOfFields() != 0) {
9366 BuildEmitInObjectProperties(boilerplate_object, object, site_context); 9401 BuildEmitInObjectProperties(boilerplate_object, object, site_context,
9402 pretenure_flag);
9367 } 9403 }
9368 return object; 9404 return object;
9369 } 9405 }
9370 9406
9371 9407
9372 void HOptimizedGraphBuilder::BuildEmitObjectHeader( 9408 void HOptimizedGraphBuilder::BuildEmitObjectHeader(
9373 Handle<JSObject> boilerplate_object, 9409 Handle<JSObject> boilerplate_object,
9374 HInstruction* object) { 9410 HInstruction* object) {
9375 ASSERT(boilerplate_object->properties()->length() == 0); 9411 ASSERT(boilerplate_object->properties()->length() == 0);
9376 9412
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
9409 object_elements = Add<HConstant>(elements_field); 9445 object_elements = Add<HConstant>(elements_field);
9410 } 9446 }
9411 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 9447 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9412 object_elements); 9448 object_elements);
9413 } 9449 }
9414 9450
9415 9451
9416 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 9452 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
9417 Handle<JSObject> boilerplate_object, 9453 Handle<JSObject> boilerplate_object,
9418 HInstruction* object, 9454 HInstruction* object,
9419 AllocationSiteUsageContext* site_context) { 9455 AllocationSiteUsageContext* site_context,
9456 PretenureFlag pretenure_flag) {
9420 Handle<DescriptorArray> descriptors( 9457 Handle<DescriptorArray> descriptors(
9421 boilerplate_object->map()->instance_descriptors()); 9458 boilerplate_object->map()->instance_descriptors());
9422 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 9459 int limit = boilerplate_object->map()->NumberOfOwnDescriptors();
9423 9460
9424 int copied_fields = 0; 9461 int copied_fields = 0;
9425 for (int i = 0; i < limit; i++) { 9462 for (int i = 0; i < limit; i++) {
9426 PropertyDetails details = descriptors->GetDetails(i); 9463 PropertyDetails details = descriptors->GetDetails(i);
9427 if (details.type() != FIELD) continue; 9464 if (details.type() != FIELD) continue;
9428 copied_fields++; 9465 copied_fields++;
9429 int index = descriptors->GetFieldIndex(i); 9466 int index = descriptors->GetFieldIndex(i);
(...skipping 15 matching lines...) Expand all
9445 BuildFastLiteral(value_object, site_context); 9482 BuildFastLiteral(value_object, site_context);
9446 site_context->ExitScope(current_site, value_object); 9483 site_context->ExitScope(current_site, value_object);
9447 Add<HStoreNamedField>(object, access, result); 9484 Add<HStoreNamedField>(object, access, result);
9448 } else { 9485 } else {
9449 Representation representation = details.representation(); 9486 Representation representation = details.representation();
9450 HInstruction* value_instruction = Add<HConstant>(value); 9487 HInstruction* value_instruction = Add<HConstant>(value);
9451 9488
9452 if (representation.IsDouble()) { 9489 if (representation.IsDouble()) {
9453 // Allocate a HeapNumber box and store the value into it. 9490 // Allocate a HeapNumber box and store the value into it.
9454 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 9491 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
9455 // TODO(mvstanton): This heap number alloc does not have a corresponding 9492 // This heap number alloc does not have a corresponding
9456 // AllocationSite. That is okay because 9493 // AllocationSite. That is okay because
9457 // 1) it's a child object of another object with a valid allocation site 9494 // 1) it's a child object of another object with a valid allocation site
9458 // 2) we can just use the mode of the parent object for pretenuring 9495 // 2) we can just use the mode of the parent object for pretenuring
9459 // The todo is replace GetPretenureMode() with
9460 // site_context->top()->GetPretenureMode().
9461 HInstruction* double_box = 9496 HInstruction* double_box =
9462 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 9497 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
9463 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE); 9498 pretenure_flag, HEAP_NUMBER_TYPE);
9464 AddStoreMapConstant(double_box, 9499 AddStoreMapConstant(double_box,
9465 isolate()->factory()->heap_number_map()); 9500 isolate()->factory()->heap_number_map());
9466 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 9501 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
9467 value_instruction); 9502 value_instruction);
9468 value_instruction = double_box; 9503 value_instruction = double_box;
9469 } 9504 }
9470 9505
9471 Add<HStoreNamedField>(object, access, value_instruction); 9506 Add<HStoreNamedField>(object, access, value_instruction);
9472 } 9507 }
9473 } 9508 }
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
10785 if (ShouldProduceTraceOutput()) { 10820 if (ShouldProduceTraceOutput()) {
10786 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10821 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10787 } 10822 }
10788 10823
10789 #ifdef DEBUG 10824 #ifdef DEBUG
10790 graph_->Verify(false); // No full verify. 10825 graph_->Verify(false); // No full verify.
10791 #endif 10826 #endif
10792 } 10827 }
10793 10828
10794 } } // namespace v8::internal 10829 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698