| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 #include "src/compiler/js-operator.h" | 5 #include "src/compiler/js-operator.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/lazy-instance.h" | 9 #include "src/base/lazy-instance.h" |
| 10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 return os << Brief(*parameters.catch_name()) << ", " | 208 return os << Brief(*parameters.catch_name()) << ", " |
| 209 << Brief(*parameters.scope_info()); | 209 << Brief(*parameters.scope_info()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 CreateCatchContextParameters const& CreateCatchContextParametersOf( | 212 CreateCatchContextParameters const& CreateCatchContextParametersOf( |
| 213 Operator const* op) { | 213 Operator const* op) { |
| 214 DCHECK_EQ(IrOpcode::kJSCreateCatchContext, op->opcode()); | 214 DCHECK_EQ(IrOpcode::kJSCreateCatchContext, op->opcode()); |
| 215 return OpParameter<CreateCatchContextParameters>(op); | 215 return OpParameter<CreateCatchContextParameters>(op); |
| 216 } | 216 } |
| 217 | 217 |
| 218 CreateFunctionContextParameters::CreateFunctionContextParameters( |
| 219 int slot_count, ScopeType scope_type) |
| 220 : slot_count_(slot_count), scope_type_(scope_type) {} |
| 221 |
| 222 bool operator==(CreateFunctionContextParameters const& lhs, |
| 223 CreateFunctionContextParameters const& rhs) { |
| 224 return lhs.slot_count() == rhs.slot_count() && |
| 225 lhs.scope_type() == rhs.scope_type(); |
| 226 } |
| 227 |
| 228 bool operator!=(CreateFunctionContextParameters const& lhs, |
| 229 CreateFunctionContextParameters const& rhs) { |
| 230 return !(lhs == rhs); |
| 231 } |
| 232 |
| 233 size_t hash_value(CreateFunctionContextParameters const& parameters) { |
| 234 return base::hash_combine(parameters.slot_count(), |
| 235 static_cast<int>(parameters.scope_type())); |
| 236 } |
| 237 |
| 238 std::ostream& operator<<(std::ostream& os, |
| 239 CreateFunctionContextParameters const& parameters) { |
| 240 return os << parameters.slot_count() << ", " << parameters.scope_type(); |
| 241 } |
| 242 |
| 243 CreateFunctionContextParameters const& CreateFunctionContextParametersOf( |
| 244 Operator const* op) { |
| 245 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode()); |
| 246 return OpParameter<CreateFunctionContextParameters>(op); |
| 247 } |
| 248 |
| 218 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { | 249 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { |
| 219 return lhs.name().location() == rhs.name().location() && | 250 return lhs.name().location() == rhs.name().location() && |
| 220 lhs.language_mode() == rhs.language_mode() && | 251 lhs.language_mode() == rhs.language_mode() && |
| 221 lhs.feedback() == rhs.feedback(); | 252 lhs.feedback() == rhs.feedback(); |
| 222 } | 253 } |
| 223 | 254 |
| 224 | 255 |
| 225 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { | 256 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { |
| 226 return !(lhs == rhs); | 257 return !(lhs == rhs); |
| 227 } | 258 } |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 Handle<String> constant_pattern, int literal_flags, int literal_index) { | 913 Handle<String> constant_pattern, int literal_flags, int literal_index) { |
| 883 CreateLiteralParameters parameters(constant_pattern, -1, literal_flags, | 914 CreateLiteralParameters parameters(constant_pattern, -1, literal_flags, |
| 884 literal_index); | 915 literal_index); |
| 885 return new (zone()) Operator1<CreateLiteralParameters>( // -- | 916 return new (zone()) Operator1<CreateLiteralParameters>( // -- |
| 886 IrOpcode::kJSCreateLiteralRegExp, Operator::kNoProperties, // opcode | 917 IrOpcode::kJSCreateLiteralRegExp, Operator::kNoProperties, // opcode |
| 887 "JSCreateLiteralRegExp", // name | 918 "JSCreateLiteralRegExp", // name |
| 888 1, 1, 1, 1, 1, 2, // counts | 919 1, 1, 1, 1, 1, 2, // counts |
| 889 parameters); // parameter | 920 parameters); // parameter |
| 890 } | 921 } |
| 891 | 922 |
| 892 | 923 const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count, |
| 893 const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count) { | 924 ScopeType scope_type) { |
| 894 return new (zone()) Operator1<int>( // -- | 925 CreateFunctionContextParameters parameters(slot_count, scope_type); |
| 926 return new (zone()) Operator1<CreateFunctionContextParameters>( // -- |
| 895 IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode | 927 IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode |
| 896 "JSCreateFunctionContext", // name | 928 "JSCreateFunctionContext", // name |
| 897 1, 1, 1, 1, 1, 2, // counts | 929 1, 1, 1, 1, 1, 2, // counts |
| 898 slot_count); // parameter | 930 parameters); // parameter |
| 899 } | 931 } |
| 900 | 932 |
| 901 const Operator* JSOperatorBuilder::CreateCatchContext( | 933 const Operator* JSOperatorBuilder::CreateCatchContext( |
| 902 const Handle<String>& name, const Handle<ScopeInfo>& scope_info) { | 934 const Handle<String>& name, const Handle<ScopeInfo>& scope_info) { |
| 903 CreateCatchContextParameters parameters(name, scope_info); | 935 CreateCatchContextParameters parameters(name, scope_info); |
| 904 return new (zone()) Operator1<CreateCatchContextParameters>( | 936 return new (zone()) Operator1<CreateCatchContextParameters>( |
| 905 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 937 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 906 "JSCreateCatchContext", // name | 938 "JSCreateCatchContext", // name |
| 907 2, 1, 1, 1, 1, 2, // counts | 939 2, 1, 1, 1, 1, 2, // counts |
| 908 parameters); // parameter | 940 parameters); // parameter |
| 909 } | 941 } |
| 910 | 942 |
| 911 const Operator* JSOperatorBuilder::CreateWithContext( | 943 const Operator* JSOperatorBuilder::CreateWithContext( |
| 912 const Handle<ScopeInfo>& scope_info) { | 944 const Handle<ScopeInfo>& scope_info) { |
| 913 return new (zone()) Operator1<Handle<ScopeInfo>>( | 945 return new (zone()) Operator1<Handle<ScopeInfo>>( |
| 914 IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode | 946 IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode |
| 915 "JSCreateWithContext", // name | 947 "JSCreateWithContext", // name |
| 916 2, 1, 1, 1, 1, 2, // counts | 948 2, 1, 1, 1, 1, 2, // counts |
| 917 scope_info); // parameter | 949 scope_info); // parameter |
| 918 } | 950 } |
| 919 | 951 |
| 920 const Operator* JSOperatorBuilder::CreateBlockContext( | 952 const Operator* JSOperatorBuilder::CreateBlockContext( |
| 921 const Handle<ScopeInfo>& scpope_info) { | 953 const Handle<ScopeInfo>& scope_info) { |
| 922 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 954 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
| 923 IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode | 955 IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode |
| 924 "JSCreateBlockContext", // name | 956 "JSCreateBlockContext", // name |
| 925 1, 1, 1, 1, 1, 2, // counts | 957 1, 1, 1, 1, 1, 2, // counts |
| 926 scpope_info); // parameter | 958 scope_info); // parameter |
| 927 } | 959 } |
| 928 | 960 |
| 929 | |
| 930 const Operator* JSOperatorBuilder::CreateScriptContext( | 961 const Operator* JSOperatorBuilder::CreateScriptContext( |
| 931 const Handle<ScopeInfo>& scpope_info) { | 962 const Handle<ScopeInfo>& scope_info) { |
| 932 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 963 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
| 933 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 964 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
| 934 "JSCreateScriptContext", // name | 965 "JSCreateScriptContext", // name |
| 935 1, 1, 1, 1, 1, 2, // counts | 966 1, 1, 1, 1, 1, 2, // counts |
| 936 scpope_info); // parameter | 967 scope_info); // parameter |
| 937 } | 968 } |
| 938 | 969 |
| 939 } // namespace compiler | 970 } // namespace compiler |
| 940 } // namespace internal | 971 } // namespace internal |
| 941 } // namespace v8 | 972 } // namespace v8 |
| OLD | NEW |