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 "src/crankshaft/mips64/lithium-codegen-mips64.h" | 5 #include "src/crankshaft/mips64/lithium-codegen-mips64.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/crankshaft/hydrogen-osr.h" | 9 #include "src/crankshaft/hydrogen-osr.h" |
10 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h" | 10 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h" |
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 DCHECK(!info()->IsStub()); | 2076 DCHECK(!info()->IsStub()); |
2077 DoubleRegister dbl_scratch = double_scratch0(); | 2077 DoubleRegister dbl_scratch = double_scratch0(); |
2078 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); | 2078 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); |
2079 // Test the double value. Zero and NaN are false. | 2079 // Test the double value. Zero and NaN are false. |
2080 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero); | 2080 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero); |
2081 } else if (type.IsString()) { | 2081 } else if (type.IsString()) { |
2082 DCHECK(!info()->IsStub()); | 2082 DCHECK(!info()->IsStub()); |
2083 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); | 2083 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); |
2084 EmitBranch(instr, ne, at, Operand(zero_reg)); | 2084 EmitBranch(instr, ne, at, Operand(zero_reg)); |
2085 } else { | 2085 } else { |
2086 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types(); | 2086 ToBooleanICStub::Types expected = |
| 2087 instr->hydrogen()->expected_input_types(); |
2087 // Avoid deopts in the case where we've never executed this path before. | 2088 // Avoid deopts in the case where we've never executed this path before. |
2088 if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic(); | 2089 if (expected.IsEmpty()) expected = ToBooleanICStub::Types::Generic(); |
2089 | 2090 |
2090 if (expected.Contains(ToBooleanStub::UNDEFINED)) { | 2091 if (expected.Contains(ToBooleanICStub::UNDEFINED)) { |
2091 // undefined -> false. | 2092 // undefined -> false. |
2092 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 2093 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
2093 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2094 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2094 } | 2095 } |
2095 if (expected.Contains(ToBooleanStub::BOOLEAN)) { | 2096 if (expected.Contains(ToBooleanICStub::BOOLEAN)) { |
2096 // Boolean -> its value. | 2097 // Boolean -> its value. |
2097 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 2098 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
2098 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at)); | 2099 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at)); |
2099 __ LoadRoot(at, Heap::kFalseValueRootIndex); | 2100 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
2100 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2101 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2101 } | 2102 } |
2102 if (expected.Contains(ToBooleanStub::NULL_TYPE)) { | 2103 if (expected.Contains(ToBooleanICStub::NULL_TYPE)) { |
2103 // 'null' -> false. | 2104 // 'null' -> false. |
2104 __ LoadRoot(at, Heap::kNullValueRootIndex); | 2105 __ LoadRoot(at, Heap::kNullValueRootIndex); |
2105 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2106 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2106 } | 2107 } |
2107 | 2108 |
2108 if (expected.Contains(ToBooleanStub::SMI)) { | 2109 if (expected.Contains(ToBooleanICStub::SMI)) { |
2109 // Smis: 0 -> false, all other -> true. | 2110 // Smis: 0 -> false, all other -> true. |
2110 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg)); | 2111 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg)); |
2111 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); | 2112 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
2112 } else if (expected.NeedsMap()) { | 2113 } else if (expected.NeedsMap()) { |
2113 // If we need a map later and have a Smi -> deopt. | 2114 // If we need a map later and have a Smi -> deopt. |
2114 __ SmiTst(reg, at); | 2115 __ SmiTst(reg, at); |
2115 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg)); | 2116 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg)); |
2116 } | 2117 } |
2117 | 2118 |
2118 const Register map = scratch0(); | 2119 const Register map = scratch0(); |
2119 if (expected.NeedsMap()) { | 2120 if (expected.NeedsMap()) { |
2120 __ ld(map, FieldMemOperand(reg, HeapObject::kMapOffset)); | 2121 __ ld(map, FieldMemOperand(reg, HeapObject::kMapOffset)); |
2121 if (expected.CanBeUndetectable()) { | 2122 if (expected.CanBeUndetectable()) { |
2122 // Undetectable -> false. | 2123 // Undetectable -> false. |
2123 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); | 2124 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); |
2124 __ And(at, at, Operand(1 << Map::kIsUndetectable)); | 2125 __ And(at, at, Operand(1 << Map::kIsUndetectable)); |
2125 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg)); | 2126 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg)); |
2126 } | 2127 } |
2127 } | 2128 } |
2128 | 2129 |
2129 if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) { | 2130 if (expected.Contains(ToBooleanICStub::SPEC_OBJECT)) { |
2130 // spec object -> true. | 2131 // spec object -> true. |
2131 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2132 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2132 __ Branch(instr->TrueLabel(chunk_), | 2133 __ Branch(instr->TrueLabel(chunk_), |
2133 ge, at, Operand(FIRST_JS_RECEIVER_TYPE)); | 2134 ge, at, Operand(FIRST_JS_RECEIVER_TYPE)); |
2134 } | 2135 } |
2135 | 2136 |
2136 if (expected.Contains(ToBooleanStub::STRING)) { | 2137 if (expected.Contains(ToBooleanICStub::STRING)) { |
2137 // String value -> false iff empty. | 2138 // String value -> false iff empty. |
2138 Label not_string; | 2139 Label not_string; |
2139 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2140 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2140 __ Branch(¬_string, ge , at, Operand(FIRST_NONSTRING_TYPE)); | 2141 __ Branch(¬_string, ge , at, Operand(FIRST_NONSTRING_TYPE)); |
2141 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); | 2142 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); |
2142 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg)); | 2143 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg)); |
2143 __ Branch(instr->FalseLabel(chunk_)); | 2144 __ Branch(instr->FalseLabel(chunk_)); |
2144 __ bind(¬_string); | 2145 __ bind(¬_string); |
2145 } | 2146 } |
2146 | 2147 |
2147 if (expected.Contains(ToBooleanStub::SYMBOL)) { | 2148 if (expected.Contains(ToBooleanICStub::SYMBOL)) { |
2148 // Symbol value -> true. | 2149 // Symbol value -> true. |
2149 const Register scratch = scratch1(); | 2150 const Register scratch = scratch1(); |
2150 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2151 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2151 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE)); | 2152 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE)); |
2152 } | 2153 } |
2153 | 2154 |
2154 if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { | 2155 if (expected.Contains(ToBooleanICStub::SIMD_VALUE)) { |
2155 // SIMD value -> true. | 2156 // SIMD value -> true. |
2156 const Register scratch = scratch1(); | 2157 const Register scratch = scratch1(); |
2157 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2158 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2158 __ Branch(instr->TrueLabel(chunk_), eq, scratch, | 2159 __ Branch(instr->TrueLabel(chunk_), eq, scratch, |
2159 Operand(SIMD128_VALUE_TYPE)); | 2160 Operand(SIMD128_VALUE_TYPE)); |
2160 } | 2161 } |
2161 | 2162 |
2162 if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { | 2163 if (expected.Contains(ToBooleanICStub::HEAP_NUMBER)) { |
2163 // heap number -> false iff +0, -0, or NaN. | 2164 // heap number -> false iff +0, -0, or NaN. |
2164 DoubleRegister dbl_scratch = double_scratch0(); | 2165 DoubleRegister dbl_scratch = double_scratch0(); |
2165 Label not_heap_number; | 2166 Label not_heap_number; |
2166 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 2167 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
2167 __ Branch(¬_heap_number, ne, map, Operand(at)); | 2168 __ Branch(¬_heap_number, ne, map, Operand(at)); |
2168 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); | 2169 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); |
2169 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_), | 2170 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_), |
2170 ne, dbl_scratch, kDoubleRegZero); | 2171 ne, dbl_scratch, kDoubleRegZero); |
2171 // Falls through if dbl_scratch == 0. | 2172 // Falls through if dbl_scratch == 0. |
2172 __ Branch(instr->FalseLabel(chunk_)); | 2173 __ Branch(instr->FalseLabel(chunk_)); |
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5692 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { | 5693 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { |
5693 Register context = ToRegister(instr->context()); | 5694 Register context = ToRegister(instr->context()); |
5694 __ sd(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 5695 __ sd(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
5695 } | 5696 } |
5696 | 5697 |
5697 | 5698 |
5698 #undef __ | 5699 #undef __ |
5699 | 5700 |
5700 } // namespace internal | 5701 } // namespace internal |
5701 } // namespace v8 | 5702 } // namespace v8 |
OLD | NEW |