| OLD | NEW |
| 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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 AllowDeferredHandleDereference smi_check; | 1839 AllowDeferredHandleDereference smi_check; |
| 1840 if (value->IsSmi()) { | 1840 if (value->IsSmi()) { |
| 1841 __ mov(ToRegister(instr->result()), Operand(value)); | 1841 __ mov(ToRegister(instr->result()), Operand(value)); |
| 1842 } else { | 1842 } else { |
| 1843 __ LoadHeapObject(ToRegister(instr->result()), | 1843 __ LoadHeapObject(ToRegister(instr->result()), |
| 1844 Handle<HeapObject>::cast(value)); | 1844 Handle<HeapObject>::cast(value)); |
| 1845 } | 1845 } |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 | 1848 |
| 1849 void LCodeGen::DoFixedArrayBaseLength(LFixedArrayBaseLength* instr) { | |
| 1850 Register result = ToRegister(instr->result()); | |
| 1851 Register array = ToRegister(instr->value()); | |
| 1852 __ ldr(result, FieldMemOperand(array, FixedArrayBase::kLengthOffset)); | |
| 1853 } | |
| 1854 | |
| 1855 | |
| 1856 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { | 1849 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { |
| 1857 Register result = ToRegister(instr->result()); | 1850 Register result = ToRegister(instr->result()); |
| 1858 Register map = ToRegister(instr->value()); | 1851 Register map = ToRegister(instr->value()); |
| 1859 __ EnumLength(result, map); | 1852 __ EnumLength(result, map); |
| 1860 } | 1853 } |
| 1861 | 1854 |
| 1862 | 1855 |
| 1863 void LCodeGen::DoElementsKind(LElementsKind* instr) { | 1856 void LCodeGen::DoElementsKind(LElementsKind* instr) { |
| 1864 Register result = ToRegister(instr->result()); | 1857 Register result = ToRegister(instr->result()); |
| 1865 Register input = ToRegister(instr->value()); | 1858 Register input = ToRegister(instr->value()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 | 2123 |
| 2131 int LCodeGen::GetNextEmittedBlock() const { | 2124 int LCodeGen::GetNextEmittedBlock() const { |
| 2132 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | 2125 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { |
| 2133 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | 2126 if (!chunk_->GetLabel(i)->HasReplacement()) return i; |
| 2134 } | 2127 } |
| 2135 return -1; | 2128 return -1; |
| 2136 } | 2129 } |
| 2137 | 2130 |
| 2138 template<class InstrType> | 2131 template<class InstrType> |
| 2139 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { | 2132 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { |
| 2133 int left_block = instr->TrueDestination(chunk_); |
| 2140 int right_block = instr->FalseDestination(chunk_); | 2134 int right_block = instr->FalseDestination(chunk_); |
| 2141 int left_block = instr->TrueDestination(chunk_); | |
| 2142 | 2135 |
| 2143 int next_block = GetNextEmittedBlock(); | 2136 int next_block = GetNextEmittedBlock(); |
| 2144 | 2137 |
| 2145 if (right_block == left_block) { | 2138 if (right_block == left_block || cc == al) { |
| 2146 EmitGoto(left_block); | 2139 EmitGoto(left_block); |
| 2147 } else if (left_block == next_block) { | 2140 } else if (left_block == next_block) { |
| 2148 __ b(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); | 2141 __ b(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); |
| 2149 } else if (right_block == next_block) { | 2142 } else if (right_block == next_block) { |
| 2150 __ b(cc, chunk_->GetAssemblyLabel(left_block)); | 2143 __ b(cc, chunk_->GetAssemblyLabel(left_block)); |
| 2151 } else { | 2144 } else { |
| 2152 __ b(cc, chunk_->GetAssemblyLabel(left_block)); | 2145 __ b(cc, chunk_->GetAssemblyLabel(left_block)); |
| 2153 __ b(chunk_->GetAssemblyLabel(right_block)); | 2146 __ b(chunk_->GetAssemblyLabel(right_block)); |
| 2154 } | 2147 } |
| 2155 } | 2148 } |
| 2156 | 2149 |
| 2157 | 2150 |
| 2158 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { | 2151 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { |
| 2159 __ stop("LBreak"); | 2152 __ stop("LBreak"); |
| 2160 } | 2153 } |
| 2161 | 2154 |
| 2162 | 2155 |
| 2156 void LCodeGen::DoIsNumberAndBranch(LIsNumberAndBranch* instr) { |
| 2157 Representation r = instr->hydrogen()->value()->representation(); |
| 2158 if (r.IsSmiOrInteger32() || r.IsDouble()) { |
| 2159 EmitBranch(instr, al); |
| 2160 } else { |
| 2161 ASSERT(r.IsTagged()); |
| 2162 Register reg = ToRegister(instr->value()); |
| 2163 HType type = instr->hydrogen()->value()->type(); |
| 2164 if (type.IsTaggedNumber()) { |
| 2165 EmitBranch(instr, al); |
| 2166 } |
| 2167 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
| 2168 __ ldr(scratch0(), FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 2169 __ CompareRoot(scratch0(), Heap::kHeapNumberMapRootIndex); |
| 2170 EmitBranch(instr, eq); |
| 2171 } |
| 2172 } |
| 2173 |
| 2174 |
| 2163 void LCodeGen::DoBranch(LBranch* instr) { | 2175 void LCodeGen::DoBranch(LBranch* instr) { |
| 2164 Representation r = instr->hydrogen()->value()->representation(); | 2176 Representation r = instr->hydrogen()->value()->representation(); |
| 2165 if (r.IsInteger32() || r.IsSmi()) { | 2177 if (r.IsInteger32() || r.IsSmi()) { |
| 2166 ASSERT(!info()->IsStub()); | 2178 ASSERT(!info()->IsStub()); |
| 2167 Register reg = ToRegister(instr->value()); | 2179 Register reg = ToRegister(instr->value()); |
| 2168 __ cmp(reg, Operand::Zero()); | 2180 __ cmp(reg, Operand::Zero()); |
| 2169 EmitBranch(instr, ne); | 2181 EmitBranch(instr, ne); |
| 2170 } else if (r.IsDouble()) { | 2182 } else if (r.IsDouble()) { |
| 2171 ASSERT(!info()->IsStub()); | 2183 ASSERT(!info()->IsStub()); |
| 2172 DwVfpRegister reg = ToDoubleRegister(instr->value()); | 2184 DwVfpRegister reg = ToDoubleRegister(instr->value()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 break; | 2341 break; |
| 2330 case Token::IN: | 2342 case Token::IN: |
| 2331 case Token::INSTANCEOF: | 2343 case Token::INSTANCEOF: |
| 2332 default: | 2344 default: |
| 2333 UNREACHABLE(); | 2345 UNREACHABLE(); |
| 2334 } | 2346 } |
| 2335 return cond; | 2347 return cond; |
| 2336 } | 2348 } |
| 2337 | 2349 |
| 2338 | 2350 |
| 2339 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 2351 void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) { |
| 2340 LOperand* left = instr->left(); | 2352 LOperand* left = instr->left(); |
| 2341 LOperand* right = instr->right(); | 2353 LOperand* right = instr->right(); |
| 2342 Condition cond = TokenToCondition(instr->op(), false); | 2354 Condition cond = TokenToCondition(instr->op(), false); |
| 2343 | 2355 |
| 2344 if (left->IsConstantOperand() && right->IsConstantOperand()) { | 2356 if (left->IsConstantOperand() && right->IsConstantOperand()) { |
| 2345 // We can statically evaluate the comparison. | 2357 // We can statically evaluate the comparison. |
| 2346 double left_val = ToDouble(LConstantOperand::cast(left)); | 2358 double left_val = ToDouble(LConstantOperand::cast(left)); |
| 2347 double right_val = ToDouble(LConstantOperand::cast(right)); | 2359 double right_val = ToDouble(LConstantOperand::cast(right)); |
| 2348 int next_block = EvalComparison(instr->op(), left_val, right_val) ? | 2360 int next_block = EvalComparison(instr->op(), left_val, right_val) ? |
| 2349 instr->TrueDestination(chunk_) : instr->FalseDestination(chunk_); | 2361 instr->TrueDestination(chunk_) : instr->FalseDestination(chunk_); |
| (...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4122 } | 4134 } |
| 4123 | 4135 |
| 4124 | 4136 |
| 4125 void LCodeGen::DoCallNewArray(LCallNewArray* instr) { | 4137 void LCodeGen::DoCallNewArray(LCallNewArray* instr) { |
| 4126 ASSERT(ToRegister(instr->constructor()).is(r1)); | 4138 ASSERT(ToRegister(instr->constructor()).is(r1)); |
| 4127 ASSERT(ToRegister(instr->result()).is(r0)); | 4139 ASSERT(ToRegister(instr->result()).is(r0)); |
| 4128 | 4140 |
| 4129 __ mov(r0, Operand(instr->arity())); | 4141 __ mov(r0, Operand(instr->arity())); |
| 4130 __ mov(r2, Operand(instr->hydrogen()->property_cell())); | 4142 __ mov(r2, Operand(instr->hydrogen()->property_cell())); |
| 4131 ElementsKind kind = instr->hydrogen()->elements_kind(); | 4143 ElementsKind kind = instr->hydrogen()->elements_kind(); |
| 4132 bool disable_allocation_sites = | 4144 AllocationSiteOverrideMode override_mode = |
| 4133 (AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE); | 4145 (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) |
| 4146 ? DISABLE_ALLOCATION_SITES |
| 4147 : DONT_OVERRIDE; |
| 4148 ContextCheckMode context_mode = CONTEXT_CHECK_NOT_REQUIRED; |
| 4134 | 4149 |
| 4135 if (instr->arity() == 0) { | 4150 if (instr->arity() == 0) { |
| 4136 ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites); | 4151 ArrayNoArgumentConstructorStub stub(kind, context_mode, override_mode); |
| 4137 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 4152 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); |
| 4138 } else if (instr->arity() == 1) { | 4153 } else if (instr->arity() == 1) { |
| 4139 Label done; | 4154 Label done; |
| 4140 if (IsFastPackedElementsKind(kind)) { | 4155 if (IsFastPackedElementsKind(kind)) { |
| 4141 Label packed_case; | 4156 Label packed_case; |
| 4142 // We might need a change here | 4157 // We might need a change here |
| 4143 // look at the first argument | 4158 // look at the first argument |
| 4144 __ ldr(r5, MemOperand(sp, 0)); | 4159 __ ldr(r5, MemOperand(sp, 0)); |
| 4145 __ cmp(r5, Operand::Zero()); | 4160 __ cmp(r5, Operand::Zero()); |
| 4146 __ b(eq, &packed_case); | 4161 __ b(eq, &packed_case); |
| 4147 | 4162 |
| 4148 ElementsKind holey_kind = GetHoleyElementsKind(kind); | 4163 ElementsKind holey_kind = GetHoleyElementsKind(kind); |
| 4149 ArraySingleArgumentConstructorStub stub(holey_kind, | 4164 ArraySingleArgumentConstructorStub stub(holey_kind, context_mode, |
| 4150 disable_allocation_sites); | 4165 override_mode); |
| 4151 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 4166 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); |
| 4152 __ jmp(&done); | 4167 __ jmp(&done); |
| 4153 __ bind(&packed_case); | 4168 __ bind(&packed_case); |
| 4154 } | 4169 } |
| 4155 | 4170 |
| 4156 ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites); | 4171 ArraySingleArgumentConstructorStub stub(kind, context_mode, override_mode); |
| 4157 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 4172 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); |
| 4158 __ bind(&done); | 4173 __ bind(&done); |
| 4159 } else { | 4174 } else { |
| 4160 ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites); | 4175 ArrayNArgumentsConstructorStub stub(kind, context_mode, override_mode); |
| 4161 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 4176 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); |
| 4162 } | 4177 } |
| 4163 } | 4178 } |
| 4164 | 4179 |
| 4165 | 4180 |
| 4166 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { | 4181 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { |
| 4167 CallRuntime(instr->function(), instr->arity(), instr); | 4182 CallRuntime(instr->function(), instr->arity(), instr); |
| 4168 } | 4183 } |
| 4169 | 4184 |
| 4170 | 4185 |
| (...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5908 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5923 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5909 __ ldr(result, FieldMemOperand(scratch, | 5924 __ ldr(result, FieldMemOperand(scratch, |
| 5910 FixedArray::kHeaderSize - kPointerSize)); | 5925 FixedArray::kHeaderSize - kPointerSize)); |
| 5911 __ bind(&done); | 5926 __ bind(&done); |
| 5912 } | 5927 } |
| 5913 | 5928 |
| 5914 | 5929 |
| 5915 #undef __ | 5930 #undef __ |
| 5916 | 5931 |
| 5917 } } // namespace v8::internal | 5932 } } // namespace v8::internal |
| OLD | NEW |