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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 11817017: Additional work to get array literal allocation tracking working, even with --always-opt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Quick adjustment to bit fields Created 7 years, 11 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/ia32/lithium-codegen-ia32.h ('k') | src/ia32/stub-cache-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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5293 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); 5293 Runtime::kAllocateInNewSpace, 1, instr, instr->context());
5294 __ StoreToSafepointRegisterSlot(result, eax); 5294 __ StoreToSafepointRegisterSlot(result, eax);
5295 } 5295 }
5296 5296
5297 5297
5298 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 5298 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
5299 ASSERT(ToRegister(instr->context()).is(esi)); 5299 ASSERT(ToRegister(instr->context()).is(esi));
5300 Handle<FixedArray> literals(instr->environment()->closure()->literals()); 5300 Handle<FixedArray> literals(instr->environment()->closure()->literals());
5301 ElementsKind boilerplate_elements_kind = 5301 ElementsKind boilerplate_elements_kind =
5302 instr->hydrogen()->boilerplate_elements_kind(); 5302 instr->hydrogen()->boilerplate_elements_kind();
5303 AllocationSiteMode allocation_site_mode =
5304 instr->hydrogen()->allocation_site_mode();
5303 5305
5304 // Deopt if the array literal boilerplate ElementsKind is of a type different 5306 // Deopt if the array literal boilerplate ElementsKind is of a type different
5305 // than the expected one. The check isn't necessary if the boilerplate has 5307 // than the expected one. The check isn't necessary if the boilerplate has
5306 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. 5308 // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
5307 if (CanTransitionToMoreGeneralFastElementsKind( 5309 if (CanTransitionToMoreGeneralFastElementsKind(
5308 boilerplate_elements_kind, true)) { 5310 boilerplate_elements_kind, true)) {
5309 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); 5311 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object());
5310 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 5312 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
5311 // Load the map's "bit field 2". We only need the first byte, 5313 // Load the map's "bit field 2". We only need the first byte,
5312 // but the following masking takes care of that anyway. 5314 // but the following masking takes care of that anyway.
(...skipping 10 matching lines...) Expand all
5323 // Boilerplate already exists, constant elements are never accessed. 5325 // Boilerplate already exists, constant elements are never accessed.
5324 // Pass an empty fixed array. 5326 // Pass an empty fixed array.
5325 __ push(Immediate(isolate()->factory()->empty_fixed_array())); 5327 __ push(Immediate(isolate()->factory()->empty_fixed_array()));
5326 5328
5327 // Pick the right runtime function or stub to call. 5329 // Pick the right runtime function or stub to call.
5328 int length = instr->hydrogen()->length(); 5330 int length = instr->hydrogen()->length();
5329 if (instr->hydrogen()->IsCopyOnWrite()) { 5331 if (instr->hydrogen()->IsCopyOnWrite()) {
5330 ASSERT(instr->hydrogen()->depth() == 1); 5332 ASSERT(instr->hydrogen()->depth() == 1);
5331 FastCloneShallowArrayStub::Mode mode = 5333 FastCloneShallowArrayStub::Mode mode =
5332 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; 5334 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
5333 FastCloneShallowArrayStub stub(mode, length); 5335 FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length);
5334 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 5336 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
5335 } else if (instr->hydrogen()->depth() > 1) { 5337 } else if (instr->hydrogen()->depth() > 1) {
5336 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); 5338 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
5337 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 5339 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
5338 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); 5340 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
5339 } else { 5341 } else {
5340 FastCloneShallowArrayStub::Mode mode = 5342 FastCloneShallowArrayStub::Mode mode =
5341 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS 5343 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
5342 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 5344 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
5343 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 5345 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
5344 FastCloneShallowArrayStub stub(mode, length); 5346 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length);
5345 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 5347 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
5346 } 5348 }
5347 } 5349 }
5348 5350
5349 5351
5350 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 5352 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
5351 Register result, 5353 Register result,
5352 Register source, 5354 Register source,
5353 int* offset) { 5355 int* offset,
5356 AllocationSiteMode mode) {
5354 ASSERT(!source.is(ecx)); 5357 ASSERT(!source.is(ecx));
5355 ASSERT(!result.is(ecx)); 5358 ASSERT(!result.is(ecx));
5356 5359
5360 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE &&
5361 object->map()->CanTrackAllocationSite();
5362
5357 if (FLAG_debug_code) { 5363 if (FLAG_debug_code) {
5358 __ LoadHeapObject(ecx, object); 5364 __ LoadHeapObject(ecx, object);
5359 __ cmp(source, ecx); 5365 __ cmp(source, ecx);
5360 __ Assert(equal, "Unexpected object literal boilerplate"); 5366 __ Assert(equal, "Unexpected object literal boilerplate");
5361 __ mov(ecx, FieldOperand(source, HeapObject::kMapOffset)); 5367 __ mov(ecx, FieldOperand(source, HeapObject::kMapOffset));
5362 __ cmp(ecx, Handle<Map>(object->map())); 5368 __ cmp(ecx, Handle<Map>(object->map()));
5363 __ Assert(equal, "Unexpected boilerplate map"); 5369 __ Assert(equal, "Unexpected boilerplate map");
5364 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset)); 5370 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset));
5365 __ and_(ecx, Map::kElementsKindMask); 5371 __ and_(ecx, Map::kElementsKindMask);
5366 __ cmp(ecx, object->GetElementsKind() << Map::kElementsKindShift); 5372 __ cmp(ecx, object->GetElementsKind() << Map::kElementsKindShift);
5367 __ Assert(equal, "Unexpected boilerplate elements kind"); 5373 __ Assert(equal, "Unexpected boilerplate elements kind");
5368 } 5374 }
5369 5375
5370 // Only elements backing stores for non-COW arrays need to be copied. 5376 // Only elements backing stores for non-COW arrays need to be copied.
5371 Handle<FixedArrayBase> elements(object->elements()); 5377 Handle<FixedArrayBase> elements(object->elements());
5372 bool has_elements = elements->length() > 0 && 5378 bool has_elements = elements->length() > 0 &&
5373 elements->map() != isolate()->heap()->fixed_cow_array_map(); 5379 elements->map() != isolate()->heap()->fixed_cow_array_map();
5374 5380
5375 // Increase the offset so that subsequent objects end up right after 5381 // Increase the offset so that subsequent objects end up right after
5376 // this object and its backing store. 5382 // this object and its backing store.
5377 int object_offset = *offset; 5383 int object_offset = *offset;
5378 int object_size = object->map()->instance_size(); 5384 int object_size = object->map()->instance_size();
5385 int elements_size = has_elements ? elements->Size() : 0;
5379 int elements_offset = *offset + object_size; 5386 int elements_offset = *offset + object_size;
5380 int elements_size = has_elements ? elements->Size() : 0; 5387 if (create_allocation_site_info) {
5388 elements_offset += AllocationSiteInfo::kSize;
5389 *offset += AllocationSiteInfo::kSize;
5390 }
5391
5381 *offset += object_size + elements_size; 5392 *offset += object_size + elements_size;
5382 5393
5383 // Copy object header. 5394 // Copy object header.
5384 ASSERT(object->properties()->length() == 0); 5395 ASSERT(object->properties()->length() == 0);
5385 int inobject_properties = object->map()->inobject_properties(); 5396 int inobject_properties = object->map()->inobject_properties();
5386 int header_size = object_size - inobject_properties * kPointerSize; 5397 int header_size = object_size - inobject_properties * kPointerSize;
5387 for (int i = 0; i < header_size; i += kPointerSize) { 5398 for (int i = 0; i < header_size; i += kPointerSize) {
5388 if (has_elements && i == JSObject::kElementsOffset) { 5399 if (has_elements && i == JSObject::kElementsOffset) {
5389 __ lea(ecx, Operand(result, elements_offset)); 5400 __ lea(ecx, Operand(result, elements_offset));
5390 } else { 5401 } else {
5391 __ mov(ecx, FieldOperand(source, i)); 5402 __ mov(ecx, FieldOperand(source, i));
5392 } 5403 }
5393 __ mov(FieldOperand(result, object_offset + i), ecx); 5404 __ mov(FieldOperand(result, object_offset + i), ecx);
5394 } 5405 }
5395 5406
5396 // Copy in-object properties. 5407 // Copy in-object properties.
5397 for (int i = 0; i < inobject_properties; i++) { 5408 for (int i = 0; i < inobject_properties; i++) {
5398 int total_offset = object_offset + object->GetInObjectPropertyOffset(i); 5409 int total_offset = object_offset + object->GetInObjectPropertyOffset(i);
5399 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i)); 5410 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
5400 if (value->IsJSObject()) { 5411 if (value->IsJSObject()) {
5401 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 5412 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
5402 __ lea(ecx, Operand(result, *offset)); 5413 __ lea(ecx, Operand(result, *offset));
5403 __ mov(FieldOperand(result, total_offset), ecx); 5414 __ mov(FieldOperand(result, total_offset), ecx);
5404 __ LoadHeapObject(source, value_object); 5415 __ LoadHeapObject(source, value_object);
5405 EmitDeepCopy(value_object, result, source, offset); 5416 EmitDeepCopy(value_object, result, source, offset,
5417 DONT_TRACK_ALLOCATION_SITE);
5406 } else if (value->IsHeapObject()) { 5418 } else if (value->IsHeapObject()) {
5407 __ LoadHeapObject(ecx, Handle<HeapObject>::cast(value)); 5419 __ LoadHeapObject(ecx, Handle<HeapObject>::cast(value));
5408 __ mov(FieldOperand(result, total_offset), ecx); 5420 __ mov(FieldOperand(result, total_offset), ecx);
5409 } else { 5421 } else {
5410 __ mov(FieldOperand(result, total_offset), Immediate(value)); 5422 __ mov(FieldOperand(result, total_offset), Immediate(value));
5411 } 5423 }
5412 } 5424 }
5413 5425
5426 // Build Allocation Site Info if desired
5427 if (create_allocation_site_info) {
5428 __ mov(FieldOperand(result, object_size),
5429 Immediate(Handle<Map>(isolate()->heap()->
5430 allocation_site_info_map())));
5431 __ mov(FieldOperand(result, object_size + kPointerSize), source);
5432 }
5433
5414 if (has_elements) { 5434 if (has_elements) {
5415 // Copy elements backing store header. 5435 // Copy elements backing store header.
5416 __ LoadHeapObject(source, elements); 5436 __ LoadHeapObject(source, elements);
5417 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) { 5437 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) {
5418 __ mov(ecx, FieldOperand(source, i)); 5438 __ mov(ecx, FieldOperand(source, i));
5419 __ mov(FieldOperand(result, elements_offset + i), ecx); 5439 __ mov(FieldOperand(result, elements_offset + i), ecx);
5420 } 5440 }
5421 5441
5422 // Copy elements backing store content. 5442 // Copy elements backing store content.
5423 int elements_length = elements->length(); 5443 int elements_length = elements->length();
(...skipping 12 matching lines...) Expand all
5436 } else if (elements->IsFixedArray()) { 5456 } else if (elements->IsFixedArray()) {
5437 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 5457 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
5438 for (int i = 0; i < elements_length; i++) { 5458 for (int i = 0; i < elements_length; i++) {
5439 int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i); 5459 int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
5440 Handle<Object> value(fast_elements->get(i)); 5460 Handle<Object> value(fast_elements->get(i));
5441 if (value->IsJSObject()) { 5461 if (value->IsJSObject()) {
5442 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 5462 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
5443 __ lea(ecx, Operand(result, *offset)); 5463 __ lea(ecx, Operand(result, *offset));
5444 __ mov(FieldOperand(result, total_offset), ecx); 5464 __ mov(FieldOperand(result, total_offset), ecx);
5445 __ LoadHeapObject(source, value_object); 5465 __ LoadHeapObject(source, value_object);
5446 EmitDeepCopy(value_object, result, source, offset); 5466 EmitDeepCopy(value_object, result, source, offset,
5467 DONT_TRACK_ALLOCATION_SITE);
5447 } else if (value->IsHeapObject()) { 5468 } else if (value->IsHeapObject()) {
5448 __ LoadHeapObject(ecx, Handle<HeapObject>::cast(value)); 5469 __ LoadHeapObject(ecx, Handle<HeapObject>::cast(value));
5449 __ mov(FieldOperand(result, total_offset), ecx); 5470 __ mov(FieldOperand(result, total_offset), ecx);
5450 } else { 5471 } else {
5451 __ mov(FieldOperand(result, total_offset), Immediate(value)); 5472 __ mov(FieldOperand(result, total_offset), Immediate(value));
5452 } 5473 }
5453 } 5474 }
5454 } else { 5475 } else {
5455 UNREACHABLE(); 5476 UNREACHABLE();
5456 } 5477 }
(...skipping 29 matching lines...) Expand all
5486 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT); 5507 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
5487 __ jmp(&allocated); 5508 __ jmp(&allocated);
5488 5509
5489 __ bind(&runtime_allocate); 5510 __ bind(&runtime_allocate);
5490 __ push(Immediate(Smi::FromInt(size))); 5511 __ push(Immediate(Smi::FromInt(size)));
5491 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); 5512 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5492 5513
5493 __ bind(&allocated); 5514 __ bind(&allocated);
5494 int offset = 0; 5515 int offset = 0;
5495 __ LoadHeapObject(ebx, instr->hydrogen()->boilerplate()); 5516 __ LoadHeapObject(ebx, instr->hydrogen()->boilerplate());
5496 EmitDeepCopy(instr->hydrogen()->boilerplate(), eax, ebx, &offset); 5517 EmitDeepCopy(instr->hydrogen()->boilerplate(), eax, ebx, &offset,
5518 instr->hydrogen()->allocation_site_mode());
5497 ASSERT_EQ(size, offset); 5519 ASSERT_EQ(size, offset);
5498 } 5520 }
5499 5521
5500 5522
5501 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { 5523 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
5502 ASSERT(ToRegister(instr->context()).is(esi)); 5524 ASSERT(ToRegister(instr->context()).is(esi));
5503 Handle<FixedArray> literals(instr->environment()->closure()->literals()); 5525 Handle<FixedArray> literals(instr->environment()->closure()->literals());
5504 Handle<FixedArray> constant_properties = 5526 Handle<FixedArray> constant_properties =
5505 instr->hydrogen()->constant_properties(); 5527 instr->hydrogen()->constant_properties();
5506 5528
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
5955 FixedArray::kHeaderSize - kPointerSize)); 5977 FixedArray::kHeaderSize - kPointerSize));
5956 __ bind(&done); 5978 __ bind(&done);
5957 } 5979 }
5958 5980
5959 5981
5960 #undef __ 5982 #undef __
5961 5983
5962 } } // namespace v8::internal 5984 } } // namespace v8::internal
5963 5985
5964 #endif // V8_TARGET_ARCH_IA32 5986 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698