OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 V(ArrayNoArgumentConstructor) \ | 76 V(ArrayNoArgumentConstructor) \ |
77 V(ArraySingleArgumentConstructor) \ | 77 V(ArraySingleArgumentConstructor) \ |
78 V(ArrayNArgumentsConstructor) \ | 78 V(ArrayNArgumentsConstructor) \ |
79 V(KeyedStoreElement) \ | 79 V(KeyedStoreElement) \ |
80 V(DebuggerStatement) \ | 80 V(DebuggerStatement) \ |
81 V(NameDictionaryLookup) \ | 81 V(NameDictionaryLookup) \ |
82 V(ElementsTransitionAndStore) \ | 82 V(ElementsTransitionAndStore) \ |
83 V(TransitionElementsKind) \ | 83 V(TransitionElementsKind) \ |
84 V(StoreArrayLiteralElement) \ | 84 V(StoreArrayLiteralElement) \ |
85 V(StubFailureTrampoline) \ | 85 V(StubFailureTrampoline) \ |
| 86 V(ArrayConstructor) \ |
86 V(ProfileEntryHook) \ | 87 V(ProfileEntryHook) \ |
87 /* IC Handler stubs */ \ | 88 /* IC Handler stubs */ \ |
88 V(LoadField) | 89 V(LoadField) |
89 | 90 |
90 // List of code stubs only used on ARM platforms. | 91 // List of code stubs only used on ARM platforms. |
91 #ifdef V8_TARGET_ARCH_ARM | 92 #ifdef V8_TARGET_ARCH_ARM |
92 #define CODE_STUB_LIST_ARM(V) \ | 93 #define CODE_STUB_LIST_ARM(V) \ |
93 V(GetProperty) \ | 94 V(GetProperty) \ |
94 V(SetProperty) \ | 95 V(SetProperty) \ |
95 V(InvokeBuiltin) \ | 96 V(InvokeBuiltin) \ |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 }; | 260 }; |
260 | 261 |
261 | 262 |
262 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 263 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
263 | 264 |
264 | 265 |
265 struct CodeStubInterfaceDescriptor { | 266 struct CodeStubInterfaceDescriptor { |
266 CodeStubInterfaceDescriptor(); | 267 CodeStubInterfaceDescriptor(); |
267 int register_param_count_; | 268 int register_param_count_; |
268 const Register* stack_parameter_count_; | 269 const Register* stack_parameter_count_; |
| 270 // if hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 271 // return sequence. Default value is -1, which means it is ignored. |
| 272 int hint_stack_parameter_count_; |
269 StubFunctionMode function_mode_; | 273 StubFunctionMode function_mode_; |
270 Register* register_params_; | 274 Register* register_params_; |
271 Address deoptimization_handler_; | 275 Address deoptimization_handler_; |
272 ExternalReference miss_handler_; | 276 ExternalReference miss_handler_; |
273 | 277 |
274 int environment_length() const { | 278 int environment_length() const { |
275 if (stack_parameter_count_ != NULL) { | 279 if (stack_parameter_count_ != NULL) { |
276 return register_param_count_ + 1; | 280 return register_param_count_ + 1; |
277 } | 281 } |
278 return register_param_count_; | 282 return register_param_count_; |
279 } | 283 } |
| 284 |
| 285 bool initialized() const { return register_param_count_ >= 0; } |
280 }; | 286 }; |
281 | 287 |
| 288 // A helper to make up for the fact that type Register is not fully |
| 289 // defined outside of the platform directories |
| 290 #define DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index) \ |
| 291 ((index) == (descriptor)->register_param_count_) \ |
| 292 ? *((descriptor)->stack_parameter_count_) \ |
| 293 : (descriptor)->register_params_[(index)] |
| 294 |
282 | 295 |
283 class HydrogenCodeStub : public CodeStub { | 296 class HydrogenCodeStub : public CodeStub { |
284 public: | 297 public: |
285 enum InitializationState { | 298 enum InitializationState { |
286 CODE_STUB_IS_NOT_MISS, | 299 CODE_STUB_IS_NOT_MISS, |
287 CODE_STUB_IS_MISS | 300 CODE_STUB_IS_MISS |
288 }; | 301 }; |
289 | 302 |
290 explicit HydrogenCodeStub(InitializationState state) { | 303 explicit HydrogenCodeStub(InitializationState state) { |
291 is_miss_ = (state == CODE_STUB_IS_MISS); | 304 is_miss_ = (state == CODE_STUB_IS_MISS); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 bool ReturnTrueFalseObject() const { | 628 bool ReturnTrueFalseObject() const { |
616 return (flags_ & kReturnTrueFalseObject) != 0; | 629 return (flags_ & kReturnTrueFalseObject) != 0; |
617 } | 630 } |
618 | 631 |
619 virtual void PrintName(StringStream* stream); | 632 virtual void PrintName(StringStream* stream); |
620 | 633 |
621 Flags flags_; | 634 Flags flags_; |
622 }; | 635 }; |
623 | 636 |
624 | 637 |
| 638 class ArrayConstructorStub: public PlatformCodeStub { |
| 639 public: |
| 640 enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE }; |
| 641 ArrayConstructorStub(Isolate* isolate, int argument_count); |
| 642 explicit ArrayConstructorStub(Isolate* isolate); |
| 643 |
| 644 void Generate(MacroAssembler* masm); |
| 645 |
| 646 private: |
| 647 virtual CodeStub::Major MajorKey() { return ArrayConstructor; } |
| 648 virtual int MinorKey() { return argument_count_; } |
| 649 |
| 650 ArgumentCountKey argument_count_; |
| 651 }; |
| 652 |
| 653 |
625 class MathPowStub: public PlatformCodeStub { | 654 class MathPowStub: public PlatformCodeStub { |
626 public: | 655 public: |
627 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; | 656 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; |
628 | 657 |
629 explicit MathPowStub(ExponentType exponent_type) | 658 explicit MathPowStub(ExponentType exponent_type) |
630 : exponent_type_(exponent_type) { } | 659 : exponent_type_(exponent_type) { } |
631 virtual void Generate(MacroAssembler* masm); | 660 virtual void Generate(MacroAssembler* masm); |
632 | 661 |
633 private: | 662 private: |
634 virtual CodeStub::Major MajorKey() { return MathPow; } | 663 virtual CodeStub::Major MajorKey() { return MathPow; } |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 class ToKindBits: public BitField<ElementsKind, 0, 8> {}; | 1469 class ToKindBits: public BitField<ElementsKind, 0, 8> {}; |
1441 uint32_t bit_field_; | 1470 uint32_t bit_field_; |
1442 | 1471 |
1443 Major MajorKey() { return TransitionElementsKind; } | 1472 Major MajorKey() { return TransitionElementsKind; } |
1444 int NotMissMinorKey() { return bit_field_; } | 1473 int NotMissMinorKey() { return bit_field_; } |
1445 | 1474 |
1446 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub); | 1475 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub); |
1447 }; | 1476 }; |
1448 | 1477 |
1449 | 1478 |
1450 class ArrayNoArgumentConstructorStub : public HydrogenCodeStub { | 1479 class ArrayConstructorStubBase : public HydrogenCodeStub { |
1451 public: | 1480 public: |
1452 ArrayNoArgumentConstructorStub() | 1481 ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode) |
1453 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) { | 1482 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) { |
| 1483 bit_field_ = ElementsKindBits::encode(kind) | |
| 1484 AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE); |
| 1485 } |
| 1486 |
| 1487 ElementsKind elements_kind() const { |
| 1488 return ElementsKindBits::decode(bit_field_); |
| 1489 } |
| 1490 |
| 1491 AllocationSiteMode mode() const { |
| 1492 return AllocationSiteModeBits::decode(bit_field_) |
| 1493 ? TRACK_ALLOCATION_SITE |
| 1494 : DONT_TRACK_ALLOCATION_SITE; |
| 1495 } |
| 1496 |
| 1497 virtual bool IsPregenerated() { return true; } |
| 1498 static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 1499 static void InstallDescriptors(Isolate* isolate); |
| 1500 |
| 1501 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1502 static const int kPropertyCell = 0; |
| 1503 |
| 1504 private: |
| 1505 int NotMissMinorKey() { return bit_field_; } |
| 1506 |
| 1507 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 1508 class AllocationSiteModeBits: public BitField<bool, 8, 1> {}; |
| 1509 uint32_t bit_field_; |
| 1510 |
| 1511 DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase); |
| 1512 }; |
| 1513 |
| 1514 |
| 1515 class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase { |
| 1516 public: |
| 1517 ArrayNoArgumentConstructorStub( |
| 1518 ElementsKind kind, |
| 1519 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) |
| 1520 : ArrayConstructorStubBase(kind, mode) { |
1454 } | 1521 } |
1455 | 1522 |
1456 virtual Handle<Code> GenerateCode(); | 1523 virtual Handle<Code> GenerateCode(); |
1457 | 1524 |
1458 virtual void InitializeInterfaceDescriptor( | 1525 virtual void InitializeInterfaceDescriptor( |
1459 Isolate* isolate, | 1526 Isolate* isolate, |
1460 CodeStubInterfaceDescriptor* descriptor); | 1527 CodeStubInterfaceDescriptor* descriptor); |
1461 | 1528 |
1462 private: | 1529 private: |
1463 Major MajorKey() { return ArrayNoArgumentConstructor; } | 1530 Major MajorKey() { return ArrayNoArgumentConstructor; } |
1464 int NotMissMinorKey() { return 0; } | |
1465 | 1531 |
1466 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub); | 1532 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub); |
1467 }; | 1533 }; |
1468 | 1534 |
1469 | 1535 |
1470 class ArraySingleArgumentConstructorStub : public HydrogenCodeStub { | 1536 class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase { |
1471 public: | 1537 public: |
1472 ArraySingleArgumentConstructorStub() | 1538 ArraySingleArgumentConstructorStub( |
1473 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {} | 1539 ElementsKind kind, |
| 1540 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) |
| 1541 : ArrayConstructorStubBase(kind, mode) { |
| 1542 } |
1474 | 1543 |
1475 virtual Handle<Code> GenerateCode(); | 1544 virtual Handle<Code> GenerateCode(); |
1476 | 1545 |
1477 virtual void InitializeInterfaceDescriptor( | 1546 virtual void InitializeInterfaceDescriptor( |
1478 Isolate* isolate, | 1547 Isolate* isolate, |
1479 CodeStubInterfaceDescriptor* descriptor); | 1548 CodeStubInterfaceDescriptor* descriptor); |
1480 | 1549 |
1481 private: | 1550 private: |
1482 Major MajorKey() { return ArraySingleArgumentConstructor; } | 1551 Major MajorKey() { return ArraySingleArgumentConstructor; } |
1483 int NotMissMinorKey() { return 0; } | |
1484 | 1552 |
1485 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub); | 1553 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub); |
1486 }; | 1554 }; |
1487 | 1555 |
1488 | 1556 |
1489 class ArrayNArgumentsConstructorStub : public HydrogenCodeStub { | 1557 class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase { |
1490 public: | 1558 public: |
1491 ArrayNArgumentsConstructorStub() | 1559 ArrayNArgumentsConstructorStub( |
1492 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {} | 1560 ElementsKind kind, |
| 1561 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) : |
| 1562 ArrayConstructorStubBase(kind, mode) { |
| 1563 } |
1493 | 1564 |
1494 virtual Handle<Code> GenerateCode(); | 1565 virtual Handle<Code> GenerateCode(); |
1495 | 1566 |
1496 virtual void InitializeInterfaceDescriptor( | 1567 virtual void InitializeInterfaceDescriptor( |
1497 Isolate* isolate, | 1568 Isolate* isolate, |
1498 CodeStubInterfaceDescriptor* descriptor); | 1569 CodeStubInterfaceDescriptor* descriptor); |
1499 | 1570 |
1500 private: | 1571 private: |
1501 Major MajorKey() { return ArrayNArgumentsConstructor; } | 1572 Major MajorKey() { return ArrayNArgumentsConstructor; } |
1502 int NotMissMinorKey() { return 0; } | |
1503 | 1573 |
1504 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); | 1574 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); |
1505 }; | 1575 }; |
1506 | 1576 |
1507 | 1577 |
1508 class KeyedStoreElementStub : public PlatformCodeStub { | 1578 class KeyedStoreElementStub : public PlatformCodeStub { |
1509 public: | 1579 public: |
1510 KeyedStoreElementStub(bool is_js_array, | 1580 KeyedStoreElementStub(bool is_js_array, |
1511 ElementsKind elements_kind, | 1581 ElementsKind elements_kind, |
1512 KeyedAccessStoreMode store_mode) | 1582 KeyedAccessStoreMode store_mode) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 | 1797 |
1728 // The current function entry hook. | 1798 // The current function entry hook. |
1729 static FunctionEntryHook entry_hook_; | 1799 static FunctionEntryHook entry_hook_; |
1730 | 1800 |
1731 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 1801 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
1732 }; | 1802 }; |
1733 | 1803 |
1734 } } // namespace v8::internal | 1804 } } // namespace v8::internal |
1735 | 1805 |
1736 #endif // V8_CODE_STUBS_H_ | 1806 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |