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

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

Issue 1084243005: [turbofan] Sanitize language mode for javascript operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | src/globals.h » ('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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 value_input_count, Operator::ZeroIfPure(properties), \ 258 value_input_count, Operator::ZeroIfPure(properties), \
259 Operator::ZeroIfEliminatable(properties), \ 259 Operator::ZeroIfEliminatable(properties), \
260 value_output_count, Operator::ZeroIfPure(properties), \ 260 value_output_count, Operator::ZeroIfPure(properties), \
261 Operator::ZeroIfNoThrow(properties)) {} \ 261 Operator::ZeroIfNoThrow(properties)) {} \
262 }; \ 262 }; \
263 Name##Operator k##Name##Operator; 263 Name##Operator k##Name##Operator;
264 CACHED_OP_LIST(CACHED) 264 CACHED_OP_LIST(CACHED)
265 #undef CACHED 265 #undef CACHED
266 266
267 267
268 #define CACHED_WITH_STRONG(Name, properties, value_input_count, \ 268 #define CACHED_WITH_LANGUAGE_MODE(Name, properties, value_input_count, \
269 value_output_count) \ 269 value_output_count) \
270 template <LanguageMode kLanguageMode> \ 270 template <LanguageMode kLanguageMode> \
271 struct Name##Operator final : public Operator1<LanguageMode> { \ 271 struct Name##Operator final : public Operator1<LanguageMode> { \
272 Name##Operator() \ 272 Name##Operator() \
273 : Operator1<LanguageMode>(IrOpcode::kJS##Name, properties, "JS" #Name, \ 273 : Operator1<LanguageMode>( \
274 value_input_count, Operator::ZeroIfPure(properties), \ 274 IrOpcode::kJS##Name, properties, "JS" #Name, value_input_count, \
275 Operator::ZeroIfEliminatable(properties), \ 275 Operator::ZeroIfPure(properties), \
276 value_output_count, Operator::ZeroIfPure(properties), \ 276 Operator::ZeroIfEliminatable(properties), value_output_count, \
277 Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \ 277 Operator::ZeroIfPure(properties), \
278 }; \ 278 Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \
279 Name##Operator<SLOPPY> k##Name##SloppyOperator; \ 279 }; \
280 Name##Operator<SLOPPY> k##Name##SloppyOperator; \
281 Name##Operator<STRICT> k##Name##StrictOperator; \
conradw 2015/04/27 10:23:52 This change means that operators which behave iden
280 Name##Operator<STRONG> k##Name##StrongOperator; 282 Name##Operator<STRONG> k##Name##StrongOperator;
281 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_STRONG) 283 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
282 #undef CACHED_WITH_STRONG 284 #undef CACHED_WITH_LANGUAGE_MODE
283 285
284 286
285 template <LanguageMode kLanguageMode> 287 template <LanguageMode kLanguageMode>
286 struct StorePropertyOperator final : public Operator1<LanguageMode> { 288 struct StorePropertyOperator final : public Operator1<LanguageMode> {
287 StorePropertyOperator() 289 StorePropertyOperator()
288 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty, 290 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty,
289 Operator::kNoProperties, "JSStoreProperty", 3, 291 Operator::kNoProperties, "JSStoreProperty", 3,
290 1, 1, 0, 1, 2, kLanguageMode) {} 292 1, 1, 0, 1, 2, kLanguageMode) {}
291 }; 293 };
292 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator; 294 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
(...skipping 10 matching lines...) Expand all
303 305
304 306
305 #define CACHED(Name, properties, value_input_count, value_output_count) \ 307 #define CACHED(Name, properties, value_input_count, value_output_count) \
306 const Operator* JSOperatorBuilder::Name() { \ 308 const Operator* JSOperatorBuilder::Name() { \
307 return &cache_.k##Name##Operator; \ 309 return &cache_.k##Name##Operator; \
308 } 310 }
309 CACHED_OP_LIST(CACHED) 311 CACHED_OP_LIST(CACHED)
310 #undef CACHED 312 #undef CACHED
311 313
312 314
313 #define CACHED_WITH_STRONG(Name, properties, value_input_count, \ 315 #define CACHED_WITH_LANGUAGE_MODE(Name, properties, value_input_count, \
314 value_output_count) \ 316 value_output_count) \
315 const Operator* JSOperatorBuilder::Name(LanguageMode language_mode) { \ 317 const Operator* JSOperatorBuilder::Name(LanguageMode language_mode) { \
316 if (is_strong(language_mode)) { \ 318 switch (language_mode) { \
317 return &cache_.k##Name##StrongOperator; \ 319 case SLOPPY: \
318 } else { \ 320 return &cache_.k##Name##SloppyOperator; \
319 return &cache_.k##Name##SloppyOperator; \ 321 case STRICT: \
322 return &cache_.k##Name##StrictOperator; \
323 case STRONG: \
324 return &cache_.k##Name##StrongOperator; \
325 case STRONG_BIT: \
326 break; /* %*!%^$#@ */ \
320 } \ 327 } \
321 UNREACHABLE(); \ 328 UNREACHABLE(); \
322 return nullptr; \ 329 return nullptr; \
323 } 330 }
324 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_STRONG) 331 CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
325 #undef CACHED_WITH_STRONG 332 #undef CACHED_WITH_LANGUAGE_MODE
326 333
327 334
328 const Operator* JSOperatorBuilder::CallFunction(size_t arity, 335 const Operator* JSOperatorBuilder::CallFunction(size_t arity,
329 CallFunctionFlags flags) { 336 CallFunctionFlags flags) {
330 CallFunctionParameters parameters(arity, flags); 337 CallFunctionParameters parameters(arity, flags);
331 return new (zone()) Operator1<CallFunctionParameters>( // -- 338 return new (zone()) Operator1<CallFunctionParameters>( // --
332 IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode 339 IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode
333 "JSCallFunction", // name 340 "JSCallFunction", // name
334 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs 341 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs
335 parameters); // parameter 342 parameters); // parameter
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return new (zone()) Operator1<Unique<String>>( // -- 449 return new (zone()) Operator1<Unique<String>>( // --
443 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode 450 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
444 "JSCreateCatchContext", // name 451 "JSCreateCatchContext", // name
445 2, 1, 1, 1, 1, 2, // counts 452 2, 1, 1, 1, 1, 2, // counts
446 name); // parameter 453 name); // parameter
447 } 454 }
448 455
449 } // namespace compiler 456 } // namespace compiler
450 } // namespace internal 457 } // namespace internal
451 } // namespace v8 458 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698