Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: src/compiler/js-operator.cc

Issue 1109733002: [turbofan] Sanitize language mode for JSStoreProperty operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/unittests/compiler/js-operator-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 V(TypeOf, Operator::kPure, 1, 1) \ 256 V(TypeOf, Operator::kPure, 1, 1) \
257 V(InstanceOf, Operator::kNoProperties, 2, 1) \ 257 V(InstanceOf, Operator::kNoProperties, 2, 1) \
258 V(StackCheck, Operator::kNoProperties, 0, 0) \ 258 V(StackCheck, Operator::kNoProperties, 0, 0) \
259 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ 259 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \
260 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ 260 V(CreateWithContext, Operator::kNoProperties, 2, 1) \
261 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ 261 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \
262 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ 262 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \
263 V(CreateScriptContext, Operator::kNoProperties, 2, 1) 263 V(CreateScriptContext, Operator::kNoProperties, 2, 1)
264 264
265 265
266 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \ 266 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
267 V(LessThan, Operator::kNoProperties, 2, 1) \ 267 V(LessThan, Operator::kNoProperties, 2, 1) \
268 V(GreaterThan, Operator::kNoProperties, 2, 1) \ 268 V(GreaterThan, Operator::kNoProperties, 2, 1) \
269 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ 269 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
270 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ 270 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
271 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ 271 V(BitwiseOr, Operator::kNoProperties, 2, 1) \
272 V(BitwiseXor, Operator::kNoProperties, 2, 1) \ 272 V(BitwiseXor, Operator::kNoProperties, 2, 1) \
273 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \ 273 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
274 V(ShiftLeft, Operator::kNoProperties, 2, 1) \ 274 V(ShiftLeft, Operator::kNoProperties, 2, 1) \
275 V(ShiftRight, Operator::kNoProperties, 2, 1) \ 275 V(ShiftRight, Operator::kNoProperties, 2, 1) \
276 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \ 276 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
277 V(Add, Operator::kNoProperties, 2, 1) \ 277 V(Add, Operator::kNoProperties, 2, 1) \
278 V(Subtract, Operator::kNoProperties, 2, 1) \ 278 V(Subtract, Operator::kNoProperties, 2, 1) \
279 V(Multiply, Operator::kNoProperties, 2, 1) \ 279 V(Multiply, Operator::kNoProperties, 2, 1) \
280 V(Divide, Operator::kNoProperties, 2, 1) \ 280 V(Divide, Operator::kNoProperties, 2, 1) \
281 V(Modulus, Operator::kNoProperties, 2, 1) 281 V(Modulus, Operator::kNoProperties, 2, 1) \
282 V(StoreProperty, Operator::kNoProperties, 3, 0)
282 283
283 284
284 struct JSOperatorGlobalCache final { 285 struct JSOperatorGlobalCache final {
285 #define CACHED(Name, properties, value_input_count, value_output_count) \ 286 #define CACHED(Name, properties, value_input_count, value_output_count) \
286 struct Name##Operator final : public Operator { \ 287 struct Name##Operator final : public Operator { \
287 Name##Operator() \ 288 Name##Operator() \
288 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ 289 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \
289 value_input_count, Operator::ZeroIfPure(properties), \ 290 value_input_count, Operator::ZeroIfPure(properties), \
290 Operator::ZeroIfEliminatable(properties), \ 291 Operator::ZeroIfEliminatable(properties), \
291 value_output_count, Operator::ZeroIfPure(properties), \ 292 value_output_count, Operator::ZeroIfPure(properties), \
(...skipping 14 matching lines...) Expand all
306 Operator::ZeroIfPure(properties), \ 307 Operator::ZeroIfPure(properties), \
307 Operator::ZeroIfEliminatable(properties), value_output_count, \ 308 Operator::ZeroIfEliminatable(properties), value_output_count, \
308 Operator::ZeroIfPure(properties), \ 309 Operator::ZeroIfPure(properties), \
309 Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \ 310 Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \
310 }; \ 311 }; \
311 Name##Operator<SLOPPY> k##Name##SloppyOperator; \ 312 Name##Operator<SLOPPY> k##Name##SloppyOperator; \
312 Name##Operator<STRICT> k##Name##StrictOperator; \ 313 Name##Operator<STRICT> k##Name##StrictOperator; \
313 Name##Operator<STRONG> k##Name##StrongOperator; 314 Name##Operator<STRONG> k##Name##StrongOperator;
314 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE) 315 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
315 #undef CACHED_WITH_LANGUAGE_MODE 316 #undef CACHED_WITH_LANGUAGE_MODE
316
317
318 template <LanguageMode kLanguageMode>
319 struct StorePropertyOperator final : public Operator1<LanguageMode> {
320 StorePropertyOperator()
321 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty,
322 Operator::kNoProperties, "JSStoreProperty", 3,
323 1, 1, 0, 1, 2, kLanguageMode) {}
324 };
325 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
326 StorePropertyOperator<STRICT> kStorePropertyStrictOperator;
327 }; 317 };
328 318
329 319
330 static base::LazyInstance<JSOperatorGlobalCache>::type kCache = 320 static base::LazyInstance<JSOperatorGlobalCache>::type kCache =
331 LAZY_INSTANCE_INITIALIZER; 321 LAZY_INSTANCE_INITIALIZER;
332 322
333 323
334 JSOperatorBuilder::JSOperatorBuilder(Zone* zone) 324 JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
335 : cache_(kCache.Get()), zone_(zone) {} 325 : cache_(kCache.Get()), zone_(zone) {}
336 326
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 const VectorSlotPair& feedback) { 403 const VectorSlotPair& feedback) {
414 LoadPropertyParameters parameters(feedback); 404 LoadPropertyParameters parameters(feedback);
415 return new (zone()) Operator1<LoadPropertyParameters>( // -- 405 return new (zone()) Operator1<LoadPropertyParameters>( // --
416 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode 406 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
417 "JSLoadProperty", // name 407 "JSLoadProperty", // name
418 2, 1, 1, 1, 1, 2, // counts 408 2, 1, 1, 1, 1, 2, // counts
419 parameters); // parameter 409 parameters); // parameter
420 } 410 }
421 411
422 412
423 const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) {
424 if (is_strict(language_mode)) {
425 return &cache_.kStorePropertyStrictOperator;
426 } else {
427 return &cache_.kStorePropertySloppyOperator;
428 }
429 UNREACHABLE();
430 return nullptr;
431 }
432
433
434 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, 413 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
435 const Unique<Name>& name, 414 const Unique<Name>& name,
436 PropertyICMode store_ic) { 415 PropertyICMode store_ic) {
437 StoreNamedParameters parameters(language_mode, name, store_ic); 416 StoreNamedParameters parameters(language_mode, name, store_ic);
438 return new (zone()) Operator1<StoreNamedParameters>( // -- 417 return new (zone()) Operator1<StoreNamedParameters>( // --
439 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode 418 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
440 "JSStoreNamed", // name 419 "JSStoreNamed", // name
441 2, 1, 1, 0, 1, 2, // counts 420 2, 1, 1, 0, 1, 2, // counts
442 parameters); // parameter 421 parameters); // parameter
443 } 422 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return new (zone()) Operator1<Unique<String>>( // -- 470 return new (zone()) Operator1<Unique<String>>( // --
492 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode 471 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
493 "JSCreateCatchContext", // name 472 "JSCreateCatchContext", // name
494 2, 1, 1, 1, 1, 2, // counts 473 2, 1, 1, 1, 1, 2, // counts
495 name); // parameter 474 name); // parameter
496 } 475 }
497 476
498 } // namespace compiler 477 } // namespace compiler
499 } // namespace internal 478 } // namespace internal
500 } // namespace v8 479 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/js-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698