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

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

Issue 1985033002: [Interpreter] Change LogicalNot to ToBooleanLogicalNot and add non-ToBoolean version. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
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 <fstream> 7 #include <fstream>
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } 845 }
846 846
847 847
848 // Dec 848 // Dec
849 // 849 //
850 // Decrements value in the accumulator by one. 850 // Decrements value in the accumulator by one.
851 void Interpreter::DoDec(InterpreterAssembler* assembler) { 851 void Interpreter::DoDec(InterpreterAssembler* assembler) {
852 DoCountOp(CodeFactory::Dec(isolate_), assembler); 852 DoCountOp(CodeFactory::Dec(isolate_), assembler);
853 } 853 }
854 854
855 855 void Interpreter::DoLogicalNotOp(Node* value, InterpreterAssembler* assembler) {
856 // LogicalNot
857 //
858 // Perform logical-not on the accumulator, first casting the
859 // accumulator to a boolean value if required.
860 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
861 Callable callable = CodeFactory::ToBoolean(isolate_);
862 Node* target = __ HeapConstant(callable.code());
863 Node* accumulator = __ GetAccumulator();
864 Node* context = __ GetContext();
865 Node* to_boolean_value =
866 __ CallStub(callable.descriptor(), target, context, accumulator);
867 Label if_true(assembler), if_false(assembler), end(assembler); 856 Label if_true(assembler), if_false(assembler), end(assembler);
868 Node* true_value = __ BooleanConstant(true); 857 Node* true_value = __ BooleanConstant(true);
869 Node* false_value = __ BooleanConstant(false); 858 Node* false_value = __ BooleanConstant(false);
870 __ BranchIfWordEqual(to_boolean_value, true_value, &if_true, &if_false); 859 __ BranchIfWordEqual(value, true_value, &if_true, &if_false);
871 __ Bind(&if_true); 860 __ Bind(&if_true);
872 { 861 {
873 __ SetAccumulator(false_value); 862 __ SetAccumulator(false_value);
874 __ Goto(&end); 863 __ Goto(&end);
875 } 864 }
876 __ Bind(&if_false); 865 __ Bind(&if_false);
877 { 866 {
867 if (FLAG_debug_code) {
868 __ AbortIfWordNotEqual(value, false_value,
869 BailoutReason::kExpectedBooleanValue);
870 }
878 __ SetAccumulator(true_value); 871 __ SetAccumulator(true_value);
879 __ Goto(&end); 872 __ Goto(&end);
880 } 873 }
881 __ Bind(&end); 874 __ Bind(&end);
875 }
876
877 // ToBooleanLogicalNot
878 //
879 // Perform logical-not on the accumulator, first casting the
880 // accumulator to a boolean value if required.
881 void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) {
882 Callable callable = CodeFactory::ToBoolean(isolate_);
883 Node* target = __ HeapConstant(callable.code());
884 Node* accumulator = __ GetAccumulator();
885 Node* context = __ GetContext();
886 Node* to_boolean_value =
887 __ CallStub(callable.descriptor(), target, context, accumulator);
888 DoLogicalNotOp(to_boolean_value, assembler);
882 __ Dispatch(); 889 __ Dispatch();
883 } 890 }
884 891
892 // LogicalNot
893 //
894 // Perform logical-not on the accumulator, which must already be a boolean
895 // value.
896 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
897 Node* value = __ GetAccumulator();
898 DoLogicalNotOp(value, assembler);
899 __ Dispatch();
900 }
901
885 // TypeOf 902 // TypeOf
886 // 903 //
887 // Load the accumulator with the string representating type of the 904 // Load the accumulator with the string representating type of the
888 // object in the accumulator. 905 // object in the accumulator.
889 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { 906 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) {
890 Callable callable = CodeFactory::Typeof(isolate_); 907 Callable callable = CodeFactory::Typeof(isolate_);
891 Node* target = __ HeapConstant(callable.code()); 908 Node* target = __ HeapConstant(callable.code());
892 Node* accumulator = __ GetAccumulator(); 909 Node* accumulator = __ GetAccumulator();
893 Node* context = __ GetContext(); 910 Node* context = __ GetContext();
894 Node* result = 911 Node* result =
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 1846 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
1830 __ SmiTag(new_state)); 1847 __ SmiTag(new_state));
1831 __ SetAccumulator(old_state); 1848 __ SetAccumulator(old_state);
1832 1849
1833 __ Dispatch(); 1850 __ Dispatch();
1834 } 1851 }
1835 1852
1836 } // namespace interpreter 1853 } // namespace interpreter
1837 } // namespace internal 1854 } // namespace internal
1838 } // namespace v8 1855 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698