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