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

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

Issue 1149563004: [turbofan] Add bounds check to Node::InputAt(index) and fix tests that go out of bounds. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
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-inl.h" 10 #include "src/types-inl.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 void set_op(const Operator* op) { op_ = op; } 51 void set_op(const Operator* op) { op_ = op; }
52 52
53 IrOpcode::Value opcode() const { 53 IrOpcode::Value opcode() const {
54 DCHECK(op_->opcode() <= IrOpcode::kLast); 54 DCHECK(op_->opcode() <= IrOpcode::kLast);
55 return static_cast<IrOpcode::Value>(op_->opcode()); 55 return static_cast<IrOpcode::Value>(op_->opcode());
56 } 56 }
57 57
58 NodeId id() const { return id_; } 58 NodeId id() const { return id_; }
59 59
60 int InputCount() const { return input_count(); } 60 int InputCount() const { return input_count(); }
61 Node* InputAt(int index) const { return GetInputRecordPtr(index)->to; } 61 Node* InputAt(int index) const {
62 #if DEBUG
63 if (index < 0 || index >= InputCount()) {
64 V8_Fatal(__FILE__, __LINE__, "Node #%d:%s->InputAt(%d) out of bounds",
65 id(), op()->mnemonic(), index);
66 }
67 #endif
68 return GetInputRecordPtr(index)->to;
69 }
62 inline void ReplaceInput(int index, Node* new_to); 70 inline void ReplaceInput(int index, Node* new_to);
63 void AppendInput(Zone* zone, Node* new_to); 71 void AppendInput(Zone* zone, Node* new_to);
64 void InsertInput(Zone* zone, int index, Node* new_to); 72 void InsertInput(Zone* zone, int index, Node* new_to);
65 void RemoveInput(int index); 73 void RemoveInput(int index);
66 void NullAllInputs(); 74 void NullAllInputs();
67 void TrimInputCount(int new_input_count); 75 void TrimInputCount(int new_input_count);
68 76
69 int UseCount() const; 77 int UseCount() const;
70 void ReplaceUses(Node* replace_to); 78 void ReplaceUses(Node* replace_to);
71 79
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 484
477 void Node::ReplaceInput(int index, Node* new_to) { 485 void Node::ReplaceInput(int index, Node* new_to) {
478 GetInputRecordPtr(index)->Update(new_to); 486 GetInputRecordPtr(index)->Update(new_to);
479 } 487 }
480 488
481 } // namespace compiler 489 } // namespace compiler
482 } // namespace internal 490 } // namespace internal
483 } // namespace v8 491 } // namespace v8
484 492
485 #endif // V8_COMPILER_NODE_H_ 493 #endif // V8_COMPILER_NODE_H_
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698