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

Unified Diff: src/compiler/instruction.h

Issue 907873002: [turbofan] make zone allocation of InstructionOperand explicit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/move-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction.h
diff --git a/src/compiler/instruction.h b/src/compiler/instruction.h
index 6ad2548b8e7a8e351b6fd1c5c1498731b090f084..d04d0367f5e62c6c788434e216b5ed4b45b4c68e 100644
--- a/src/compiler/instruction.h
+++ b/src/compiler/instruction.h
@@ -60,6 +60,10 @@ class InstructionOperand {
ConvertTo(kind, index);
}
+ static InstructionOperand* New(Zone* zone, Kind kind, int index) {
+ return New(zone, InstructionOperand(kind, index));
+ }
+
Kind kind() const { return KindField::decode(value_); }
int index() const { return static_cast<int>(value_) >> KindField::kSize; }
#define INSTRUCTION_OPERAND_PREDICATE(name, type) \
@@ -80,14 +84,13 @@ class InstructionOperand {
if (kind != UNALLOCATED) virtual_register_ = kInvalidVirtualRegister;
}
- // TODO(dcarney): get rid of these
- void* operator new(size_t, void* location) { return location; }
- void* operator new(size_t size, Zone* zone) {
- return zone->New(static_cast<int>(size));
+ protected:
+ template <typename SubKindOperand>
+ static SubKindOperand* New(Zone* zone, const SubKindOperand& op) {
+ void* buffer = zone->New(sizeof(op));
+ return new (buffer) SubKindOperand(op);
}
- void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
- protected:
InstructionOperand(Kind kind, int index, int virtual_register)
: virtual_register_(virtual_register) {
ConvertTo(kind, index);
@@ -166,8 +169,10 @@ class UnallocatedOperand : public InstructionOperand {
value_ |= LifetimeField::encode(lifetime);
}
+ UnallocatedOperand* Copy(Zone* zone) { return New(zone, *this); }
+
UnallocatedOperand* CopyUnconstrained(Zone* zone) {
- return new (zone) UnallocatedOperand(ANY, virtual_register());
+ return New(zone, UnallocatedOperand(ANY, virtual_register()));
}
static const UnallocatedOperand* cast(const InstructionOperand* op) {
@@ -349,7 +354,7 @@ std::ostream& operator<<(std::ostream& os, const PrintableMoveOperands& mo);
: InstructionOperand(kOperandKind, index) {} \
\
static SubKind##Operand* New(int index, Zone* zone) { \
- return new (zone) SubKind##Operand(index); \
+ return InstructionOperand::New(zone, SubKind##Operand(index)); \
} \
\
static SubKind##Operand* cast(InstructionOperand* op) { \
@@ -436,7 +441,7 @@ class PointerMap FINAL : public ZoneObject {
std::ostream& operator<<(std::ostream& os, const PointerMap& pm);
// TODO(titzer): s/PointerMap/ReferenceMap/
-class Instruction : public ZoneObject {
+class Instruction {
public:
size_t OutputCount() const { return OutputCountField::decode(bit_field_); }
const InstructionOperand* OutputAt(size_t i) const {
@@ -535,12 +540,6 @@ class Instruction : public ZoneObject {
pointer_map_ = map;
}
- // Placement new operator so that we can smash instructions into
- // zone-allocated memory.
- void* operator new(size_t, void* location) { return location; }
-
- void operator delete(void* pointer, void* location) { UNREACHABLE(); }
-
void OverwriteWithNop() {
opcode_ = ArchOpcodeField::encode(kArchNop);
bit_field_ = 0;
@@ -559,7 +558,6 @@ class Instruction : public ZoneObject {
InstructionOperand* inputs, size_t temp_count,
InstructionOperand* temps);
- protected:
typedef BitField<size_t, 0, 8> OutputCountField;
typedef BitField<size_t, 8, 16> InputCountField;
typedef BitField<size_t, 24, 6> TempCountField;
@@ -570,6 +568,9 @@ class Instruction : public ZoneObject {
uint32_t bit_field_;
PointerMap* pointer_map_;
InstructionOperand operands_[1];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Instruction);
};
« no previous file with comments | « no previous file | src/compiler/move-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698