OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 Label* true_label = chunk_->GetAssemblyLabel(true_block); | 1851 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
1852 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 1852 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
1853 | 1853 |
1854 Condition true_cond = | 1854 Condition true_cond = |
1855 EmitIsObject(reg, temp1, false_label, true_label); | 1855 EmitIsObject(reg, temp1, false_label, true_label); |
1856 | 1856 |
1857 EmitBranch(true_block, false_block, true_cond); | 1857 EmitBranch(true_block, false_block, true_cond); |
1858 } | 1858 } |
1859 | 1859 |
1860 | 1860 |
1861 Condition LCodeGen::EmitIsString(Register input, | |
1862 Register temp1, | |
1863 Label* is_not_string, | |
1864 Label* is_string) { | |
1865 __ JumpIfSmi(input, is_not_string); | |
1866 __ CompareObjectType(input, temp1, temp1, FIRST_NONSTRING_TYPE); | |
1867 | |
1868 return lt; | |
1869 } | |
1870 | |
1871 | |
1872 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { | |
1873 Register reg = ToRegister(instr->InputAt(0)); | |
1874 Register temp1 = ToRegister(instr->TempAt(0)); | |
1875 | |
1876 int true_block = chunk_->LookupDestination(instr->true_block_id()); | |
1877 int false_block = chunk_->LookupDestination(instr->false_block_id()); | |
1878 Label* true_label = chunk_->GetAssemblyLabel(true_block); | |
1879 Label* false_label = chunk_->GetAssemblyLabel(false_block); | |
1880 | |
1881 Condition true_cond = | |
1882 EmitIsString(reg, temp1, false_label, true_label); | |
1883 | |
1884 EmitBranch(true_block, false_block, true_cond); | |
1885 } | |
1886 | |
1887 | |
1888 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 1861 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { |
1889 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1862 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1890 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1863 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1891 | 1864 |
1892 Register input_reg = EmitLoadRegister(instr->InputAt(0), ip); | 1865 Register input_reg = EmitLoadRegister(instr->InputAt(0), ip); |
1893 __ tst(input_reg, Operand(kSmiTagMask)); | 1866 __ tst(input_reg, Operand(kSmiTagMask)); |
1894 EmitBranch(true_block, false_block, eq); | 1867 EmitBranch(true_block, false_block, eq); |
1895 } | 1868 } |
1896 | 1869 |
1897 | 1870 |
1898 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { | 1871 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { |
1899 Register input = ToRegister(instr->InputAt(0)); | 1872 Register input = ToRegister(instr->InputAt(0)); |
1900 Register temp = ToRegister(instr->TempAt(0)); | 1873 Register temp = ToRegister(instr->TempAt(0)); |
1901 | 1874 |
1902 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1875 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1903 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1876 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1904 | 1877 |
1905 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); | 1878 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); |
1906 __ ldr(temp, FieldMemOperand(input, HeapObject::kMapOffset)); | 1879 __ ldr(temp, FieldMemOperand(input, HeapObject::kMapOffset)); |
1907 __ ldrb(temp, FieldMemOperand(temp, Map::kBitFieldOffset)); | 1880 __ ldrb(temp, FieldMemOperand(temp, Map::kBitFieldOffset)); |
1908 __ tst(temp, Operand(1 << Map::kIsUndetectable)); | 1881 __ tst(temp, Operand(1 << Map::kIsUndetectable)); |
1909 EmitBranch(true_block, false_block, ne); | 1882 EmitBranch(true_block, false_block, ne); |
1910 } | 1883 } |
1911 | 1884 |
1912 | 1885 |
1913 static Condition ComputeCompareCondition(Token::Value op) { | |
1914 switch (op) { | |
1915 case Token::EQ_STRICT: | |
1916 case Token::EQ: | |
1917 return eq; | |
1918 case Token::LT: | |
1919 return lt; | |
1920 case Token::GT: | |
1921 return gt; | |
1922 case Token::LTE: | |
1923 return le; | |
1924 case Token::GTE: | |
1925 return ge; | |
1926 default: | |
1927 UNREACHABLE(); | |
1928 return kNoCondition; | |
1929 } | |
1930 } | |
1931 | |
1932 | |
1933 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { | |
1934 Token::Value op = instr->op(); | |
1935 int true_block = chunk_->LookupDestination(instr->true_block_id()); | |
1936 int false_block = chunk_->LookupDestination(instr->false_block_id()); | |
1937 | |
1938 Handle<Code> ic = CompareIC::GetUninitialized(op); | |
1939 CallCode(ic, RelocInfo::CODE_TARGET, instr); | |
1940 __ cmp(r0, Operand(0)); // This instruction also signals no smi code inlined. | |
1941 | |
1942 Condition condition = ComputeCompareCondition(op); | |
1943 | |
1944 EmitBranch(true_block, false_block, condition); | |
1945 } | |
1946 | |
1947 | |
1948 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 1886 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { |
1949 InstanceType from = instr->from(); | 1887 InstanceType from = instr->from(); |
1950 InstanceType to = instr->to(); | 1888 InstanceType to = instr->to(); |
1951 if (from == FIRST_TYPE) return to; | 1889 if (from == FIRST_TYPE) return to; |
1952 ASSERT(from == to || to == LAST_TYPE); | 1890 ASSERT(from == to || to == LAST_TYPE); |
1953 return from; | 1891 return from; |
1954 } | 1892 } |
1955 | 1893 |
1956 | 1894 |
1957 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { | 1895 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 CallCodeGeneric(stub.GetCode(), | 2161 CallCodeGeneric(stub.GetCode(), |
2224 RelocInfo::CODE_TARGET, | 2162 RelocInfo::CODE_TARGET, |
2225 instr, | 2163 instr, |
2226 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2164 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
2227 // Put the result value into the result register slot and | 2165 // Put the result value into the result register slot and |
2228 // restore all registers. | 2166 // restore all registers. |
2229 __ StoreToSafepointRegisterSlot(result, result); | 2167 __ StoreToSafepointRegisterSlot(result, result); |
2230 } | 2168 } |
2231 | 2169 |
2232 | 2170 |
| 2171 static Condition ComputeCompareCondition(Token::Value op) { |
| 2172 switch (op) { |
| 2173 case Token::EQ_STRICT: |
| 2174 case Token::EQ: |
| 2175 return eq; |
| 2176 case Token::LT: |
| 2177 return lt; |
| 2178 case Token::GT: |
| 2179 return gt; |
| 2180 case Token::LTE: |
| 2181 return le; |
| 2182 case Token::GTE: |
| 2183 return ge; |
| 2184 default: |
| 2185 UNREACHABLE(); |
| 2186 return kNoCondition; |
| 2187 } |
| 2188 } |
| 2189 |
| 2190 |
2233 void LCodeGen::DoCmpT(LCmpT* instr) { | 2191 void LCodeGen::DoCmpT(LCmpT* instr) { |
2234 Token::Value op = instr->op(); | 2192 Token::Value op = instr->op(); |
2235 | 2193 |
2236 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2194 Handle<Code> ic = CompareIC::GetUninitialized(op); |
2237 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2195 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2238 __ cmp(r0, Operand(0)); // This instruction also signals no smi code inlined. | 2196 __ cmp(r0, Operand(0)); // This instruction also signals no smi code inlined. |
2239 | 2197 |
2240 Condition condition = ComputeCompareCondition(op); | 2198 Condition condition = ComputeCompareCondition(op); |
2241 __ LoadRoot(ToRegister(instr->result()), | 2199 __ LoadRoot(ToRegister(instr->result()), |
2242 Heap::kTrueValueRootIndex, | 2200 Heap::kTrueValueRootIndex, |
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4707 ASSERT(osr_pc_offset_ == -1); | 4665 ASSERT(osr_pc_offset_ == -1); |
4708 osr_pc_offset_ = masm()->pc_offset(); | 4666 osr_pc_offset_ = masm()->pc_offset(); |
4709 } | 4667 } |
4710 | 4668 |
4711 | 4669 |
4712 | 4670 |
4713 | 4671 |
4714 #undef __ | 4672 #undef __ |
4715 | 4673 |
4716 } } // namespace v8::internal | 4674 } } // namespace v8::internal |
OLD | NEW |