Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: src/code-stubs.h

Issue 12385014: Hydrogen stubs for array constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 int hint_stack_parameter_count_;
269 StubFunctionMode function_mode_; 271 StubFunctionMode function_mode_;
270 Register* register_params_; 272 Register* register_params_;
271 Address deoptimization_handler_; 273 Address deoptimization_handler_;
272 ExternalReference miss_handler_; 274 ExternalReference miss_handler_;
273 275
274 int environment_length() const { 276 int environment_length() const {
275 if (stack_parameter_count_ != NULL) { 277 if (stack_parameter_count_ != NULL) {
276 return register_param_count_ + 1; 278 return register_param_count_ + 1;
277 } 279 }
278 return register_param_count_; 280 return register_param_count_;
279 } 281 }
282
283 bool initialized() const { return register_param_count_ >= 0; }
280 }; 284 };
281 285
286 // A helper to make up for the fact that type Register is not fully
287 // defined outside of the platform directories
288 #define DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index) \
289 ((index) == (descriptor)->register_param_count_) \
290 ? *((descriptor)->stack_parameter_count_) \
291 : (descriptor)->register_params_[(index)]
292
282 293
283 class HydrogenCodeStub : public CodeStub { 294 class HydrogenCodeStub : public CodeStub {
284 public: 295 public:
285 enum InitializationState { 296 enum InitializationState {
286 CODE_STUB_IS_NOT_MISS, 297 CODE_STUB_IS_NOT_MISS,
287 CODE_STUB_IS_MISS 298 CODE_STUB_IS_MISS
288 }; 299 };
289 300
290 explicit HydrogenCodeStub(InitializationState state) { 301 explicit HydrogenCodeStub(InitializationState state) {
291 is_miss_ = (state == CODE_STUB_IS_MISS); 302 is_miss_ = (state == CODE_STUB_IS_MISS);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 bool ReturnTrueFalseObject() const { 626 bool ReturnTrueFalseObject() const {
616 return (flags_ & kReturnTrueFalseObject) != 0; 627 return (flags_ & kReturnTrueFalseObject) != 0;
617 } 628 }
618 629
619 virtual void PrintName(StringStream* stream); 630 virtual void PrintName(StringStream* stream);
620 631
621 Flags flags_; 632 Flags flags_;
622 }; 633 };
623 634
624 635
636 class ArrayConstructorStub: public PlatformCodeStub {
637 public:
638 enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE };
639 explicit ArrayConstructorStub(Isolate* isolate, int argument_count);
Hannes Payer (out of office) 2013/04/23 11:42:50 explicit is just used in the single argument case
mvstanton 2013/04/23 14:19:58 Done.
640 explicit ArrayConstructorStub(Isolate* isolate);
641
642 void Generate(MacroAssembler* masm);
643
644 private:
645 virtual CodeStub::Major MajorKey() { return ArrayConstructor; }
646 virtual int MinorKey() { return argument_count_; }
647
648 ArgumentCountKey argument_count_;
649 };
650
651
625 class MathPowStub: public PlatformCodeStub { 652 class MathPowStub: public PlatformCodeStub {
626 public: 653 public:
627 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; 654 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK};
628 655
629 explicit MathPowStub(ExponentType exponent_type) 656 explicit MathPowStub(ExponentType exponent_type)
630 : exponent_type_(exponent_type) { } 657 : exponent_type_(exponent_type) { }
631 virtual void Generate(MacroAssembler* masm); 658 virtual void Generate(MacroAssembler* masm);
632 659
633 private: 660 private:
634 virtual CodeStub::Major MajorKey() { return MathPow; } 661 virtual CodeStub::Major MajorKey() { return MathPow; }
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 class ToKindBits: public BitField<ElementsKind, 0, 8> {}; 1467 class ToKindBits: public BitField<ElementsKind, 0, 8> {};
1441 uint32_t bit_field_; 1468 uint32_t bit_field_;
1442 1469
1443 Major MajorKey() { return TransitionElementsKind; } 1470 Major MajorKey() { return TransitionElementsKind; }
1444 int NotMissMinorKey() { return bit_field_; } 1471 int NotMissMinorKey() { return bit_field_; }
1445 1472
1446 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub); 1473 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub);
1447 }; 1474 };
1448 1475
1449 1476
1450 class ArrayNoArgumentConstructorStub : public HydrogenCodeStub { 1477 class ArrayConstructorStubBase : public HydrogenCodeStub {
1451 public: 1478 public:
1452 ArrayNoArgumentConstructorStub() 1479 ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode)
1453 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) { 1480 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
1481 bit_field_ = ElementsKindBits::encode(kind) |
1482 AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
1483 }
1484
1485 ElementsKind elements_kind() const {
1486 return ElementsKindBits::decode(bit_field_);
1487 }
1488
1489 AllocationSiteMode mode() const {
1490 return AllocationSiteModeBits::decode(bit_field_)
1491 ? TRACK_ALLOCATION_SITE
1492 : DONT_TRACK_ALLOCATION_SITE;
1493 }
1494
1495 virtual bool IsPregenerated() { return true; }
1496 static void GenerateStubsAheadOfTime(Isolate* isolate);
1497 static void InstallDescriptors(Isolate* isolate);
1498
1499 // Parameters accessed via CodeStubGraphBuilder::GetParameter()
1500 static const int kPropertyCell = 0;
1501
1502 private:
1503 int NotMissMinorKey() { return bit_field_; }
1504
1505 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
1506 class AllocationSiteModeBits: public BitField<bool, 8, 1> {};
1507 uint32_t bit_field_;
1508
1509 DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase);
1510 };
1511
1512
1513 class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase {
1514 public:
1515 ArrayNoArgumentConstructorStub(
1516 ElementsKind kind,
1517 AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
1518 : ArrayConstructorStubBase(kind, mode) {
1454 } 1519 }
1455 1520
1456 virtual Handle<Code> GenerateCode(); 1521 virtual Handle<Code> GenerateCode();
1457 1522
1458 virtual void InitializeInterfaceDescriptor( 1523 virtual void InitializeInterfaceDescriptor(
1459 Isolate* isolate, 1524 Isolate* isolate,
1460 CodeStubInterfaceDescriptor* descriptor); 1525 CodeStubInterfaceDescriptor* descriptor);
1461 1526
1462 private: 1527 private:
1463 Major MajorKey() { return ArrayNoArgumentConstructor; } 1528 Major MajorKey() { return ArrayNoArgumentConstructor; }
1464 int NotMissMinorKey() { return 0; }
1465 1529
1466 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub); 1530 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub);
1467 }; 1531 };
1468 1532
1469 1533
1470 class ArraySingleArgumentConstructorStub : public HydrogenCodeStub { 1534 class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase {
1471 public: 1535 public:
1472 ArraySingleArgumentConstructorStub() 1536 ArraySingleArgumentConstructorStub(
1473 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {} 1537 ElementsKind kind,
1538 AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
1539 : ArrayConstructorStubBase(kind, mode) {
1540 }
1474 1541
1475 virtual Handle<Code> GenerateCode(); 1542 virtual Handle<Code> GenerateCode();
1476 1543
1477 virtual void InitializeInterfaceDescriptor( 1544 virtual void InitializeInterfaceDescriptor(
1478 Isolate* isolate, 1545 Isolate* isolate,
1479 CodeStubInterfaceDescriptor* descriptor); 1546 CodeStubInterfaceDescriptor* descriptor);
1480 1547
1481 private: 1548 private:
1482 Major MajorKey() { return ArraySingleArgumentConstructor; } 1549 Major MajorKey() { return ArraySingleArgumentConstructor; }
1483 int NotMissMinorKey() { return 0; }
1484 1550
1485 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub); 1551 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub);
1486 }; 1552 };
1487 1553
1488 1554
1489 class ArrayNArgumentsConstructorStub : public HydrogenCodeStub { 1555 class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase {
1490 public: 1556 public:
1491 ArrayNArgumentsConstructorStub() 1557 ArrayNArgumentsConstructorStub(
1492 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {} 1558 ElementsKind kind,
1559 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
1560 ArrayConstructorStubBase(kind, mode) {
1561 }
1493 1562
1494 virtual Handle<Code> GenerateCode(); 1563 virtual Handle<Code> GenerateCode();
1495 1564
1496 virtual void InitializeInterfaceDescriptor( 1565 virtual void InitializeInterfaceDescriptor(
1497 Isolate* isolate, 1566 Isolate* isolate,
1498 CodeStubInterfaceDescriptor* descriptor); 1567 CodeStubInterfaceDescriptor* descriptor);
1499 1568
1500 private: 1569 private:
1501 Major MajorKey() { return ArrayNArgumentsConstructor; } 1570 Major MajorKey() { return ArrayNArgumentsConstructor; }
1502 int NotMissMinorKey() { return 0; }
1503 1571
1504 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); 1572 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub);
1505 }; 1573 };
1506 1574
1507 1575
1508 class KeyedStoreElementStub : public PlatformCodeStub { 1576 class KeyedStoreElementStub : public PlatformCodeStub {
1509 public: 1577 public:
1510 KeyedStoreElementStub(bool is_js_array, 1578 KeyedStoreElementStub(bool is_js_array,
1511 ElementsKind elements_kind, 1579 ElementsKind elements_kind,
1512 KeyedAccessStoreMode store_mode) 1580 KeyedAccessStoreMode store_mode)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1795
1728 // The current function entry hook. 1796 // The current function entry hook.
1729 static FunctionEntryHook entry_hook_; 1797 static FunctionEntryHook entry_hook_;
1730 1798
1731 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 1799 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
1732 }; 1800 };
1733 1801
1734 } } // namespace v8::internal 1802 } } // namespace v8::internal
1735 1803
1736 #endif // V8_CODE_STUBS_H_ 1804 #endif // V8_CODE_STUBS_H_
OLDNEW
« src/arm/lithium-codegen-arm.cc ('K') | « src/builtins.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698