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

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: Rebase 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
« no previous file with comments | « src/interpreter/interpreter.h ('k') | src/interpreter/interpreter-assembler.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 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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 855 }
856 856
857 857
858 // Dec 858 // Dec
859 // 859 //
860 // Decrements value in the accumulator by one. 860 // Decrements value in the accumulator by one.
861 void Interpreter::DoDec(InterpreterAssembler* assembler) { 861 void Interpreter::DoDec(InterpreterAssembler* assembler) {
862 DoCountOp(CodeFactory::Dec(isolate_), assembler); 862 DoCountOp(CodeFactory::Dec(isolate_), assembler);
863 } 863 }
864 864
865 865 void Interpreter::DoLogicalNotOp(Node* value, InterpreterAssembler* assembler) {
866 // LogicalNot
867 //
868 // Perform logical-not on the accumulator, first casting the
869 // accumulator to a boolean value if required.
870 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
871 Callable callable = CodeFactory::ToBoolean(isolate_);
872 Node* target = __ HeapConstant(callable.code());
873 Node* accumulator = __ GetAccumulator();
874 Node* context = __ GetContext();
875 Node* to_boolean_value =
876 __ CallStub(callable.descriptor(), target, context, accumulator);
877 Label if_true(assembler), if_false(assembler), end(assembler); 866 Label if_true(assembler), if_false(assembler), end(assembler);
878 Node* true_value = __ BooleanConstant(true); 867 Node* true_value = __ BooleanConstant(true);
879 Node* false_value = __ BooleanConstant(false); 868 Node* false_value = __ BooleanConstant(false);
880 __ BranchIfWordEqual(to_boolean_value, true_value, &if_true, &if_false); 869 __ BranchIfWordEqual(value, true_value, &if_true, &if_false);
881 __ Bind(&if_true); 870 __ Bind(&if_true);
882 { 871 {
883 __ SetAccumulator(false_value); 872 __ SetAccumulator(false_value);
884 __ Goto(&end); 873 __ Goto(&end);
885 } 874 }
886 __ Bind(&if_false); 875 __ Bind(&if_false);
887 { 876 {
877 if (FLAG_debug_code) {
878 __ AbortIfWordNotEqual(value, false_value,
879 BailoutReason::kExpectedBooleanValue);
880 }
888 __ SetAccumulator(true_value); 881 __ SetAccumulator(true_value);
889 __ Goto(&end); 882 __ Goto(&end);
890 } 883 }
891 __ Bind(&end); 884 __ Bind(&end);
885 }
886
887 // ToBooleanLogicalNot
888 //
889 // Perform logical-not on the accumulator, first casting the
890 // accumulator to a boolean value if required.
891 void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) {
892 Callable callable = CodeFactory::ToBoolean(isolate_);
893 Node* target = __ HeapConstant(callable.code());
894 Node* accumulator = __ GetAccumulator();
895 Node* context = __ GetContext();
896 Node* to_boolean_value =
897 __ CallStub(callable.descriptor(), target, context, accumulator);
898 DoLogicalNotOp(to_boolean_value, assembler);
892 __ Dispatch(); 899 __ Dispatch();
893 } 900 }
894 901
902 // LogicalNot
903 //
904 // Perform logical-not on the accumulator, which must already be a boolean
905 // value.
906 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
907 Node* value = __ GetAccumulator();
908 DoLogicalNotOp(value, assembler);
909 __ Dispatch();
910 }
911
895 // TypeOf 912 // TypeOf
896 // 913 //
897 // Load the accumulator with the string representating type of the 914 // Load the accumulator with the string representating type of the
898 // object in the accumulator. 915 // object in the accumulator.
899 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { 916 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) {
900 Callable callable = CodeFactory::Typeof(isolate_); 917 Callable callable = CodeFactory::Typeof(isolate_);
901 Node* target = __ HeapConstant(callable.code()); 918 Node* target = __ HeapConstant(callable.code());
902 Node* accumulator = __ GetAccumulator(); 919 Node* accumulator = __ GetAccumulator();
903 Node* context = __ GetContext(); 920 Node* context = __ GetContext();
904 Node* result = 921 Node* result =
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 1856 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
1840 __ SmiTag(new_state)); 1857 __ SmiTag(new_state));
1841 __ SetAccumulator(old_state); 1858 __ SetAccumulator(old_state);
1842 1859
1843 __ Dispatch(); 1860 __ Dispatch();
1844 } 1861 }
1845 1862
1846 } // namespace interpreter 1863 } // namespace interpreter
1847 } // namespace internal 1864 } // namespace internal
1848 } // namespace v8 1865 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698