Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 public: | 1111 public: |
| 1112 HLeaveInlined() {} | 1112 HLeaveInlined() {} |
| 1113 | 1113 |
| 1114 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined, "leave_inlined") | 1114 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined, "leave_inlined") |
| 1115 }; | 1115 }; |
| 1116 | 1116 |
| 1117 | 1117 |
| 1118 class HPushArgument: public HUnaryOperation { | 1118 class HPushArgument: public HUnaryOperation { |
| 1119 public: | 1119 public: |
| 1120 explicit HPushArgument(HValue* value) | 1120 explicit HPushArgument(HValue* value) |
| 1121 : HUnaryOperation(value), argument_index_(-1) { | 1121 : HUnaryOperation(value) { |
| 1122 set_representation(Representation::Tagged()); | 1122 set_representation(Representation::Tagged()); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 virtual Representation RequiredInputRepresentation(int index) const { | 1125 virtual Representation RequiredInputRepresentation(int index) const { |
| 1126 return Representation::Tagged(); | 1126 return Representation::Tagged(); |
| 1127 } | 1127 } |
| 1128 | 1128 |
| 1129 virtual void PrintDataTo(StringStream* stream) const; | |
| 1130 HValue* argument() const { return OperandAt(0); } | 1129 HValue* argument() const { return OperandAt(0); } |
| 1131 int argument_index() const { return argument_index_; } | |
| 1132 void set_argument_index(int index) { | |
| 1133 ASSERT(argument_index_ == -1 || index == argument_index_); | |
| 1134 argument_index_ = index; | |
| 1135 } | |
| 1136 | 1130 |
| 1137 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument") | 1131 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument") |
| 1138 | |
| 1139 private: | |
| 1140 int argument_index_; | |
| 1141 }; | 1132 }; |
| 1142 | 1133 |
| 1143 | 1134 |
| 1144 class HGlobalObject: public HInstruction { | 1135 class HGlobalObject: public HInstruction { |
| 1145 public: | 1136 public: |
| 1146 HGlobalObject() { | 1137 HGlobalObject() { |
| 1147 set_representation(Representation::Tagged()); | 1138 set_representation(Representation::Tagged()); |
| 1148 SetFlag(kUseGVN); | 1139 SetFlag(kUseGVN); |
| 1149 SetFlag(kDependsOnCalls); | 1140 SetFlag(kDependsOnCalls); |
| 1150 } | 1141 } |
| 1151 | 1142 |
| 1152 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") | 1143 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") |
| 1153 }; | 1144 }; |
| 1154 | 1145 |
| 1155 | 1146 |
| 1156 class HGlobalReceiver: public HInstruction { | 1147 class HGlobalReceiver: public HInstruction { |
| 1157 public: | 1148 public: |
| 1158 HGlobalReceiver() { | 1149 HGlobalReceiver() { |
| 1159 set_representation(Representation::Tagged()); | 1150 set_representation(Representation::Tagged()); |
| 1160 SetFlag(kUseGVN); | 1151 SetFlag(kUseGVN); |
| 1161 SetFlag(kDependsOnCalls); | 1152 SetFlag(kDependsOnCalls); |
| 1162 } | 1153 } |
| 1163 | 1154 |
| 1164 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") | 1155 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") |
| 1165 }; | 1156 }; |
| 1166 | 1157 |
| 1167 | 1158 |
| 1168 class HCall: public HInstruction { | 1159 class HCall: public HInstruction { |
| 1169 public: | 1160 public: |
| 1170 // Construct a call with uninitialized arguments. The argument count | 1161 // The argument count includes the receiver. |
| 1171 // includes the receiver. | 1162 explicit HCall(int argument_count); |
| 1172 explicit HCall(int count); | |
| 1173 | 1163 |
| 1174 virtual HType CalculateInferredType() const { return HType::Tagged(); } | 1164 virtual HType CalculateInferredType() const { return HType::Tagged(); } |
| 1175 | 1165 |
| 1176 // TODO(3190496): This needs a cleanup. We don't want the arguments | 1166 int argument_count() const { return argument_count_; } |
| 1177 // be operands of the call instruction. This results in bad code quality. | |
| 1178 virtual int argument_count() const { return arguments_.length(); } | |
| 1179 virtual int OperandCount() const { return argument_count(); } | |
| 1180 virtual HValue* OperandAt(int index) const { return arguments_[index]; } | |
| 1181 virtual HPushArgument* PushArgumentAt(int index) const { | |
| 1182 return HPushArgument::cast(OperandAt(index)); | |
| 1183 } | |
| 1184 virtual HValue* ArgumentAt(int index) const { | |
| 1185 return PushArgumentAt(index)->argument(); | |
| 1186 } | |
| 1187 virtual void SetArgumentAt(int index, HPushArgument* push_argument); | |
| 1188 | 1167 |
| 1189 virtual void PrintDataTo(StringStream* stream) const; | 1168 virtual void PrintDataTo(StringStream* stream) const; |
| 1190 | 1169 |
| 1191 DECLARE_INSTRUCTION(Call) | 1170 DECLARE_INSTRUCTION(Call) |
| 1192 | 1171 |
| 1193 protected: | 1172 protected: |
| 1194 virtual void InternalSetOperandAt(int index, HValue* value) { | |
| 1195 arguments_[index] = value; | |
| 1196 } | |
| 1197 | |
| 1198 int argument_count_; | 1173 int argument_count_; |
| 1199 Vector<HValue*> arguments_; | |
| 1200 }; | 1174 }; |
| 1201 | 1175 |
| 1202 | 1176 |
| 1203 class HCallConstantFunction: public HCall { | 1177 class HCallConstantFunction: public HCall { |
| 1204 public: | 1178 public: |
| 1205 HCallConstantFunction(Handle<JSFunction> function, int argument_count) | 1179 HCallConstantFunction(Handle<JSFunction> function, int argument_count) |
| 1206 : HCall(argument_count), function_(function) { } | 1180 : HCall(argument_count), function_(function) { } |
| 1207 | 1181 |
| 1208 Handle<JSFunction> function() const { return function_; } | 1182 Handle<JSFunction> function() const { return function_; } |
| 1209 bool IsApplyFunction() const { | 1183 bool IsApplyFunction() const { |
| 1210 return function_->code() == Builtins::builtin(Builtins::FunctionApply); | 1184 return function_->code() == Builtins::builtin(Builtins::FunctionApply); |
| 1211 } | 1185 } |
| 1212 | 1186 |
| 1213 virtual void PrintDataTo(StringStream* stream) const; | 1187 virtual void PrintDataTo(StringStream* stream) const; |
| 1214 | 1188 |
| 1215 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call_constant_function") | 1189 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call_constant_function") |
| 1216 | 1190 |
| 1217 private: | 1191 private: |
| 1218 Handle<JSFunction> function_; | 1192 Handle<JSFunction> function_; |
| 1219 }; | 1193 }; |
| 1220 | 1194 |
| 1221 | 1195 |
| 1222 class HCallKeyed: public HCall { | 1196 class HCallKeyed: public HCall { |
| 1223 public: | 1197 public: |
| 1224 HCallKeyed(HValue* key, int argument_count) | 1198 HCallKeyed(HValue* key, int argument_count) : HCall(argument_count) { |
| 1225 : HCall(argument_count + 1) { | |
| 1226 SetOperandAt(0, key); | 1199 SetOperandAt(0, key); |
| 1227 } | 1200 } |
| 1228 | 1201 |
| 1229 virtual Representation RequiredInputRepresentation(int index) const { | 1202 virtual Representation RequiredInputRepresentation(int index) const { |
| 1230 return Representation::Tagged(); | 1203 return Representation::Tagged(); |
| 1231 } | 1204 } |
| 1232 | 1205 |
| 1233 // TODO(3190496): This is a hack to get an additional operand that | |
| 1234 // is not an argument to work with the current setup. This _needs_ a cleanup. | |
| 1235 // (see HCall) | |
| 1236 virtual void PrintDataTo(StringStream* stream) const; | 1206 virtual void PrintDataTo(StringStream* stream) const; |
| 1237 HValue* key() const { return OperandAt(0); } | 1207 HValue* key() const { return operands_[0]; } |
| 1238 virtual int argument_count() const { return arguments_.length() - 1; } | 1208 virtual int OperandCount() const { return 1; } |
| 1239 virtual int OperandCount() const { return arguments_.length(); } | 1209 virtual HValue* OperandAt(int index) const { return operands_[index]; } |
| 1240 virtual HValue* OperandAt(int index) const { return arguments_[index]; } | 1210 |
| 1241 virtual HPushArgument* PushArgumentAt(int index) const { | 1211 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call_keyed") |
| 1242 return HPushArgument::cast(OperandAt(index + 1)); | 1212 |
| 1243 } | 1213 protected: |
| 1244 virtual void SetArgumentAt(int index, HPushArgument* push_argument) { | 1214 virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1245 HCall::SetArgumentAt(index + 1, push_argument); | 1215 operands_[index] = value; |
| 1246 } | 1216 } |
| 1247 | 1217 |
| 1248 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call_keyed") | 1218 private: |
| 1219 HOperandVector<1> operands_; | |
|
fschneider
2010/12/20 16:13:02
There are now 3 types of calls that take an extra
| |
| 1249 }; | 1220 }; |
| 1250 | 1221 |
| 1251 | 1222 |
| 1252 class HCallNamed: public HCall { | 1223 class HCallNamed: public HCall { |
| 1253 public: | 1224 public: |
| 1254 HCallNamed(Handle<String> name, int argument_count) | 1225 HCallNamed(Handle<String> name, int argument_count) |
| 1255 : HCall(argument_count), name_(name) { } | 1226 : HCall(argument_count), name_(name) { } |
| 1256 virtual void PrintDataTo(StringStream* stream) const; | 1227 virtual void PrintDataTo(StringStream* stream) const; |
| 1257 | 1228 |
| 1258 Handle<String> name() const { return name_; } | 1229 Handle<String> name() const { return name_; } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1283 | 1254 |
| 1284 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call_global") | 1255 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call_global") |
| 1285 | 1256 |
| 1286 private: | 1257 private: |
| 1287 Handle<String> name_; | 1258 Handle<String> name_; |
| 1288 }; | 1259 }; |
| 1289 | 1260 |
| 1290 | 1261 |
| 1291 class HCallKnownGlobal: public HCall { | 1262 class HCallKnownGlobal: public HCall { |
| 1292 public: | 1263 public: |
| 1293 HCallKnownGlobal(Handle<JSFunction> target, | 1264 HCallKnownGlobal(HValue* receiver, |
| 1265 Handle<JSFunction> target, | |
| 1294 int argument_count) | 1266 int argument_count) |
| 1295 : HCall(argument_count), target_(target) { } | 1267 : HCall(argument_count), target_(target) { |
| 1268 SetOperandAt(0, receiver); | |
| 1269 } | |
| 1296 | 1270 |
| 1271 virtual void PrintDataTo(StringStream* stream) const; | |
| 1272 | |
| 1273 virtual int OperandCount() const { return 1; } | |
| 1274 virtual HValue* OperandAt(int index) const { return operands_[index]; } | |
| 1275 | |
| 1276 HValue* receiver() const { return operands_[0]; } | |
| 1297 Handle<JSFunction> target() const { return target_; } | 1277 Handle<JSFunction> target() const { return target_; } |
| 1298 | 1278 |
| 1299 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call_known_global") | 1279 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call_known_global") |
| 1300 | 1280 |
| 1281 protected: | |
| 1282 virtual void InternalSetOperandAt(int index, HValue* value) { | |
| 1283 operands_[index] = value; | |
| 1284 } | |
| 1285 | |
| 1301 private: | 1286 private: |
| 1287 HOperandVector<1> operands_; | |
| 1302 Handle<JSFunction> target_; | 1288 Handle<JSFunction> target_; |
| 1303 }; | 1289 }; |
| 1304 | 1290 |
| 1305 | 1291 |
| 1306 class HCallNew: public HCall { | 1292 class HCallNew: public HCall { |
| 1307 public: | 1293 public: |
| 1308 explicit HCallNew(int argument_count) : HCall(argument_count) { } | 1294 HCallNew(HValue* constructor, int argument_count) : HCall(argument_count) { |
| 1295 SetOperandAt(0, constructor); | |
| 1296 } | |
| 1309 | 1297 |
| 1310 virtual Representation RequiredInputRepresentation(int index) const { | 1298 virtual Representation RequiredInputRepresentation(int index) const { |
| 1311 return Representation::Tagged(); | 1299 return Representation::Tagged(); |
| 1312 } | 1300 } |
| 1313 | 1301 |
| 1314 HValue* constructor() const { return ArgumentAt(0); } | 1302 virtual void PrintDataTo(StringStream* stream) const; |
| 1303 HValue* constructor() const { return operands_[0]; } | |
| 1304 virtual int OperandCount() const { return 1; } | |
| 1305 virtual HValue* OperandAt(int index) const { return operands_[index]; } | |
| 1315 | 1306 |
| 1316 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call_new") | 1307 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call_new") |
| 1308 | |
| 1309 protected: | |
| 1310 virtual void InternalSetOperandAt(int index, HValue* value) { | |
| 1311 operands_[index] = value; | |
| 1312 } | |
| 1313 | |
| 1314 private: | |
| 1315 HOperandVector<1> operands_; | |
| 1317 }; | 1316 }; |
| 1318 | 1317 |
| 1319 | 1318 |
| 1320 class HCallRuntime: public HCall { | 1319 class HCallRuntime: public HCall { |
| 1321 public: | 1320 public: |
| 1322 HCallRuntime(Handle<String> name, | 1321 HCallRuntime(Handle<String> name, |
| 1323 Runtime::Function* c_function, | 1322 Runtime::Function* c_function, |
| 1324 int argument_count) | 1323 int argument_count) |
| 1325 : HCall(argument_count), c_function_(c_function), name_(name) { } | 1324 : HCall(argument_count), c_function_(c_function), name_(name) { } |
| 1325 | |
| 1326 virtual void PrintDataTo(StringStream* stream) const; | 1326 virtual void PrintDataTo(StringStream* stream) const; |
| 1327 | 1327 |
| 1328 Runtime::Function* function() const { return c_function_; } | 1328 Runtime::Function* function() const { return c_function_; } |
| 1329 Handle<String> name() const { return name_; } | 1329 Handle<String> name() const { return name_; } |
| 1330 | 1330 |
| 1331 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call_runtime") | 1331 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call_runtime") |
| 1332 | 1332 |
| 1333 private: | 1333 private: |
| 1334 Runtime::Function* c_function_; | 1334 Runtime::Function* c_function_; |
| 1335 Handle<String> name_; | 1335 Handle<String> name_; |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2940 HValue* object() const { return left(); } | 2940 HValue* object() const { return left(); } |
| 2941 HValue* key() const { return right(); } | 2941 HValue* key() const { return right(); } |
| 2942 }; | 2942 }; |
| 2943 | 2943 |
| 2944 #undef DECLARE_INSTRUCTION | 2944 #undef DECLARE_INSTRUCTION |
| 2945 #undef DECLARE_CONCRETE_INSTRUCTION | 2945 #undef DECLARE_CONCRETE_INSTRUCTION |
| 2946 | 2946 |
| 2947 } } // namespace v8::internal | 2947 } } // namespace v8::internal |
| 2948 | 2948 |
| 2949 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 2949 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |