OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/osr.h" | 10 #include "src/compiler/osr.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 UNIMPLEMENTED(); | 211 UNIMPLEMENTED(); |
212 USE(result_); | 212 USE(result_); |
213 USE(input_); | 213 USE(input_); |
214 } | 214 } |
215 | 215 |
216 private: | 216 private: |
217 Register const result_; | 217 Register const result_; |
218 X87Register const input_; | 218 X87Register const input_; |
219 }; | 219 }; |
220 | 220 |
| 221 |
| 222 class OutOfLineRecordWrite final : public OutOfLineCode { |
| 223 public: |
| 224 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Operand operand, |
| 225 Register value, Register scratch0, Register scratch1, |
| 226 RecordWriteMode mode) |
| 227 : OutOfLineCode(gen), |
| 228 object_(object), |
| 229 operand_(operand), |
| 230 value_(value), |
| 231 scratch0_(scratch0), |
| 232 scratch1_(scratch1), |
| 233 mode_(mode) {} |
| 234 |
| 235 void Generate() final { |
| 236 if (mode_ > RecordWriteMode::kValueIsPointer) { |
| 237 __ JumpIfSmi(value_, exit()); |
| 238 } |
| 239 if (mode_ > RecordWriteMode::kValueIsMap) { |
| 240 __ CheckPageFlag(value_, scratch0_, |
| 241 MemoryChunk::kPointersToHereAreInterestingMask, zero, |
| 242 exit()); |
| 243 } |
| 244 SaveFPRegsMode const save_fp_mode = |
| 245 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; |
| 246 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_, |
| 247 EMIT_REMEMBERED_SET, save_fp_mode); |
| 248 __ lea(scratch1_, operand_); |
| 249 __ CallStub(&stub); |
| 250 } |
| 251 |
| 252 private: |
| 253 Register const object_; |
| 254 Operand const operand_; |
| 255 Register const value_; |
| 256 Register const scratch0_; |
| 257 Register const scratch1_; |
| 258 RecordWriteMode const mode_; |
| 259 }; |
| 260 |
221 } // namespace | 261 } // namespace |
222 | 262 |
223 | 263 |
224 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ | 264 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ |
225 do { \ | 265 do { \ |
226 auto result = i.OutputDoubleRegister(); \ | 266 auto result = i.OutputDoubleRegister(); \ |
227 auto offset = i.InputRegister(0); \ | 267 auto offset = i.InputRegister(0); \ |
228 DCHECK(result.code() == 0); \ | 268 DCHECK(result.code() == 0); \ |
229 if (instr->InputAt(1)->IsRegister()) { \ | 269 if (instr->InputAt(1)->IsRegister()) { \ |
230 __ cmp(offset, i.InputRegister(1)); \ | 270 __ cmp(offset, i.InputRegister(1)); \ |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 case kArchTruncateDoubleToI: { | 489 case kArchTruncateDoubleToI: { |
450 if (!instr->InputAt(0)->IsDoubleRegister()) { | 490 if (!instr->InputAt(0)->IsDoubleRegister()) { |
451 __ fld_d(i.InputOperand(0)); | 491 __ fld_d(i.InputOperand(0)); |
452 } | 492 } |
453 __ TruncateX87TOSToI(i.OutputRegister()); | 493 __ TruncateX87TOSToI(i.OutputRegister()); |
454 if (!instr->InputAt(0)->IsDoubleRegister()) { | 494 if (!instr->InputAt(0)->IsDoubleRegister()) { |
455 __ fstp(0); | 495 __ fstp(0); |
456 } | 496 } |
457 break; | 497 break; |
458 } | 498 } |
| 499 case kArchStoreWithWriteBarrier: { |
| 500 RecordWriteMode mode = |
| 501 static_cast<RecordWriteMode>(MiscField::decode(instr->opcode())); |
| 502 Register object = i.InputRegister(0); |
| 503 size_t index = 0; |
| 504 Operand operand = i.MemoryOperand(&index); |
| 505 Register value = i.InputRegister(index); |
| 506 Register scratch0 = i.TempRegister(0); |
| 507 Register scratch1 = i.TempRegister(1); |
| 508 auto ool = new (zone()) OutOfLineRecordWrite(this, object, operand, value, |
| 509 scratch0, scratch1, mode); |
| 510 __ mov(operand, value); |
| 511 __ CheckPageFlag(object, scratch0, |
| 512 MemoryChunk::kPointersFromHereAreInterestingMask, |
| 513 not_zero, ool->entry()); |
| 514 __ bind(ool->exit()); |
| 515 break; |
| 516 } |
459 case kX87Add: | 517 case kX87Add: |
460 if (HasImmediateInput(instr, 1)) { | 518 if (HasImmediateInput(instr, 1)) { |
461 __ add(i.InputOperand(0), i.InputImmediate(1)); | 519 __ add(i.InputOperand(0), i.InputImmediate(1)); |
462 } else { | 520 } else { |
463 __ add(i.InputRegister(0), i.InputOperand(1)); | 521 __ add(i.InputRegister(0), i.InputOperand(1)); |
464 } | 522 } |
465 break; | 523 break; |
466 case kX87And: | 524 case kX87And: |
467 if (HasImmediateInput(instr, 1)) { | 525 if (HasImmediateInput(instr, 1)) { |
468 __ and_(i.InputOperand(0), i.InputImmediate(1)); | 526 __ and_(i.InputOperand(0), i.InputImmediate(1)); |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 __ lea(esp, Operand(esp, -kDoubleSize)); | 1267 __ lea(esp, Operand(esp, -kDoubleSize)); |
1210 if (instr->InputAt(0)->IsDoubleStackSlot()) { | 1268 if (instr->InputAt(0)->IsDoubleStackSlot()) { |
1211 __ fld_d(i.InputOperand(0)); | 1269 __ fld_d(i.InputOperand(0)); |
1212 __ fstp_d(MemOperand(esp, 0)); | 1270 __ fstp_d(MemOperand(esp, 0)); |
1213 } else if (instr->InputAt(0)->IsDoubleRegister()) { | 1271 } else if (instr->InputAt(0)->IsDoubleRegister()) { |
1214 __ fst_d(MemOperand(esp, 0)); | 1272 __ fst_d(MemOperand(esp, 0)); |
1215 } else { | 1273 } else { |
1216 UNREACHABLE(); | 1274 UNREACHABLE(); |
1217 } | 1275 } |
1218 break; | 1276 break; |
1219 case kX87StoreWriteBarrier: { | |
1220 Register object = i.InputRegister(0); | |
1221 Register value = i.InputRegister(2); | |
1222 SaveFPRegsMode mode = | |
1223 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; | |
1224 if (HasImmediateInput(instr, 1)) { | |
1225 int index = i.InputInt32(1); | |
1226 Register scratch = i.TempRegister(1); | |
1227 __ mov(Operand(object, index), value); | |
1228 __ RecordWriteContextSlot(object, index, value, scratch, mode); | |
1229 } else { | |
1230 Register index = i.InputRegister(1); | |
1231 __ mov(Operand(object, index, times_1, 0), value); | |
1232 __ lea(index, Operand(object, index, times_1, 0)); | |
1233 __ RecordWrite(object, index, value, mode); | |
1234 } | |
1235 break; | |
1236 } | |
1237 case kCheckedLoadInt8: | 1277 case kCheckedLoadInt8: |
1238 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_b); | 1278 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_b); |
1239 break; | 1279 break; |
1240 case kCheckedLoadUint8: | 1280 case kCheckedLoadUint8: |
1241 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_b); | 1281 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_b); |
1242 break; | 1282 break; |
1243 case kCheckedLoadInt16: | 1283 case kCheckedLoadInt16: |
1244 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); | 1284 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); |
1245 break; | 1285 break; |
1246 case kCheckedLoadUint16: | 1286 case kCheckedLoadUint16: |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1952 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1913 __ Nop(padding_size); | 1953 __ Nop(padding_size); |
1914 } | 1954 } |
1915 } | 1955 } |
1916 | 1956 |
1917 #undef __ | 1957 #undef __ |
1918 | 1958 |
1919 } // namespace compiler | 1959 } // namespace compiler |
1920 } // namespace internal | 1960 } // namespace internal |
1921 } // namespace v8 | 1961 } // namespace v8 |
OLD | NEW |