| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 bool LGapResolver::CanReach(LGapNode* a, LGapNode* b) { | 168 bool LGapResolver::CanReach(LGapNode* a, LGapNode* b) { |
| 169 ASSERT(a != b); | 169 ASSERT(a != b); |
| 170 return CanReach(a, b, next_visited_id_++); | 170 return CanReach(a, b, next_visited_id_++); |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 void LGapResolver::RegisterMove(LMoveOperands move) { | 174 void LGapResolver::RegisterMove(LMoveOperands move) { |
| 175 if (move.from()->IsConstantOperand()) { | 175 if (move.source()->IsConstantOperand()) { |
| 176 // Constant moves should be last in the machine code. Therefore add them | 176 // Constant moves should be last in the machine code. Therefore add them |
| 177 // first to the result set. | 177 // first to the result set. |
| 178 AddResultMove(move.from(), move.to()); | 178 AddResultMove(move.source(), move.destination()); |
| 179 } else { | 179 } else { |
| 180 LGapNode* from = LookupNode(move.from()); | 180 LGapNode* from = LookupNode(move.source()); |
| 181 LGapNode* to = LookupNode(move.to()); | 181 LGapNode* to = LookupNode(move.destination()); |
| 182 if (to->IsAssigned() && to->assigned_from() == from) { | 182 if (to->IsAssigned() && to->assigned_from() == from) { |
| 183 move.Eliminate(); | 183 move.Eliminate(); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 ASSERT(!to->IsAssigned()); | 186 ASSERT(!to->IsAssigned()); |
| 187 if (CanReach(from, to)) { | 187 if (CanReach(from, to)) { |
| 188 // This introduces a cycle. Save. | 188 // This introduces a cycle. Save. |
| 189 identified_cycles_.Add(from); | 189 identified_cycles_.Add(from); |
| 190 } | 190 } |
| 191 to->set_assigned_from(from); | 191 to->set_assigned_from(from); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 bool LCodeGen::GenerateDeferredCode() { | 335 bool LCodeGen::GenerateDeferredCode() { |
| 336 ASSERT(is_generating()); | 336 ASSERT(is_generating()); |
| 337 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 337 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
| 338 LDeferredCode* code = deferred_[i]; | 338 LDeferredCode* code = deferred_[i]; |
| 339 __ bind(code->entry()); | 339 __ bind(code->entry()); |
| 340 code->Generate(); | 340 code->Generate(); |
| 341 __ jmp(code->exit()); | 341 __ jmp(code->exit()); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Force constant pool emission at the end of deferred code to make |
| 345 // sure that no constant pools are emitted after the official end of |
| 346 // the instruction sequence. |
| 347 masm()->CheckConstPool(true, false); |
| 348 |
| 344 // Deferred code is the last part of the instruction sequence. Mark | 349 // Deferred code is the last part of the instruction sequence. Mark |
| 345 // the generated code as done unless we bailed out. | 350 // the generated code as done unless we bailed out. |
| 346 if (!is_aborted()) status_ = DONE; | 351 if (!is_aborted()) status_ = DONE; |
| 347 return !is_aborted(); | 352 return !is_aborted(); |
| 348 } | 353 } |
| 349 | 354 |
| 350 | 355 |
| 351 bool LCodeGen::GenerateSafepointTable() { | 356 bool LCodeGen::GenerateSafepointTable() { |
| 352 ASSERT(is_done()); | 357 ASSERT(is_done()); |
| 353 safepoints_.Emit(masm(), StackSlotCount()); | 358 safepoints_.Emit(masm(), StackSlotCount()); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 DoubleRegister dbl_scratch = d0; | 814 DoubleRegister dbl_scratch = d0; |
| 810 LUnallocated marker_operand(LUnallocated::NONE); | 815 LUnallocated marker_operand(LUnallocated::NONE); |
| 811 | 816 |
| 812 Register core_scratch = scratch0(); | 817 Register core_scratch = scratch0(); |
| 813 bool destroys_core_scratch = false; | 818 bool destroys_core_scratch = false; |
| 814 | 819 |
| 815 const ZoneList<LMoveOperands>* moves = | 820 const ZoneList<LMoveOperands>* moves = |
| 816 resolver_.Resolve(move->move_operands(), &marker_operand); | 821 resolver_.Resolve(move->move_operands(), &marker_operand); |
| 817 for (int i = moves->length() - 1; i >= 0; --i) { | 822 for (int i = moves->length() - 1; i >= 0; --i) { |
| 818 LMoveOperands move = moves->at(i); | 823 LMoveOperands move = moves->at(i); |
| 819 LOperand* from = move.from(); | 824 LOperand* from = move.source(); |
| 820 LOperand* to = move.to(); | 825 LOperand* to = move.destination(); |
| 821 ASSERT(!from->IsDoubleRegister() || | 826 ASSERT(!from->IsDoubleRegister() || |
| 822 !ToDoubleRegister(from).is(dbl_scratch)); | 827 !ToDoubleRegister(from).is(dbl_scratch)); |
| 823 ASSERT(!to->IsDoubleRegister() || !ToDoubleRegister(to).is(dbl_scratch)); | 828 ASSERT(!to->IsDoubleRegister() || !ToDoubleRegister(to).is(dbl_scratch)); |
| 824 ASSERT(!from->IsRegister() || !ToRegister(from).is(core_scratch)); | 829 ASSERT(!from->IsRegister() || !ToRegister(from).is(core_scratch)); |
| 825 ASSERT(!to->IsRegister() || !ToRegister(to).is(core_scratch)); | 830 ASSERT(!to->IsRegister() || !ToRegister(to).is(core_scratch)); |
| 826 if (from == &marker_operand) { | 831 if (from == &marker_operand) { |
| 827 if (to->IsRegister()) { | 832 if (to->IsRegister()) { |
| 828 __ mov(ToRegister(to), core_scratch); | 833 __ mov(ToRegister(to), core_scratch); |
| 829 ASSERT(destroys_core_scratch); | 834 ASSERT(destroys_core_scratch); |
| 830 } else if (to->IsStackSlot()) { | 835 } else if (to->IsStackSlot()) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 } | 997 } |
| 993 } | 998 } |
| 994 | 999 |
| 995 | 1000 |
| 996 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1001 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 997 // Nothing to do. | 1002 // Nothing to do. |
| 998 } | 1003 } |
| 999 | 1004 |
| 1000 | 1005 |
| 1001 void LCodeGen::DoModI(LModI* instr) { | 1006 void LCodeGen::DoModI(LModI* instr) { |
| 1002 Abort("ModI not implemented"); | |
| 1003 class DeferredModI: public LDeferredCode { | 1007 class DeferredModI: public LDeferredCode { |
| 1004 public: | 1008 public: |
| 1005 DeferredModI(LCodeGen* codegen, LModI* instr) | 1009 DeferredModI(LCodeGen* codegen, LModI* instr) |
| 1006 : LDeferredCode(codegen), instr_(instr) { } | 1010 : LDeferredCode(codegen), instr_(instr) { } |
| 1007 virtual void Generate() { | 1011 virtual void Generate() { |
| 1008 codegen()->DoDeferredGenericBinaryStub(instr_, Token::MOD); | 1012 codegen()->DoDeferredGenericBinaryStub(instr_, Token::MOD); |
| 1009 } | 1013 } |
| 1010 private: | 1014 private: |
| 1011 LModI* instr_; | 1015 LModI* instr_; |
| 1012 }; | 1016 }; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 __ mov(result, Operand(result, ASR, 1)); | 1052 __ mov(result, Operand(result, ASR, 1)); |
| 1049 | 1053 |
| 1050 __ b(al, &done); | 1054 __ b(al, &done); |
| 1051 __ bind(&deoptimize); | 1055 __ bind(&deoptimize); |
| 1052 DeoptimizeIf(al, instr->environment()); | 1056 DeoptimizeIf(al, instr->environment()); |
| 1053 __ bind(&done); | 1057 __ bind(&done); |
| 1054 } | 1058 } |
| 1055 | 1059 |
| 1056 | 1060 |
| 1057 void LCodeGen::DoDivI(LDivI* instr) { | 1061 void LCodeGen::DoDivI(LDivI* instr) { |
| 1058 Abort("DivI not implemented"); | |
| 1059 class DeferredDivI: public LDeferredCode { | 1062 class DeferredDivI: public LDeferredCode { |
| 1060 public: | 1063 public: |
| 1061 DeferredDivI(LCodeGen* codegen, LDivI* instr) | 1064 DeferredDivI(LCodeGen* codegen, LDivI* instr) |
| 1062 : LDeferredCode(codegen), instr_(instr) { } | 1065 : LDeferredCode(codegen), instr_(instr) { } |
| 1063 virtual void Generate() { | 1066 virtual void Generate() { |
| 1064 codegen()->DoDeferredGenericBinaryStub(instr_, Token::DIV); | 1067 codegen()->DoDeferredGenericBinaryStub(instr_, Token::DIV); |
| 1065 } | 1068 } |
| 1066 private: | 1069 private: |
| 1067 LDivI* instr_; | 1070 LDivI* instr_; |
| 1068 }; | 1071 }; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 } | 1289 } |
| 1287 | 1290 |
| 1288 | 1291 |
| 1289 void LCodeGen::DoConstantI(LConstantI* instr) { | 1292 void LCodeGen::DoConstantI(LConstantI* instr) { |
| 1290 ASSERT(instr->result()->IsRegister()); | 1293 ASSERT(instr->result()->IsRegister()); |
| 1291 __ mov(ToRegister(instr->result()), Operand(instr->value())); | 1294 __ mov(ToRegister(instr->result()), Operand(instr->value())); |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 | 1297 |
| 1295 void LCodeGen::DoConstantD(LConstantD* instr) { | 1298 void LCodeGen::DoConstantD(LConstantD* instr) { |
| 1296 Abort("DoConstantD unimplemented."); | 1299 ASSERT(instr->result()->IsDoubleRegister()); |
| 1300 DwVfpRegister result = ToDoubleRegister(instr->result()); |
| 1301 double v = instr->value(); |
| 1302 __ vmov(result, v); |
| 1297 } | 1303 } |
| 1298 | 1304 |
| 1299 | 1305 |
| 1300 void LCodeGen::DoConstantT(LConstantT* instr) { | 1306 void LCodeGen::DoConstantT(LConstantT* instr) { |
| 1301 ASSERT(instr->result()->IsRegister()); | 1307 ASSERT(instr->result()->IsRegister()); |
| 1302 __ mov(ToRegister(instr->result()), Operand(instr->value())); | 1308 __ mov(ToRegister(instr->result()), Operand(instr->value())); |
| 1303 } | 1309 } |
| 1304 | 1310 |
| 1305 | 1311 |
| 1306 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { | 1312 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 | 2335 |
| 2330 // Retrieve FPSCR and check for vfp exceptions. | 2336 // Retrieve FPSCR and check for vfp exceptions. |
| 2331 __ vmrs(scratch); | 2337 __ vmrs(scratch); |
| 2332 // Restore FPSCR | 2338 // Restore FPSCR |
| 2333 __ vmsr(prev_fpscr); | 2339 __ vmsr(prev_fpscr); |
| 2334 __ tst(scratch, Operand(kVFPExceptionMask)); | 2340 __ tst(scratch, Operand(kVFPExceptionMask)); |
| 2335 DeoptimizeIf(ne, instr->environment()); | 2341 DeoptimizeIf(ne, instr->environment()); |
| 2336 | 2342 |
| 2337 // Move the result back to general purpose register r0. | 2343 // Move the result back to general purpose register r0. |
| 2338 __ vmov(result, single_scratch); | 2344 __ vmov(result, single_scratch); |
| 2345 |
| 2346 // Test for -0. |
| 2347 Label done; |
| 2348 __ cmp(result, Operand(0)); |
| 2349 __ b(ne, &done); |
| 2350 __ vmov(scratch, input.high()); |
| 2351 __ tst(scratch, Operand(HeapNumber::kSignMask)); |
| 2352 DeoptimizeIf(ne, instr->environment()); |
| 2353 __ bind(&done); |
| 2339 } | 2354 } |
| 2340 | 2355 |
| 2341 | 2356 |
| 2342 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2357 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
| 2343 DoubleRegister input = ToDoubleRegister(instr->input()); | 2358 DoubleRegister input = ToDoubleRegister(instr->input()); |
| 2344 ASSERT(ToDoubleRegister(instr->result()).is(input)); | 2359 ASSERT(ToDoubleRegister(instr->result()).is(input)); |
| 2345 __ vsqrt(input, input); | 2360 __ vsqrt(input, input); |
| 2346 } | 2361 } |
| 2347 | 2362 |
| 2348 | 2363 |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3199 | 3214 |
| 3200 | 3215 |
| 3201 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3216 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 3202 Abort("DoOsrEntry unimplemented."); | 3217 Abort("DoOsrEntry unimplemented."); |
| 3203 } | 3218 } |
| 3204 | 3219 |
| 3205 | 3220 |
| 3206 #undef __ | 3221 #undef __ |
| 3207 | 3222 |
| 3208 } } // namespace v8::internal | 3223 } } // namespace v8::internal |
| OLD | NEW |