| OLD | NEW |
| 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_JS_OPERATOR_H_ | 5 #ifndef V8_COMPILER_JS_OPERATOR_H_ |
| 6 #define V8_COMPILER_JS_OPERATOR_H_ | 6 #define V8_COMPILER_JS_OPERATOR_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/unique.h" | 10 #include "src/unique.h" |
| 11 #include "src/zone.h" | 11 #include "src/zone.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 namespace compiler { | 15 namespace compiler { |
| 16 | 16 |
| 17 // Defines the location of a context slot relative to a specific scope. This is | 17 // Defines the location of a context slot relative to a specific scope. This is |
| 18 // used as a parameter by JSLoadContext and JSStoreContext operators and allows | 18 // used as a parameter by JSLoadContext and JSStoreContext operators and allows |
| 19 // accessing a context-allocated variable without keeping track of the scope. | 19 // accessing a context-allocated variable without keeping track of the scope. |
| 20 class ContextAccess { | 20 class ContextAccess { |
| 21 public: | 21 public: |
| 22 ContextAccess(int depth, int index, bool immutable) | 22 ContextAccess(int depth, int index, bool immutable) |
| 23 : immutable_(immutable), depth_(depth), index_(index) { | 23 : immutable_(immutable), depth_(depth), index_(index) { |
| 24 ASSERT(0 <= depth && depth <= kMaxUInt16); | 24 DCHECK(0 <= depth && depth <= kMaxUInt16); |
| 25 ASSERT(0 <= index && static_cast<uint32_t>(index) <= kMaxUInt32); | 25 DCHECK(0 <= index && static_cast<uint32_t>(index) <= kMaxUInt32); |
| 26 } | 26 } |
| 27 int depth() const { return depth_; } | 27 int depth() const { return depth_; } |
| 28 int index() const { return index_; } | 28 int index() const { return index_; } |
| 29 bool immutable() const { return immutable_; } | 29 bool immutable() const { return immutable_; } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // For space reasons, we keep this tightly packed, otherwise we could just use | 32 // For space reasons, we keep this tightly packed, otherwise we could just use |
| 33 // a simple int/int/bool POD. | 33 // a simple int/int/bool POD. |
| 34 const bool immutable_; | 34 const bool immutable_; |
| 35 const uint16_t depth_; | 35 const uint16_t depth_; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 OP1(JSCreateCatchContext, PrintableUnique<String>, name, | 147 OP1(JSCreateCatchContext, PrintableUnique<String>, name, |
| 148 Operator::kNoProperties, 1, 1); | 148 Operator::kNoProperties, 1, 1); |
| 149 } | 149 } |
| 150 Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } | 150 Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } |
| 151 Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } | 151 Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } |
| 152 Operator* CreateModuleContext() { NOPROPS(JSCreateModuleContext, 2, 1); } | 152 Operator* CreateModuleContext() { NOPROPS(JSCreateModuleContext, 2, 1); } |
| 153 Operator* CreateGlobalContext() { NOPROPS(JSCreateGlobalContext, 2, 1); } | 153 Operator* CreateGlobalContext() { NOPROPS(JSCreateGlobalContext, 2, 1); } |
| 154 | 154 |
| 155 Operator* Runtime(Runtime::FunctionId function, int arguments) { | 155 Operator* Runtime(Runtime::FunctionId function, int arguments) { |
| 156 const Runtime::Function* f = Runtime::FunctionForId(function); | 156 const Runtime::Function* f = Runtime::FunctionForId(function); |
| 157 ASSERT(f->nargs == -1 || f->nargs == arguments); | 157 DCHECK(f->nargs == -1 || f->nargs == arguments); |
| 158 OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties, | 158 OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties, |
| 159 arguments, f->result_size); | 159 arguments, f->result_size); |
| 160 } | 160 } |
| 161 | 161 |
| 162 #undef SIMPLE | 162 #undef SIMPLE |
| 163 #undef NOPROPS | 163 #undef NOPROPS |
| 164 #undef OP1 | 164 #undef OP1 |
| 165 #undef BINOP | 165 #undef BINOP |
| 166 #undef UNOP | 166 #undef UNOP |
| 167 | 167 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 195 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } | 195 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } |
| 196 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { | 196 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { |
| 197 return a == b; | 197 return a == b; |
| 198 } | 198 } |
| 199 }; | 199 }; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } // namespace v8::internal::compiler | 202 } // namespace v8::internal::compiler |
| 203 | 203 |
| 204 #endif // V8_COMPILER_JS_OPERATOR_H_ | 204 #endif // V8_COMPILER_JS_OPERATOR_H_ |
| OLD | NEW |