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

Side by Side Diff: src/compiler/node.h

Issue 1366753003: [turbofan] Make Node::set_op safer via wrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | src/compiler/node-properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8_COMPILER_NODE_H_ 5 #ifndef V8_COMPILER_NODE_H_
6 #define V8_COMPILER_NODE_H_ 6 #define V8_COMPILER_NODE_H_
7 7
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "src/types.h" 10 #include "src/types.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class Node final { 42 class Node final {
43 public: 43 public:
44 static Node* New(Zone* zone, NodeId id, const Operator* op, int input_count, 44 static Node* New(Zone* zone, NodeId id, const Operator* op, int input_count,
45 Node* const* inputs, bool has_extensible_inputs); 45 Node* const* inputs, bool has_extensible_inputs);
46 static Node* Clone(Zone* zone, NodeId id, const Node* node); 46 static Node* Clone(Zone* zone, NodeId id, const Node* node);
47 47
48 bool IsDead() const { return InputCount() > 0 && !InputAt(0); } 48 bool IsDead() const { return InputCount() > 0 && !InputAt(0); }
49 void Kill(); 49 void Kill();
50 50
51 const Operator* op() const { return op_; } 51 const Operator* op() const { return op_; }
52 void set_op(const Operator* op) { op_ = op; }
53 52
54 IrOpcode::Value opcode() const { 53 IrOpcode::Value opcode() const {
55 DCHECK(op_->opcode() <= IrOpcode::kLast); 54 DCHECK(op_->opcode() <= IrOpcode::kLast);
56 return static_cast<IrOpcode::Value>(op_->opcode()); 55 return static_cast<IrOpcode::Value>(op_->opcode());
57 } 56 }
58 57
59 NodeId id() const { return IdField::decode(bit_field_); } 58 NodeId id() const { return IdField::decode(bit_field_); }
60 59
61 int InputCount() const { 60 int InputCount() const {
62 return has_inline_inputs() ? InlineCountField::decode(bit_field_) 61 return has_inline_inputs() ? InlineCountField::decode(bit_field_)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 Use* ptr = has_inline_inputs() ? reinterpret_cast<Use*>(this) 276 Use* ptr = has_inline_inputs() ? reinterpret_cast<Use*>(this)
278 : reinterpret_cast<Use*>(inputs_.outline_); 277 : reinterpret_cast<Use*>(inputs_.outline_);
279 return &ptr[-1 - input_index]; 278 return &ptr[-1 - input_index];
280 } 279 }
281 280
282 void AppendUse(Use* use); 281 void AppendUse(Use* use);
283 void RemoveUse(Use* use); 282 void RemoveUse(Use* use);
284 283
285 void* operator new(size_t, void* location) { return location; } 284 void* operator new(size_t, void* location) { return location; }
286 285
286 // Only NodeProperties should manipulate the op.
287 void set_op(const Operator* op) { op_ = op; }
288
287 // Only NodeProperties should manipulate the type. 289 // Only NodeProperties should manipulate the type.
288 Type* type() const { return type_; } 290 Type* type() const { return type_; }
289 void set_type(Type* type) { type_ = type; } 291 void set_type(Type* type) { type_ = type; }
290 292
291 // Only NodeMarkers should manipulate the marks on nodes. 293 // Only NodeMarkers should manipulate the marks on nodes.
292 Mark mark() { return mark_; } 294 Mark mark() { return mark_; }
293 void set_mark(Mark mark) { mark_ = mark; } 295 void set_mark(Mark mark) { mark_ = mark; }
294 296
295 inline bool has_inline_inputs() const { 297 inline bool has_inline_inputs() const {
296 return InlineCountField::decode(bit_field_) != kOutlineMarker; 298 return InlineCountField::decode(bit_field_) != kOutlineMarker;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 554 }
553 555
554 556
555 Node::Uses::const_iterator Node::Uses::end() const { return const_iterator(); } 557 Node::Uses::const_iterator Node::Uses::end() const { return const_iterator(); }
556 558
557 } // namespace compiler 559 } // namespace compiler
558 } // namespace internal 560 } // namespace internal
559 } // namespace v8 561 } // namespace v8
560 562
561 #endif // V8_COMPILER_NODE_H_ 563 #endif // V8_COMPILER_NODE_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | src/compiler/node-properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698