OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 __ movl(EDI, ESP); | 91 __ movl(EDI, ESP); |
92 __ subl(EDI, EBP); | 92 __ subl(EDI, EBP); |
93 __ cmpl(EDI, Immediate(fp_sp_dist)); | 93 __ cmpl(EDI, Immediate(fp_sp_dist)); |
94 __ j(EQUAL, &done, Assembler::kNearJump); | 94 __ j(EQUAL, &done, Assembler::kNearJump); |
95 __ int3(); | 95 __ int3(); |
96 __ Bind(&done); | 96 __ Bind(&done); |
97 } | 97 } |
98 #endif | 98 #endif |
99 __ LeaveFrame(); | 99 __ LeaveFrame(); |
100 __ ret(); | 100 __ ret(); |
101 | |
102 // Generate 1 byte NOP so that the debugger can patch the | |
103 // return pattern with a call to the debug stub. | |
104 __ nop(1); | |
105 compiler->AddCurrentDescriptor(PcDescriptors::kReturn, | |
106 Isolate::kNoDeoptId, | |
107 token_pos()); | |
108 } | 101 } |
109 | 102 |
110 | 103 |
111 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const { | 104 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const { |
112 const intptr_t kNumInputs = 0; | 105 const intptr_t kNumInputs = 0; |
113 return LocationSummary::Make(kNumInputs, | 106 return LocationSummary::Make(kNumInputs, |
114 Location::RequiresRegister(), | 107 Location::RequiresRegister(), |
115 LocationSummary::kNoCall); | 108 LocationSummary::kNoCall); |
116 } | 109 } |
117 | 110 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 Register result = locs()->out().reg(); | 728 Register result = locs()->out().reg(); |
736 __ movl(result, | 729 __ movl(result, |
737 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); | 730 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); |
738 __ movl(result, Address(result, | 731 __ movl(result, Address(result, |
739 char_code, | 732 char_code, |
740 TIMES_HALF_WORD_SIZE, // Char code is a smi. | 733 TIMES_HALF_WORD_SIZE, // Char code is a smi. |
741 Symbols::kNullCharCodeSymbolOffset * kWordSize)); | 734 Symbols::kNullCharCodeSymbolOffset * kWordSize)); |
742 } | 735 } |
743 | 736 |
744 | 737 |
| 738 LocationSummary* StringToCharCodeInstr::MakeLocationSummary(bool opt) const { |
| 739 const intptr_t kNumInputs = 1; |
| 740 return LocationSummary::Make(kNumInputs, |
| 741 Location::RequiresRegister(), |
| 742 LocationSummary::kNoCall); |
| 743 } |
| 744 |
| 745 |
| 746 void StringToCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 747 ASSERT(cid_ == kOneByteStringCid); |
| 748 Register str = locs()->in(0).reg(); |
| 749 Register result = locs()->out().reg(); |
| 750 Label is_one, done; |
| 751 __ movl(result, FieldAddress(str, String::length_offset())); |
| 752 __ cmpl(result, Immediate(Smi::RawValue(1))); |
| 753 __ j(EQUAL, &is_one, Assembler::kNearJump); |
| 754 __ movl(result, Immediate(Smi::RawValue(-1))); |
| 755 __ jmp(&done); |
| 756 __ Bind(&is_one); |
| 757 __ movzxb(result, FieldAddress(str, OneByteString::data_offset())); |
| 758 __ SmiTag(result); |
| 759 __ Bind(&done); |
| 760 } |
| 761 |
| 762 |
745 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { | 763 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { |
746 const intptr_t kNumInputs = 1; | 764 const intptr_t kNumInputs = 1; |
747 const intptr_t kNumTemps = 0; | 765 const intptr_t kNumTemps = 0; |
748 LocationSummary* summary = | 766 LocationSummary* summary = |
749 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 767 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
750 summary->set_in(0, Location::RegisterLocation(EAX)); | 768 summary->set_in(0, Location::RegisterLocation(EAX)); |
751 summary->set_out(Location::RegisterLocation(EAX)); | 769 summary->set_out(Location::RegisterLocation(EAX)); |
752 return summary; | 770 return summary; |
753 } | 771 } |
754 | 772 |
(...skipping 3706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4461 | 4479 |
4462 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4480 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4463 Register value = locs()->in(0).reg(); | 4481 Register value = locs()->in(0).reg(); |
4464 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 4482 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
4465 kDeoptCheckSmi); | 4483 kDeoptCheckSmi); |
4466 __ testl(value, Immediate(kSmiTagMask)); | 4484 __ testl(value, Immediate(kSmiTagMask)); |
4467 __ j(NOT_ZERO, deopt); | 4485 __ j(NOT_ZERO, deopt); |
4468 } | 4486 } |
4469 | 4487 |
4470 | 4488 |
| 4489 // Length: register or constant. |
| 4490 // Index: register, constant or stack slot. |
4471 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(bool opt) const { | 4491 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(bool opt) const { |
4472 const intptr_t kNumInputs = 2; | 4492 const intptr_t kNumInputs = 2; |
4473 const intptr_t kNumTemps = 0; | 4493 const intptr_t kNumTemps = 0; |
4474 LocationSummary* locs = | 4494 LocationSummary* locs = |
4475 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4495 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4476 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); | 4496 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); |
4477 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); | 4497 ConstantInstr* index_constant = index()->definition()->AsConstant(); |
| 4498 if (index_constant != NULL) { |
| 4499 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); |
| 4500 } else { |
| 4501 locs->set_in(kIndexPos, Location::PrefersRegister()); |
| 4502 } |
4478 return locs; | 4503 return locs; |
4479 } | 4504 } |
4480 | 4505 |
4481 | 4506 |
4482 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4507 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4483 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound); | 4508 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound); |
4484 | 4509 |
4485 Location length_loc = locs()->in(kLengthPos); | 4510 Location length_loc = locs()->in(kLengthPos); |
4486 Location index_loc = locs()->in(kIndexPos); | 4511 Location index_loc = locs()->in(kIndexPos); |
4487 | 4512 |
(...skipping 14 matching lines...) Expand all Loading... |
4502 return; | 4527 return; |
4503 } | 4528 } |
4504 | 4529 |
4505 if (index_loc.IsConstant()) { | 4530 if (index_loc.IsConstant()) { |
4506 Register length = length_loc.reg(); | 4531 Register length = length_loc.reg(); |
4507 const Object& index = Smi::Cast(index_loc.constant()); | 4532 const Object& index = Smi::Cast(index_loc.constant()); |
4508 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); | 4533 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); |
4509 __ j(BELOW_EQUAL, deopt); | 4534 __ j(BELOW_EQUAL, deopt); |
4510 } else if (length_loc.IsConstant()) { | 4535 } else if (length_loc.IsConstant()) { |
4511 const Smi& length = Smi::Cast(length_loc.constant()); | 4536 const Smi& length = Smi::Cast(length_loc.constant()); |
4512 Register index = index_loc.reg(); | 4537 if (index_loc.IsStackSlot()) { |
4513 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); | 4538 const Address& index = index_loc.ToStackSlotAddress(); |
| 4539 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); |
| 4540 } else { |
| 4541 Register index = index_loc.reg(); |
| 4542 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); |
| 4543 } |
4514 __ j(ABOVE_EQUAL, deopt); | 4544 __ j(ABOVE_EQUAL, deopt); |
| 4545 } else if (index_loc.IsStackSlot()) { |
| 4546 Register length = length_loc.reg(); |
| 4547 const Address& index = index_loc.ToStackSlotAddress(); |
| 4548 __ cmpl(length, index); |
| 4549 __ j(BELOW_EQUAL, deopt); |
4515 } else { | 4550 } else { |
4516 Register length = length_loc.reg(); | 4551 Register length = length_loc.reg(); |
4517 Register index = index_loc.reg(); | 4552 Register index = index_loc.reg(); |
4518 __ cmpl(index, length); | 4553 __ cmpl(index, length); |
4519 __ j(ABOVE_EQUAL, deopt); | 4554 __ j(ABOVE_EQUAL, deopt); |
4520 } | 4555 } |
4521 } | 4556 } |
4522 | 4557 |
4523 | 4558 |
4524 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(bool opt) const { | 4559 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(bool opt) const { |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5202 PcDescriptors::kOther, | 5237 PcDescriptors::kOther, |
5203 locs()); | 5238 locs()); |
5204 __ Drop(2); // Discard type arguments and receiver. | 5239 __ Drop(2); // Discard type arguments and receiver. |
5205 } | 5240 } |
5206 | 5241 |
5207 } // namespace dart | 5242 } // namespace dart |
5208 | 5243 |
5209 #undef __ | 5244 #undef __ |
5210 | 5245 |
5211 #endif // defined TARGET_ARCH_IA32 | 5246 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |