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

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

Issue 14108003: MIPS: Build fast literals in hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | « no previous file | src/mips/lithium-mips.h » ('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 5412 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 FastCloneShallowArrayStub::Mode mode = 5423 FastCloneShallowArrayStub::Mode mode =
5424 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS 5424 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
5425 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 5425 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
5426 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 5426 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
5427 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); 5427 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length);
5428 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 5428 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
5429 } 5429 }
5430 } 5430 }
5431 5431
5432 5432
5433 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
5434 Register result,
5435 Register source,
5436 int* offset,
5437 AllocationSiteMode mode) {
5438 ASSERT(!source.is(a2));
5439 ASSERT(!result.is(a2));
5440
5441 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE &&
5442 object->map()->CanTrackAllocationSite();
5443
5444 // Only elements backing stores for non-COW arrays need to be copied.
5445 Handle<FixedArrayBase> elements(object->elements());
5446 bool has_elements = elements->length() > 0 &&
5447 elements->map() != isolate()->heap()->fixed_cow_array_map();
5448
5449 // Increase the offset so that subsequent objects end up right after
5450 // this object and its backing store.
5451 int object_offset = *offset;
5452 int object_size = object->map()->instance_size();
5453 int elements_size = has_elements ? elements->Size() : 0;
5454 int elements_offset = *offset + object_size;
5455 if (create_allocation_site_info) {
5456 elements_offset += AllocationSiteInfo::kSize;
5457 *offset += AllocationSiteInfo::kSize;
5458 }
5459
5460 *offset += object_size + elements_size;
5461
5462 // Copy object header.
5463 ASSERT(object->properties()->length() == 0);
5464 int inobject_properties = object->map()->inobject_properties();
5465 int header_size = object_size - inobject_properties * kPointerSize;
5466 for (int i = 0; i < header_size; i += kPointerSize) {
5467 if (has_elements && i == JSObject::kElementsOffset) {
5468 __ Addu(a2, result, Operand(elements_offset));
5469 } else {
5470 __ lw(a2, FieldMemOperand(source, i));
5471 }
5472 __ sw(a2, FieldMemOperand(result, object_offset + i));
5473 }
5474
5475 // Copy in-object properties.
5476 for (int i = 0; i < inobject_properties; i++) {
5477 int total_offset = object_offset + object->GetInObjectPropertyOffset(i);
5478 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i),
5479 isolate());
5480 if (value->IsJSObject()) {
5481 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
5482 __ Addu(a2, result, Operand(*offset));
5483 __ sw(a2, FieldMemOperand(result, total_offset));
5484 __ LoadHeapObject(source, value_object);
5485 EmitDeepCopy(value_object, result, source, offset,
5486 DONT_TRACK_ALLOCATION_SITE);
5487 } else if (value->IsHeapObject()) {
5488 __ LoadHeapObject(a2, Handle<HeapObject>::cast(value));
5489 __ sw(a2, FieldMemOperand(result, total_offset));
5490 } else {
5491 __ li(a2, Operand(value));
5492 __ sw(a2, FieldMemOperand(result, total_offset));
5493 }
5494 }
5495
5496 // Build Allocation Site Info if desired
5497 if (create_allocation_site_info) {
5498 __ li(a2, Operand(Handle<Map>(isolate()->heap()->
5499 allocation_site_info_map())));
5500 __ sw(a2, FieldMemOperand(result, object_size));
5501 __ sw(source, FieldMemOperand(result, object_size + kPointerSize));
5502 }
5503
5504 if (has_elements) {
5505 // Copy elements backing store header.
5506 __ LoadHeapObject(source, elements);
5507 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) {
5508 __ lw(a2, FieldMemOperand(source, i));
5509 __ sw(a2, FieldMemOperand(result, elements_offset + i));
5510 }
5511
5512 // Copy elements backing store content.
5513 int elements_length = has_elements ? elements->length() : 0;
5514 if (elements->IsFixedDoubleArray()) {
5515 Handle<FixedDoubleArray> double_array =
5516 Handle<FixedDoubleArray>::cast(elements);
5517 for (int i = 0; i < elements_length; i++) {
5518 int64_t value = double_array->get_representation(i);
5519 // We only support little endian mode...
5520 int32_t value_low = static_cast<int32_t>(value & 0xFFFFFFFF);
5521 int32_t value_high = static_cast<int32_t>(value >> 32);
5522 int total_offset =
5523 elements_offset + FixedDoubleArray::OffsetOfElementAt(i);
5524 __ li(a2, Operand(value_low));
5525 __ sw(a2, FieldMemOperand(result, total_offset));
5526 __ li(a2, Operand(value_high));
5527 __ sw(a2, FieldMemOperand(result, total_offset + 4));
5528 }
5529 } else if (elements->IsFixedArray()) {
5530 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
5531 for (int i = 0; i < elements_length; i++) {
5532 int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
5533 Handle<Object> value(fast_elements->get(i), isolate());
5534 if (value->IsJSObject()) {
5535 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
5536 __ Addu(a2, result, Operand(*offset));
5537 __ sw(a2, FieldMemOperand(result, total_offset));
5538 __ LoadHeapObject(source, value_object);
5539 EmitDeepCopy(value_object, result, source, offset,
5540 DONT_TRACK_ALLOCATION_SITE);
5541 } else if (value->IsHeapObject()) {
5542 __ LoadHeapObject(a2, Handle<HeapObject>::cast(value));
5543 __ sw(a2, FieldMemOperand(result, total_offset));
5544 } else {
5545 __ li(a2, Operand(value));
5546 __ sw(a2, FieldMemOperand(result, total_offset));
5547 }
5548 }
5549 } else {
5550 UNREACHABLE();
5551 }
5552 }
5553 }
5554
5555
5556 void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
5557 int size = instr->hydrogen()->total_size();
5558 ElementsKind boilerplate_elements_kind =
5559 instr->hydrogen()->boilerplate()->GetElementsKind();
5560
5561 // Deopt if the array literal boilerplate ElementsKind is of a type different
5562 // than the expected one. The check isn't necessary if the boilerplate has
5563 // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
5564 if (CanTransitionToMoreGeneralFastElementsKind(
5565 boilerplate_elements_kind, true)) {
5566 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate());
5567 // Load map into a2.
5568 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
5569 // Load the map's "bit field 2".
5570 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset));
5571 // Retrieve elements_kind from bit field 2.
5572 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount);
5573 DeoptimizeIf(ne, instr->environment(), a2,
5574 Operand(boilerplate_elements_kind));
5575 }
5576
5577 // Allocate all objects that are part of the literal in one big
5578 // allocation. This avoids multiple limit checks.
5579 Label allocated, runtime_allocate;
5580 __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
5581 __ jmp(&allocated);
5582
5583 __ bind(&runtime_allocate);
5584 __ li(a0, Operand(Smi::FromInt(size)));
5585 __ push(a0);
5586 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5587
5588 __ bind(&allocated);
5589 int offset = 0;
5590 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate());
5591 EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset,
5592 instr->hydrogen()->allocation_site_mode());
5593 ASSERT_EQ(size, offset);
5594 }
5595
5596
5597 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { 5433 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
5598 ASSERT(ToRegister(instr->result()).is(v0)); 5434 ASSERT(ToRegister(instr->result()).is(v0));
5599 Handle<FixedArray> literals(instr->environment()->closure()->literals()); 5435 Handle<FixedArray> literals(instr->environment()->closure()->literals());
5600 Handle<FixedArray> constant_properties = 5436 Handle<FixedArray> constant_properties =
5601 instr->hydrogen()->constant_properties(); 5437 instr->hydrogen()->constant_properties();
5602 5438
5603 // Set up the parameters to the stub/runtime call. 5439 // Set up the parameters to the stub/runtime call.
5604 __ LoadHeapObject(a3, literals); 5440 __ LoadHeapObject(a3, literals);
5605 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); 5441 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
5606 __ li(a1, Operand(constant_properties)); 5442 __ li(a1, Operand(constant_properties));
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
6100 __ Subu(scratch, result, scratch); 5936 __ Subu(scratch, result, scratch);
6101 __ lw(result, FieldMemOperand(scratch, 5937 __ lw(result, FieldMemOperand(scratch,
6102 FixedArray::kHeaderSize - kPointerSize)); 5938 FixedArray::kHeaderSize - kPointerSize));
6103 __ bind(&done); 5939 __ bind(&done);
6104 } 5940 }
6105 5941
6106 5942
6107 #undef __ 5943 #undef __
6108 5944
6109 } } // namespace v8::internal 5945 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698