| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 // Returns information for computing the number key. | 277 // Returns information for computing the number key. |
| 278 virtual Major MajorKey() const = 0; | 278 virtual Major MajorKey() const = 0; |
| 279 uint32_t MinorKey() const { return minor_key_; } | 279 uint32_t MinorKey() const { return minor_key_; } |
| 280 | 280 |
| 281 // BinaryOpStub needs to override this. | 281 // BinaryOpStub needs to override this. |
| 282 virtual Code::Kind GetCodeKind() const; | 282 virtual Code::Kind GetCodeKind() const; |
| 283 | 283 |
| 284 virtual InlineCacheState GetICState() const { return UNINITIALIZED; } | 284 virtual InlineCacheState GetICState() const { return UNINITIALIZED; } |
| 285 virtual ExtraICState GetExtraICState() const { return kNoExtraICState; } | 285 virtual ExtraICState GetExtraICState() const { return kNoExtraICState; } |
| 286 virtual Code::StubType GetStubType() const { return Code::NORMAL; } | |
| 287 | 286 |
| 288 Code::Flags GetCodeFlags() const; | 287 Code::Flags GetCodeFlags() const; |
| 289 | 288 |
| 290 friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) { | 289 friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) { |
| 291 s.PrintName(os); | 290 s.PrintName(os); |
| 292 return os; | 291 return os; |
| 293 } | 292 } |
| 294 | 293 |
| 295 Isolate* isolate() const { return isolate_; } | 294 Isolate* isolate() const { return isolate_; } |
| 296 | 295 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 570 |
| 572 class TurboFanCodeStub : public CodeStub { | 571 class TurboFanCodeStub : public CodeStub { |
| 573 public: | 572 public: |
| 574 // Retrieve the code for the stub. Generate the code if needed. | 573 // Retrieve the code for the stub. Generate the code if needed. |
| 575 Handle<Code> GenerateCode() override; | 574 Handle<Code> GenerateCode() override; |
| 576 | 575 |
| 577 int GetStackParameterCount() const override { | 576 int GetStackParameterCount() const override { |
| 578 return GetCallInterfaceDescriptor().GetStackParameterCount(); | 577 return GetCallInterfaceDescriptor().GetStackParameterCount(); |
| 579 } | 578 } |
| 580 | 579 |
| 581 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 582 | |
| 583 protected: | 580 protected: |
| 584 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} | 581 explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
| 585 | 582 |
| 586 virtual void GenerateAssembly( | 583 virtual void GenerateAssembly( |
| 587 compiler::CodeStubAssembler* assembler) const = 0; | 584 compiler::CodeStubAssembler* assembler) const = 0; |
| 588 | 585 |
| 589 private: | 586 private: |
| 590 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); | 587 DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); |
| 591 }; | 588 }; |
| 592 | 589 |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 DEFINE_PLATFORM_CODE_STUB(FunctionPrototype, PlatformCodeStub); | 1261 DEFINE_PLATFORM_CODE_STUB(FunctionPrototype, PlatformCodeStub); |
| 1265 }; | 1262 }; |
| 1266 | 1263 |
| 1267 | 1264 |
| 1268 class LoadIndexedStringStub : public PlatformCodeStub { | 1265 class LoadIndexedStringStub : public PlatformCodeStub { |
| 1269 public: | 1266 public: |
| 1270 explicit LoadIndexedStringStub(Isolate* isolate) | 1267 explicit LoadIndexedStringStub(Isolate* isolate) |
| 1271 : PlatformCodeStub(isolate) {} | 1268 : PlatformCodeStub(isolate) {} |
| 1272 | 1269 |
| 1273 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 1270 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 1274 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1275 | 1271 |
| 1276 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); | 1272 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); |
| 1277 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub); | 1273 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub); |
| 1278 }; | 1274 }; |
| 1279 | 1275 |
| 1280 | 1276 |
| 1281 class HandlerStub : public HydrogenCodeStub { | 1277 class HandlerStub : public HydrogenCodeStub { |
| 1282 public: | 1278 public: |
| 1283 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 1279 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 1284 ExtraICState GetExtraICState() const override { return kind(); } | 1280 ExtraICState GetExtraICState() const override { return kind(); } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1304 set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key)); | 1300 set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key)); |
| 1305 } | 1301 } |
| 1306 | 1302 |
| 1307 FieldIndex index() const { | 1303 FieldIndex index() const { |
| 1308 int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key()); | 1304 int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key()); |
| 1309 return FieldIndex::FromFieldAccessStubKey(property_index_key); | 1305 return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1310 } | 1306 } |
| 1311 | 1307 |
| 1312 protected: | 1308 protected: |
| 1313 Code::Kind kind() const override { return Code::LOAD_IC; } | 1309 Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1314 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1315 | 1310 |
| 1316 private: | 1311 private: |
| 1317 class LoadFieldByIndexBits : public BitField<int, 0, 13> {}; | 1312 class LoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1318 | 1313 |
| 1319 DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub); | 1314 DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub); |
| 1320 }; | 1315 }; |
| 1321 | 1316 |
| 1322 | 1317 |
| 1323 class ArrayBufferViewLoadFieldStub : public HandlerStub { | 1318 class ArrayBufferViewLoadFieldStub : public HandlerStub { |
| 1324 public: | 1319 public: |
| 1325 ArrayBufferViewLoadFieldStub(Isolate* isolate, FieldIndex index) | 1320 ArrayBufferViewLoadFieldStub(Isolate* isolate, FieldIndex index) |
| 1326 : HandlerStub(isolate) { | 1321 : HandlerStub(isolate) { |
| 1327 int property_index_key = index.GetFieldAccessStubKey(); | 1322 int property_index_key = index.GetFieldAccessStubKey(); |
| 1328 set_sub_minor_key( | 1323 set_sub_minor_key( |
| 1329 ArrayBufferViewLoadFieldByIndexBits::encode(property_index_key)); | 1324 ArrayBufferViewLoadFieldByIndexBits::encode(property_index_key)); |
| 1330 } | 1325 } |
| 1331 | 1326 |
| 1332 FieldIndex index() const { | 1327 FieldIndex index() const { |
| 1333 int property_index_key = | 1328 int property_index_key = |
| 1334 ArrayBufferViewLoadFieldByIndexBits::decode(sub_minor_key()); | 1329 ArrayBufferViewLoadFieldByIndexBits::decode(sub_minor_key()); |
| 1335 return FieldIndex::FromFieldAccessStubKey(property_index_key); | 1330 return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1336 } | 1331 } |
| 1337 | 1332 |
| 1338 protected: | 1333 protected: |
| 1339 Code::Kind kind() const override { return Code::LOAD_IC; } | 1334 Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1340 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1341 | 1335 |
| 1342 private: | 1336 private: |
| 1343 class ArrayBufferViewLoadFieldByIndexBits : public BitField<int, 0, 13> {}; | 1337 class ArrayBufferViewLoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1344 | 1338 |
| 1345 DEFINE_HANDLER_CODE_STUB(ArrayBufferViewLoadField, HandlerStub); | 1339 DEFINE_HANDLER_CODE_STUB(ArrayBufferViewLoadField, HandlerStub); |
| 1346 }; | 1340 }; |
| 1347 | 1341 |
| 1348 | 1342 |
| 1349 class KeyedLoadSloppyArgumentsStub : public HandlerStub { | 1343 class KeyedLoadSloppyArgumentsStub : public HandlerStub { |
| 1350 public: | 1344 public: |
| 1351 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) | 1345 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) |
| 1352 : HandlerStub(isolate) {} | 1346 : HandlerStub(isolate) {} |
| 1353 | 1347 |
| 1354 protected: | 1348 protected: |
| 1355 Code::Kind kind() const override { return Code::KEYED_LOAD_IC; } | 1349 Code::Kind kind() const override { return Code::KEYED_LOAD_IC; } |
| 1356 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1357 | 1350 |
| 1358 private: | 1351 private: |
| 1359 DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub); | 1352 DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub); |
| 1360 }; | 1353 }; |
| 1361 | 1354 |
| 1362 | 1355 |
| 1363 class CommonStoreModeBits : public BitField<KeyedAccessStoreMode, 0, 3> {}; | 1356 class CommonStoreModeBits : public BitField<KeyedAccessStoreMode, 0, 3> {}; |
| 1364 | 1357 |
| 1365 class KeyedStoreSloppyArgumentsStub : public HandlerStub { | 1358 class KeyedStoreSloppyArgumentsStub : public HandlerStub { |
| 1366 public: | 1359 public: |
| 1367 explicit KeyedStoreSloppyArgumentsStub(Isolate* isolate, | 1360 explicit KeyedStoreSloppyArgumentsStub(Isolate* isolate, |
| 1368 KeyedAccessStoreMode mode) | 1361 KeyedAccessStoreMode mode) |
| 1369 : HandlerStub(isolate) { | 1362 : HandlerStub(isolate) { |
| 1370 set_sub_minor_key(CommonStoreModeBits::encode(mode)); | 1363 set_sub_minor_key(CommonStoreModeBits::encode(mode)); |
| 1371 } | 1364 } |
| 1372 | 1365 |
| 1373 protected: | 1366 protected: |
| 1374 Code::Kind kind() const override { return Code::KEYED_STORE_IC; } | 1367 Code::Kind kind() const override { return Code::KEYED_STORE_IC; } |
| 1375 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1376 | 1368 |
| 1377 private: | 1369 private: |
| 1378 DEFINE_HANDLER_CODE_STUB(KeyedStoreSloppyArguments, HandlerStub); | 1370 DEFINE_HANDLER_CODE_STUB(KeyedStoreSloppyArguments, HandlerStub); |
| 1379 }; | 1371 }; |
| 1380 | 1372 |
| 1381 | 1373 |
| 1382 class LoadConstantStub : public HandlerStub { | 1374 class LoadConstantStub : public HandlerStub { |
| 1383 public: | 1375 public: |
| 1384 LoadConstantStub(Isolate* isolate, int constant_index) | 1376 LoadConstantStub(Isolate* isolate, int constant_index) |
| 1385 : HandlerStub(isolate) { | 1377 : HandlerStub(isolate) { |
| 1386 set_sub_minor_key(ConstantIndexBits::encode(constant_index)); | 1378 set_sub_minor_key(ConstantIndexBits::encode(constant_index)); |
| 1387 } | 1379 } |
| 1388 | 1380 |
| 1389 int constant_index() const { | 1381 int constant_index() const { |
| 1390 return ConstantIndexBits::decode(sub_minor_key()); | 1382 return ConstantIndexBits::decode(sub_minor_key()); |
| 1391 } | 1383 } |
| 1392 | 1384 |
| 1393 protected: | 1385 protected: |
| 1394 Code::Kind kind() const override { return Code::LOAD_IC; } | 1386 Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1395 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1396 | 1387 |
| 1397 private: | 1388 private: |
| 1398 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; | 1389 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
| 1399 | 1390 |
| 1400 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); | 1391 DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); |
| 1401 }; | 1392 }; |
| 1402 | 1393 |
| 1403 | 1394 |
| 1404 class StoreFieldStub : public HandlerStub { | 1395 class StoreFieldStub : public HandlerStub { |
| 1405 public: | 1396 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1417 return FieldIndex::FromFieldAccessStubKey(property_index_key); | 1408 return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1418 } | 1409 } |
| 1419 | 1410 |
| 1420 Representation representation() { | 1411 Representation representation() { |
| 1421 uint8_t repr = RepresentationBits::decode(sub_minor_key()); | 1412 uint8_t repr = RepresentationBits::decode(sub_minor_key()); |
| 1422 return PropertyDetails::DecodeRepresentation(repr); | 1413 return PropertyDetails::DecodeRepresentation(repr); |
| 1423 } | 1414 } |
| 1424 | 1415 |
| 1425 protected: | 1416 protected: |
| 1426 Code::Kind kind() const override { return Code::STORE_IC; } | 1417 Code::Kind kind() const override { return Code::STORE_IC; } |
| 1427 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1428 | 1418 |
| 1429 private: | 1419 private: |
| 1430 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | 1420 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1431 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; | 1421 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
| 1432 | 1422 |
| 1433 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); | 1423 DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); |
| 1434 }; | 1424 }; |
| 1435 | 1425 |
| 1436 | 1426 |
| 1437 // Register and parameter access methods are specified here instead of in | 1427 // Register and parameter access methods are specified here instead of in |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 } | 1517 } |
| 1528 | 1518 |
| 1529 StoreMode store_mode() const { | 1519 StoreMode store_mode() const { |
| 1530 return StoreModeBits::decode(sub_minor_key()); | 1520 return StoreModeBits::decode(sub_minor_key()); |
| 1531 } | 1521 } |
| 1532 | 1522 |
| 1533 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; | 1523 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; |
| 1534 | 1524 |
| 1535 protected: | 1525 protected: |
| 1536 Code::Kind kind() const override { return Code::STORE_IC; } | 1526 Code::Kind kind() const override { return Code::STORE_IC; } |
| 1537 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 1538 | 1527 |
| 1539 private: | 1528 private: |
| 1540 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | 1529 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1541 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; | 1530 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
| 1542 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; | 1531 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; |
| 1543 | 1532 |
| 1544 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); | 1533 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); |
| 1545 }; | 1534 }; |
| 1546 | 1535 |
| 1547 | 1536 |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2481 SlotIndexBits::is_valid(lookup_result->slot_index); | 2470 SlotIndexBits::is_valid(lookup_result->slot_index); |
| 2482 } | 2471 } |
| 2483 | 2472 |
| 2484 private: | 2473 private: |
| 2485 static const int kContextIndexBits = 9; | 2474 static const int kContextIndexBits = 9; |
| 2486 static const int kSlotIndexBits = 13; | 2475 static const int kSlotIndexBits = 13; |
| 2487 class ContextIndexBits : public BitField<int, 0, kContextIndexBits> {}; | 2476 class ContextIndexBits : public BitField<int, 0, kContextIndexBits> {}; |
| 2488 class SlotIndexBits | 2477 class SlotIndexBits |
| 2489 : public BitField<int, kContextIndexBits, kSlotIndexBits> {}; | 2478 : public BitField<int, kContextIndexBits, kSlotIndexBits> {}; |
| 2490 | 2479 |
| 2491 Code::StubType GetStubType() const override { return Code::FAST; } | |
| 2492 | |
| 2493 DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub); | 2480 DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub); |
| 2494 }; | 2481 }; |
| 2495 | 2482 |
| 2496 | 2483 |
| 2497 class LoadScriptContextFieldStub : public ScriptContextFieldStub { | 2484 class LoadScriptContextFieldStub : public ScriptContextFieldStub { |
| 2498 public: | 2485 public: |
| 2499 LoadScriptContextFieldStub( | 2486 LoadScriptContextFieldStub( |
| 2500 Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result) | 2487 Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result) |
| 2501 : ScriptContextFieldStub(isolate, lookup_result) {} | 2488 : ScriptContextFieldStub(isolate, lookup_result) {} |
| 2502 | 2489 |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 #undef DEFINE_HYDROGEN_CODE_STUB | 3081 #undef DEFINE_HYDROGEN_CODE_STUB |
| 3095 #undef DEFINE_CODE_STUB | 3082 #undef DEFINE_CODE_STUB |
| 3096 #undef DEFINE_CODE_STUB_BASE | 3083 #undef DEFINE_CODE_STUB_BASE |
| 3097 | 3084 |
| 3098 extern Representation RepresentationFromType(Type* type); | 3085 extern Representation RepresentationFromType(Type* type); |
| 3099 | 3086 |
| 3100 } // namespace internal | 3087 } // namespace internal |
| 3101 } // namespace v8 | 3088 } // namespace v8 |
| 3102 | 3089 |
| 3103 #endif // V8_CODE_STUBS_H_ | 3090 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |