| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/compiler/code-generator-impl.h" | 9 #include "src/compiler/code-generator-impl.h" |
| 10 #include "src/compiler/gap-resolver.h" | 10 #include "src/compiler/gap-resolver.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 | 200 |
| 201 class OutOfLineRecordWrite final : public OutOfLineCode { | 201 class OutOfLineRecordWrite final : public OutOfLineCode { |
| 202 public: | 202 public: |
| 203 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, | 203 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, |
| 204 Register value, Register scratch0, Register scratch1, | 204 Register value, Register scratch0, Register scratch1, |
| 205 RecordWriteMode mode) | 205 RecordWriteMode mode) |
| 206 : OutOfLineCode(gen), | 206 : OutOfLineCode(gen), |
| 207 object_(object), | 207 object_(object), |
| 208 index_(index), | 208 index_(index), |
| 209 index_immediate_(0), |
| 209 value_(value), | 210 value_(value), |
| 210 scratch0_(scratch0), | 211 scratch0_(scratch0), |
| 211 scratch1_(scratch1), | 212 scratch1_(scratch1), |
| 213 mode_(mode) {} |
| 214 |
| 215 OutOfLineRecordWrite(CodeGenerator* gen, Register object, int32_t index, |
| 216 Register value, Register scratch0, Register scratch1, |
| 217 RecordWriteMode mode) |
| 218 : OutOfLineCode(gen), |
| 219 object_(object), |
| 220 index_(no_reg), |
| 221 index_immediate_(index), |
| 222 value_(value), |
| 223 scratch0_(scratch0), |
| 224 scratch1_(scratch1), |
| 212 mode_(mode) {} | 225 mode_(mode) {} |
| 213 | 226 |
| 214 void Generate() final { | 227 void Generate() final { |
| 215 if (mode_ > RecordWriteMode::kValueIsPointer) { | 228 if (mode_ > RecordWriteMode::kValueIsPointer) { |
| 216 __ JumpIfSmi(value_, exit()); | 229 __ JumpIfSmi(value_, exit()); |
| 217 } | 230 } |
| 218 if (mode_ > RecordWriteMode::kValueIsMap) { | 231 if (mode_ > RecordWriteMode::kValueIsMap) { |
| 219 __ CheckPageFlag(value_, scratch0_, | 232 __ CheckPageFlag(value_, scratch0_, |
| 220 MemoryChunk::kPointersToHereAreInterestingMask, eq, | 233 MemoryChunk::kPointersToHereAreInterestingMask, eq, |
| 221 exit()); | 234 exit()); |
| 222 } | 235 } |
| 223 SaveFPRegsMode const save_fp_mode = | 236 SaveFPRegsMode const save_fp_mode = |
| 224 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; | 237 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; |
| 225 // TODO(turbofan): Once we get frame elision working, we need to save | 238 // TODO(turbofan): Once we get frame elision working, we need to save |
| 226 // and restore lr properly here if the frame was elided. | 239 // and restore lr properly here if the frame was elided. |
| 227 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_, | 240 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_, |
| 228 EMIT_REMEMBERED_SET, save_fp_mode); | 241 EMIT_REMEMBERED_SET, save_fp_mode); |
| 229 __ add(scratch1_, object_, index_); | 242 if (index_.is(no_reg)) { |
| 243 __ add(scratch1_, object_, Operand(index_immediate_)); |
| 244 } else { |
| 245 DCHECK_EQ(0, index_immediate_); |
| 246 __ add(scratch1_, object_, Operand(index_)); |
| 247 } |
| 230 __ CallStub(&stub); | 248 __ CallStub(&stub); |
| 231 } | 249 } |
| 232 | 250 |
| 233 private: | 251 private: |
| 234 Register const object_; | 252 Register const object_; |
| 235 Register const index_; | 253 Register const index_; |
| 254 int32_t const index_immediate_; // Valid if index_.is(no_reg). |
| 236 Register const value_; | 255 Register const value_; |
| 237 Register const scratch0_; | 256 Register const scratch0_; |
| 238 Register const scratch1_; | 257 Register const scratch1_; |
| 239 RecordWriteMode const mode_; | 258 RecordWriteMode const mode_; |
| 240 }; | 259 }; |
| 241 | 260 |
| 242 | 261 |
| 243 Condition FlagsConditionToCondition(FlagsCondition condition) { | 262 Condition FlagsConditionToCondition(FlagsCondition condition) { |
| 244 switch (condition) { | 263 switch (condition) { |
| 245 case kEqual: | 264 case kEqual: |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 DCHECK_EQ(LeaveCC, i.OutputSBit()); | 534 DCHECK_EQ(LeaveCC, i.OutputSBit()); |
| 516 break; | 535 break; |
| 517 case kArchTruncateDoubleToI: | 536 case kArchTruncateDoubleToI: |
| 518 __ TruncateDoubleToI(i.OutputRegister(), i.InputFloat64Register(0)); | 537 __ TruncateDoubleToI(i.OutputRegister(), i.InputFloat64Register(0)); |
| 519 DCHECK_EQ(LeaveCC, i.OutputSBit()); | 538 DCHECK_EQ(LeaveCC, i.OutputSBit()); |
| 520 break; | 539 break; |
| 521 case kArchStoreWithWriteBarrier: { | 540 case kArchStoreWithWriteBarrier: { |
| 522 RecordWriteMode mode = | 541 RecordWriteMode mode = |
| 523 static_cast<RecordWriteMode>(MiscField::decode(instr->opcode())); | 542 static_cast<RecordWriteMode>(MiscField::decode(instr->opcode())); |
| 524 Register object = i.InputRegister(0); | 543 Register object = i.InputRegister(0); |
| 525 Register index = i.InputRegister(1); | |
| 526 Register value = i.InputRegister(2); | 544 Register value = i.InputRegister(2); |
| 527 Register scratch0 = i.TempRegister(0); | 545 Register scratch0 = i.TempRegister(0); |
| 528 Register scratch1 = i.TempRegister(1); | 546 Register scratch1 = i.TempRegister(1); |
| 529 auto ool = new (zone()) OutOfLineRecordWrite(this, object, index, value, | 547 OutOfLineRecordWrite* ool; |
| 530 scratch0, scratch1, mode); | 548 |
| 531 __ str(value, MemOperand(object, index)); | 549 AddressingMode addressing_mode = |
| 550 AddressingModeField::decode(instr->opcode()); |
| 551 if (addressing_mode == kMode_Offset_RI) { |
| 552 int32_t index = i.InputInt32(1); |
| 553 ool = new (zone()) OutOfLineRecordWrite(this, object, index, value, |
| 554 scratch0, scratch1, mode); |
| 555 __ str(value, MemOperand(object, index)); |
| 556 } else { |
| 557 DCHECK_EQ(kMode_Offset_RR, addressing_mode); |
| 558 Register index(i.InputRegister(1)); |
| 559 ool = new (zone()) OutOfLineRecordWrite(this, object, index, value, |
| 560 scratch0, scratch1, mode); |
| 561 __ str(value, MemOperand(object, index)); |
| 562 } |
| 532 __ CheckPageFlag(object, scratch0, | 563 __ CheckPageFlag(object, scratch0, |
| 533 MemoryChunk::kPointersFromHereAreInterestingMask, ne, | 564 MemoryChunk::kPointersFromHereAreInterestingMask, ne, |
| 534 ool->entry()); | 565 ool->entry()); |
| 535 __ bind(ool->exit()); | 566 __ bind(ool->exit()); |
| 536 break; | 567 break; |
| 537 } | 568 } |
| 538 case kArchStackSlot: { | 569 case kArchStackSlot: { |
| 539 FrameOffset offset = | 570 FrameOffset offset = |
| 540 frame_access_state()->GetFrameOffset(i.InputInt32(0)); | 571 frame_access_state()->GetFrameOffset(i.InputInt32(0)); |
| 541 Register base; | 572 Register base; |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 padding_size -= v8::internal::Assembler::kInstrSize; | 1448 padding_size -= v8::internal::Assembler::kInstrSize; |
| 1418 } | 1449 } |
| 1419 } | 1450 } |
| 1420 } | 1451 } |
| 1421 | 1452 |
| 1422 #undef __ | 1453 #undef __ |
| 1423 | 1454 |
| 1424 } // namespace compiler | 1455 } // namespace compiler |
| 1425 } // namespace internal | 1456 } // namespace internal |
| 1426 } // namespace v8 | 1457 } // namespace v8 |
| OLD | NEW |