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_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 V(StubFailureTrampoline) \ | 60 V(StubFailureTrampoline) \ |
61 /* These are only called from FCG */ \ | 61 /* These are only called from FCG */ \ |
62 /* They can be removed when only the TF */ \ | 62 /* They can be removed when only the TF */ \ |
63 /* version of the corresponding stub is */ \ | 63 /* version of the corresponding stub is */ \ |
64 /* used universally */ \ | 64 /* used universally */ \ |
65 V(CallICTrampoline) \ | 65 V(CallICTrampoline) \ |
66 /* --- HydrogenCodeStubs --- */ \ | 66 /* --- HydrogenCodeStubs --- */ \ |
67 /* These will be ported/eliminated */ \ | 67 /* These will be ported/eliminated */ \ |
68 /* as part of the new IC system, ask */ \ | 68 /* as part of the new IC system, ask */ \ |
69 /* ishell before doing anything */ \ | 69 /* ishell before doing anything */ \ |
70 V(LoadConstant) \ | |
71 V(LoadField) \ | 70 V(LoadField) \ |
72 /* These should never be ported to TF */ \ | 71 /* These should never be ported to TF */ \ |
73 /* because they are either used only by */ \ | 72 /* because they are either used only by */ \ |
74 /* FCG/Crankshaft or are deprecated */ \ | 73 /* FCG/Crankshaft or are deprecated */ \ |
75 V(BinaryOpIC) \ | 74 V(BinaryOpIC) \ |
76 V(BinaryOpWithAllocationSite) \ | 75 V(BinaryOpWithAllocationSite) \ |
77 V(ToBooleanIC) \ | 76 V(ToBooleanIC) \ |
78 V(TransitionElementsKind) \ | 77 V(TransitionElementsKind) \ |
79 /* --- TurboFanCodeStubs --- */ \ | 78 /* --- TurboFanCodeStubs --- */ \ |
80 V(AllocateHeapNumber) \ | 79 V(AllocateHeapNumber) \ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 V(KeyedStoreSloppyArguments) \ | 112 V(KeyedStoreSloppyArguments) \ |
114 V(LoadScriptContextField) \ | 113 V(LoadScriptContextField) \ |
115 V(StoreScriptContextField) \ | 114 V(StoreScriptContextField) \ |
116 V(NumberToString) \ | 115 V(NumberToString) \ |
117 V(StringAdd) \ | 116 V(StringAdd) \ |
118 V(GetProperty) \ | 117 V(GetProperty) \ |
119 V(LoadIC) \ | 118 V(LoadIC) \ |
120 V(LoadICProtoArray) \ | 119 V(LoadICProtoArray) \ |
121 V(KeyedLoadICTF) \ | 120 V(KeyedLoadICTF) \ |
122 V(StoreFastElement) \ | 121 V(StoreFastElement) \ |
123 V(StoreField) \ | |
124 V(StoreGlobal) \ | 122 V(StoreGlobal) \ |
125 V(StoreIC) \ | 123 V(StoreIC) \ |
126 V(KeyedStoreICTF) \ | 124 V(KeyedStoreICTF) \ |
127 V(StoreInterceptor) \ | 125 V(StoreInterceptor) \ |
128 V(StoreMap) \ | |
129 V(StoreTransition) \ | |
130 V(LoadApiGetter) \ | 126 V(LoadApiGetter) \ |
131 V(LoadIndexedInterceptor) \ | 127 V(LoadIndexedInterceptor) \ |
132 V(GrowArrayElements) \ | 128 V(GrowArrayElements) \ |
133 /* These are only called from FGC and */ \ | 129 /* These are only called from FGC and */ \ |
134 /* can be removed when we use ignition */ \ | 130 /* can be removed when we use ignition */ \ |
135 /* only */ \ | 131 /* only */ \ |
136 V(LoadICTrampoline) \ | 132 V(LoadICTrampoline) \ |
137 V(LoadGlobalICTrampoline) \ | 133 V(LoadGlobalICTrampoline) \ |
138 V(KeyedLoadICTrampolineTF) \ | 134 V(KeyedLoadICTrampolineTF) \ |
139 V(StoreICTrampoline) \ | 135 V(StoreICTrampoline) \ |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 } | 1218 } |
1223 | 1219 |
1224 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 1220 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
1225 ExtraICState GetExtraICState() const override { return Code::STORE_IC; } | 1221 ExtraICState GetExtraICState() const override { return Code::STORE_IC; } |
1226 | 1222 |
1227 protected: | 1223 protected: |
1228 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector); | 1224 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector); |
1229 DEFINE_TURBOFAN_CODE_STUB(KeyedStoreSloppyArguments, TurboFanCodeStub); | 1225 DEFINE_TURBOFAN_CODE_STUB(KeyedStoreSloppyArguments, TurboFanCodeStub); |
1230 }; | 1226 }; |
1231 | 1227 |
1232 | |
1233 class LoadConstantStub : public HandlerStub { | |
1234 public: | |
1235 LoadConstantStub(Isolate* isolate, int constant_index) | |
1236 : HandlerStub(isolate) { | |
1237 set_sub_minor_key(ConstantIndexBits::encode(constant_index)); | |
1238 } | |
1239 | |
1240 int constant_index() const { | |
1241 return ConstantIndexBits::decode(sub_minor_key()); | |
1242 } | |
1243 | |
1244 protected: | |
1245 Code::Kind kind() const override { return Code::LOAD_IC; } | |
1246 | |
1247 private: | |
1248 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; | |
1249 | |
1250 // TODO(ishell): The stub uses only kReceiver parameter. | |
1251 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); | |
1252 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); | |
1253 }; | |
1254 | |
1255 class LoadApiGetterStub : public TurboFanCodeStub { | 1228 class LoadApiGetterStub : public TurboFanCodeStub { |
1256 public: | 1229 public: |
1257 LoadApiGetterStub(Isolate* isolate, bool receiver_is_holder, int index) | 1230 LoadApiGetterStub(Isolate* isolate, bool receiver_is_holder, int index) |
1258 : TurboFanCodeStub(isolate) { | 1231 : TurboFanCodeStub(isolate) { |
1259 // If that's not true, we need to ensure that the receiver is actually a | 1232 // If that's not true, we need to ensure that the receiver is actually a |
1260 // JSReceiver. http://crbug.com/609134 | 1233 // JSReceiver. http://crbug.com/609134 |
1261 DCHECK(receiver_is_holder); | 1234 DCHECK(receiver_is_holder); |
1262 minor_key_ = IndexBits::encode(index) | | 1235 minor_key_ = IndexBits::encode(index) | |
1263 ReceiverIsHolderBits::encode(receiver_is_holder); | 1236 ReceiverIsHolderBits::encode(receiver_is_holder); |
1264 } | 1237 } |
1265 | 1238 |
1266 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 1239 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
1267 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } | 1240 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
1268 | 1241 |
1269 int index() const { return IndexBits::decode(minor_key_); } | 1242 int index() const { return IndexBits::decode(minor_key_); } |
1270 bool receiver_is_holder() const { | 1243 bool receiver_is_holder() const { |
1271 return ReceiverIsHolderBits::decode(minor_key_); | 1244 return ReceiverIsHolderBits::decode(minor_key_); |
1272 } | 1245 } |
1273 | 1246 |
1274 private: | 1247 private: |
1275 class ReceiverIsHolderBits : public BitField<bool, 0, 1> {}; | 1248 class ReceiverIsHolderBits : public BitField<bool, 0, 1> {}; |
1276 class IndexBits : public BitField<int, 1, kDescriptorIndexBitCount> {}; | 1249 class IndexBits : public BitField<int, 1, kDescriptorIndexBitCount> {}; |
1277 | 1250 |
1278 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); | 1251 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); |
1279 DEFINE_TURBOFAN_CODE_STUB(LoadApiGetter, TurboFanCodeStub); | 1252 DEFINE_TURBOFAN_CODE_STUB(LoadApiGetter, TurboFanCodeStub); |
1280 }; | 1253 }; |
1281 | 1254 |
1282 class StoreFieldStub : public TurboFanCodeStub { | |
1283 public: | |
1284 StoreFieldStub(Isolate* isolate, FieldIndex index, | |
1285 Representation representation) | |
1286 : TurboFanCodeStub(isolate) { | |
1287 int property_index_key = index.GetFieldAccessStubKey(); | |
1288 minor_key_ = StoreFieldByIndexBits::encode(property_index_key) | | |
1289 RepresentationBits::encode(representation.kind()); | |
1290 } | |
1291 | |
1292 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | |
1293 ExtraICState GetExtraICState() const override { return Code::STORE_IC; } | |
1294 | |
1295 FieldIndex index() const { | |
1296 int property_index_key = StoreFieldByIndexBits::decode(minor_key_); | |
1297 return FieldIndex::FromFieldAccessStubKey(property_index_key); | |
1298 } | |
1299 | |
1300 Representation representation() const { | |
1301 return Representation::FromKind(RepresentationBits::decode(minor_key_)); | |
1302 } | |
1303 | |
1304 private: | |
1305 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | |
1306 class RepresentationBits | |
1307 : public BitField<Representation::Kind, StoreFieldByIndexBits::kNext, 4> { | |
1308 }; | |
1309 STATIC_ASSERT(Representation::kNumRepresentations - 1 < | |
1310 RepresentationBits::kMax); | |
1311 | |
1312 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector); | |
1313 DEFINE_TURBOFAN_CODE_STUB(StoreField, TurboFanCodeStub); | |
1314 }; | |
1315 | |
1316 class StoreMapStub : public TurboFanCodeStub { | |
1317 public: | |
1318 explicit StoreMapStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} | |
1319 | |
1320 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | |
1321 ExtraICState GetExtraICState() const override { return Code::STORE_IC; } | |
1322 | |
1323 private: | |
1324 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreTransition); | |
1325 DEFINE_TURBOFAN_CODE_STUB(StoreMap, TurboFanCodeStub); | |
1326 }; | |
1327 | |
1328 class StoreTransitionStub : public TurboFanCodeStub { | |
1329 public: | |
1330 enum StoreMode { | |
1331 StoreMapAndValue, | |
1332 ExtendStorageAndStoreMapAndValue | |
1333 }; | |
1334 | |
1335 StoreTransitionStub(Isolate* isolate, bool is_inobject, | |
1336 Representation representation, StoreMode store_mode) | |
1337 : TurboFanCodeStub(isolate) { | |
1338 minor_key_ = IsInobjectBits::encode(is_inobject) | | |
1339 RepresentationBits::encode(representation.kind()) | | |
1340 StoreModeBits::encode(store_mode); | |
1341 } | |
1342 | |
1343 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | |
1344 ExtraICState GetExtraICState() const override { return Code::STORE_IC; } | |
1345 | |
1346 bool is_inobject() const { return IsInobjectBits::decode(minor_key_); } | |
1347 | |
1348 Representation representation() const { | |
1349 return Representation::FromKind(RepresentationBits::decode(minor_key_)); | |
1350 } | |
1351 | |
1352 StoreMode store_mode() const { return StoreModeBits::decode(minor_key_); } | |
1353 | |
1354 private: | |
1355 class IsInobjectBits : public BitField<bool, 0, 1> {}; | |
1356 class RepresentationBits | |
1357 : public BitField<Representation::Kind, IsInobjectBits::kNext, 4> {}; | |
1358 STATIC_ASSERT(Representation::kNumRepresentations - 1 < | |
1359 RepresentationBits::kMax); | |
1360 class StoreModeBits | |
1361 : public BitField<StoreMode, RepresentationBits::kNext, 1> {}; | |
1362 | |
1363 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreNamedTransition); | |
1364 DEFINE_TURBOFAN_CODE_STUB(StoreTransition, TurboFanCodeStub); | |
1365 }; | |
1366 | |
1367 class StoreGlobalStub : public TurboFanCodeStub { | 1255 class StoreGlobalStub : public TurboFanCodeStub { |
1368 public: | 1256 public: |
1369 StoreGlobalStub(Isolate* isolate, PropertyCellType type, | 1257 StoreGlobalStub(Isolate* isolate, PropertyCellType type, |
1370 Maybe<PropertyCellConstantType> constant_type, | 1258 Maybe<PropertyCellConstantType> constant_type, |
1371 bool check_global) | 1259 bool check_global) |
1372 : TurboFanCodeStub(isolate) { | 1260 : TurboFanCodeStub(isolate) { |
1373 PropertyCellConstantType encoded_constant_type = | 1261 PropertyCellConstantType encoded_constant_type = |
1374 constant_type.FromMaybe(PropertyCellConstantType::kSmi); | 1262 constant_type.FromMaybe(PropertyCellConstantType::kSmi); |
1375 minor_key_ = CellTypeBits::encode(type) | | 1263 minor_key_ = CellTypeBits::encode(type) | |
1376 ConstantTypeBits::encode(encoded_constant_type) | | 1264 ConstantTypeBits::encode(encoded_constant_type) | |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 #undef DEFINE_PLATFORM_CODE_STUB | 2503 #undef DEFINE_PLATFORM_CODE_STUB |
2616 #undef DEFINE_HANDLER_CODE_STUB | 2504 #undef DEFINE_HANDLER_CODE_STUB |
2617 #undef DEFINE_HYDROGEN_CODE_STUB | 2505 #undef DEFINE_HYDROGEN_CODE_STUB |
2618 #undef DEFINE_CODE_STUB | 2506 #undef DEFINE_CODE_STUB |
2619 #undef DEFINE_CODE_STUB_BASE | 2507 #undef DEFINE_CODE_STUB_BASE |
2620 | 2508 |
2621 } // namespace internal | 2509 } // namespace internal |
2622 } // namespace v8 | 2510 } // namespace v8 |
2623 | 2511 |
2624 #endif // V8_CODE_STUBS_H_ | 2512 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |