Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / v8 / src / compiler / operator.cc
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
3 // found in the LICENSE file.
4
5 #include "src/compiler/operator.h"
6
7 #include <limits>
8
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12
13
14 template <typename N>
15 static inline N CheckRange(size_t val) {
16   CHECK(val <= std::numeric_limits<N>::max());
17   return static_cast<N>(val);
18 }
19
20
21 Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic,
22                    size_t value_in, size_t effect_in, size_t control_in,
23                    size_t value_out, size_t effect_out, size_t control_out)
24     : opcode_(opcode),
25       properties_(properties),
26       mnemonic_(mnemonic),
27       value_in_(CheckRange<uint32_t>(value_in)),
28       effect_in_(CheckRange<uint16_t>(effect_in)),
29       control_in_(CheckRange<uint16_t>(control_in)),
30       value_out_(CheckRange<uint16_t>(value_out)),
31       effect_out_(CheckRange<uint8_t>(effect_out)),
32       control_out_(CheckRange<uint8_t>(control_out)) {}
33
34
35 std::ostream& operator<<(std::ostream& os, const Operator& op) {
36   op.PrintTo(os);
37   return os;
38 }
39
40
41 void Operator::PrintTo(std::ostream& os) const { os << mnemonic(); }
42
43 }  // namespace compiler
44 }  // namespace internal
45 }  // namespace v8