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