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

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

Issue 1304633002: Correctify instanceof and make it optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Add MIPS/MIPS64 ports. Created 5 years, 3 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
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | src/objects.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 // 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_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 #include "src/base/division-by-constant.h" 9 #include "src/base/division-by-constant.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4255 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 bind(&loop); 4266 bind(&loop);
4267 JumpIfSmi(result, &done); 4267 JumpIfSmi(result, &done);
4268 GetObjectType(result, temp, temp2); 4268 GetObjectType(result, temp, temp2);
4269 Branch(&done, ne, temp2, Operand(MAP_TYPE)); 4269 Branch(&done, ne, temp2, Operand(MAP_TYPE));
4270 ld(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); 4270 ld(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset));
4271 Branch(&loop); 4271 Branch(&loop);
4272 bind(&done); 4272 bind(&done);
4273 } 4273 }
4274 4274
4275 4275
4276 void MacroAssembler::TryGetFunctionPrototype(Register function, 4276 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result,
4277 Register result, 4277 Register scratch, Label* miss) {
4278 Register scratch,
4279 Label* miss,
4280 bool miss_on_bound_function) {
4281 Label non_instance;
4282 if (miss_on_bound_function) {
4283 // Check that the receiver isn't a smi.
4284 JumpIfSmi(function, miss);
4285
4286 // Check that the function really is a function. Load map into result reg.
4287 GetObjectType(function, result, scratch);
4288 Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE));
4289
4290 ld(scratch,
4291 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
4292 lwu(scratch,
4293 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
4294 And(scratch, scratch,
4295 Operand(1 << SharedFunctionInfo::kBoundFunction));
4296 Branch(miss, ne, scratch, Operand(zero_reg));
4297
4298 // Make sure that the function has an instance prototype.
4299 lbu(scratch, FieldMemOperand(result, Map::kBitFieldOffset));
4300 And(scratch, scratch, Operand(1 << Map::kHasNonInstancePrototype));
4301 Branch(&non_instance, ne, scratch, Operand(zero_reg));
4302 }
4303
4304 // Get the prototype or initial map from the function. 4278 // Get the prototype or initial map from the function.
4305 ld(result, 4279 ld(result,
4306 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 4280 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
4307 4281
4308 // If the prototype or initial map is the hole, don't return it and 4282 // If the prototype or initial map is the hole, don't return it and
4309 // simply miss the cache instead. This will allow us to allocate a 4283 // simply miss the cache instead. This will allow us to allocate a
4310 // prototype object on-demand in the runtime system. 4284 // prototype object on-demand in the runtime system.
4311 LoadRoot(t8, Heap::kTheHoleValueRootIndex); 4285 LoadRoot(t8, Heap::kTheHoleValueRootIndex);
4312 Branch(miss, eq, result, Operand(t8)); 4286 Branch(miss, eq, result, Operand(t8));
4313 4287
4314 // If the function does not have an initial map, we're done. 4288 // If the function does not have an initial map, we're done.
4315 Label done; 4289 Label done;
4316 GetObjectType(result, scratch, scratch); 4290 GetObjectType(result, scratch, scratch);
4317 Branch(&done, ne, scratch, Operand(MAP_TYPE)); 4291 Branch(&done, ne, scratch, Operand(MAP_TYPE));
4318 4292
4319 // Get the prototype from the initial map. 4293 // Get the prototype from the initial map.
4320 ld(result, FieldMemOperand(result, Map::kPrototypeOffset)); 4294 ld(result, FieldMemOperand(result, Map::kPrototypeOffset));
4321 4295
4322 if (miss_on_bound_function) {
4323 jmp(&done);
4324
4325 // Non-instance prototype: Fetch prototype from constructor field
4326 // in initial map.
4327 bind(&non_instance);
4328 GetMapConstructor(result, result, scratch, scratch);
4329 }
4330
4331 // All done. 4296 // All done.
4332 bind(&done); 4297 bind(&done);
4333 } 4298 }
4334 4299
4335 4300
4336 void MacroAssembler::GetObjectType(Register object, 4301 void MacroAssembler::GetObjectType(Register object,
4337 Register map, 4302 Register map,
4338 Register type_reg) { 4303 Register type_reg) {
4339 ld(map, FieldMemOperand(object, HeapObject::kMapOffset)); 4304 ld(map, FieldMemOperand(object, HeapObject::kMapOffset));
4340 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); 4305 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
5743 ld(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); 5708 ld(sp, MemOperand(sp, stack_passed_arguments * kPointerSize));
5744 } else { 5709 } else {
5745 Daddu(sp, sp, Operand(stack_passed_arguments * kPointerSize)); 5710 Daddu(sp, sp, Operand(stack_passed_arguments * kPointerSize));
5746 } 5711 }
5747 } 5712 }
5748 5713
5749 5714
5750 #undef BRANCH_ARGS_CHECK 5715 #undef BRANCH_ARGS_CHECK
5751 5716
5752 5717
5753 void MacroAssembler::PatchRelocatedValue(Register li_location,
5754 Register scratch,
5755 Register new_value) {
5756 lwu(scratch, MemOperand(li_location));
5757 // At this point scratch is a lui(at, ...) instruction.
5758 if (emit_debug_code()) {
5759 And(scratch, scratch, kOpcodeMask);
5760 Check(eq, kTheInstructionToPatchShouldBeALui,
5761 scratch, Operand(LUI));
5762 lwu(scratch, MemOperand(li_location));
5763 }
5764 dsrl32(t9, new_value, 0);
5765 Ins(scratch, t9, 0, kImm16Bits);
5766 sw(scratch, MemOperand(li_location));
5767
5768 lwu(scratch, MemOperand(li_location, kInstrSize));
5769 // scratch is now ori(at, ...).
5770 if (emit_debug_code()) {
5771 And(scratch, scratch, kOpcodeMask);
5772 Check(eq, kTheInstructionToPatchShouldBeAnOri,
5773 scratch, Operand(ORI));
5774 lwu(scratch, MemOperand(li_location, kInstrSize));
5775 }
5776 dsrl(t9, new_value, kImm16Bits);
5777 Ins(scratch, t9, 0, kImm16Bits);
5778 sw(scratch, MemOperand(li_location, kInstrSize));
5779
5780 lwu(scratch, MemOperand(li_location, kInstrSize * 3));
5781 // scratch is now ori(at, ...).
5782 if (emit_debug_code()) {
5783 And(scratch, scratch, kOpcodeMask);
5784 Check(eq, kTheInstructionToPatchShouldBeAnOri,
5785 scratch, Operand(ORI));
5786 lwu(scratch, MemOperand(li_location, kInstrSize * 3));
5787 }
5788
5789 Ins(scratch, new_value, 0, kImm16Bits);
5790 sw(scratch, MemOperand(li_location, kInstrSize * 3));
5791
5792 // Update the I-cache so the new lui and ori can be executed.
5793 FlushICache(li_location, 4);
5794 }
5795
5796 void MacroAssembler::GetRelocatedValue(Register li_location,
5797 Register value,
5798 Register scratch) {
5799 lwu(value, MemOperand(li_location));
5800 if (emit_debug_code()) {
5801 And(value, value, kOpcodeMask);
5802 Check(eq, kTheInstructionShouldBeALui,
5803 value, Operand(LUI));
5804 lwu(value, MemOperand(li_location));
5805 }
5806
5807 // value now holds a lui instruction. Extract the immediate.
5808 andi(value, value, kImm16Mask);
5809 dsll32(value, value, kImm16Bits);
5810
5811 lwu(scratch, MemOperand(li_location, kInstrSize));
5812 if (emit_debug_code()) {
5813 And(scratch, scratch, kOpcodeMask);
5814 Check(eq, kTheInstructionShouldBeAnOri,
5815 scratch, Operand(ORI));
5816 lwu(scratch, MemOperand(li_location, kInstrSize));
5817 }
5818 // "scratch" now holds an ori instruction. Extract the immediate.
5819 andi(scratch, scratch, kImm16Mask);
5820 dsll32(scratch, scratch, 0);
5821
5822 or_(value, value, scratch);
5823
5824 lwu(scratch, MemOperand(li_location, kInstrSize * 3));
5825 if (emit_debug_code()) {
5826 And(scratch, scratch, kOpcodeMask);
5827 Check(eq, kTheInstructionShouldBeAnOri,
5828 scratch, Operand(ORI));
5829 lwu(scratch, MemOperand(li_location, kInstrSize * 3));
5830 }
5831 // "scratch" now holds an ori instruction. Extract the immediate.
5832 andi(scratch, scratch, kImm16Mask);
5833 dsll(scratch, scratch, kImm16Bits);
5834
5835 or_(value, value, scratch);
5836 // Sign extend extracted address.
5837 dsra(value, value, kImm16Bits);
5838 }
5839
5840
5841 void MacroAssembler::CheckPageFlag( 5718 void MacroAssembler::CheckPageFlag(
5842 Register object, 5719 Register object,
5843 Register scratch, 5720 Register scratch,
5844 int mask, 5721 int mask,
5845 Condition cc, 5722 Condition cc,
5846 Label* condition_met) { 5723 Label* condition_met) {
5847 And(scratch, object, Operand(~Page::kPageAlignmentMask)); 5724 And(scratch, object, Operand(~Page::kPageAlignmentMask));
5848 ld(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset)); 5725 ld(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset));
5849 And(scratch, scratch, Operand(mask)); 5726 And(scratch, scratch, Operand(mask));
5850 Branch(condition_met, cc, scratch, Operand(zero_reg)); 5727 Branch(condition_met, cc, scratch, Operand(zero_reg));
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 if (mag.shift > 0) sra(result, result, mag.shift); 6217 if (mag.shift > 0) sra(result, result, mag.shift);
6341 srl(at, dividend, 31); 6218 srl(at, dividend, 31);
6342 Addu(result, result, Operand(at)); 6219 Addu(result, result, Operand(at));
6343 } 6220 }
6344 6221
6345 6222
6346 } // namespace internal 6223 } // namespace internal
6347 } // namespace v8 6224 } // namespace v8
6348 6225
6349 #endif // V8_TARGET_ARCH_MIPS64 6226 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698