Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: src/compiler/ia32/code-generator-ia32.cc

Issue 1414183006: [turbofan] Avoid unnecessary write barriers and improve code generation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 __ movsd(MemOperand(esp, 0), input_); 210 __ movsd(MemOperand(esp, 0), input_);
211 __ SlowTruncateToI(result_, esp, 0); 211 __ SlowTruncateToI(result_, esp, 0);
212 __ add(esp, Immediate(kDoubleSize)); 212 __ add(esp, Immediate(kDoubleSize));
213 } 213 }
214 214
215 private: 215 private:
216 Register const result_; 216 Register const result_;
217 XMMRegister const input_; 217 XMMRegister const input_;
218 }; 218 };
219 219
220
221 class OutOfLineRecordWrite final : public OutOfLineCode {
222 public:
223 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Operand operand,
224 Register value, Register scratch0, Register scratch1,
225 RecordWriteMode mode)
226 : OutOfLineCode(gen),
227 object_(object),
228 operand_(operand),
229 value_(value),
230 scratch0_(scratch0),
231 scratch1_(scratch1),
232 mode_(mode) {}
233
234 void Generate() final {
235 if (mode_ > RecordWriteMode::kValueIsPointer) {
236 __ JumpIfSmi(value_, exit());
237 }
238 if (mode_ > RecordWriteMode::kValueIsMap) {
239 __ CheckPageFlag(value_, scratch0_,
240 MemoryChunk::kPointersToHereAreInterestingMask, zero,
241 exit());
242 }
243 SaveFPRegsMode const save_fp_mode =
244 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
245 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_,
246 EMIT_REMEMBERED_SET, save_fp_mode);
247 __ lea(scratch1_, operand_);
248 __ CallStub(&stub);
249 }
250
251 private:
252 Register const object_;
253 Operand const operand_;
254 Register const value_;
255 Register const scratch0_;
256 Register const scratch1_;
257 RecordWriteMode const mode_;
258 };
259
220 } // namespace 260 } // namespace
221 261
222 262
223 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ 263 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \
224 do { \ 264 do { \
225 auto result = i.OutputDoubleRegister(); \ 265 auto result = i.OutputDoubleRegister(); \
226 auto offset = i.InputRegister(0); \ 266 auto offset = i.InputRegister(0); \
227 if (instr->InputAt(1)->IsRegister()) { \ 267 if (instr->InputAt(1)->IsRegister()) { \
228 __ cmp(offset, i.InputRegister(1)); \ 268 __ cmp(offset, i.InputRegister(1)); \
229 } else { \ 269 } else { \
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 case kArchTruncateDoubleToI: { 440 case kArchTruncateDoubleToI: {
401 auto result = i.OutputRegister(); 441 auto result = i.OutputRegister();
402 auto input = i.InputDoubleRegister(0); 442 auto input = i.InputDoubleRegister(0);
403 auto ool = new (zone()) OutOfLineTruncateDoubleToI(this, result, input); 443 auto ool = new (zone()) OutOfLineTruncateDoubleToI(this, result, input);
404 __ cvttsd2si(result, Operand(input)); 444 __ cvttsd2si(result, Operand(input));
405 __ cmp(result, 1); 445 __ cmp(result, 1);
406 __ j(overflow, ool->entry()); 446 __ j(overflow, ool->entry());
407 __ bind(ool->exit()); 447 __ bind(ool->exit());
408 break; 448 break;
409 } 449 }
450 case kArchStoreWithWriteBarrier: {
451 RecordWriteMode mode =
452 static_cast<RecordWriteMode>(MiscField::decode(instr->opcode()));
453 Register object = i.InputRegister(0);
454 size_t index = 0;
455 Operand operand = i.MemoryOperand(&index);
456 Register value = i.InputRegister(index);
457 Register scratch0 = i.TempRegister(0);
458 Register scratch1 = i.TempRegister(1);
459 auto ool = new (zone()) OutOfLineRecordWrite(this, object, operand, value,
460 scratch0, scratch1, mode);
461 __ mov(operand, value);
462 __ CheckPageFlag(object, scratch0,
463 MemoryChunk::kPointersFromHereAreInterestingMask,
464 not_zero, ool->entry());
465 __ bind(ool->exit());
466 break;
467 }
410 case kIA32Add: 468 case kIA32Add:
411 if (HasImmediateInput(instr, 1)) { 469 if (HasImmediateInput(instr, 1)) {
412 __ add(i.InputOperand(0), i.InputImmediate(1)); 470 __ add(i.InputOperand(0), i.InputImmediate(1));
413 } else { 471 } else {
414 __ add(i.InputRegister(0), i.InputOperand(1)); 472 __ add(i.InputRegister(0), i.InputOperand(1));
415 } 473 }
416 break; 474 break;
417 case kIA32And: 475 case kIA32And:
418 if (HasImmediateInput(instr, 1)) { 476 if (HasImmediateInput(instr, 1)) {
419 __ and_(i.InputOperand(0), i.InputImmediate(1)); 477 __ and_(i.InputOperand(0), i.InputImmediate(1));
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 break; 971 break;
914 case kIA32Poke: { 972 case kIA32Poke: {
915 int const slot = MiscField::decode(instr->opcode()); 973 int const slot = MiscField::decode(instr->opcode());
916 if (HasImmediateInput(instr, 0)) { 974 if (HasImmediateInput(instr, 0)) {
917 __ mov(Operand(esp, slot * kPointerSize), i.InputImmediate(0)); 975 __ mov(Operand(esp, slot * kPointerSize), i.InputImmediate(0));
918 } else { 976 } else {
919 __ mov(Operand(esp, slot * kPointerSize), i.InputRegister(0)); 977 __ mov(Operand(esp, slot * kPointerSize), i.InputRegister(0));
920 } 978 }
921 break; 979 break;
922 } 980 }
923 case kIA32StoreWriteBarrier: {
924 Register object = i.InputRegister(0);
925 Register value = i.InputRegister(2);
926 SaveFPRegsMode mode =
927 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
928 if (HasImmediateInput(instr, 1)) {
929 int index = i.InputInt32(1);
930 Register scratch = i.TempRegister(1);
931 __ mov(Operand(object, index), value);
932 __ RecordWriteContextSlot(object, index, value, scratch, mode);
933 } else {
934 Register index = i.InputRegister(1);
935 __ mov(Operand(object, index, times_1, 0), value);
936 __ lea(index, Operand(object, index, times_1, 0));
937 __ RecordWrite(object, index, value, mode);
938 }
939 break;
940 }
941 case kCheckedLoadInt8: 981 case kCheckedLoadInt8:
942 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_b); 982 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_b);
943 break; 983 break;
944 case kCheckedLoadUint8: 984 case kCheckedLoadUint8:
945 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_b); 985 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_b);
946 break; 986 break;
947 case kCheckedLoadInt16: 987 case kCheckedLoadInt16:
948 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); 988 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w);
949 break; 989 break;
950 case kCheckedLoadUint16: 990 case kCheckedLoadUint16:
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 1606 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
1567 __ Nop(padding_size); 1607 __ Nop(padding_size);
1568 } 1608 }
1569 } 1609 }
1570 1610
1571 #undef __ 1611 #undef __
1572 1612
1573 } // namespace compiler 1613 } // namespace compiler
1574 } // namespace internal 1614 } // namespace internal
1575 } // namespace v8 1615 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698