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

Side by Side Diff: src/crankshaft/hydrogen-instructions.h

Issue 2391043005: [crankshaft] Remove HLoadKeyedGeneric and use HCallWithDescriptor to call KeyedLoadIC. (Closed)
Patch Set: Created 4 years, 2 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 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
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 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 2150
2152 class HCallWithDescriptor final : public HInstruction { 2151 class HCallWithDescriptor final : public HInstruction {
2153 public: 2152 public:
2154 static HCallWithDescriptor* New( 2153 static HCallWithDescriptor* New(
2155 Isolate* isolate, Zone* zone, HValue* context, HValue* target, 2154 Isolate* isolate, Zone* zone, HValue* context, HValue* target,
2156 int argument_count, CallInterfaceDescriptor descriptor, 2155 int argument_count, CallInterfaceDescriptor descriptor,
2157 const Vector<HValue*>& operands, 2156 const Vector<HValue*>& operands,
2158 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, 2157 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow,
2159 TailCallMode tail_call_mode = TailCallMode::kDisallow) { 2158 TailCallMode tail_call_mode = TailCallMode::kDisallow) {
2160 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( 2159 HCallWithDescriptor* res = new (zone) HCallWithDescriptor(
2161 context, target, argument_count, descriptor, operands, 2160 Code::STUB, context, target, argument_count, descriptor, operands,
2162 syntactic_tail_call_mode, tail_call_mode, zone); 2161 syntactic_tail_call_mode, tail_call_mode, zone);
2163 return res; 2162 return res;
2164 } 2163 }
2164
2165 static HCallWithDescriptor* New(
2166 Isolate* isolate, Zone* zone, HValue* context, Code::Kind kind,
2167 HValue* target, int argument_count, CallInterfaceDescriptor descriptor,
2168 const Vector<HValue*>& operands,
2169 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow,
2170 TailCallMode tail_call_mode = TailCallMode::kDisallow) {
2171 HCallWithDescriptor* res = new (zone) HCallWithDescriptor(
2172 kind, context, target, argument_count, descriptor, operands,
2173 syntactic_tail_call_mode, tail_call_mode, zone);
2174 return res;
2175 }
2165 2176
2166 int OperandCount() const final { return values_.length(); } 2177 int OperandCount() const final { return values_.length(); }
2167 HValue* OperandAt(int index) const final { return values_[index]; } 2178 HValue* OperandAt(int index) const final { return values_[index]; }
2168 2179
2169 Representation RequiredInputRepresentation(int index) final { 2180 Representation RequiredInputRepresentation(int index) final {
2170 if (index == 0 || index == 1) { 2181 if (index == 0 || index == 1) {
2171 // Target + context 2182 // Target + context
2172 return Representation::Tagged(); 2183 return Representation::Tagged();
2173 } else { 2184 } else {
2174 int par_index = index - 2; 2185 int par_index = index - 2;
2175 DCHECK(par_index < GetParameterCount()); 2186 DCHECK(par_index < GetParameterCount());
2176 return RepresentationFromMachineType( 2187 return RepresentationFromMachineType(
2177 descriptor_.GetParameterType(par_index)); 2188 descriptor_.GetParameterType(par_index));
2178 } 2189 }
2179 } 2190 }
2180 2191
2181 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) 2192 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor)
2182 2193
2183 // Defines whether this instruction corresponds to a JS call at tail position. 2194 // Defines whether this instruction corresponds to a JS call at tail position.
2184 TailCallMode syntactic_tail_call_mode() const { 2195 TailCallMode syntactic_tail_call_mode() const {
2185 return SyntacticTailCallModeField::decode(bit_field_); 2196 return SyntacticTailCallModeField::decode(bit_field_);
2186 } 2197 }
2187 2198
2188 // Defines whether this call should be generated as a tail call. 2199 // Defines whether this call should be generated as a tail call.
2189 TailCallMode tail_call_mode() const { 2200 TailCallMode tail_call_mode() const {
2190 return TailCallModeField::decode(bit_field_); 2201 return TailCallModeField::decode(bit_field_);
2191 } 2202 }
2192 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; } 2203 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; }
2193 2204
2205 Code::Kind kind() const { return KindField::decode(bit_field_); }
2206
2194 virtual int argument_count() const { 2207 virtual int argument_count() const {
2195 return argument_count_; 2208 return argument_count_;
2196 } 2209 }
2197 2210
2198 int argument_delta() const override { return -argument_count_; } 2211 int argument_delta() const override { return -argument_count_; }
2199 2212
2200 CallInterfaceDescriptor descriptor() const { return descriptor_; } 2213 CallInterfaceDescriptor descriptor() const { return descriptor_; }
2201 2214
2202 HValue* target() { return OperandAt(0); } 2215 HValue* target() { return OperandAt(0); }
2203 HValue* context() { return OperandAt(1); } 2216 HValue* context() { return OperandAt(1); }
2204 HValue* parameter(int index) { 2217 HValue* parameter(int index) {
2205 DCHECK_LT(index, GetParameterCount()); 2218 DCHECK_LT(index, GetParameterCount());
2206 return OperandAt(index + 2); 2219 return OperandAt(index + 2);
2207 } 2220 }
2208 2221
2222 HValue* Canonicalize() override;
2223
2209 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT 2224 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT
2210 2225
2211 private: 2226 private:
2212 // The argument count includes the receiver. 2227 // The argument count includes the receiver.
2213 HCallWithDescriptor(HValue* context, HValue* target, int argument_count, 2228 HCallWithDescriptor(Code::Kind kind, HValue* context, HValue* target,
2214 CallInterfaceDescriptor descriptor, 2229 int argument_count, CallInterfaceDescriptor descriptor,
2215 const Vector<HValue*>& operands, 2230 const Vector<HValue*>& operands,
2216 TailCallMode syntactic_tail_call_mode, 2231 TailCallMode syntactic_tail_call_mode,
2217 TailCallMode tail_call_mode, Zone* zone) 2232 TailCallMode tail_call_mode, Zone* zone)
2218 : descriptor_(descriptor), 2233 : descriptor_(descriptor),
2219 values_(GetParameterCount() + 2, zone), // +2 for context and target. 2234 values_(GetParameterCount() + 2, zone), // +2 for context and target.
2220 argument_count_(argument_count), 2235 argument_count_(argument_count),
2221 bit_field_( 2236 bit_field_(
2222 TailCallModeField::encode(tail_call_mode) | 2237 TailCallModeField::encode(tail_call_mode) |
2223 SyntacticTailCallModeField::encode(syntactic_tail_call_mode)) { 2238 SyntacticTailCallModeField::encode(syntactic_tail_call_mode) |
2239 KindField::encode(kind)) {
2224 DCHECK_EQ(operands.length(), GetParameterCount()); 2240 DCHECK_EQ(operands.length(), GetParameterCount());
2225 // We can only tail call without any stack arguments. 2241 // We can only tail call without any stack arguments.
2226 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0); 2242 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0);
2227 AddOperand(target, zone); 2243 AddOperand(target, zone);
2228 AddOperand(context, zone); 2244 AddOperand(context, zone);
2229 for (int i = 0; i < operands.length(); i++) { 2245 for (int i = 0; i < operands.length(); i++) {
2230 AddOperand(operands[i], zone); 2246 AddOperand(operands[i], zone);
2231 } 2247 }
2232 this->set_representation(Representation::Tagged()); 2248 this->set_representation(Representation::Tagged());
2233 this->SetAllSideEffects(); 2249 this->SetAllSideEffects();
2234 } 2250 }
2235 2251
2236 void AddOperand(HValue* v, Zone* zone) { 2252 void AddOperand(HValue* v, Zone* zone) {
2237 values_.Add(NULL, zone); 2253 values_.Add(NULL, zone);
2238 SetOperandAt(values_.length() - 1, v); 2254 SetOperandAt(values_.length() - 1, v);
2239 } 2255 }
2240 2256
2241 int GetParameterCount() const { return descriptor_.GetParameterCount(); } 2257 int GetParameterCount() const { return descriptor_.GetParameterCount(); }
2242 2258
2243 void InternalSetOperandAt(int index, HValue* value) final { 2259 void InternalSetOperandAt(int index, HValue* value) final {
2244 values_[index] = value; 2260 values_[index] = value;
2245 } 2261 }
2246 2262
2247 CallInterfaceDescriptor descriptor_; 2263 CallInterfaceDescriptor descriptor_;
2248 ZoneList<HValue*> values_; 2264 ZoneList<HValue*> values_;
2249 int argument_count_; 2265 int argument_count_;
2250 class TailCallModeField : public BitField<TailCallMode, 0, 1> {}; 2266 class TailCallModeField : public BitField<TailCallMode, 0, 1> {};
2251 class SyntacticTailCallModeField 2267 class SyntacticTailCallModeField
2252 : public BitField<TailCallMode, TailCallModeField::kNext, 1> {}; 2268 : public BitField<TailCallMode, TailCallModeField::kNext, 1> {};
2269 class KindField
2270 : public BitField<Code::Kind, SyntacticTailCallModeField::kNext, 5> {};
2253 uint32_t bit_field_; 2271 uint32_t bit_field_;
2254 }; 2272 };
2255 2273
2256 2274
2257 class HInvokeFunction final : public HBinaryCall { 2275 class HInvokeFunction final : public HBinaryCall {
2258 public: 2276 public:
2259 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HInvokeFunction, HValue*, 2277 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HInvokeFunction, HValue*,
2260 Handle<JSFunction>, int, 2278 Handle<JSFunction>, int,
2261 TailCallMode, TailCallMode); 2279 TailCallMode, TailCallMode);
2262 2280
(...skipping 3775 matching lines...) Expand 10 before | Expand all | Expand 10 after
6038 class BaseOffsetField: 6056 class BaseOffsetField:
6039 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> 6057 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset>
6040 {}; // NOLINT 6058 {}; // NOLINT
6041 class IsDehoistedField: 6059 class IsDehoistedField:
6042 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> 6060 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted>
6043 {}; // NOLINT 6061 {}; // NOLINT
6044 uint32_t bit_field_; 6062 uint32_t bit_field_;
6045 }; 6063 };
6046 6064
6047 6065
6048 class HLoadKeyedGeneric final : public HTemplateInstruction<3> {
6049 public:
6050 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HLoadKeyedGeneric, HValue*,
6051 HValue*,
6052 Handle<TypeFeedbackVector>,
6053 FeedbackVectorSlot);
6054 HValue* object() const { return OperandAt(0); }
6055 HValue* key() const { return OperandAt(1); }
6056 HValue* context() const { return OperandAt(2); }
6057 FeedbackVectorSlot slot() const { return slot_; }
6058 Handle<TypeFeedbackVector> feedback_vector() const {
6059 return feedback_vector_;
6060 }
6061
6062 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT
6063
6064 Representation RequiredInputRepresentation(int index) override {
6065 // tagged[tagged]
6066 return Representation::Tagged();
6067 }
6068
6069 HValue* Canonicalize() override;
6070
6071 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
6072
6073 private:
6074 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key,
6075 Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
6076 : feedback_vector_(vector), slot_(slot) {
6077 set_representation(Representation::Tagged());
6078 SetOperandAt(0, obj);
6079 SetOperandAt(1, key);
6080 SetOperandAt(2, context);
6081 SetAllSideEffects();
6082 }
6083
6084 Handle<TypeFeedbackVector> feedback_vector_;
6085 FeedbackVectorSlot slot_;
6086 };
6087
6088
6089 // Indicates whether the store is a store to an entry that was previously 6066 // Indicates whether the store is a store to an entry that was previously
6090 // initialized or not. 6067 // initialized or not.
6091 enum StoreFieldOrKeyedMode { 6068 enum StoreFieldOrKeyedMode {
6092 // The entry could be either previously initialized or not. 6069 // The entry could be either previously initialized or not.
6093 INITIALIZING_STORE, 6070 INITIALIZING_STORE,
6094 // At the time of this store it is guaranteed that the entry is already 6071 // At the time of this store it is guaranteed that the entry is already
6095 // initialized. 6072 // initialized.
6096 STORE_TO_INITIALIZED_ENTRY 6073 STORE_TO_INITIALIZED_ENTRY
6097 }; 6074 };
6098 6075
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
6955 bool IsDeletable() const override { return true; } 6932 bool IsDeletable() const override { return true; }
6956 }; 6933 };
6957 6934
6958 #undef DECLARE_INSTRUCTION 6935 #undef DECLARE_INSTRUCTION
6959 #undef DECLARE_CONCRETE_INSTRUCTION 6936 #undef DECLARE_CONCRETE_INSTRUCTION
6960 6937
6961 } // namespace internal 6938 } // namespace internal
6962 } // namespace v8 6939 } // namespace v8
6963 6940
6964 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ 6941 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698