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

Side by Side Diff: src/mips/macro-assembler-mips.cc

Issue 9372063: MIPS: Enable serialization for MIPS architecture. (Closed)
Patch Set: Rework on serialization handling of root references. Created 8 years, 9 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
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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } else { 752 } else {
753 srl(at, rs, rt.imm32_); 753 srl(at, rs, rt.imm32_);
754 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f); 754 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f);
755 or_(rd, rd, at); 755 or_(rd, rd, at);
756 } 756 }
757 } 757 }
758 } 758 }
759 } 759 }
760 760
761 761
762 static const int kInvalidRootIndex = -1;
763
764 int MacroAssembler::FindRootIndex(Object* heap_object) {
765 Heap* heap = HEAP;
766 if (heap->InNewSpace(heap_object)) return kInvalidRootIndex;
Erik Corry 2012/03/17 02:49:18 Since your comment indicated that this function is
767 for (int i = 0; i < Heap::kRootListLength; i++) {
768 Object* root = heap->roots_array_start()[i];
769 if (!root->IsSmi() && root == heap_object) return i;
770 }
771 return kInvalidRootIndex;
772 }
773
774
762 //------------Pseudo-instructions------------- 775 //------------Pseudo-instructions-------------
763 776
764 void MacroAssembler::li(Register rd, Operand j, bool gen2instr) { 777 void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
765 ASSERT(!j.is_reg()); 778 ASSERT(!j.is_reg());
766 BlockTrampolinePoolScope block_trampoline_pool(this); 779 BlockTrampolinePoolScope block_trampoline_pool(this);
767 if (!MustUseReg(j.rmode_) && !gen2instr) { 780 if (!MustUseReg(j.rmode_) && mode == OPTIMIZE_SIZE) {
768 // Normal load of an immediate value which does not need Relocation Info. 781 // Normal load of an immediate value which does not need Relocation Info.
769 if (is_int16(j.imm32_)) { 782 if (is_int16(j.imm32_)) {
770 addiu(rd, zero_reg, j.imm32_); 783 addiu(rd, zero_reg, j.imm32_);
771 } else if (!(j.imm32_ & kHiMask)) { 784 } else if (!(j.imm32_ & kHiMask)) {
772 ori(rd, zero_reg, j.imm32_); 785 ori(rd, zero_reg, j.imm32_);
773 } else if (!(j.imm32_ & kImm16Mask)) { 786 } else if (!(j.imm32_ & kImm16Mask)) {
774 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); 787 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask);
775 } else { 788 } else {
776 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); 789 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask);
777 ori(rd, rd, (j.imm32_ & kImm16Mask)); 790 ori(rd, rd, (j.imm32_ & kImm16Mask));
778 } 791 }
779 } else if (MustUseReg(j.rmode_) || gen2instr) { 792 } else if (SerializingTryLoadFromRoot(j.rmode_) && mode == OPTIMIZE_SIZE) {
Erik Corry 2012/03/17 02:49:18 I took out this change.
793 int32_t index = FindRootIndex(*(reinterpret_cast<Object**>(j.imm32_)));
794 if (index != kInvalidRootIndex) {
795 // Replace lui/ori pair for references that are found in root array with
796 // relative load using LoadRoot with no relocation info. This replacement
797 // is performed only if serialization is turned on.
798 LoadRoot(rd, static_cast<Heap::RootListIndex>(index));
799 } else {
800 if (MustUseReg(j.rmode_)) {
801 RecordRelocInfo(j.rmode_, j.imm32_);
802 }
803 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask);
804 ori(rd, rd, (j.imm32_ & kImm16Mask));
805 }
806 } else {
780 if (MustUseReg(j.rmode_)) { 807 if (MustUseReg(j.rmode_)) {
781 RecordRelocInfo(j.rmode_, j.imm32_); 808 RecordRelocInfo(j.rmode_, j.imm32_);
782 } 809 }
783 // We always need the same number of instructions as we may need to patch 810 // We always need the same number of instructions as we may need to patch
784 // this code to load another value which may need 2 instructions to load. 811 // this code to load another value which may need 2 instructions to load.
785 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); 812 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask);
786 ori(rd, rd, (j.imm32_ & kImm16Mask)); 813 ori(rd, rd, (j.imm32_ & kImm16Mask));
787 } 814 }
788 } 815 }
789 816
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 BranchShort(&skip, neg_cond, rs, rt); 1517 BranchShort(&skip, neg_cond, rs, rt);
1491 Jr(L, bdslot); 1518 Jr(L, bdslot);
1492 bind(&skip); 1519 bind(&skip);
1493 } else { 1520 } else {
1494 BranchShort(L, cond, rs, rt, bdslot); 1521 BranchShort(L, cond, rs, rt, bdslot);
1495 } 1522 }
1496 } 1523 }
1497 } 1524 }
1498 1525
1499 1526
1527 void MacroAssembler::Branch(Label* L,
1528 Condition cond,
1529 Register rs,
1530 Heap::RootListIndex index,
1531 BranchDelaySlot bdslot) {
1532 LoadRoot(at, index);
1533 Branch(L, cond, rs, Operand(at), bdslot);
1534 }
1535
1536
1500 void MacroAssembler::BranchShort(int16_t offset, BranchDelaySlot bdslot) { 1537 void MacroAssembler::BranchShort(int16_t offset, BranchDelaySlot bdslot) {
1501 b(offset); 1538 b(offset);
1502 1539
1503 // Emit a nop in the branch delay slot if required. 1540 // Emit a nop in the branch delay slot if required.
1504 if (bdslot == PROTECT) 1541 if (bdslot == PROTECT)
1505 nop(); 1542 nop();
1506 } 1543 }
1507 1544
1508 1545
1509 void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, 1546 void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs,
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 Register rs, 2414 Register rs,
2378 const Operand& rt, 2415 const Operand& rt,
2379 BranchDelaySlot bd) { 2416 BranchDelaySlot bd) {
2380 BlockTrampolinePoolScope block_trampoline_pool(this); 2417 BlockTrampolinePoolScope block_trampoline_pool(this);
2381 Label start; 2418 Label start;
2382 bind(&start); 2419 bind(&start);
2383 int32_t target_int = reinterpret_cast<int32_t>(target); 2420 int32_t target_int = reinterpret_cast<int32_t>(target);
2384 // Must record previous source positions before the 2421 // Must record previous source positions before the
2385 // li() generates a new code target. 2422 // li() generates a new code target.
2386 positions_recorder()->WriteRecordedPositions(); 2423 positions_recorder()->WriteRecordedPositions();
2387 li(t9, Operand(target_int, rmode), true); 2424 li(t9, Operand(target_int, rmode), CONSTANT_SIZE);
2388 Call(t9, cond, rs, rt, bd); 2425 Call(t9, cond, rs, rt, bd);
2389 ASSERT_EQ(CallSize(target, rmode, cond, rs, rt, bd), 2426 ASSERT_EQ(CallSize(target, rmode, cond, rs, rt, bd),
2390 SizeOfCodeGeneratedSince(&start)); 2427 SizeOfCodeGeneratedSince(&start));
2391 } 2428 }
2392 2429
2393 2430
2394 int MacroAssembler::CallSize(Handle<Code> code, 2431 int MacroAssembler::CallSize(Handle<Code> code,
2395 RelocInfo::Mode rmode, 2432 RelocInfo::Mode rmode,
2396 unsigned ast_id, 2433 unsigned ast_id,
2397 Condition cond, 2434 Condition cond,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2586 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 2623 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
2587 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 2624 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
2588 2625
2589 // For the JSEntry handler, we must preserve a0-a3 and s0. 2626 // For the JSEntry handler, we must preserve a0-a3 and s0.
2590 // t1-t3 are available. We will build up the handler from the bottom by 2627 // t1-t3 are available. We will build up the handler from the bottom by
2591 // pushing on the stack. 2628 // pushing on the stack.
2592 // Set up the code object (t1) and the state (t2) for pushing. 2629 // Set up the code object (t1) and the state (t2) for pushing.
2593 unsigned state = 2630 unsigned state =
2594 StackHandler::IndexField::encode(handler_index) | 2631 StackHandler::IndexField::encode(handler_index) |
2595 StackHandler::KindField::encode(kind); 2632 StackHandler::KindField::encode(kind);
2596 li(t1, Operand(CodeObject())); 2633 li(t1, Operand(CodeObject()), CONSTANT_SIZE);
2597 li(t2, Operand(state)); 2634 li(t2, Operand(state));
2598 2635
2599 // Push the frame pointer, context, state, and code object. 2636 // Push the frame pointer, context, state, and code object.
2600 if (kind == StackHandler::JS_ENTRY) { 2637 if (kind == StackHandler::JS_ENTRY) {
2601 ASSERT_EQ(Smi::FromInt(0), 0); 2638 ASSERT_EQ(Smi::FromInt(0), 0);
2602 // The second zero_reg indicates no context. 2639 // The second zero_reg indicates no context.
2603 // The first zero_reg is the NULL frame pointer. 2640 // The first zero_reg is the NULL frame pointer.
2604 // The operands are reversed to match the order of MultiPush/Pop. 2641 // The operands are reversed to match the order of MultiPush/Pop.
2605 Push(zero_reg, zero_reg, t2, t1); 2642 Push(zero_reg, zero_reg, t2, t1);
2606 } else { 2643 } else {
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
3215 Label smi_value, maybe_nan, have_double_value, is_nan, done; 3252 Label smi_value, maybe_nan, have_double_value, is_nan, done;
3216 Register mantissa_reg = scratch2; 3253 Register mantissa_reg = scratch2;
3217 Register exponent_reg = scratch3; 3254 Register exponent_reg = scratch3;
3218 3255
3219 // Handle smi values specially. 3256 // Handle smi values specially.
3220 JumpIfSmi(value_reg, &smi_value); 3257 JumpIfSmi(value_reg, &smi_value);
3221 3258
3222 // Ensure that the object is a heap number 3259 // Ensure that the object is a heap number
3223 CheckMap(value_reg, 3260 CheckMap(value_reg,
3224 scratch1, 3261 scratch1,
3225 isolate()->factory()->heap_number_map(), 3262 Heap::kHeapNumberMapRootIndex,
3226 fail, 3263 fail,
3227 DONT_DO_SMI_CHECK); 3264 DONT_DO_SMI_CHECK);
3228 3265
3229 // Check for nan: all NaN values have a value greater (signed) than 0x7ff00000 3266 // Check for nan: all NaN values have a value greater (signed) than 0x7ff00000
3230 // in the exponent. 3267 // in the exponent.
3231 li(scratch1, Operand(kNaNOrInfinityLowerBoundUpper32)); 3268 li(scratch1, Operand(kNaNOrInfinityLowerBoundUpper32));
3232 lw(exponent_reg, FieldMemOperand(value_reg, HeapNumber::kExponentOffset)); 3269 lw(exponent_reg, FieldMemOperand(value_reg, HeapNumber::kExponentOffset));
3233 Branch(&maybe_nan, ge, exponent_reg, Operand(scratch1)); 3270 Branch(&maybe_nan, ge, exponent_reg, Operand(scratch1));
3234 3271
3235 lw(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset)); 3272 lw(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset));
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
4318 bind(&fail); 4355 bind(&fail);
4319 Abort("Global functions must have initial map"); 4356 Abort("Global functions must have initial map");
4320 bind(&ok); 4357 bind(&ok);
4321 } 4358 }
4322 } 4359 }
4323 4360
4324 4361
4325 void MacroAssembler::EnterFrame(StackFrame::Type type) { 4362 void MacroAssembler::EnterFrame(StackFrame::Type type) {
4326 addiu(sp, sp, -5 * kPointerSize); 4363 addiu(sp, sp, -5 * kPointerSize);
4327 li(t8, Operand(Smi::FromInt(type))); 4364 li(t8, Operand(Smi::FromInt(type)));
4328 li(t9, Operand(CodeObject())); 4365 li(t9, Operand(CodeObject()), CONSTANT_SIZE);
4329 sw(ra, MemOperand(sp, 4 * kPointerSize)); 4366 sw(ra, MemOperand(sp, 4 * kPointerSize));
4330 sw(fp, MemOperand(sp, 3 * kPointerSize)); 4367 sw(fp, MemOperand(sp, 3 * kPointerSize));
4331 sw(cp, MemOperand(sp, 2 * kPointerSize)); 4368 sw(cp, MemOperand(sp, 2 * kPointerSize));
4332 sw(t8, MemOperand(sp, 1 * kPointerSize)); 4369 sw(t8, MemOperand(sp, 1 * kPointerSize));
4333 sw(t9, MemOperand(sp, 0 * kPointerSize)); 4370 sw(t9, MemOperand(sp, 0 * kPointerSize));
4334 addiu(fp, sp, 3 * kPointerSize); 4371 addiu(fp, sp, 3 * kPointerSize);
4335 } 4372 }
4336 4373
4337 4374
4338 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 4375 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
(...skipping 23 matching lines...) Expand all
4362 // Save registers. 4399 // Save registers.
4363 addiu(sp, sp, -4 * kPointerSize); 4400 addiu(sp, sp, -4 * kPointerSize);
4364 sw(ra, MemOperand(sp, 3 * kPointerSize)); 4401 sw(ra, MemOperand(sp, 3 * kPointerSize));
4365 sw(fp, MemOperand(sp, 2 * kPointerSize)); 4402 sw(fp, MemOperand(sp, 2 * kPointerSize));
4366 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer. 4403 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer.
4367 4404
4368 if (emit_debug_code()) { 4405 if (emit_debug_code()) {
4369 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); 4406 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset));
4370 } 4407 }
4371 4408
4372 li(t8, Operand(CodeObject())); // Accessed from ExitFrame::code_slot. 4409 // Accessed from ExitFrame::code_slot.
4410 li(t8, Operand(CodeObject()), CONSTANT_SIZE);
4373 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); 4411 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset));
4374 4412
4375 // Save the frame pointer and the context in top. 4413 // Save the frame pointer and the context in top.
4376 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); 4414 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
4377 sw(fp, MemOperand(t8)); 4415 sw(fp, MemOperand(t8));
4378 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 4416 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
4379 sw(cp, MemOperand(t8)); 4417 sw(cp, MemOperand(t8));
4380 4418
4381 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); 4419 const int frame_alignment = MacroAssembler::ActivationFrameAlignment();
4382 if (save_doubles) { 4420 if (save_doubles) {
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
5081 bind(&done); 5119 bind(&done);
5082 } 5120 }
5083 5121
5084 5122
5085 void MacroAssembler::LoadInstanceDescriptors(Register map, 5123 void MacroAssembler::LoadInstanceDescriptors(Register map,
5086 Register descriptors) { 5124 Register descriptors) {
5087 lw(descriptors, 5125 lw(descriptors,
5088 FieldMemOperand(map, Map::kInstanceDescriptorsOrBitField3Offset)); 5126 FieldMemOperand(map, Map::kInstanceDescriptorsOrBitField3Offset));
5089 Label not_smi; 5127 Label not_smi;
5090 JumpIfNotSmi(descriptors, &not_smi); 5128 JumpIfNotSmi(descriptors, &not_smi);
5091 li(descriptors, Operand(FACTORY->empty_descriptor_array())); 5129 LoadRoot(descriptors, Heap::kEmptyDescriptorArrayRootIndex);
5092 bind(&not_smi); 5130 bind(&not_smi);
5093 } 5131 }
5094 5132
5095 5133
5096 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) { 5134 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) {
5097 Label next; 5135 Label next;
5098 // Preload a couple of values used in the loop. 5136 // Preload a couple of values used in the loop.
5099 Register empty_fixed_array_value = t2; 5137 Register empty_fixed_array_value = t2;
5100 LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex); 5138 LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex);
5101 Register empty_descriptor_array_value = t3; 5139 Register empty_descriptor_array_value = t3;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 opcode == BGTZL); 5277 opcode == BGTZL);
5240 opcode = (cond == eq) ? BEQ : BNE; 5278 opcode = (cond == eq) ? BEQ : BNE;
5241 instr = (instr & ~kOpcodeMask) | opcode; 5279 instr = (instr & ~kOpcodeMask) | opcode;
5242 masm_.emit(instr); 5280 masm_.emit(instr);
5243 } 5281 }
5244 5282
5245 5283
5246 } } // namespace v8::internal 5284 } } // namespace v8::internal
5247 5285
5248 #endif // V8_TARGET_ARCH_MIPS 5286 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698