| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
| 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
| 7 | 7 |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 V(InvokeFunction) \ | 99 V(InvokeFunction) \ |
| 100 V(HasInPrototypeChainAndBranch) \ | 100 V(HasInPrototypeChainAndBranch) \ |
| 101 V(IsStringAndBranch) \ | 101 V(IsStringAndBranch) \ |
| 102 V(IsSmiAndBranch) \ | 102 V(IsSmiAndBranch) \ |
| 103 V(IsUndetectableAndBranch) \ | 103 V(IsUndetectableAndBranch) \ |
| 104 V(LeaveInlined) \ | 104 V(LeaveInlined) \ |
| 105 V(LoadContextSlot) \ | 105 V(LoadContextSlot) \ |
| 106 V(LoadFieldByIndex) \ | 106 V(LoadFieldByIndex) \ |
| 107 V(LoadFunctionPrototype) \ | 107 V(LoadFunctionPrototype) \ |
| 108 V(LoadKeyed) \ | 108 V(LoadKeyed) \ |
| 109 V(LoadKeyedGeneric) \ | |
| 110 V(LoadNamedField) \ | 109 V(LoadNamedField) \ |
| 111 V(LoadRoot) \ | 110 V(LoadRoot) \ |
| 112 V(MathFloorOfDiv) \ | 111 V(MathFloorOfDiv) \ |
| 113 V(MathMinMax) \ | 112 V(MathMinMax) \ |
| 114 V(MaybeGrowElements) \ | 113 V(MaybeGrowElements) \ |
| 115 V(Mod) \ | 114 V(Mod) \ |
| 116 V(Mul) \ | 115 V(Mul) \ |
| 117 V(OsrEntry) \ | 116 V(OsrEntry) \ |
| 118 V(Parameter) \ | 117 V(Parameter) \ |
| 119 V(Power) \ | 118 V(Power) \ |
| (...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 | 2151 |
| 2153 class HCallWithDescriptor final : public HInstruction { | 2152 class HCallWithDescriptor final : public HInstruction { |
| 2154 public: | 2153 public: |
| 2155 static HCallWithDescriptor* New( | 2154 static HCallWithDescriptor* New( |
| 2156 Isolate* isolate, Zone* zone, HValue* context, HValue* target, | 2155 Isolate* isolate, Zone* zone, HValue* context, HValue* target, |
| 2157 int argument_count, CallInterfaceDescriptor descriptor, | 2156 int argument_count, CallInterfaceDescriptor descriptor, |
| 2158 const Vector<HValue*>& operands, | 2157 const Vector<HValue*>& operands, |
| 2159 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, | 2158 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, |
| 2160 TailCallMode tail_call_mode = TailCallMode::kDisallow) { | 2159 TailCallMode tail_call_mode = TailCallMode::kDisallow) { |
| 2161 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( | 2160 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( |
| 2162 context, target, argument_count, descriptor, operands, | 2161 Code::STUB, context, target, argument_count, descriptor, operands, |
| 2163 syntactic_tail_call_mode, tail_call_mode, zone); | 2162 syntactic_tail_call_mode, tail_call_mode, zone); |
| 2164 return res; | 2163 return res; |
| 2165 } | 2164 } |
| 2165 |
| 2166 static HCallWithDescriptor* New( |
| 2167 Isolate* isolate, Zone* zone, HValue* context, Code::Kind kind, |
| 2168 HValue* target, int argument_count, CallInterfaceDescriptor descriptor, |
| 2169 const Vector<HValue*>& operands, |
| 2170 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, |
| 2171 TailCallMode tail_call_mode = TailCallMode::kDisallow) { |
| 2172 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( |
| 2173 kind, context, target, argument_count, descriptor, operands, |
| 2174 syntactic_tail_call_mode, tail_call_mode, zone); |
| 2175 return res; |
| 2176 } |
| 2166 | 2177 |
| 2167 int OperandCount() const final { return values_.length(); } | 2178 int OperandCount() const final { return values_.length(); } |
| 2168 HValue* OperandAt(int index) const final { return values_[index]; } | 2179 HValue* OperandAt(int index) const final { return values_[index]; } |
| 2169 | 2180 |
| 2170 Representation RequiredInputRepresentation(int index) final { | 2181 Representation RequiredInputRepresentation(int index) final { |
| 2171 if (index == 0 || index == 1) { | 2182 if (index == 0 || index == 1) { |
| 2172 // Target + context | 2183 // Target + context |
| 2173 return Representation::Tagged(); | 2184 return Representation::Tagged(); |
| 2174 } else { | 2185 } else { |
| 2175 int par_index = index - 2; | 2186 int par_index = index - 2; |
| 2176 DCHECK(par_index < GetParameterCount()); | 2187 DCHECK(par_index < GetParameterCount()); |
| 2177 return RepresentationFromMachineType( | 2188 return RepresentationFromMachineType( |
| 2178 descriptor_.GetParameterType(par_index)); | 2189 descriptor_.GetParameterType(par_index)); |
| 2179 } | 2190 } |
| 2180 } | 2191 } |
| 2181 | 2192 |
| 2182 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) | 2193 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) |
| 2183 | 2194 |
| 2184 // Defines whether this instruction corresponds to a JS call at tail position. | 2195 // Defines whether this instruction corresponds to a JS call at tail position. |
| 2185 TailCallMode syntactic_tail_call_mode() const { | 2196 TailCallMode syntactic_tail_call_mode() const { |
| 2186 return SyntacticTailCallModeField::decode(bit_field_); | 2197 return SyntacticTailCallModeField::decode(bit_field_); |
| 2187 } | 2198 } |
| 2188 | 2199 |
| 2189 // Defines whether this call should be generated as a tail call. | 2200 // Defines whether this call should be generated as a tail call. |
| 2190 TailCallMode tail_call_mode() const { | 2201 TailCallMode tail_call_mode() const { |
| 2191 return TailCallModeField::decode(bit_field_); | 2202 return TailCallModeField::decode(bit_field_); |
| 2192 } | 2203 } |
| 2193 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; } | 2204 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; } |
| 2194 | 2205 |
| 2206 Code::Kind kind() const { return KindField::decode(bit_field_); } |
| 2207 |
| 2195 virtual int argument_count() const { | 2208 virtual int argument_count() const { |
| 2196 return argument_count_; | 2209 return argument_count_; |
| 2197 } | 2210 } |
| 2198 | 2211 |
| 2199 int argument_delta() const override { return -argument_count_; } | 2212 int argument_delta() const override { return -argument_count_; } |
| 2200 | 2213 |
| 2201 CallInterfaceDescriptor descriptor() const { return descriptor_; } | 2214 CallInterfaceDescriptor descriptor() const { return descriptor_; } |
| 2202 | 2215 |
| 2203 HValue* target() { return OperandAt(0); } | 2216 HValue* target() { return OperandAt(0); } |
| 2204 HValue* context() { return OperandAt(1); } | 2217 HValue* context() { return OperandAt(1); } |
| 2205 HValue* parameter(int index) { | 2218 HValue* parameter(int index) { |
| 2206 DCHECK_LT(index, GetParameterCount()); | 2219 DCHECK_LT(index, GetParameterCount()); |
| 2207 return OperandAt(index + 2); | 2220 return OperandAt(index + 2); |
| 2208 } | 2221 } |
| 2209 | 2222 |
| 2223 HValue* Canonicalize() override; |
| 2224 |
| 2210 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 2225 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
| 2211 | 2226 |
| 2212 private: | 2227 private: |
| 2213 // The argument count includes the receiver. | 2228 // The argument count includes the receiver. |
| 2214 HCallWithDescriptor(HValue* context, HValue* target, int argument_count, | 2229 HCallWithDescriptor(Code::Kind kind, HValue* context, HValue* target, |
| 2215 CallInterfaceDescriptor descriptor, | 2230 int argument_count, CallInterfaceDescriptor descriptor, |
| 2216 const Vector<HValue*>& operands, | 2231 const Vector<HValue*>& operands, |
| 2217 TailCallMode syntactic_tail_call_mode, | 2232 TailCallMode syntactic_tail_call_mode, |
| 2218 TailCallMode tail_call_mode, Zone* zone) | 2233 TailCallMode tail_call_mode, Zone* zone) |
| 2219 : descriptor_(descriptor), | 2234 : descriptor_(descriptor), |
| 2220 values_(GetParameterCount() + 2, zone), // +2 for context and target. | 2235 values_(GetParameterCount() + 2, zone), // +2 for context and target. |
| 2221 argument_count_(argument_count), | 2236 argument_count_(argument_count), |
| 2222 bit_field_( | 2237 bit_field_( |
| 2223 TailCallModeField::encode(tail_call_mode) | | 2238 TailCallModeField::encode(tail_call_mode) | |
| 2224 SyntacticTailCallModeField::encode(syntactic_tail_call_mode)) { | 2239 SyntacticTailCallModeField::encode(syntactic_tail_call_mode) | |
| 2240 KindField::encode(kind)) { |
| 2225 DCHECK_EQ(operands.length(), GetParameterCount()); | 2241 DCHECK_EQ(operands.length(), GetParameterCount()); |
| 2226 // We can only tail call without any stack arguments. | 2242 // We can only tail call without any stack arguments. |
| 2227 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0); | 2243 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0); |
| 2228 AddOperand(target, zone); | 2244 AddOperand(target, zone); |
| 2229 AddOperand(context, zone); | 2245 AddOperand(context, zone); |
| 2230 for (int i = 0; i < operands.length(); i++) { | 2246 for (int i = 0; i < operands.length(); i++) { |
| 2231 AddOperand(operands[i], zone); | 2247 AddOperand(operands[i], zone); |
| 2232 } | 2248 } |
| 2233 this->set_representation(Representation::Tagged()); | 2249 this->set_representation(Representation::Tagged()); |
| 2234 this->SetAllSideEffects(); | 2250 this->SetAllSideEffects(); |
| 2235 } | 2251 } |
| 2236 | 2252 |
| 2237 void AddOperand(HValue* v, Zone* zone) { | 2253 void AddOperand(HValue* v, Zone* zone) { |
| 2238 values_.Add(NULL, zone); | 2254 values_.Add(NULL, zone); |
| 2239 SetOperandAt(values_.length() - 1, v); | 2255 SetOperandAt(values_.length() - 1, v); |
| 2240 } | 2256 } |
| 2241 | 2257 |
| 2242 int GetParameterCount() const { return descriptor_.GetParameterCount(); } | 2258 int GetParameterCount() const { return descriptor_.GetParameterCount(); } |
| 2243 | 2259 |
| 2244 void InternalSetOperandAt(int index, HValue* value) final { | 2260 void InternalSetOperandAt(int index, HValue* value) final { |
| 2245 values_[index] = value; | 2261 values_[index] = value; |
| 2246 } | 2262 } |
| 2247 | 2263 |
| 2248 CallInterfaceDescriptor descriptor_; | 2264 CallInterfaceDescriptor descriptor_; |
| 2249 ZoneList<HValue*> values_; | 2265 ZoneList<HValue*> values_; |
| 2250 int argument_count_; | 2266 int argument_count_; |
| 2251 class TailCallModeField : public BitField<TailCallMode, 0, 1> {}; | 2267 class TailCallModeField : public BitField<TailCallMode, 0, 1> {}; |
| 2252 class SyntacticTailCallModeField | 2268 class SyntacticTailCallModeField |
| 2253 : public BitField<TailCallMode, TailCallModeField::kNext, 1> {}; | 2269 : public BitField<TailCallMode, TailCallModeField::kNext, 1> {}; |
| 2270 class KindField |
| 2271 : public BitField<Code::Kind, SyntacticTailCallModeField::kNext, 5> {}; |
| 2254 uint32_t bit_field_; | 2272 uint32_t bit_field_; |
| 2255 }; | 2273 }; |
| 2256 | 2274 |
| 2257 | 2275 |
| 2258 class HInvokeFunction final : public HBinaryCall { | 2276 class HInvokeFunction final : public HBinaryCall { |
| 2259 public: | 2277 public: |
| 2260 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HInvokeFunction, HValue*, | 2278 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HInvokeFunction, HValue*, |
| 2261 Handle<JSFunction>, int, | 2279 Handle<JSFunction>, int, |
| 2262 TailCallMode, TailCallMode); | 2280 TailCallMode, TailCallMode); |
| 2263 | 2281 |
| (...skipping 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6034 class BaseOffsetField: | 6052 class BaseOffsetField: |
| 6035 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> | 6053 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> |
| 6036 {}; // NOLINT | 6054 {}; // NOLINT |
| 6037 class IsDehoistedField: | 6055 class IsDehoistedField: |
| 6038 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> | 6056 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
| 6039 {}; // NOLINT | 6057 {}; // NOLINT |
| 6040 uint32_t bit_field_; | 6058 uint32_t bit_field_; |
| 6041 }; | 6059 }; |
| 6042 | 6060 |
| 6043 | 6061 |
| 6044 class HLoadKeyedGeneric final : public HTemplateInstruction<3> { | |
| 6045 public: | |
| 6046 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HLoadKeyedGeneric, HValue*, | |
| 6047 HValue*, | |
| 6048 Handle<TypeFeedbackVector>, | |
| 6049 FeedbackVectorSlot); | |
| 6050 HValue* object() const { return OperandAt(0); } | |
| 6051 HValue* key() const { return OperandAt(1); } | |
| 6052 HValue* context() const { return OperandAt(2); } | |
| 6053 FeedbackVectorSlot slot() const { return slot_; } | |
| 6054 Handle<TypeFeedbackVector> feedback_vector() const { | |
| 6055 return feedback_vector_; | |
| 6056 } | |
| 6057 | |
| 6058 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | |
| 6059 | |
| 6060 Representation RequiredInputRepresentation(int index) override { | |
| 6061 // tagged[tagged] | |
| 6062 return Representation::Tagged(); | |
| 6063 } | |
| 6064 | |
| 6065 HValue* Canonicalize() override; | |
| 6066 | |
| 6067 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) | |
| 6068 | |
| 6069 private: | |
| 6070 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key, | |
| 6071 Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) | |
| 6072 : feedback_vector_(vector), slot_(slot) { | |
| 6073 set_representation(Representation::Tagged()); | |
| 6074 SetOperandAt(0, obj); | |
| 6075 SetOperandAt(1, key); | |
| 6076 SetOperandAt(2, context); | |
| 6077 SetAllSideEffects(); | |
| 6078 } | |
| 6079 | |
| 6080 Handle<TypeFeedbackVector> feedback_vector_; | |
| 6081 FeedbackVectorSlot slot_; | |
| 6082 }; | |
| 6083 | |
| 6084 | |
| 6085 // Indicates whether the store is a store to an entry that was previously | 6062 // Indicates whether the store is a store to an entry that was previously |
| 6086 // initialized or not. | 6063 // initialized or not. |
| 6087 enum StoreFieldOrKeyedMode { | 6064 enum StoreFieldOrKeyedMode { |
| 6088 // The entry could be either previously initialized or not. | 6065 // The entry could be either previously initialized or not. |
| 6089 INITIALIZING_STORE, | 6066 INITIALIZING_STORE, |
| 6090 // At the time of this store it is guaranteed that the entry is already | 6067 // At the time of this store it is guaranteed that the entry is already |
| 6091 // initialized. | 6068 // initialized. |
| 6092 STORE_TO_INITIALIZED_ENTRY | 6069 STORE_TO_INITIALIZED_ENTRY |
| 6093 }; | 6070 }; |
| 6094 | 6071 |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6951 bool IsDeletable() const override { return true; } | 6928 bool IsDeletable() const override { return true; } |
| 6952 }; | 6929 }; |
| 6953 | 6930 |
| 6954 #undef DECLARE_INSTRUCTION | 6931 #undef DECLARE_INSTRUCTION |
| 6955 #undef DECLARE_CONCRETE_INSTRUCTION | 6932 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6956 | 6933 |
| 6957 } // namespace internal | 6934 } // namespace internal |
| 6958 } // namespace v8 | 6935 } // namespace v8 |
| 6959 | 6936 |
| 6960 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6937 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |