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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 input_type->Is(Type::TaggedPointer())) { | 458 input_type->Is(Type::TaggedPointer())) { |
459 // Write barriers for heap objects don't need a Smi check. | 459 // Write barriers for heap objects don't need a Smi check. |
460 return kPointerWriteBarrier; | 460 return kPointerWriteBarrier; |
461 } | 461 } |
462 // Write barriers are only for writes into heap objects (i.e. tagged base). | 462 // Write barriers are only for writes into heap objects (i.e. tagged base). |
463 return kFullWriteBarrier; | 463 return kFullWriteBarrier; |
464 } | 464 } |
465 return kNoWriteBarrier; | 465 return kNoWriteBarrier; |
466 } | 466 } |
467 | 467 |
| 468 |
| 469 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, |
| 470 MachineRepresentation representation, |
| 471 int field_offset, Type* field_type, |
| 472 Type* input_type) { |
| 473 if (base_is_tagged == kTaggedBase && field_offset == HeapObject::kMapOffset) { |
| 474 // Write barriers for storing maps are cheaper. |
| 475 return kMapWriteBarrier; |
| 476 } |
| 477 return ComputeWriteBarrierKind(base_is_tagged, representation, field_type, |
| 478 input_type); |
| 479 } |
| 480 |
468 } // namespace | 481 } // namespace |
469 | 482 |
470 | 483 |
471 Reduction ChangeLowering::LoadField(Node* node) { | 484 Reduction ChangeLowering::LoadField(Node* node) { |
472 const FieldAccess& access = FieldAccessOf(node->op()); | 485 const FieldAccess& access = FieldAccessOf(node->op()); |
473 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 486 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
474 node->InsertInput(graph()->zone(), 1, offset); | 487 node->InsertInput(graph()->zone(), 1, offset); |
475 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); | 488 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); |
476 return Changed(node); | 489 return Changed(node); |
477 } | 490 } |
478 | 491 |
479 | 492 |
480 Reduction ChangeLowering::StoreField(Node* node) { | 493 Reduction ChangeLowering::StoreField(Node* node) { |
481 const FieldAccess& access = FieldAccessOf(node->op()); | 494 const FieldAccess& access = FieldAccessOf(node->op()); |
482 Type* type = NodeProperties::GetType(node->InputAt(1)); | 495 Type* type = NodeProperties::GetType(node->InputAt(1)); |
483 WriteBarrierKind kind = ComputeWriteBarrierKind( | 496 WriteBarrierKind kind = ComputeWriteBarrierKind( |
484 access.base_is_tagged, access.machine_type.representation(), access.type, | 497 access.base_is_tagged, access.machine_type.representation(), |
485 type); | 498 access.offset, access.type, type); |
486 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 499 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
487 node->InsertInput(graph()->zone(), 1, offset); | 500 node->InsertInput(graph()->zone(), 1, offset); |
488 NodeProperties::ChangeOp(node, | 501 NodeProperties::ChangeOp(node, |
489 machine()->Store(StoreRepresentation( | 502 machine()->Store(StoreRepresentation( |
490 access.machine_type.representation(), kind))); | 503 access.machine_type.representation(), kind))); |
491 return Changed(node); | 504 return Changed(node); |
492 } | 505 } |
493 | 506 |
494 | 507 |
495 Node* ChangeLowering::ComputeIndex(const ElementAccess& access, | 508 Node* ChangeLowering::ComputeIndex(const ElementAccess& access, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 594 } |
582 | 595 |
583 | 596 |
584 MachineOperatorBuilder* ChangeLowering::machine() const { | 597 MachineOperatorBuilder* ChangeLowering::machine() const { |
585 return jsgraph()->machine(); | 598 return jsgraph()->machine(); |
586 } | 599 } |
587 | 600 |
588 } // namespace compiler | 601 } // namespace compiler |
589 } // namespace internal | 602 } // namespace internal |
590 } // namespace v8 | 603 } // namespace v8 |
OLD | NEW |