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 19 matching lines...) Expand all Loading... |
30 void AfterCall() const override { | 30 void AfterCall() const override { |
31 codegen_->RecordSafepoint(pointers_, deopt_mode_); | 31 codegen_->RecordSafepoint(pointers_, deopt_mode_); |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 LCodeGen* codegen_; | 35 LCodeGen* codegen_; |
36 LPointerMap* pointers_; | 36 LPointerMap* pointers_; |
37 Safepoint::DeoptMode deopt_mode_; | 37 Safepoint::DeoptMode deopt_mode_; |
38 }; | 38 }; |
39 | 39 |
| 40 LCodeGen::PushSafepointRegistersScope::PushSafepointRegistersScope( |
| 41 LCodeGen* codegen) |
| 42 : codegen_(codegen) { |
| 43 DCHECK(codegen_->info()->is_calling()); |
| 44 DCHECK(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 45 codegen_->expected_safepoint_kind_ = Safepoint::kWithRegisters; |
| 46 |
| 47 StoreRegistersStateStub stub(codegen_->isolate()); |
| 48 codegen_->masm_->push(ra); |
| 49 codegen_->masm_->CallStub(&stub); |
| 50 } |
| 51 |
| 52 LCodeGen::PushSafepointRegistersScope::~PushSafepointRegistersScope() { |
| 53 DCHECK(codegen_->expected_safepoint_kind_ == Safepoint::kWithRegisters); |
| 54 RestoreRegistersStateStub stub(codegen_->isolate()); |
| 55 codegen_->masm_->push(ra); |
| 56 codegen_->masm_->CallStub(&stub); |
| 57 codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 58 } |
40 | 59 |
41 #define __ masm()-> | 60 #define __ masm()-> |
42 | 61 |
43 bool LCodeGen::GenerateCode() { | 62 bool LCodeGen::GenerateCode() { |
44 LPhase phase("Z_Code generation", chunk()); | 63 LPhase phase("Z_Code generation", chunk()); |
45 DCHECK(is_unused()); | 64 DCHECK(is_unused()); |
46 status_ = GENERATING; | 65 status_ = GENERATING; |
47 | 66 |
48 // Open a frame scope to indicate that there is a frame on the stack. The | 67 // Open a frame scope to indicate that there is a frame on the stack. The |
49 // NONE indicates that the scope shouldn't actually generate code to set up | 68 // NONE indicates that the scope shouldn't actually generate code to set up |
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 DCHECK(!info()->IsStub()); | 2069 DCHECK(!info()->IsStub()); |
2051 DoubleRegister dbl_scratch = double_scratch0(); | 2070 DoubleRegister dbl_scratch = double_scratch0(); |
2052 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); | 2071 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); |
2053 // Test the double value. Zero and NaN are false. | 2072 // Test the double value. Zero and NaN are false. |
2054 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero); | 2073 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero); |
2055 } else if (type.IsString()) { | 2074 } else if (type.IsString()) { |
2056 DCHECK(!info()->IsStub()); | 2075 DCHECK(!info()->IsStub()); |
2057 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); | 2076 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); |
2058 EmitBranch(instr, ne, at, Operand(zero_reg)); | 2077 EmitBranch(instr, ne, at, Operand(zero_reg)); |
2059 } else { | 2078 } else { |
2060 ToBooleanICStub::Types expected = | 2079 ToBooleanHints expected = instr->hydrogen()->expected_input_types(); |
2061 instr->hydrogen()->expected_input_types(); | |
2062 // Avoid deopts in the case where we've never executed this path before. | 2080 // Avoid deopts in the case where we've never executed this path before. |
2063 if (expected.IsEmpty()) expected = ToBooleanICStub::Types::Generic(); | 2081 if (expected == ToBooleanHint::kNone) expected = ToBooleanHint::kAny; |
2064 | 2082 |
2065 if (expected.Contains(ToBooleanICStub::UNDEFINED)) { | 2083 if (expected & ToBooleanHint::kUndefined) { |
2066 // undefined -> false. | 2084 // undefined -> false. |
2067 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 2085 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
2068 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2086 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2069 } | 2087 } |
2070 if (expected.Contains(ToBooleanICStub::BOOLEAN)) { | 2088 if (expected & ToBooleanHint::kBoolean) { |
2071 // Boolean -> its value. | 2089 // Boolean -> its value. |
2072 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 2090 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
2073 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at)); | 2091 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at)); |
2074 __ LoadRoot(at, Heap::kFalseValueRootIndex); | 2092 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
2075 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2093 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2076 } | 2094 } |
2077 if (expected.Contains(ToBooleanICStub::NULL_TYPE)) { | 2095 if (expected & ToBooleanHint::kNull) { |
2078 // 'null' -> false. | 2096 // 'null' -> false. |
2079 __ LoadRoot(at, Heap::kNullValueRootIndex); | 2097 __ LoadRoot(at, Heap::kNullValueRootIndex); |
2080 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); | 2098 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); |
2081 } | 2099 } |
2082 | 2100 |
2083 if (expected.Contains(ToBooleanICStub::SMI)) { | 2101 if (expected & ToBooleanHint::kSmallInteger) { |
2084 // Smis: 0 -> false, all other -> true. | 2102 // Smis: 0 -> false, all other -> true. |
2085 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg)); | 2103 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg)); |
2086 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); | 2104 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
2087 } else if (expected.NeedsMap()) { | 2105 } else if (expected & ToBooleanHint::kNeedsMap) { |
2088 // If we need a map later and have a Smi -> deopt. | 2106 // If we need a map later and have a Smi -> deopt. |
2089 __ SmiTst(reg, at); | 2107 __ SmiTst(reg, at); |
2090 DeoptimizeIf(eq, instr, DeoptimizeReason::kSmi, at, Operand(zero_reg)); | 2108 DeoptimizeIf(eq, instr, DeoptimizeReason::kSmi, at, Operand(zero_reg)); |
2091 } | 2109 } |
2092 | 2110 |
2093 const Register map = scratch0(); | 2111 const Register map = scratch0(); |
2094 if (expected.NeedsMap()) { | 2112 if (expected & ToBooleanHint::kNeedsMap) { |
2095 __ ld(map, FieldMemOperand(reg, HeapObject::kMapOffset)); | 2113 __ ld(map, FieldMemOperand(reg, HeapObject::kMapOffset)); |
2096 if (expected.CanBeUndetectable()) { | 2114 if (expected & ToBooleanHint::kCanBeUndetectable) { |
2097 // Undetectable -> false. | 2115 // Undetectable -> false. |
2098 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); | 2116 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); |
2099 __ And(at, at, Operand(1 << Map::kIsUndetectable)); | 2117 __ And(at, at, Operand(1 << Map::kIsUndetectable)); |
2100 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg)); | 2118 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg)); |
2101 } | 2119 } |
2102 } | 2120 } |
2103 | 2121 |
2104 if (expected.Contains(ToBooleanICStub::SPEC_OBJECT)) { | 2122 if (expected & ToBooleanHint::kReceiver) { |
2105 // spec object -> true. | 2123 // spec object -> true. |
2106 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2124 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2107 __ Branch(instr->TrueLabel(chunk_), | 2125 __ Branch(instr->TrueLabel(chunk_), |
2108 ge, at, Operand(FIRST_JS_RECEIVER_TYPE)); | 2126 ge, at, Operand(FIRST_JS_RECEIVER_TYPE)); |
2109 } | 2127 } |
2110 | 2128 |
2111 if (expected.Contains(ToBooleanICStub::STRING)) { | 2129 if (expected & ToBooleanHint::kString) { |
2112 // String value -> false iff empty. | 2130 // String value -> false iff empty. |
2113 Label not_string; | 2131 Label not_string; |
2114 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2132 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2115 __ Branch(¬_string, ge , at, Operand(FIRST_NONSTRING_TYPE)); | 2133 __ Branch(¬_string, ge , at, Operand(FIRST_NONSTRING_TYPE)); |
2116 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); | 2134 __ ld(at, FieldMemOperand(reg, String::kLengthOffset)); |
2117 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg)); | 2135 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg)); |
2118 __ Branch(instr->FalseLabel(chunk_)); | 2136 __ Branch(instr->FalseLabel(chunk_)); |
2119 __ bind(¬_string); | 2137 __ bind(¬_string); |
2120 } | 2138 } |
2121 | 2139 |
2122 if (expected.Contains(ToBooleanICStub::SYMBOL)) { | 2140 if (expected & ToBooleanHint::kSymbol) { |
2123 // Symbol value -> true. | 2141 // Symbol value -> true. |
2124 const Register scratch = scratch1(); | 2142 const Register scratch = scratch1(); |
2125 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2143 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2126 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE)); | 2144 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE)); |
2127 } | 2145 } |
2128 | 2146 |
2129 if (expected.Contains(ToBooleanICStub::SIMD_VALUE)) { | 2147 if (expected & ToBooleanHint::kSimdValue) { |
2130 // SIMD value -> true. | 2148 // SIMD value -> true. |
2131 const Register scratch = scratch1(); | 2149 const Register scratch = scratch1(); |
2132 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 2150 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
2133 __ Branch(instr->TrueLabel(chunk_), eq, scratch, | 2151 __ Branch(instr->TrueLabel(chunk_), eq, scratch, |
2134 Operand(SIMD128_VALUE_TYPE)); | 2152 Operand(SIMD128_VALUE_TYPE)); |
2135 } | 2153 } |
2136 | 2154 |
2137 if (expected.Contains(ToBooleanICStub::HEAP_NUMBER)) { | 2155 if (expected & ToBooleanHint::kHeapNumber) { |
2138 // heap number -> false iff +0, -0, or NaN. | 2156 // heap number -> false iff +0, -0, or NaN. |
2139 DoubleRegister dbl_scratch = double_scratch0(); | 2157 DoubleRegister dbl_scratch = double_scratch0(); |
2140 Label not_heap_number; | 2158 Label not_heap_number; |
2141 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 2159 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
2142 __ Branch(¬_heap_number, ne, map, Operand(at)); | 2160 __ Branch(¬_heap_number, ne, map, Operand(at)); |
2143 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); | 2161 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); |
2144 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_), | 2162 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_), |
2145 ne, dbl_scratch, kDoubleRegZero); | 2163 ne, dbl_scratch, kDoubleRegZero); |
2146 // Falls through if dbl_scratch == 0. | 2164 // Falls through if dbl_scratch == 0. |
2147 __ Branch(instr->FalseLabel(chunk_)); | 2165 __ Branch(instr->FalseLabel(chunk_)); |
2148 __ bind(¬_heap_number); | 2166 __ bind(¬_heap_number); |
2149 } | 2167 } |
2150 | 2168 |
2151 if (!expected.IsGeneric()) { | 2169 if (expected != ToBooleanHint::kAny) { |
2152 // We've seen something for the first time -> deopt. | 2170 // We've seen something for the first time -> deopt. |
2153 // This can only happen if we are not generic already. | 2171 // This can only happen if we are not generic already. |
2154 DeoptimizeIf(al, instr, DeoptimizeReason::kUnexpectedObject, zero_reg, | 2172 DeoptimizeIf(al, instr, DeoptimizeReason::kUnexpectedObject, zero_reg, |
2155 Operand(zero_reg)); | 2173 Operand(zero_reg)); |
2156 } | 2174 } |
2157 } | 2175 } |
2158 } | 2176 } |
2159 } | 2177 } |
2160 | 2178 |
2161 | 2179 |
(...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5604 __ ld(result, FieldMemOperand(scratch, | 5622 __ ld(result, FieldMemOperand(scratch, |
5605 FixedArray::kHeaderSize - kPointerSize)); | 5623 FixedArray::kHeaderSize - kPointerSize)); |
5606 __ bind(deferred->exit()); | 5624 __ bind(deferred->exit()); |
5607 __ bind(&done); | 5625 __ bind(&done); |
5608 } | 5626 } |
5609 | 5627 |
5610 #undef __ | 5628 #undef __ |
5611 | 5629 |
5612 } // namespace internal | 5630 } // namespace internal |
5613 } // namespace v8 | 5631 } // namespace v8 |
OLD | NEW |