| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 | 176 |
| 177 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { | 177 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { |
| 178 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); | 178 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); |
| 179 return OpParameter<LoadNamedParameters>(op); | 179 return OpParameter<LoadNamedParameters>(op); |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 bool operator==(StoreNamedParameters const& lhs, | 183 bool operator==(StoreNamedParameters const& lhs, |
| 184 StoreNamedParameters const& rhs) { | 184 StoreNamedParameters const& rhs) { |
| 185 return lhs.strict_mode() == rhs.strict_mode() && lhs.name() == rhs.name(); | 185 return lhs.language_mode() == rhs.language_mode() && lhs.name() == rhs.name(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 bool operator!=(StoreNamedParameters const& lhs, | 189 bool operator!=(StoreNamedParameters const& lhs, |
| 190 StoreNamedParameters const& rhs) { | 190 StoreNamedParameters const& rhs) { |
| 191 return !(lhs == rhs); | 191 return !(lhs == rhs); |
| 192 } | 192 } |
| 193 | 193 |
| 194 | 194 |
| 195 size_t hash_value(StoreNamedParameters const& p) { | 195 size_t hash_value(StoreNamedParameters const& p) { |
| 196 return base::hash_combine(p.strict_mode(), p.name()); | 196 return base::hash_combine(p.language_mode(), p.name()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 | 199 |
| 200 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { | 200 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { |
| 201 return os << p.strict_mode() << ", " << Brief(*p.name().handle()); | 201 return os << p.language_mode() << ", " << Brief(*p.name().handle()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 | 204 |
| 205 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { | 205 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { |
| 206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | 206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); |
| 207 return OpParameter<StoreNamedParameters>(op); | 207 return OpParameter<StoreNamedParameters>(op); |
| 208 } | 208 } |
| 209 | 209 |
| 210 | 210 |
| 211 #define CACHED_OP_LIST(V) \ | 211 #define CACHED_OP_LIST(V) \ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 Name##Operator() \ | 253 Name##Operator() \ |
| 254 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ | 254 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ |
| 255 value_input_count, Operator::ZeroIfPure(properties), \ | 255 value_input_count, Operator::ZeroIfPure(properties), \ |
| 256 Operator::ZeroIfPure(properties), value_output_count, \ | 256 Operator::ZeroIfPure(properties), value_output_count, \ |
| 257 Operator::ZeroIfPure(properties), 0) {} \ | 257 Operator::ZeroIfPure(properties), 0) {} \ |
| 258 }; \ | 258 }; \ |
| 259 Name##Operator k##Name##Operator; | 259 Name##Operator k##Name##Operator; |
| 260 CACHED_OP_LIST(CACHED) | 260 CACHED_OP_LIST(CACHED) |
| 261 #undef CACHED | 261 #undef CACHED |
| 262 | 262 |
| 263 template <StrictMode kStrictMode> | 263 template <LanguageMode kLanguageMode> |
| 264 struct StorePropertyOperator FINAL : public Operator1<StrictMode> { | 264 struct StorePropertyOperator FINAL : public Operator1<LanguageMode> { |
| 265 StorePropertyOperator() | 265 StorePropertyOperator() |
| 266 : Operator1<StrictMode>(IrOpcode::kJSStoreProperty, | 266 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty, |
| 267 Operator::kNoProperties, "JSStoreProperty", 3, | 267 Operator::kNoProperties, "JSStoreProperty", 3, |
| 268 1, 1, 0, 1, 0, kStrictMode) {} | 268 1, 1, 0, 1, 0, kLanguageMode) {} |
| 269 }; | 269 }; |
| 270 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator; | 270 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator; |
| 271 StorePropertyOperator<STRICT> kStorePropertyStrictOperator; | 271 StorePropertyOperator<STRICT> kStorePropertyStrictOperator; |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 | 274 |
| 275 static base::LazyInstance<JSOperatorGlobalCache>::type kCache = | 275 static base::LazyInstance<JSOperatorGlobalCache>::type kCache = |
| 276 LAZY_INSTANCE_INITIALIZER; | 276 LAZY_INSTANCE_INITIALIZER; |
| 277 | 277 |
| 278 | 278 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 const VectorSlotPair& feedback) { | 337 const VectorSlotPair& feedback) { |
| 338 LoadPropertyParameters parameters(feedback); | 338 LoadPropertyParameters parameters(feedback); |
| 339 return new (zone()) Operator1<LoadPropertyParameters>( // -- | 339 return new (zone()) Operator1<LoadPropertyParameters>( // -- |
| 340 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode | 340 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode |
| 341 "JSLoadProperty", // name | 341 "JSLoadProperty", // name |
| 342 2, 1, 1, 1, 1, 0, // counts | 342 2, 1, 1, 1, 1, 0, // counts |
| 343 parameters); // parameter | 343 parameters); // parameter |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 const Operator* JSOperatorBuilder::StoreProperty(StrictMode strict_mode) { | 347 const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) { |
| 348 switch (strict_mode) { | 348 if (is_strict(language_mode)) { |
| 349 case SLOPPY: | 349 return &cache_.kStorePropertyStrictOperator; |
| 350 return &cache_.kStorePropertySloppyOperator; | 350 } else { |
| 351 case STRICT: | 351 return &cache_.kStorePropertySloppyOperator; |
| 352 return &cache_.kStorePropertyStrictOperator; | |
| 353 } | 352 } |
| 354 UNREACHABLE(); | 353 UNREACHABLE(); |
| 355 return nullptr; | 354 return nullptr; |
| 356 } | 355 } |
| 357 | 356 |
| 358 | 357 |
| 359 const Operator* JSOperatorBuilder::StoreNamed(StrictMode strict_mode, | 358 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, |
| 360 const Unique<Name>& name) { | 359 const Unique<Name>& name) { |
| 361 StoreNamedParameters parameters(strict_mode, name); | 360 StoreNamedParameters parameters(language_mode, name); |
| 362 return new (zone()) Operator1<StoreNamedParameters>( // -- | 361 return new (zone()) Operator1<StoreNamedParameters>( // -- |
| 363 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode | 362 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode |
| 364 "JSStoreNamed", // name | 363 "JSStoreNamed", // name |
| 365 2, 1, 1, 0, 1, 0, // counts | 364 2, 1, 1, 0, 1, 0, // counts |
| 366 parameters); // parameter | 365 parameters); // parameter |
| 367 } | 366 } |
| 368 | 367 |
| 369 | 368 |
| 370 const Operator* JSOperatorBuilder::DeleteProperty(StrictMode strict_mode) { | 369 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { |
| 371 return new (zone()) Operator1<StrictMode>( // -- | 370 return new (zone()) Operator1<LanguageMode>( // -- |
| 372 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode | 371 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode |
| 373 "JSDeleteProperty", // name | 372 "JSDeleteProperty", // name |
| 374 2, 1, 1, 1, 1, 0, // counts | 373 2, 1, 1, 1, 1, 0, // counts |
| 375 strict_mode); // parameter | 374 language_mode); // parameter |
| 376 } | 375 } |
| 377 | 376 |
| 378 | 377 |
| 379 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, | 378 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, |
| 380 bool immutable) { | 379 bool immutable) { |
| 381 ContextAccess access(depth, index, immutable); | 380 ContextAccess access(depth, index, immutable); |
| 382 return new (zone()) Operator1<ContextAccess>( // -- | 381 return new (zone()) Operator1<ContextAccess>( // -- |
| 383 IrOpcode::kJSLoadContext, Operator::kNoWrite, // opcode | 382 IrOpcode::kJSLoadContext, Operator::kNoWrite, // opcode |
| 384 "JSLoadContext", // name | 383 "JSLoadContext", // name |
| 385 1, 1, 0, 1, 1, 0, // counts | 384 1, 1, 0, 1, 1, 0, // counts |
| (...skipping 16 matching lines...) Expand all Loading... |
| 402 return new (zone()) Operator1<Unique<String>>( // -- | 401 return new (zone()) Operator1<Unique<String>>( // -- |
| 403 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 402 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 404 "JSCreateCatchContext", // name | 403 "JSCreateCatchContext", // name |
| 405 2, 1, 1, 1, 1, 0, // counts | 404 2, 1, 1, 1, 1, 0, // counts |
| 406 name); // parameter | 405 name); // parameter |
| 407 } | 406 } |
| 408 | 407 |
| 409 } // namespace compiler | 408 } // namespace compiler |
| 410 } // namespace internal | 409 } // namespace internal |
| 411 } // namespace v8 | 410 } // namespace v8 |
| OLD | NEW |