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

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

Issue 1634153002: [Interpreter] Adds support for const/let variables to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased the patch and fixes tests. 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 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 1599
1600 // JumpIfNullConstantWide <idx16> 1600 // JumpIfNullConstantWide <idx16>
1601 // 1601 //
1602 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool 1602 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool
1603 // if the object referenced by the accumulator is the null constant. 1603 // if the object referenced by the accumulator is the null constant.
1604 void Interpreter::DoJumpIfNullConstantWide( 1604 void Interpreter::DoJumpIfNullConstantWide(
1605 compiler::InterpreterAssembler* assembler) { 1605 compiler::InterpreterAssembler* assembler) {
1606 DoJumpIfNullConstant(assembler); 1606 DoJumpIfNullConstant(assembler);
1607 } 1607 }
1608 1608
1609 1609 // JumpIfUndefined <imm8>
1610 // jumpifundefined <imm8>
1611 // 1610 //
1612 // Jump by number of bytes represented by an immediate operand if the object 1611 // Jump by number of bytes represented by an immediate operand if the object
1613 // referenced by the accumulator is the undefined constant. 1612 // referenced by the accumulator is the undefined constant.
1614 void Interpreter::DoJumpIfUndefined(compiler::InterpreterAssembler* assembler) { 1613 void Interpreter::DoJumpIfUndefined(compiler::InterpreterAssembler* assembler) {
1615 Node* accumulator = __ GetAccumulator(); 1614 Node* accumulator = __ GetAccumulator();
1616 Node* undefined_value = 1615 Node* undefined_value =
1617 __ HeapConstant(isolate_->factory()->undefined_value()); 1616 __ HeapConstant(isolate_->factory()->undefined_value());
1618 Node* relative_jump = __ BytecodeOperandImm(0); 1617 Node* relative_jump = __ BytecodeOperandImm(0);
1619 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); 1618 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump);
1620 } 1619 }
(...skipping 17 matching lines...) Expand all
1638 1637
1639 // JumpIfUndefinedConstantWide <idx16> 1638 // JumpIfUndefinedConstantWide <idx16>
1640 // 1639 //
1641 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool 1640 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool
1642 // if the object referenced by the accumulator is the undefined constant. 1641 // if the object referenced by the accumulator is the undefined constant.
1643 void Interpreter::DoJumpIfUndefinedConstantWide( 1642 void Interpreter::DoJumpIfUndefinedConstantWide(
1644 compiler::InterpreterAssembler* assembler) { 1643 compiler::InterpreterAssembler* assembler) {
1645 DoJumpIfUndefinedConstant(assembler); 1644 DoJumpIfUndefinedConstant(assembler);
1646 } 1645 }
1647 1646
1647 // JumpIfHole <imm8>
1648 //
1649 // Jump by number of bytes represented by an immediate operand if the object
1650 // referenced by the accumulator is the hole.
1651 void Interpreter::DoJumpIfHole(compiler::InterpreterAssembler* assembler) {
1652 Node* accumulator = __ GetAccumulator();
1653 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
1654 Node* relative_jump = __ BytecodeOperandImm(0);
1655 __ JumpIfWordEqual(accumulator, the_hole_value, relative_jump);
1656 }
1657
1658 // JumpIfNotHole <imm8>
1659 //
1660 // Jump by number of bytes represented by an immediate operand if the object
1661 // referenced by the accumulator is not the hole.
1662 void Interpreter::DoJumpIfNotHole(compiler::InterpreterAssembler* assembler) {
1663 Node* accumulator = __ GetAccumulator();
1664 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
1665 Node* relative_jump = __ BytecodeOperandImm(0);
1666 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump);
1667 }
1648 1668
1649 void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id, 1669 void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id,
1650 compiler::InterpreterAssembler* assembler) { 1670 compiler::InterpreterAssembler* assembler) {
1651 Node* index = __ BytecodeOperandIdx(0); 1671 Node* index = __ BytecodeOperandIdx(0);
1652 Node* constant_elements = __ LoadConstantPoolEntry(index); 1672 Node* constant_elements = __ LoadConstantPoolEntry(index);
1653 Node* literal_index_raw = __ BytecodeOperandIdx(1); 1673 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1654 Node* literal_index = __ SmiTag(literal_index_raw); 1674 Node* literal_index = __ SmiTag(literal_index_raw);
1655 Node* flags_raw = __ BytecodeOperandImm(2); 1675 Node* flags_raw = __ BytecodeOperandImm(2);
1656 Node* flags = __ SmiTag(flags_raw); 1676 Node* flags = __ SmiTag(flags_raw);
1657 Node* closure = __ LoadRegister(Register::function_closure()); 1677 Node* closure = __ LoadRegister(Register::function_closure());
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 Node* index_reg = __ BytecodeOperandReg(0); 1937 Node* index_reg = __ BytecodeOperandReg(0);
1918 Node* index = __ LoadRegister(index_reg); 1938 Node* index = __ LoadRegister(index_reg);
1919 Node* result = __ CallRuntime(Runtime::kForInStep, index); 1939 Node* result = __ CallRuntime(Runtime::kForInStep, index);
1920 __ SetAccumulator(result); 1940 __ SetAccumulator(result);
1921 __ Dispatch(); 1941 __ Dispatch();
1922 } 1942 }
1923 1943
1924 } // namespace interpreter 1944 } // namespace interpreter
1925 } // namespace internal 1945 } // namespace internal
1926 } // namespace v8 1946 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698