| 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/runtime/runtime.h" | 8 #include "src/runtime/runtime.h" |
| 9 #include "src/unique.h" | 9 #include "src/unique.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 // Forward declarations. | 15 // Forward declarations. |
| 16 class Operator; | 16 class Operator; |
| 17 struct JSOperatorGlobalCache; | 17 struct JSOperatorGlobalCache; |
| 18 | 18 |
| 19 | 19 |
| 20 // Defines the arity and the call flags for a JavaScript function call. This is | 20 // Defines the arity and the call flags for a JavaScript function call. This is |
| 21 // used as a parameter by JSCallFunction operators. | 21 // used as a parameter by JSCallFunction operators. |
| 22 class CallFunctionParameters final { | 22 class CallFunctionParameters final { |
| 23 public: | 23 public: |
| 24 CallFunctionParameters(size_t arity, CallFunctionFlags flags, | 24 CallFunctionParameters(size_t arity, CallFunctionFlags flags) |
| 25 LanguageMode language_mode) | 25 : arity_(arity), flags_(flags) {} |
| 26 : bit_field_(ArityField::encode(arity) | FlagsField::encode(flags) | | |
| 27 LanguageModeField::encode(language_mode)) {} | |
| 28 | 26 |
| 29 size_t arity() const { return ArityField::decode(bit_field_); } | 27 size_t arity() const { return arity_; } |
| 30 CallFunctionFlags flags() const { return FlagsField::decode(bit_field_); } | 28 CallFunctionFlags flags() const { return flags_; } |
| 31 LanguageMode language_mode() const { | |
| 32 return LanguageModeField::decode(bit_field_); | |
| 33 } | |
| 34 | |
| 35 bool operator==(CallFunctionParameters const& that) const { | |
| 36 return this->bit_field_ == that.bit_field_; | |
| 37 } | |
| 38 bool operator!=(CallFunctionParameters const& that) const { | |
| 39 return !(*this == that); | |
| 40 } | |
| 41 | 29 |
| 42 private: | 30 private: |
| 43 friend size_t hash_value(CallFunctionParameters const& p) { | 31 const size_t arity_; |
| 44 return p.bit_field_; | 32 const CallFunctionFlags flags_; |
| 45 } | 33 }; |
| 46 | 34 |
| 47 typedef BitField<unsigned, 0, 28> ArityField; | 35 bool operator==(CallFunctionParameters const&, CallFunctionParameters const&); |
| 48 typedef BitField<CallFunctionFlags, 28, 2> FlagsField; | 36 bool operator!=(CallFunctionParameters const&, CallFunctionParameters const&); |
| 49 typedef BitField<LanguageMode, 30, 2> LanguageModeField; | |
| 50 | |
| 51 const uint32_t bit_field_; | |
| 52 }; | |
| 53 | 37 |
| 54 size_t hash_value(CallFunctionParameters const&); | 38 size_t hash_value(CallFunctionParameters const&); |
| 55 | 39 |
| 56 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); | 40 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); |
| 57 | 41 |
| 58 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); | 42 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); |
| 59 | 43 |
| 60 | 44 |
| 61 // Defines the arity and the ID for a runtime function call. This is used as a | 45 // Defines the arity and the ID for a runtime function call. This is used as a |
| 62 // parameter by JSCallRuntime operators. | 46 // parameter by JSCallRuntime operators. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const Operator* ToNumber(); | 264 const Operator* ToNumber(); |
| 281 const Operator* ToString(); | 265 const Operator* ToString(); |
| 282 const Operator* ToName(); | 266 const Operator* ToName(); |
| 283 const Operator* ToObject(); | 267 const Operator* ToObject(); |
| 284 const Operator* Yield(); | 268 const Operator* Yield(); |
| 285 | 269 |
| 286 const Operator* Create(); | 270 const Operator* Create(); |
| 287 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info, | 271 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info, |
| 288 PretenureFlag pretenure); | 272 PretenureFlag pretenure); |
| 289 | 273 |
| 290 const Operator* CallFunction(size_t arity, CallFunctionFlags flags, | 274 const Operator* CallFunction(size_t arity, CallFunctionFlags flags); |
| 291 LanguageMode language_mode); | |
| 292 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); | 275 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); |
| 293 | 276 |
| 294 const Operator* CallConstruct(int arguments); | 277 const Operator* CallConstruct(int arguments); |
| 295 | 278 |
| 296 const Operator* LoadProperty(const VectorSlotPair& feedback); | 279 const Operator* LoadProperty(const VectorSlotPair& feedback); |
| 297 const Operator* LoadNamed(const Unique<Name>& name, | 280 const Operator* LoadNamed(const Unique<Name>& name, |
| 298 const VectorSlotPair& feedback, | 281 const VectorSlotPair& feedback, |
| 299 ContextualMode contextual_mode = NOT_CONTEXTUAL, | 282 ContextualMode contextual_mode = NOT_CONTEXTUAL, |
| 300 PropertyICMode load_ic = NAMED); | 283 PropertyICMode load_ic = NAMED); |
| 301 | 284 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 331 Zone* const zone_; | 314 Zone* const zone_; |
| 332 | 315 |
| 333 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); | 316 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); |
| 334 }; | 317 }; |
| 335 | 318 |
| 336 } // namespace compiler | 319 } // namespace compiler |
| 337 } // namespace internal | 320 } // namespace internal |
| 338 } // namespace v8 | 321 } // namespace v8 |
| 339 | 322 |
| 340 #endif // V8_COMPILER_JS_OPERATOR_H_ | 323 #endif // V8_COMPILER_JS_OPERATOR_H_ |
| OLD | NEW |