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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1683103002: [compiler] Sanitize entry points to LookupSlot access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Ross comment. Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/ast/prettyprinter.h" 7 #include "src/ast/prettyprinter.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/compiler/interpreter-assembler.h" 10 #include "src/compiler/interpreter-assembler.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 void Interpreter::DoStaContextSlotWide( 463 void Interpreter::DoStaContextSlotWide(
464 compiler::InterpreterAssembler* assembler) { 464 compiler::InterpreterAssembler* assembler) {
465 DoStaContextSlot(assembler); 465 DoStaContextSlot(assembler);
466 } 466 }
467 467
468 468
469 void Interpreter::DoLoadLookupSlot(Runtime::FunctionId function_id, 469 void Interpreter::DoLoadLookupSlot(Runtime::FunctionId function_id,
470 compiler::InterpreterAssembler* assembler) { 470 compiler::InterpreterAssembler* assembler) {
471 Node* index = __ BytecodeOperandIdx(0); 471 Node* index = __ BytecodeOperandIdx(0);
472 Node* name = __ LoadConstantPoolEntry(index); 472 Node* name = __ LoadConstantPoolEntry(index);
473 Node* context = __ GetContext(); 473 Node* result = __ CallRuntime(function_id, name);
474 Node* result_pair = __ CallRuntime(function_id, context, name);
475 Node* result = __ Projection(0, result_pair);
476 __ SetAccumulator(result); 474 __ SetAccumulator(result);
477 __ Dispatch(); 475 __ Dispatch();
478 } 476 }
479 477
480 478
481 // LdaLookupSlot <name_index> 479 // LdaLookupSlot <name_index>
482 // 480 //
483 // Lookup the object with the name in constant pool entry |name_index| 481 // Lookup the object with the name in constant pool entry |name_index|
484 // dynamically. 482 // dynamically.
485 void Interpreter::DoLdaLookupSlot(compiler::InterpreterAssembler* assembler) { 483 void Interpreter::DoLdaLookupSlot(compiler::InterpreterAssembler* assembler) {
486 DoLoadLookupSlot(Runtime::kLoadLookupSlot, assembler); 484 DoLoadLookupSlot(Runtime::kLoadLookupSlot, assembler);
487 } 485 }
488 486
489 487
490 // LdaLookupSlotInsideTypeof <name_index> 488 // LdaLookupSlotInsideTypeof <name_index>
491 // 489 //
492 // Lookup the object with the name in constant pool entry |name_index| 490 // Lookup the object with the name in constant pool entry |name_index|
493 // dynamically without causing a NoReferenceError. 491 // dynamically without causing a NoReferenceError.
494 void Interpreter::DoLdaLookupSlotInsideTypeof( 492 void Interpreter::DoLdaLookupSlotInsideTypeof(
495 compiler::InterpreterAssembler* assembler) { 493 compiler::InterpreterAssembler* assembler) {
496 DoLoadLookupSlot(Runtime::kLoadLookupSlotNoReferenceError, assembler); 494 DoLoadLookupSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler);
497 } 495 }
498 496
499 497
500 // LdaLookupSlotWide <name_index> 498 // LdaLookupSlotWide <name_index>
501 // 499 //
502 // Lookup the object with the name in constant pool entry |name_index| 500 // Lookup the object with the name in constant pool entry |name_index|
503 // dynamically. 501 // dynamically.
504 void Interpreter::DoLdaLookupSlotWide( 502 void Interpreter::DoLdaLookupSlotWide(
505 compiler::InterpreterAssembler* assembler) { 503 compiler::InterpreterAssembler* assembler) {
506 DoLdaLookupSlot(assembler); 504 DoLdaLookupSlot(assembler);
507 } 505 }
508 506
509 507
510 // LdaLookupSlotInsideTypeofWide <name_index> 508 // LdaLookupSlotInsideTypeofWide <name_index>
511 // 509 //
512 // Lookup the object with the name in constant pool entry |name_index| 510 // Lookup the object with the name in constant pool entry |name_index|
513 // dynamically without causing a NoReferenceError. 511 // dynamically without causing a NoReferenceError.
514 void Interpreter::DoLdaLookupSlotInsideTypeofWide( 512 void Interpreter::DoLdaLookupSlotInsideTypeofWide(
515 compiler::InterpreterAssembler* assembler) { 513 compiler::InterpreterAssembler* assembler) {
516 DoLdaLookupSlotInsideTypeof(assembler); 514 DoLdaLookupSlotInsideTypeof(assembler);
517 } 515 }
518 516
519 517
520 void Interpreter::DoStoreLookupSlot(LanguageMode language_mode, 518 void Interpreter::DoStoreLookupSlot(LanguageMode language_mode,
521 compiler::InterpreterAssembler* assembler) { 519 compiler::InterpreterAssembler* assembler) {
522 Node* value = __ GetAccumulator(); 520 Node* value = __ GetAccumulator();
523 Node* index = __ BytecodeOperandIdx(0); 521 Node* index = __ BytecodeOperandIdx(0);
524 Node* name = __ LoadConstantPoolEntry(index); 522 Node* name = __ LoadConstantPoolEntry(index);
525 Node* context = __ GetContext(); 523 Node* result = __ CallRuntime(is_strict(language_mode)
526 Node* language_mode_node = __ NumberConstant(language_mode); 524 ? Runtime::kStoreLookupSlot_Strict
527 Node* result = __ CallRuntime(Runtime::kStoreLookupSlot, value, context, name, 525 : Runtime::kStoreLookupSlot_Sloppy,
528 language_mode_node); 526 name, value);
529 __ SetAccumulator(result); 527 __ SetAccumulator(result);
530 __ Dispatch(); 528 __ Dispatch();
531 } 529 }
532 530
533 531
534 // StaLookupSlotSloppy <name_index> 532 // StaLookupSlotSloppy <name_index>
535 // 533 //
536 // Store the object in accumulator to the object with the name in constant 534 // Store the object in accumulator to the object with the name in constant
537 // pool entry |name_index| in sloppy mode. 535 // pool entry |name_index| in sloppy mode.
538 void Interpreter::DoStaLookupSlotSloppy( 536 void Interpreter::DoStaLookupSlotSloppy(
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 Node* index_reg = __ BytecodeOperandReg(0); 1920 Node* index_reg = __ BytecodeOperandReg(0);
1923 Node* index = __ LoadRegister(index_reg); 1921 Node* index = __ LoadRegister(index_reg);
1924 Node* result = __ CallRuntime(Runtime::kForInStep, index); 1922 Node* result = __ CallRuntime(Runtime::kForInStep, index);
1925 __ SetAccumulator(result); 1923 __ SetAccumulator(result);
1926 __ Dispatch(); 1924 __ Dispatch();
1927 } 1925 }
1928 1926
1929 } // namespace interpreter 1927 } // namespace interpreter
1930 } // namespace internal 1928 } // namespace internal
1931 } // namespace v8 1929 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698