OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 4252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4263 bind(&loop); | 4263 bind(&loop); |
4264 JumpIfSmi(result, &done); | 4264 JumpIfSmi(result, &done); |
4265 GetObjectType(result, temp, temp2); | 4265 GetObjectType(result, temp, temp2); |
4266 Branch(&done, ne, temp2, Operand(MAP_TYPE)); | 4266 Branch(&done, ne, temp2, Operand(MAP_TYPE)); |
4267 lw(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); | 4267 lw(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); |
4268 Branch(&loop); | 4268 Branch(&loop); |
4269 bind(&done); | 4269 bind(&done); |
4270 } | 4270 } |
4271 | 4271 |
4272 | 4272 |
4273 void MacroAssembler::TryGetFunctionPrototype(Register function, | 4273 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result, |
4274 Register result, | 4274 Register scratch, Label* miss) { |
4275 Register scratch, | |
4276 Label* miss, | |
4277 bool miss_on_bound_function) { | |
4278 Label non_instance; | |
4279 if (miss_on_bound_function) { | |
4280 // Check that the receiver isn't a smi. | |
4281 JumpIfSmi(function, miss); | |
4282 | |
4283 // Check that the function really is a function. Load map into result reg. | |
4284 GetObjectType(function, result, scratch); | |
4285 Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE)); | |
4286 | |
4287 lw(scratch, | |
4288 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); | |
4289 lw(scratch, | |
4290 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); | |
4291 And(scratch, scratch, | |
4292 Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction))); | |
4293 Branch(miss, ne, scratch, Operand(zero_reg)); | |
4294 | |
4295 // Make sure that the function has an instance prototype. | |
4296 lbu(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); | |
4297 And(scratch, scratch, Operand(1 << Map::kHasNonInstancePrototype)); | |
4298 Branch(&non_instance, ne, scratch, Operand(zero_reg)); | |
4299 } | |
4300 | |
4301 // Get the prototype or initial map from the function. | 4275 // Get the prototype or initial map from the function. |
4302 lw(result, | 4276 lw(result, |
4303 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 4277 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
4304 | 4278 |
4305 // If the prototype or initial map is the hole, don't return it and | 4279 // If the prototype or initial map is the hole, don't return it and |
4306 // simply miss the cache instead. This will allow us to allocate a | 4280 // simply miss the cache instead. This will allow us to allocate a |
4307 // prototype object on-demand in the runtime system. | 4281 // prototype object on-demand in the runtime system. |
4308 LoadRoot(t8, Heap::kTheHoleValueRootIndex); | 4282 LoadRoot(t8, Heap::kTheHoleValueRootIndex); |
4309 Branch(miss, eq, result, Operand(t8)); | 4283 Branch(miss, eq, result, Operand(t8)); |
4310 | 4284 |
4311 // If the function does not have an initial map, we're done. | 4285 // If the function does not have an initial map, we're done. |
4312 Label done; | 4286 Label done; |
4313 GetObjectType(result, scratch, scratch); | 4287 GetObjectType(result, scratch, scratch); |
4314 Branch(&done, ne, scratch, Operand(MAP_TYPE)); | 4288 Branch(&done, ne, scratch, Operand(MAP_TYPE)); |
4315 | 4289 |
4316 // Get the prototype from the initial map. | 4290 // Get the prototype from the initial map. |
4317 lw(result, FieldMemOperand(result, Map::kPrototypeOffset)); | 4291 lw(result, FieldMemOperand(result, Map::kPrototypeOffset)); |
4318 | 4292 |
4319 if (miss_on_bound_function) { | |
4320 jmp(&done); | |
4321 | |
4322 // Non-instance prototype: Fetch prototype from constructor field | |
4323 // in initial map. | |
4324 bind(&non_instance); | |
4325 GetMapConstructor(result, result, scratch, scratch); | |
4326 } | |
4327 | |
4328 // All done. | 4293 // All done. |
4329 bind(&done); | 4294 bind(&done); |
4330 } | 4295 } |
4331 | 4296 |
4332 | 4297 |
4333 void MacroAssembler::GetObjectType(Register object, | 4298 void MacroAssembler::GetObjectType(Register object, |
4334 Register map, | 4299 Register map, |
4335 Register type_reg) { | 4300 Register type_reg) { |
4336 lw(map, FieldMemOperand(object, HeapObject::kMapOffset)); | 4301 lw(map, FieldMemOperand(object, HeapObject::kMapOffset)); |
4337 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 4302 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5549 lw(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 5514 lw(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
5550 } else { | 5515 } else { |
5551 Addu(sp, sp, Operand(stack_passed_arguments * kPointerSize)); | 5516 Addu(sp, sp, Operand(stack_passed_arguments * kPointerSize)); |
5552 } | 5517 } |
5553 } | 5518 } |
5554 | 5519 |
5555 | 5520 |
5556 #undef BRANCH_ARGS_CHECK | 5521 #undef BRANCH_ARGS_CHECK |
5557 | 5522 |
5558 | 5523 |
5559 void MacroAssembler::PatchRelocatedValue(Register li_location, | |
5560 Register scratch, | |
5561 Register new_value) { | |
5562 lw(scratch, MemOperand(li_location)); | |
5563 // At this point scratch is a lui(at, ...) instruction. | |
5564 if (emit_debug_code()) { | |
5565 And(scratch, scratch, kOpcodeMask); | |
5566 Check(eq, kTheInstructionToPatchShouldBeALui, | |
5567 scratch, Operand(LUI)); | |
5568 lw(scratch, MemOperand(li_location)); | |
5569 } | |
5570 srl(t9, new_value, kImm16Bits); | |
5571 Ins(scratch, t9, 0, kImm16Bits); | |
5572 sw(scratch, MemOperand(li_location)); | |
5573 | |
5574 lw(scratch, MemOperand(li_location, kInstrSize)); | |
5575 // scratch is now ori(at, ...). | |
5576 if (emit_debug_code()) { | |
5577 And(scratch, scratch, kOpcodeMask); | |
5578 Check(eq, kTheInstructionToPatchShouldBeAnOri, | |
5579 scratch, Operand(ORI)); | |
5580 lw(scratch, MemOperand(li_location, kInstrSize)); | |
5581 } | |
5582 Ins(scratch, new_value, 0, kImm16Bits); | |
5583 sw(scratch, MemOperand(li_location, kInstrSize)); | |
5584 | |
5585 // Update the I-cache so the new lui and ori can be executed. | |
5586 FlushICache(li_location, 2); | |
5587 } | |
5588 | |
5589 void MacroAssembler::GetRelocatedValue(Register li_location, | |
5590 Register value, | |
5591 Register scratch) { | |
5592 lw(value, MemOperand(li_location)); | |
5593 if (emit_debug_code()) { | |
5594 And(value, value, kOpcodeMask); | |
5595 Check(eq, kTheInstructionShouldBeALui, | |
5596 value, Operand(LUI)); | |
5597 lw(value, MemOperand(li_location)); | |
5598 } | |
5599 | |
5600 // value now holds a lui instruction. Extract the immediate. | |
5601 sll(value, value, kImm16Bits); | |
5602 | |
5603 lw(scratch, MemOperand(li_location, kInstrSize)); | |
5604 if (emit_debug_code()) { | |
5605 And(scratch, scratch, kOpcodeMask); | |
5606 Check(eq, kTheInstructionShouldBeAnOri, | |
5607 scratch, Operand(ORI)); | |
5608 lw(scratch, MemOperand(li_location, kInstrSize)); | |
5609 } | |
5610 // "scratch" now holds an ori instruction. Extract the immediate. | |
5611 andi(scratch, scratch, kImm16Mask); | |
5612 | |
5613 // Merge the results. | |
5614 or_(value, value, scratch); | |
5615 } | |
5616 | |
5617 | |
5618 void MacroAssembler::CheckPageFlag( | 5524 void MacroAssembler::CheckPageFlag( |
5619 Register object, | 5525 Register object, |
5620 Register scratch, | 5526 Register scratch, |
5621 int mask, | 5527 int mask, |
5622 Condition cc, | 5528 Condition cc, |
5623 Label* condition_met) { | 5529 Label* condition_met) { |
5624 And(scratch, object, Operand(~Page::kPageAlignmentMask)); | 5530 And(scratch, object, Operand(~Page::kPageAlignmentMask)); |
5625 lw(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset)); | 5531 lw(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset)); |
5626 And(scratch, scratch, Operand(mask)); | 5532 And(scratch, scratch, Operand(mask)); |
5627 Branch(condition_met, cc, scratch, Operand(zero_reg)); | 5533 Branch(condition_met, cc, scratch, Operand(zero_reg)); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6116 if (mag.shift > 0) sra(result, result, mag.shift); | 6022 if (mag.shift > 0) sra(result, result, mag.shift); |
6117 srl(at, dividend, 31); | 6023 srl(at, dividend, 31); |
6118 Addu(result, result, Operand(at)); | 6024 Addu(result, result, Operand(at)); |
6119 } | 6025 } |
6120 | 6026 |
6121 | 6027 |
6122 } // namespace internal | 6028 } // namespace internal |
6123 } // namespace v8 | 6029 } // namespace v8 |
6124 | 6030 |
6125 #endif // V8_TARGET_ARCH_MIPS | 6031 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |