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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 12387076: MIPS: Minor cleanup of CompareIC state (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.16
Patch Set: Fixed nits Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1777
1778 1778
1779 static void ICCompareStub_CheckInputType(MacroAssembler* masm, 1779 static void ICCompareStub_CheckInputType(MacroAssembler* masm,
1780 Register input, 1780 Register input,
1781 Register scratch, 1781 Register scratch,
1782 CompareIC::State expected, 1782 CompareIC::State expected,
1783 Label* fail) { 1783 Label* fail) {
1784 Label ok; 1784 Label ok;
1785 if (expected == CompareIC::SMI) { 1785 if (expected == CompareIC::SMI) {
1786 __ JumpIfNotSmi(input, fail); 1786 __ JumpIfNotSmi(input, fail);
1787 } else if (expected == CompareIC::HEAP_NUMBER) { 1787 } else if (expected == CompareIC::NUMBER) {
1788 __ JumpIfSmi(input, &ok); 1788 __ JumpIfSmi(input, &ok);
1789 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, 1789 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail,
1790 DONT_DO_SMI_CHECK); 1790 DONT_DO_SMI_CHECK);
1791 } 1791 }
1792 // We could be strict about symbol/string here, but as long as 1792 // We could be strict about symbol/string here, but as long as
1793 // hydrogen doesn't care, the stub doesn't have to care either. 1793 // hydrogen doesn't care, the stub doesn't have to care either.
1794 __ bind(&ok); 1794 __ bind(&ok);
1795 } 1795 }
1796 1796
1797 1797
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 2136
2137 // TODO(svenpanne): Use virtual functions instead of switch. 2137 // TODO(svenpanne): Use virtual functions instead of switch.
2138 void UnaryOpStub::Generate(MacroAssembler* masm) { 2138 void UnaryOpStub::Generate(MacroAssembler* masm) {
2139 switch (operand_type_) { 2139 switch (operand_type_) {
2140 case UnaryOpIC::UNINITIALIZED: 2140 case UnaryOpIC::UNINITIALIZED:
2141 GenerateTypeTransition(masm); 2141 GenerateTypeTransition(masm);
2142 break; 2142 break;
2143 case UnaryOpIC::SMI: 2143 case UnaryOpIC::SMI:
2144 GenerateSmiStub(masm); 2144 GenerateSmiStub(masm);
2145 break; 2145 break;
2146 case UnaryOpIC::HEAP_NUMBER: 2146 case UnaryOpIC::NUMBER:
2147 GenerateHeapNumberStub(masm); 2147 GenerateNumberStub(masm);
2148 break; 2148 break;
2149 case UnaryOpIC::GENERIC: 2149 case UnaryOpIC::GENERIC:
2150 GenerateGenericStub(masm); 2150 GenerateGenericStub(masm);
2151 break; 2151 break;
2152 } 2152 }
2153 } 2153 }
2154 2154
2155 2155
2156 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { 2156 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
2157 // Argument is in a0 and v0 at this point, so we can overwrite a0. 2157 // Argument is in a0 and v0 at this point, so we can overwrite a0.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 __ JumpIfNotSmi(a0, non_smi); 2217 __ JumpIfNotSmi(a0, non_smi);
2218 2218
2219 // Flip bits and revert inverted smi-tag. 2219 // Flip bits and revert inverted smi-tag.
2220 __ Neg(v0, a0); 2220 __ Neg(v0, a0);
2221 __ And(v0, v0, ~kSmiTagMask); 2221 __ And(v0, v0, ~kSmiTagMask);
2222 __ Ret(); 2222 __ Ret();
2223 } 2223 }
2224 2224
2225 2225
2226 // TODO(svenpanne): Use virtual functions instead of switch. 2226 // TODO(svenpanne): Use virtual functions instead of switch.
2227 void UnaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { 2227 void UnaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
2228 switch (op_) { 2228 switch (op_) {
2229 case Token::SUB: 2229 case Token::SUB:
2230 GenerateHeapNumberStubSub(masm); 2230 GenerateNumberStubSub(masm);
2231 break; 2231 break;
2232 case Token::BIT_NOT: 2232 case Token::BIT_NOT:
2233 GenerateHeapNumberStubBitNot(masm); 2233 GenerateNumberStubBitNot(masm);
2234 break; 2234 break;
2235 default: 2235 default:
2236 UNREACHABLE(); 2236 UNREACHABLE();
2237 } 2237 }
2238 } 2238 }
2239 2239
2240 2240
2241 void UnaryOpStub::GenerateHeapNumberStubSub(MacroAssembler* masm) { 2241 void UnaryOpStub::GenerateNumberStubSub(MacroAssembler* masm) {
2242 Label non_smi, slow, call_builtin; 2242 Label non_smi, slow, call_builtin;
2243 GenerateSmiCodeSub(masm, &non_smi, &call_builtin); 2243 GenerateSmiCodeSub(masm, &non_smi, &call_builtin);
2244 __ bind(&non_smi); 2244 __ bind(&non_smi);
2245 GenerateHeapNumberCodeSub(masm, &slow); 2245 GenerateHeapNumberCodeSub(masm, &slow);
2246 __ bind(&slow); 2246 __ bind(&slow);
2247 GenerateTypeTransition(masm); 2247 GenerateTypeTransition(masm);
2248 __ bind(&call_builtin); 2248 __ bind(&call_builtin);
2249 GenerateGenericCodeFallback(masm); 2249 GenerateGenericCodeFallback(masm);
2250 } 2250 }
2251 2251
2252 2252
2253 void UnaryOpStub::GenerateHeapNumberStubBitNot(MacroAssembler* masm) { 2253 void UnaryOpStub::GenerateNumberStubBitNot(MacroAssembler* masm) {
2254 Label non_smi, slow; 2254 Label non_smi, slow;
2255 GenerateSmiCodeBitNot(masm, &non_smi); 2255 GenerateSmiCodeBitNot(masm, &non_smi);
2256 __ bind(&non_smi); 2256 __ bind(&non_smi);
2257 GenerateHeapNumberCodeBitNot(masm, &slow); 2257 GenerateHeapNumberCodeBitNot(masm, &slow);
2258 __ bind(&slow); 2258 __ bind(&slow);
2259 GenerateTypeTransition(masm); 2259 GenerateTypeTransition(masm);
2260 } 2260 }
2261 2261
2262 2262
2263 void UnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, 2263 void UnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm,
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 // Load the operands. 2658 // Load the operands.
2659 if (smi_operands) { 2659 if (smi_operands) {
2660 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2); 2660 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2);
2661 } else { 2661 } else {
2662 // Load right operand to f14 or a2/a3. 2662 // Load right operand to f14 or a2/a3.
2663 if (right_type == BinaryOpIC::INT32) { 2663 if (right_type == BinaryOpIC::INT32) {
2664 FloatingPointHelper::LoadNumberAsInt32Double( 2664 FloatingPointHelper::LoadNumberAsInt32Double(
2665 masm, right, destination, f14, f16, a2, a3, heap_number_map, 2665 masm, right, destination, f14, f16, a2, a3, heap_number_map,
2666 scratch1, scratch2, f2, miss); 2666 scratch1, scratch2, f2, miss);
2667 } else { 2667 } else {
2668 Label* fail = (right_type == BinaryOpIC::HEAP_NUMBER) ? miss 2668 Label* fail = (right_type == BinaryOpIC::NUMBER) ? miss : not_numbers;
2669 : not_numbers;
2670 FloatingPointHelper::LoadNumber( 2669 FloatingPointHelper::LoadNumber(
2671 masm, destination, right, f14, a2, a3, heap_number_map, 2670 masm, destination, right, f14, a2, a3, heap_number_map,
2672 scratch1, scratch2, fail); 2671 scratch1, scratch2, fail);
2673 } 2672 }
2674 // Load left operand to f12 or a0/a1. This keeps a0/a1 intact if it 2673 // Load left operand to f12 or a0/a1. This keeps a0/a1 intact if it
2675 // jumps to |miss|. 2674 // jumps to |miss|.
2676 if (left_type == BinaryOpIC::INT32) { 2675 if (left_type == BinaryOpIC::INT32) {
2677 FloatingPointHelper::LoadNumberAsInt32Double( 2676 FloatingPointHelper::LoadNumberAsInt32Double(
2678 masm, left, destination, f12, f16, a0, a1, heap_number_map, 2677 masm, left, destination, f12, f16, a0, a1, heap_number_map,
2679 scratch1, scratch2, f2, miss); 2678 scratch1, scratch2, f2, miss);
2680 } else { 2679 } else {
2681 Label* fail = (left_type == BinaryOpIC::HEAP_NUMBER) ? miss 2680 Label* fail = (left_type == BinaryOpIC::NUMBER) ? miss : not_numbers;
2682 : not_numbers;
2683 FloatingPointHelper::LoadNumber( 2681 FloatingPointHelper::LoadNumber(
2684 masm, destination, left, f12, a0, a1, heap_number_map, 2682 masm, destination, left, f12, a0, a1, heap_number_map,
2685 scratch1, scratch2, fail); 2683 scratch1, scratch2, fail);
2686 } 2684 }
2687 } 2685 }
2688 2686
2689 // Calculate the result. 2687 // Calculate the result.
2690 if (destination == FloatingPointHelper::kFPURegisters) { 2688 if (destination == FloatingPointHelper::kFPURegisters) {
2691 // Using FPU registers: 2689 // Using FPU registers:
2692 // f12: Left value. 2690 // f12: Left value.
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 // Tag the result and return. 3069 // Tag the result and return.
3072 __ SmiTag(v0, scratch1); 3070 __ SmiTag(v0, scratch1);
3073 __ Ret(); 3071 __ Ret();
3074 } else { 3072 } else {
3075 // DIV just falls through to allocating a heap number. 3073 // DIV just falls through to allocating a heap number.
3076 } 3074 }
3077 3075
3078 __ bind(&return_heap_number); 3076 __ bind(&return_heap_number);
3079 // Return a heap number, or fall through to type transition or runtime 3077 // Return a heap number, or fall through to type transition or runtime
3080 // call if we can't. 3078 // call if we can't.
3081 if (result_type_ >= ((op_ == Token::DIV) ? BinaryOpIC::HEAP_NUMBER 3079 if (result_type_ >= ((op_ == Token::DIV) ? BinaryOpIC::NUMBER
3082 : BinaryOpIC::INT32)) { 3080 : BinaryOpIC::INT32)) {
3083 // We are using FPU registers so s0 is available. 3081 // We are using FPU registers so s0 is available.
3084 heap_number_result = s0; 3082 heap_number_result = s0;
3085 BinaryOpStub_GenerateHeapResultAllocation(masm, 3083 BinaryOpStub_GenerateHeapResultAllocation(masm,
3086 heap_number_result, 3084 heap_number_result,
3087 heap_number_map, 3085 heap_number_map,
3088 scratch1, 3086 scratch1,
3089 scratch2, 3087 scratch2,
3090 &call_runtime, 3088 &call_runtime,
3091 mode_); 3089 mode_);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 __ bind(&check); 3298 __ bind(&check);
3301 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); 3299 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex);
3302 __ Branch(&done, ne, a0, Operand(t0)); 3300 __ Branch(&done, ne, a0, Operand(t0));
3303 if (Token::IsBitOp(op_)) { 3301 if (Token::IsBitOp(op_)) {
3304 __ li(a0, Operand(Smi::FromInt(0))); 3302 __ li(a0, Operand(Smi::FromInt(0)));
3305 } else { 3303 } else {
3306 __ LoadRoot(a0, Heap::kNanValueRootIndex); 3304 __ LoadRoot(a0, Heap::kNanValueRootIndex);
3307 } 3305 }
3308 __ bind(&done); 3306 __ bind(&done);
3309 3307
3310 GenerateHeapNumberStub(masm); 3308 GenerateNumberStub(masm);
3311 } 3309 }
3312 3310
3313 3311
3314 void BinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { 3312 void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
3315 Label call_runtime, transition; 3313 Label call_runtime, transition;
3316 BinaryOpStub_GenerateFPOperation( 3314 BinaryOpStub_GenerateFPOperation(
3317 masm, left_type_, right_type_, false, 3315 masm, left_type_, right_type_, false,
3318 &transition, &call_runtime, &transition, op_, mode_); 3316 &transition, &call_runtime, &transition, op_, mode_);
3319 3317
3320 __ bind(&transition); 3318 __ bind(&transition);
3321 GenerateTypeTransition(masm); 3319 GenerateTypeTransition(masm);
3322 3320
3323 __ bind(&call_runtime); 3321 __ bind(&call_runtime);
3324 GenerateRegisterArgsPush(masm); 3322 GenerateRegisterArgsPush(masm);
(...skipping 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after
7001 __ SmiUntag(a0); 6999 __ SmiUntag(a0);
7002 __ Subu(v0, a1, a0); 7000 __ Subu(v0, a1, a0);
7003 } 7001 }
7004 __ Ret(); 7002 __ Ret();
7005 7003
7006 __ bind(&miss); 7004 __ bind(&miss);
7007 GenerateMiss(masm); 7005 GenerateMiss(masm);
7008 } 7006 }
7009 7007
7010 7008
7011 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { 7009 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) {
7012 ASSERT(state_ == CompareIC::HEAP_NUMBER); 7010 ASSERT(state_ == CompareIC::NUMBER);
7013 7011
7014 Label generic_stub; 7012 Label generic_stub;
7015 Label unordered, maybe_undefined1, maybe_undefined2; 7013 Label unordered, maybe_undefined1, maybe_undefined2;
7016 Label miss; 7014 Label miss;
7017 7015
7018 if (left_ == CompareIC::SMI) { 7016 if (left_ == CompareIC::SMI) {
7019 __ JumpIfNotSmi(a1, &miss); 7017 __ JumpIfNotSmi(a1, &miss);
7020 } 7018 }
7021 if (right_ == CompareIC::SMI) { 7019 if (right_ == CompareIC::SMI) {
7022 __ JumpIfNotSmi(a0, &miss); 7020 __ JumpIfNotSmi(a0, &miss);
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 __ Pop(ra, t1, a1); 8024 __ Pop(ra, t1, a1);
8027 __ Ret(); 8025 __ Ret();
8028 } 8026 }
8029 8027
8030 8028
8031 #undef __ 8029 #undef __
8032 8030
8033 } } // namespace v8::internal 8031 } } // namespace v8::internal
8034 8032
8035 #endif // V8_TARGET_ARCH_MIPS 8033 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698