| 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-intrinsics.h" | 5 #include "src/interpreter/interpreter-intrinsics.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 result.Bind(__ UndefinedConstant()); | 98 result.Bind(__ UndefinedConstant()); |
| 99 __ Goto(&end); | 99 __ Goto(&end); |
| 100 } | 100 } |
| 101 | 101 |
| 102 __ Bind(&end); | 102 __ Bind(&end); |
| 103 return result.value(); | 103 return result.value(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 Node* IntrinsicsHelper::CompareInstanceType(Node* object, int type, | 106 Node* IntrinsicsHelper::CompareInstanceType(Node* object, int type, |
| 107 InstanceTypeCompareMode mode) { | 107 InstanceTypeCompareMode mode) { |
| 108 InterpreterAssembler::Variable return_value(assembler_, | |
| 109 MachineRepresentation::kTagged); | |
| 110 Node* instance_type = __ LoadInstanceType(object); | 108 Node* instance_type = __ LoadInstanceType(object); |
| 111 | 109 |
| 112 InterpreterAssembler::Label if_true(assembler_), if_false(assembler_), | |
| 113 end(assembler_); | |
| 114 if (mode == kInstanceTypeEqual) { | 110 if (mode == kInstanceTypeEqual) { |
| 115 return __ Word32Equal(instance_type, __ Int32Constant(type)); | 111 return __ Word32Equal(instance_type, __ Int32Constant(type)); |
| 116 } else { | 112 } else { |
| 117 DCHECK(mode == kInstanceTypeGreaterThanOrEqual); | 113 DCHECK(mode == kInstanceTypeGreaterThanOrEqual); |
| 118 return __ Int32GreaterThanOrEqual(instance_type, __ Int32Constant(type)); | 114 return __ Int32GreaterThanOrEqual(instance_type, __ Int32Constant(type)); |
| 119 } | 115 } |
| 120 } | 116 } |
| 121 | 117 |
| 122 Node* IntrinsicsHelper::IsInstanceType(Node* input, int type) { | 118 Node* IntrinsicsHelper::IsInstanceType(Node* input, int type) { |
| 123 InterpreterAssembler::Variable return_value(assembler_, | 119 InterpreterAssembler::Variable return_value(assembler_, |
| 124 MachineRepresentation::kTagged); | 120 MachineRepresentation::kTagged); |
| 121 // TODO(ishell): Use Select here. |
| 125 InterpreterAssembler::Label if_not_smi(assembler_), return_true(assembler_), | 122 InterpreterAssembler::Label if_not_smi(assembler_), return_true(assembler_), |
| 126 return_false(assembler_), end(assembler_); | 123 return_false(assembler_), end(assembler_); |
| 127 Node* arg = __ LoadRegister(input); | 124 Node* arg = __ LoadRegister(input); |
| 128 __ GotoIf(__ TaggedIsSmi(arg), &return_false); | 125 __ GotoIf(__ TaggedIsSmi(arg), &return_false); |
| 129 | 126 |
| 130 Node* condition = CompareInstanceType(arg, type, kInstanceTypeEqual); | 127 Node* condition = CompareInstanceType(arg, type, kInstanceTypeEqual); |
| 131 __ Branch(condition, &return_true, &return_false); | 128 __ Branch(condition, &return_true, &return_false); |
| 132 | 129 |
| 133 __ Bind(&return_true); | 130 __ Bind(&return_true); |
| 134 { | 131 { |
| 135 return_value.Bind(__ BooleanConstant(true)); | 132 return_value.Bind(__ BooleanConstant(true)); |
| 136 __ Goto(&end); | 133 __ Goto(&end); |
| 137 } | 134 } |
| 138 | 135 |
| 139 __ Bind(&return_false); | 136 __ Bind(&return_false); |
| 140 { | 137 { |
| 141 return_value.Bind(__ BooleanConstant(false)); | 138 return_value.Bind(__ BooleanConstant(false)); |
| 142 __ Goto(&end); | 139 __ Goto(&end); |
| 143 } | 140 } |
| 144 | 141 |
| 145 __ Bind(&end); | 142 __ Bind(&end); |
| 146 return return_value.value(); | 143 return return_value.value(); |
| 147 } | 144 } |
| 148 | 145 |
| 149 Node* IntrinsicsHelper::IsJSReceiver(Node* input, Node* arg_count, | 146 Node* IntrinsicsHelper::IsJSReceiver(Node* input, Node* arg_count, |
| 150 Node* context) { | 147 Node* context) { |
| 148 // TODO(ishell): Use Select here. |
| 149 // TODO(ishell): Use CSA::IsJSReceiverInstanceType here. |
| 151 InterpreterAssembler::Variable return_value(assembler_, | 150 InterpreterAssembler::Variable return_value(assembler_, |
| 152 MachineRepresentation::kTagged); | 151 MachineRepresentation::kTagged); |
| 153 InterpreterAssembler::Label return_true(assembler_), return_false(assembler_), | 152 InterpreterAssembler::Label return_true(assembler_), return_false(assembler_), |
| 154 end(assembler_); | 153 end(assembler_); |
| 155 | 154 |
| 156 Node* arg = __ LoadRegister(input); | 155 Node* arg = __ LoadRegister(input); |
| 157 __ GotoIf(__ TaggedIsSmi(arg), &return_false); | 156 __ GotoIf(__ TaggedIsSmi(arg), &return_false); |
| 158 | 157 |
| 159 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | 158 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
| 160 Node* condition = CompareInstanceType(arg, FIRST_JS_RECEIVER_TYPE, | 159 Node* condition = CompareInstanceType(arg, FIRST_JS_RECEIVER_TYPE, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 188 Node* IntrinsicsHelper::IsRegExp(Node* input, Node* arg_count, Node* context) { | 187 Node* IntrinsicsHelper::IsRegExp(Node* input, Node* arg_count, Node* context) { |
| 189 return IsInstanceType(input, JS_REGEXP_TYPE); | 188 return IsInstanceType(input, JS_REGEXP_TYPE); |
| 190 } | 189 } |
| 191 | 190 |
| 192 Node* IntrinsicsHelper::IsTypedArray(Node* input, Node* arg_count, | 191 Node* IntrinsicsHelper::IsTypedArray(Node* input, Node* arg_count, |
| 193 Node* context) { | 192 Node* context) { |
| 194 return IsInstanceType(input, JS_TYPED_ARRAY_TYPE); | 193 return IsInstanceType(input, JS_TYPED_ARRAY_TYPE); |
| 195 } | 194 } |
| 196 | 195 |
| 197 Node* IntrinsicsHelper::IsSmi(Node* input, Node* arg_count, Node* context) { | 196 Node* IntrinsicsHelper::IsSmi(Node* input, Node* arg_count, Node* context) { |
| 197 // TODO(ishell): Use SelectBooleanConstant here. |
| 198 InterpreterAssembler::Variable return_value(assembler_, | 198 InterpreterAssembler::Variable return_value(assembler_, |
| 199 MachineRepresentation::kTagged); | 199 MachineRepresentation::kTagged); |
| 200 InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_), | 200 InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_), |
| 201 end(assembler_); | 201 end(assembler_); |
| 202 | 202 |
| 203 Node* arg = __ LoadRegister(input); | 203 Node* arg = __ LoadRegister(input); |
| 204 | 204 |
| 205 __ Branch(__ TaggedIsSmi(arg), &if_smi, &if_not_smi); | 205 __ Branch(__ TaggedIsSmi(arg), &if_smi, &if_not_smi); |
| 206 __ Bind(&if_smi); | 206 __ Bind(&if_smi); |
| 207 { | 207 { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); | 395 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); |
| 396 __ GotoIf(comparison, &match); | 396 __ GotoIf(comparison, &match); |
| 397 __ Abort(kWrongArgumentCountForInvokeIntrinsic); | 397 __ Abort(kWrongArgumentCountForInvokeIntrinsic); |
| 398 __ Goto(&match); | 398 __ Goto(&match); |
| 399 __ Bind(&match); | 399 __ Bind(&match); |
| 400 } | 400 } |
| 401 | 401 |
| 402 } // namespace interpreter | 402 } // namespace interpreter |
| 403 } // namespace internal | 403 } // namespace internal |
| 404 } // namespace v8 | 404 } // namespace v8 |
| OLD | NEW |