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

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

Issue 10170030: Implement tracking and optimizations of packed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 7 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/mips/ic-mips.cc ('k') | src/mips/lithium-mips.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 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 Label done, fail; 2441 Label done, fail;
2442 __ lw(scratch, FieldMemOperand(result, HeapObject::kMapOffset)); 2442 __ lw(scratch, FieldMemOperand(result, HeapObject::kMapOffset));
2443 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); 2443 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
2444 __ Branch(USE_DELAY_SLOT, &done, eq, scratch, Operand(at)); 2444 __ Branch(USE_DELAY_SLOT, &done, eq, scratch, Operand(at));
2445 __ LoadRoot(at, Heap::kFixedCOWArrayMapRootIndex); // In the delay slot. 2445 __ LoadRoot(at, Heap::kFixedCOWArrayMapRootIndex); // In the delay slot.
2446 __ Branch(&done, eq, scratch, Operand(at)); 2446 __ Branch(&done, eq, scratch, Operand(at));
2447 // |scratch| still contains |input|'s map. 2447 // |scratch| still contains |input|'s map.
2448 __ lbu(scratch, FieldMemOperand(scratch, Map::kBitField2Offset)); 2448 __ lbu(scratch, FieldMemOperand(scratch, Map::kBitField2Offset));
2449 __ Ext(scratch, scratch, Map::kElementsKindShift, 2449 __ Ext(scratch, scratch, Map::kElementsKindShift,
2450 Map::kElementsKindBitCount); 2450 Map::kElementsKindBitCount);
2451 __ Branch(&done, eq, scratch, 2451 __ Branch(&fail, lt, scratch,
2452 Operand(FAST_ELEMENTS)); 2452 Operand(GetInitialFastElementsKind()));
2453 __ Branch(&done, le, scratch,
2454 Operand(TERMINAL_FAST_ELEMENTS_KIND));
2453 __ Branch(&fail, lt, scratch, 2455 __ Branch(&fail, lt, scratch,
2454 Operand(FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2456 Operand(FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2455 __ Branch(&done, le, scratch, 2457 __ Branch(&done, le, scratch,
2456 Operand(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2458 Operand(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2457 __ bind(&fail); 2459 __ bind(&fail);
2458 __ Abort("Check for fast or external elements failed."); 2460 __ Abort("Check for fast or external elements failed.");
2459 __ bind(&done); 2461 __ bind(&done);
2460 } 2462 }
2461 } 2463 }
2462 2464
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 if (key_is_constant) { 2537 if (key_is_constant) {
2536 __ Addu(elements, elements, Operand(constant_key * (1 << shift_size) + 2538 __ Addu(elements, elements, Operand(constant_key * (1 << shift_size) +
2537 FixedDoubleArray::kHeaderSize - kHeapObjectTag)); 2539 FixedDoubleArray::kHeaderSize - kHeapObjectTag));
2538 } else { 2540 } else {
2539 __ sll(scratch, key, shift_size); 2541 __ sll(scratch, key, shift_size);
2540 __ Addu(elements, elements, Operand(scratch)); 2542 __ Addu(elements, elements, Operand(scratch));
2541 __ Addu(elements, elements, 2543 __ Addu(elements, elements,
2542 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); 2544 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
2543 } 2545 }
2544 2546
2545 __ lw(scratch, MemOperand(elements, sizeof(kHoleNanLower32))); 2547 if (instr->hydrogen()->RequiresHoleCheck()) {
2546 DeoptimizeIf(eq, instr->environment(), scratch, Operand(kHoleNanUpper32)); 2548 __ lw(scratch, MemOperand(elements, sizeof(kHoleNanLower32)));
2549 DeoptimizeIf(eq, instr->environment(), scratch, Operand(kHoleNanUpper32));
2550 }
2547 2551
2548 __ ldc1(result, MemOperand(elements)); 2552 __ ldc1(result, MemOperand(elements));
2549 } 2553 }
2550 2554
2551 2555
2552 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2556 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2553 LLoadKeyedSpecializedArrayElement* instr) { 2557 LLoadKeyedSpecializedArrayElement* instr) {
2554 Register external_pointer = ToRegister(instr->external_pointer()); 2558 Register external_pointer = ToRegister(instr->external_pointer());
2555 Register key = no_reg; 2559 Register key = no_reg;
2556 ElementsKind elements_kind = instr->elements_kind(); 2560 ElementsKind elements_kind = instr->elements_kind();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 // TODO(danno): we could be more clever here, perhaps having a special 2620 // TODO(danno): we could be more clever here, perhaps having a special
2617 // version of the stub that detects if the overflow case actually 2621 // version of the stub that detects if the overflow case actually
2618 // happens, and generate code that returns a double rather than int. 2622 // happens, and generate code that returns a double rather than int.
2619 DeoptimizeIf(Ugreater_equal, instr->environment(), 2623 DeoptimizeIf(Ugreater_equal, instr->environment(),
2620 result, Operand(0x80000000)); 2624 result, Operand(0x80000000));
2621 break; 2625 break;
2622 case EXTERNAL_FLOAT_ELEMENTS: 2626 case EXTERNAL_FLOAT_ELEMENTS:
2623 case EXTERNAL_DOUBLE_ELEMENTS: 2627 case EXTERNAL_DOUBLE_ELEMENTS:
2624 case FAST_DOUBLE_ELEMENTS: 2628 case FAST_DOUBLE_ELEMENTS:
2625 case FAST_ELEMENTS: 2629 case FAST_ELEMENTS:
2626 case FAST_SMI_ONLY_ELEMENTS: 2630 case FAST_SMI_ELEMENTS:
2631 case FAST_HOLEY_DOUBLE_ELEMENTS:
2632 case FAST_HOLEY_ELEMENTS:
2633 case FAST_HOLEY_SMI_ELEMENTS:
2627 case DICTIONARY_ELEMENTS: 2634 case DICTIONARY_ELEMENTS:
2628 case NON_STRICT_ARGUMENTS_ELEMENTS: 2635 case NON_STRICT_ARGUMENTS_ELEMENTS:
2629 UNREACHABLE(); 2636 UNREACHABLE();
2630 break; 2637 break;
2631 } 2638 }
2632 } 2639 }
2633 } 2640 }
2634 2641
2635 2642
2636 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2643 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3634 __ sh(value, mem_operand); 3641 __ sh(value, mem_operand);
3635 break; 3642 break;
3636 case EXTERNAL_INT_ELEMENTS: 3643 case EXTERNAL_INT_ELEMENTS:
3637 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 3644 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
3638 __ sw(value, mem_operand); 3645 __ sw(value, mem_operand);
3639 break; 3646 break;
3640 case EXTERNAL_FLOAT_ELEMENTS: 3647 case EXTERNAL_FLOAT_ELEMENTS:
3641 case EXTERNAL_DOUBLE_ELEMENTS: 3648 case EXTERNAL_DOUBLE_ELEMENTS:
3642 case FAST_DOUBLE_ELEMENTS: 3649 case FAST_DOUBLE_ELEMENTS:
3643 case FAST_ELEMENTS: 3650 case FAST_ELEMENTS:
3644 case FAST_SMI_ONLY_ELEMENTS: 3651 case FAST_SMI_ELEMENTS:
3652 case FAST_HOLEY_DOUBLE_ELEMENTS:
3653 case FAST_HOLEY_ELEMENTS:
3654 case FAST_HOLEY_SMI_ELEMENTS:
3645 case DICTIONARY_ELEMENTS: 3655 case DICTIONARY_ELEMENTS:
3646 case NON_STRICT_ARGUMENTS_ELEMENTS: 3656 case NON_STRICT_ARGUMENTS_ELEMENTS:
3647 UNREACHABLE(); 3657 UNREACHABLE();
3648 break; 3658 break;
3649 } 3659 }
3650 } 3660 }
3651 } 3661 }
3652 3662
3653 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { 3663 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3654 ASSERT(ToRegister(instr->object()).is(a2)); 3664 ASSERT(ToRegister(instr->object()).is(a2));
(...skipping 17 matching lines...) Expand all
3672 ElementsKind from_kind = from_map->elements_kind(); 3682 ElementsKind from_kind = from_map->elements_kind();
3673 ElementsKind to_kind = to_map->elements_kind(); 3683 ElementsKind to_kind = to_map->elements_kind();
3674 3684
3675 __ mov(ToRegister(instr->result()), object_reg); 3685 __ mov(ToRegister(instr->result()), object_reg);
3676 3686
3677 Label not_applicable; 3687 Label not_applicable;
3678 __ lw(scratch, FieldMemOperand(object_reg, HeapObject::kMapOffset)); 3688 __ lw(scratch, FieldMemOperand(object_reg, HeapObject::kMapOffset));
3679 __ Branch(&not_applicable, ne, scratch, Operand(from_map)); 3689 __ Branch(&not_applicable, ne, scratch, Operand(from_map));
3680 3690
3681 __ li(new_map_reg, Operand(to_map)); 3691 __ li(new_map_reg, Operand(to_map));
3682 if (from_kind == FAST_SMI_ONLY_ELEMENTS && to_kind == FAST_ELEMENTS) { 3692 if (IsFastSmiElementsKind(from_kind) && IsFastObjectElementsKind(to_kind)) {
3683 __ sw(new_map_reg, FieldMemOperand(object_reg, HeapObject::kMapOffset)); 3693 __ sw(new_map_reg, FieldMemOperand(object_reg, HeapObject::kMapOffset));
3684 // Write barrier. 3694 // Write barrier.
3685 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, 3695 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg,
3686 scratch, kRAHasBeenSaved, kDontSaveFPRegs); 3696 scratch, kRAHasBeenSaved, kDontSaveFPRegs);
3687 } else if (from_kind == FAST_SMI_ONLY_ELEMENTS && 3697 } else if (IsFastSmiElementsKind(from_kind) &&
3688 to_kind == FAST_DOUBLE_ELEMENTS) { 3698 IsFastDoubleElementsKind(to_kind)) {
3689 Register fixed_object_reg = ToRegister(instr->temp_reg()); 3699 Register fixed_object_reg = ToRegister(instr->temp_reg());
3690 ASSERT(fixed_object_reg.is(a2)); 3700 ASSERT(fixed_object_reg.is(a2));
3691 ASSERT(new_map_reg.is(a3)); 3701 ASSERT(new_map_reg.is(a3));
3692 __ mov(fixed_object_reg, object_reg); 3702 __ mov(fixed_object_reg, object_reg);
3693 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(), 3703 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(),
3694 RelocInfo::CODE_TARGET, instr); 3704 RelocInfo::CODE_TARGET, instr);
3695 } else if (from_kind == FAST_DOUBLE_ELEMENTS && to_kind == FAST_ELEMENTS) { 3705 } else if (IsFastDoubleElementsKind(from_kind) &&
3706 IsFastObjectElementsKind(to_kind)) {
3696 Register fixed_object_reg = ToRegister(instr->temp_reg()); 3707 Register fixed_object_reg = ToRegister(instr->temp_reg());
3697 ASSERT(fixed_object_reg.is(a2)); 3708 ASSERT(fixed_object_reg.is(a2));
3698 ASSERT(new_map_reg.is(a3)); 3709 ASSERT(new_map_reg.is(a3));
3699 __ mov(fixed_object_reg, object_reg); 3710 __ mov(fixed_object_reg, object_reg);
3700 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(), 3711 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(),
3701 RelocInfo::CODE_TARGET, instr); 3712 RelocInfo::CODE_TARGET, instr);
3702 } else { 3713 } else {
3703 UNREACHABLE(); 3714 UNREACHABLE();
3704 } 3715 }
3705 __ bind(&not_applicable); 3716 __ bind(&not_applicable);
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 } 4451 }
4441 4452
4442 4453
4443 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 4454 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
4444 Heap* heap = isolate()->heap(); 4455 Heap* heap = isolate()->heap();
4445 ElementsKind boilerplate_elements_kind = 4456 ElementsKind boilerplate_elements_kind =
4446 instr->hydrogen()->boilerplate_elements_kind(); 4457 instr->hydrogen()->boilerplate_elements_kind();
4447 4458
4448 // Deopt if the array literal boilerplate ElementsKind is of a type different 4459 // Deopt if the array literal boilerplate ElementsKind is of a type different
4449 // than the expected one. The check isn't necessary if the boilerplate has 4460 // than the expected one. The check isn't necessary if the boilerplate has
4450 // already been converted to FAST_ELEMENTS. 4461 // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
4451 if (boilerplate_elements_kind != FAST_ELEMENTS) { 4462 if (CanTransitionToMoreGeneralFastElementsKind(
4463 boilerplate_elements_kind, true)) {
4452 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate_object()); 4464 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate_object());
4453 // Load map into a2. 4465 // Load map into a2.
4454 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset)); 4466 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
4455 // Load the map's "bit field 2". 4467 // Load the map's "bit field 2".
4456 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset)); 4468 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset));
4457 // Retrieve elements_kind from bit field 2. 4469 // Retrieve elements_kind from bit field 2.
4458 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount); 4470 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount);
4459 DeoptimizeIf(ne, 4471 DeoptimizeIf(ne,
4460 instr->environment(), 4472 instr->environment(),
4461 a2, 4473 a2,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 } 4606 }
4595 } 4607 }
4596 } 4608 }
4597 4609
4598 4610
4599 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { 4611 void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
4600 int size = instr->hydrogen()->total_size(); 4612 int size = instr->hydrogen()->total_size();
4601 ElementsKind boilerplate_elements_kind = 4613 ElementsKind boilerplate_elements_kind =
4602 instr->hydrogen()->boilerplate()->GetElementsKind(); 4614 instr->hydrogen()->boilerplate()->GetElementsKind();
4603 4615
4604 // Deopt if the literal boilerplate ElementsKind is of a type different than 4616 // Deopt if the array literal boilerplate ElementsKind is of a type different
4605 // the expected one. The check isn't necessary if the boilerplate has already 4617 // than the expected one. The check isn't necessary if the boilerplate has
4606 // been converted to FAST_ELEMENTS. 4618 // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
4607 if (boilerplate_elements_kind != FAST_ELEMENTS) { 4619 if (CanTransitionToMoreGeneralFastElementsKind(
4620 boilerplate_elements_kind, true)) {
4608 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate()); 4621 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate());
4609 // Load map into a2. 4622 // Load map into a2.
4610 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset)); 4623 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
4611 // Load the map's "bit field 2". 4624 // Load the map's "bit field 2".
4612 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset)); 4625 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset));
4613 // Retrieve elements_kind from bit field 2. 4626 // Retrieve elements_kind from bit field 2.
4614 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount); 4627 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount);
4615 DeoptimizeIf(ne, instr->environment(), a2, 4628 DeoptimizeIf(ne, instr->environment(), a2,
4616 Operand(boilerplate_elements_kind)); 4629 Operand(boilerplate_elements_kind));
4617 } 4630 }
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 __ Subu(scratch, result, scratch); 5135 __ Subu(scratch, result, scratch);
5123 __ lw(result, FieldMemOperand(scratch, 5136 __ lw(result, FieldMemOperand(scratch,
5124 FixedArray::kHeaderSize - kPointerSize)); 5137 FixedArray::kHeaderSize - kPointerSize));
5125 __ bind(&done); 5138 __ bind(&done);
5126 } 5139 }
5127 5140
5128 5141
5129 #undef __ 5142 #undef __
5130 5143
5131 } } // namespace v8::internal 5144 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/ic-mips.cc ('k') | src/mips/lithium-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698