| 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 23 matching lines...) Expand all Loading... |
| 34 V(CallApiCallback) \ | 34 V(CallApiCallback) \ |
| 35 V(CallApiGetter) \ | 35 V(CallApiGetter) \ |
| 36 V(CallConstruct) \ | 36 V(CallConstruct) \ |
| 37 V(CallIC) \ | 37 V(CallIC) \ |
| 38 V(CEntry) \ | 38 V(CEntry) \ |
| 39 V(CompareIC) \ | 39 V(CompareIC) \ |
| 40 V(DoubleToI) \ | 40 V(DoubleToI) \ |
| 41 V(FunctionPrototype) \ | 41 V(FunctionPrototype) \ |
| 42 V(InternalArrayConstructor) \ | 42 V(InternalArrayConstructor) \ |
| 43 V(JSEntry) \ | 43 V(JSEntry) \ |
| 44 V(LoadIndexedString) \ | |
| 45 V(MathPow) \ | 44 V(MathPow) \ |
| 46 V(ProfileEntryHook) \ | 45 V(ProfileEntryHook) \ |
| 47 V(RecordWrite) \ | 46 V(RecordWrite) \ |
| 48 V(RegExpExec) \ | 47 V(RegExpExec) \ |
| 49 V(StoreBufferOverflow) \ | 48 V(StoreBufferOverflow) \ |
| 50 V(StoreSlowElement) \ | 49 V(StoreSlowElement) \ |
| 51 V(SubString) \ | 50 V(SubString) \ |
| 52 V(NameDictionaryLookup) \ | 51 V(NameDictionaryLookup) \ |
| 53 /* This can be removed once there are no */ \ | 52 /* This can be removed once there are no */ \ |
| 54 /* more deopting Hydrogen stubs. */ \ | 53 /* more deopting Hydrogen stubs. */ \ |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 // TODO(mvstanton): only the receiver register is accessed. When this is | 885 // TODO(mvstanton): only the receiver register is accessed. When this is |
| 887 // translated to a hydrogen code stub, a new CallInterfaceDescriptor | 886 // translated to a hydrogen code stub, a new CallInterfaceDescriptor |
| 888 // should be created that just uses that register for more efficient code. | 887 // should be created that just uses that register for more efficient code. |
| 889 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { | 888 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 890 return LoadWithVectorDescriptor(isolate()); | 889 return LoadWithVectorDescriptor(isolate()); |
| 891 } | 890 } |
| 892 | 891 |
| 893 DEFINE_PLATFORM_CODE_STUB(FunctionPrototype, PlatformCodeStub); | 892 DEFINE_PLATFORM_CODE_STUB(FunctionPrototype, PlatformCodeStub); |
| 894 }; | 893 }; |
| 895 | 894 |
| 896 | |
| 897 class LoadIndexedStringStub : public PlatformCodeStub { | |
| 898 public: | |
| 899 explicit LoadIndexedStringStub(Isolate* isolate) | |
| 900 : PlatformCodeStub(isolate) {} | |
| 901 | |
| 902 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | |
| 903 ExtraICState GetExtraICState() const override { return Code::KEYED_LOAD_IC; } | |
| 904 | |
| 905 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); | |
| 906 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub); | |
| 907 }; | |
| 908 | |
| 909 class KeyedLoadSloppyArgumentsStub : public TurboFanCodeStub { | 895 class KeyedLoadSloppyArgumentsStub : public TurboFanCodeStub { |
| 910 public: | 896 public: |
| 911 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) | 897 explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) |
| 912 : TurboFanCodeStub(isolate) {} | 898 : TurboFanCodeStub(isolate) {} |
| 913 | 899 |
| 914 Code::Kind GetCodeKind() const override { return Code::HANDLER; } | 900 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 915 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } | 901 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
| 916 | 902 |
| 917 protected: | 903 protected: |
| 918 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); | 904 DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 // Generates the fast case code. On the fallthrough path |result| | 1362 // Generates the fast case code. On the fallthrough path |result| |
| 1377 // register contains the result. | 1363 // register contains the result. |
| 1378 void GenerateFast(MacroAssembler* masm); | 1364 void GenerateFast(MacroAssembler* masm); |
| 1379 | 1365 |
| 1380 // Generates the slow case code. Must not be naturally | 1366 // Generates the slow case code. Must not be naturally |
| 1381 // reachable. Expected to be put after a ret instruction (e.g., in | 1367 // reachable. Expected to be put after a ret instruction (e.g., in |
| 1382 // deferred code). Always jumps back to the fast case. | 1368 // deferred code). Always jumps back to the fast case. |
| 1383 void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, | 1369 void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, |
| 1384 const RuntimeCallHelper& call_helper); | 1370 const RuntimeCallHelper& call_helper); |
| 1385 | 1371 |
| 1386 // Skip handling slow case and directly jump to bailout. | |
| 1387 void SkipSlow(MacroAssembler* masm, Label* bailout) { | |
| 1388 masm->bind(&index_not_smi_); | |
| 1389 masm->bind(&call_runtime_); | |
| 1390 masm->jmp(bailout); | |
| 1391 } | |
| 1392 | |
| 1393 private: | 1372 private: |
| 1394 Register object_; | 1373 Register object_; |
| 1395 Register index_; | 1374 Register index_; |
| 1396 Register result_; | 1375 Register result_; |
| 1397 | 1376 |
| 1398 Label* receiver_not_string_; | 1377 Label* receiver_not_string_; |
| 1399 Label* index_not_number_; | 1378 Label* index_not_number_; |
| 1400 Label* index_out_of_range_; | 1379 Label* index_out_of_range_; |
| 1401 | 1380 |
| 1402 ReceiverCheckMode check_mode_; | 1381 ReceiverCheckMode check_mode_; |
| 1403 | 1382 |
| 1404 Label call_runtime_; | 1383 Label call_runtime_; |
| 1405 Label index_not_smi_; | 1384 Label index_not_smi_; |
| 1406 Label got_smi_index_; | 1385 Label got_smi_index_; |
| 1407 Label exit_; | 1386 Label exit_; |
| 1408 | 1387 |
| 1409 DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); | 1388 DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); |
| 1410 }; | 1389 }; |
| 1411 | 1390 |
| 1412 | |
| 1413 // Generates code for creating a one-char string from a char code. | |
| 1414 class StringCharFromCodeGenerator { | |
| 1415 public: | |
| 1416 StringCharFromCodeGenerator(Register code, | |
| 1417 Register result) | |
| 1418 : code_(code), | |
| 1419 result_(result) { | |
| 1420 DCHECK(!code_.is(result_)); | |
| 1421 } | |
| 1422 | |
| 1423 // Generates the fast case code. On the fallthrough path |result| | |
| 1424 // register contains the result. | |
| 1425 void GenerateFast(MacroAssembler* masm); | |
| 1426 | |
| 1427 // Generates the slow case code. Must not be naturally | |
| 1428 // reachable. Expected to be put after a ret instruction (e.g., in | |
| 1429 // deferred code). Always jumps back to the fast case. | |
| 1430 void GenerateSlow(MacroAssembler* masm, | |
| 1431 const RuntimeCallHelper& call_helper); | |
| 1432 | |
| 1433 // Skip handling slow case and directly jump to bailout. | |
| 1434 void SkipSlow(MacroAssembler* masm, Label* bailout) { | |
| 1435 masm->bind(&slow_case_); | |
| 1436 masm->jmp(bailout); | |
| 1437 } | |
| 1438 | |
| 1439 private: | |
| 1440 Register code_; | |
| 1441 Register result_; | |
| 1442 | |
| 1443 Label slow_case_; | |
| 1444 Label exit_; | |
| 1445 | |
| 1446 DISALLOW_COPY_AND_ASSIGN(StringCharFromCodeGenerator); | |
| 1447 }; | |
| 1448 | |
| 1449 | |
| 1450 // Generates code implementing String.prototype.charAt. | |
| 1451 // | |
| 1452 // Only supports the case when the receiver is a string and the index | |
| 1453 // is a number (smi or heap number) that is a valid index into the | |
| 1454 // string. Additional index constraints are specified by the | |
| 1455 // flags. Otherwise, bails out to the provided labels. | |
| 1456 // | |
| 1457 // Register usage: |object| may be changed to another string in a way | |
| 1458 // that doesn't affect charCodeAt/charAt semantics, |index| is | |
| 1459 // preserved, |scratch1|, |scratch2|, and |result| are clobbered. | |
| 1460 class StringCharAtGenerator { | |
| 1461 public: | |
| 1462 StringCharAtGenerator(Register object, Register index, Register scratch, | |
| 1463 Register result, Label* receiver_not_string, | |
| 1464 Label* index_not_number, Label* index_out_of_range, | |
| 1465 ReceiverCheckMode check_mode = RECEIVER_IS_UNKNOWN) | |
| 1466 : char_code_at_generator_(object, index, scratch, receiver_not_string, | |
| 1467 index_not_number, index_out_of_range, | |
| 1468 check_mode), | |
| 1469 char_from_code_generator_(scratch, result) {} | |
| 1470 | |
| 1471 // Generates the fast case code. On the fallthrough path |result| | |
| 1472 // register contains the result. | |
| 1473 void GenerateFast(MacroAssembler* masm) { | |
| 1474 char_code_at_generator_.GenerateFast(masm); | |
| 1475 char_from_code_generator_.GenerateFast(masm); | |
| 1476 } | |
| 1477 | |
| 1478 // Generates the slow case code. Must not be naturally | |
| 1479 // reachable. Expected to be put after a ret instruction (e.g., in | |
| 1480 // deferred code). Always jumps back to the fast case. | |
| 1481 void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, | |
| 1482 const RuntimeCallHelper& call_helper) { | |
| 1483 char_code_at_generator_.GenerateSlow(masm, embed_mode, call_helper); | |
| 1484 char_from_code_generator_.GenerateSlow(masm, call_helper); | |
| 1485 } | |
| 1486 | |
| 1487 // Skip handling slow case and directly jump to bailout. | |
| 1488 void SkipSlow(MacroAssembler* masm, Label* bailout) { | |
| 1489 char_code_at_generator_.SkipSlow(masm, bailout); | |
| 1490 char_from_code_generator_.SkipSlow(masm, bailout); | |
| 1491 } | |
| 1492 | |
| 1493 private: | |
| 1494 StringCharCodeAtGenerator char_code_at_generator_; | |
| 1495 StringCharFromCodeGenerator char_from_code_generator_; | |
| 1496 | |
| 1497 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | |
| 1498 }; | |
| 1499 | |
| 1500 class CallICTrampolineStub : public TurboFanCodeStub { | 1391 class CallICTrampolineStub : public TurboFanCodeStub { |
| 1501 public: | 1392 public: |
| 1502 CallICTrampolineStub(Isolate* isolate, ConvertReceiverMode convert_mode, | 1393 CallICTrampolineStub(Isolate* isolate, ConvertReceiverMode convert_mode, |
| 1503 TailCallMode tail_call_mode) | 1394 TailCallMode tail_call_mode) |
| 1504 : TurboFanCodeStub(isolate) { | 1395 : TurboFanCodeStub(isolate) { |
| 1505 minor_key_ = ConvertModeBits::encode(convert_mode) | | 1396 minor_key_ = ConvertModeBits::encode(convert_mode) | |
| 1506 TailCallModeBits::encode(tail_call_mode); | 1397 TailCallModeBits::encode(tail_call_mode); |
| 1507 } | 1398 } |
| 1508 | 1399 |
| 1509 protected: | 1400 protected: |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 #undef DEFINE_PLATFORM_CODE_STUB | 1895 #undef DEFINE_PLATFORM_CODE_STUB |
| 2005 #undef DEFINE_HANDLER_CODE_STUB | 1896 #undef DEFINE_HANDLER_CODE_STUB |
| 2006 #undef DEFINE_HYDROGEN_CODE_STUB | 1897 #undef DEFINE_HYDROGEN_CODE_STUB |
| 2007 #undef DEFINE_CODE_STUB | 1898 #undef DEFINE_CODE_STUB |
| 2008 #undef DEFINE_CODE_STUB_BASE | 1899 #undef DEFINE_CODE_STUB_BASE |
| 2009 | 1900 |
| 2010 } // namespace internal | 1901 } // namespace internal |
| 2011 } // namespace v8 | 1902 } // namespace v8 |
| 2012 | 1903 |
| 2013 #endif // V8_CODE_STUBS_H_ | 1904 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |