OLD | NEW |
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-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 base_index = nullptr; | 838 base_index = nullptr; |
839 } | 839 } |
840 Node* target_index = IntPtrAdd(base_index, next_bytecode); | 840 Node* target_index = IntPtrAdd(base_index, next_bytecode); |
841 Node* target_code_entry = | 841 Node* target_code_entry = |
842 Load(MachineType::Pointer(), DispatchTableRawPointer(), | 842 Load(MachineType::Pointer(), DispatchTableRawPointer(), |
843 WordShl(target_index, kPointerSizeLog2)); | 843 WordShl(target_index, kPointerSizeLog2)); |
844 | 844 |
845 DispatchToBytecodeHandlerEntry(target_code_entry, next_bytecode_offset); | 845 DispatchToBytecodeHandlerEntry(target_code_entry, next_bytecode_offset); |
846 } | 846 } |
847 | 847 |
| 848 Node* InterpreterAssembler::TruncateTaggedToWord32WithFeedback( |
| 849 Node* context, Node* value, Variable* var_type_feedback) { |
| 850 // We might need to loop once due to ToNumber conversion. |
| 851 Variable var_value(this, MachineRepresentation::kTagged), |
| 852 var_result(this, MachineRepresentation::kWord32); |
| 853 Variable* loop_vars[] = {&var_value, var_type_feedback}; |
| 854 Label loop(this, 2, loop_vars), done_loop(this, &var_result); |
| 855 var_value.Bind(value); |
| 856 var_type_feedback->Bind(Int32Constant(BinaryOperationFeedback::kNone)); |
| 857 Goto(&loop); |
| 858 Bind(&loop); |
| 859 { |
| 860 // Load the current {value}. |
| 861 value = var_value.value(); |
| 862 |
| 863 // Check if the {value} is a Smi or a HeapObject. |
| 864 Label if_valueissmi(this), if_valueisnotsmi(this); |
| 865 Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi); |
| 866 |
| 867 Bind(&if_valueissmi); |
| 868 { |
| 869 // Convert the Smi {value}. |
| 870 var_result.Bind(SmiToWord32(value)); |
| 871 var_type_feedback->Bind( |
| 872 Word32And(var_type_feedback->value(), |
| 873 Int32Constant(BinaryOperationFeedback::kSignedSmall))); |
| 874 Goto(&done_loop); |
| 875 } |
| 876 |
| 877 Bind(&if_valueisnotsmi); |
| 878 { |
| 879 // Check if {value} is a HeapNumber. |
| 880 Label if_valueisheapnumber(this), |
| 881 if_valueisnotheapnumber(this, Label::kDeferred); |
| 882 Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()), |
| 883 &if_valueisheapnumber, &if_valueisnotheapnumber); |
| 884 |
| 885 Bind(&if_valueisheapnumber); |
| 886 { |
| 887 // Truncate the floating point value. |
| 888 var_result.Bind(TruncateHeapNumberValueToWord32(value)); |
| 889 var_type_feedback->Bind( |
| 890 Word32Or(var_type_feedback->value(), |
| 891 Int32Constant(BinaryOperationFeedback::kNumber))); |
| 892 Goto(&done_loop); |
| 893 } |
| 894 |
| 895 Bind(&if_valueisnotheapnumber); |
| 896 { |
| 897 // Convert the {value} to a Number first. |
| 898 Callable callable = CodeFactory::NonNumberToNumber(isolate()); |
| 899 var_value.Bind(CallStub(callable, context, value)); |
| 900 var_type_feedback->Bind(Int32Constant(BinaryOperationFeedback::kAny)); |
| 901 Goto(&loop); |
| 902 } |
| 903 } |
| 904 } |
| 905 Bind(&done_loop); |
| 906 return var_result.value(); |
| 907 } |
| 908 |
848 void InterpreterAssembler::UpdateInterruptBudgetOnReturn() { | 909 void InterpreterAssembler::UpdateInterruptBudgetOnReturn() { |
849 // TODO(rmcilroy): Investigate whether it is worth supporting self | 910 // TODO(rmcilroy): Investigate whether it is worth supporting self |
850 // optimization of primitive functions like FullCodegen. | 911 // optimization of primitive functions like FullCodegen. |
851 | 912 |
852 // Update profiling count by -BytecodeOffset to simulate backedge to start of | 913 // Update profiling count by -BytecodeOffset to simulate backedge to start of |
853 // function. | 914 // function. |
854 Node* profiling_weight = | 915 Node* profiling_weight = |
855 Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), | 916 Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), |
856 BytecodeOffset()); | 917 BytecodeOffset()); |
857 UpdateInterruptBudget(profiling_weight); | 918 UpdateInterruptBudget(profiling_weight); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 Goto(&loop); | 1073 Goto(&loop); |
1013 } | 1074 } |
1014 Bind(&done_loop); | 1075 Bind(&done_loop); |
1015 | 1076 |
1016 return array; | 1077 return array; |
1017 } | 1078 } |
1018 | 1079 |
1019 } // namespace interpreter | 1080 } // namespace interpreter |
1020 } // namespace internal | 1081 } // namespace internal |
1021 } // namespace v8 | 1082 } // namespace v8 |
OLD | NEW |