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

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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 V(ArrayNoArgumentConstructor) \ 75 V(ArrayNoArgumentConstructor) \
76 V(ArraySingleArgumentConstructor) \ 76 V(ArraySingleArgumentConstructor) \
77 V(ArrayNArgumentsConstructor) \ 77 V(ArrayNArgumentsConstructor) \
78 V(KeyedStoreElement) \ 78 V(KeyedStoreElement) \
79 V(DebuggerStatement) \ 79 V(DebuggerStatement) \
80 V(NameDictionaryLookup) \ 80 V(NameDictionaryLookup) \
81 V(ElementsTransitionAndStore) \ 81 V(ElementsTransitionAndStore) \
82 V(TransitionElementsKind) \ 82 V(TransitionElementsKind) \
83 V(StoreArrayLiteralElement) \ 83 V(StoreArrayLiteralElement) \
84 V(StubFailureTrampoline) \ 84 V(StubFailureTrampoline) \
85 V(ArrayConstructor) \
85 V(ProfileEntryHook) \ 86 V(ProfileEntryHook) \
86 /* IC Handler stubs */ \ 87 /* IC Handler stubs */ \
87 V(LoadField) 88 V(LoadField)
88 89
89 // List of code stubs only used on ARM platforms. 90 // List of code stubs only used on ARM platforms.
90 #ifdef V8_TARGET_ARCH_ARM 91 #ifdef V8_TARGET_ARCH_ARM
91 #define CODE_STUB_LIST_ARM(V) \ 92 #define CODE_STUB_LIST_ARM(V) \
92 V(GetProperty) \ 93 V(GetProperty) \
93 V(SetProperty) \ 94 V(SetProperty) \
94 V(InvokeBuiltin) \ 95 V(InvokeBuiltin) \
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 virtual void Generate(MacroAssembler* masm) = 0; 258 virtual void Generate(MacroAssembler* masm) = 0;
258 }; 259 };
259 260
260 261
261 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; 262 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE };
262 263
263 struct CodeStubInterfaceDescriptor { 264 struct CodeStubInterfaceDescriptor {
264 CodeStubInterfaceDescriptor() 265 CodeStubInterfaceDescriptor()
265 : register_param_count_(-1), 266 : register_param_count_(-1),
266 stack_parameter_count_(NULL), 267 stack_parameter_count_(NULL),
268 hint_stack_parameter_count_(-1),
267 function_mode_(NOT_JS_FUNCTION_STUB_MODE), 269 function_mode_(NOT_JS_FUNCTION_STUB_MODE),
268 register_params_(NULL) { } 270 register_params_(NULL) { }
269 int register_param_count_; 271 int register_param_count_;
270 const Register* stack_parameter_count_; 272 const Register* stack_parameter_count_;
273 int hint_stack_parameter_count_;
271 StubFunctionMode function_mode_; 274 StubFunctionMode function_mode_;
272 Register* register_params_; 275 Register* register_params_;
273 Address deoptimization_handler_; 276 Address deoptimization_handler_;
274 277
275 int environment_length() const { 278 int environment_length() const {
276 if (stack_parameter_count_ != NULL) { 279 if (stack_parameter_count_ != NULL) {
277 return register_param_count_ + 1; 280 return register_param_count_ + 1;
278 } 281 }
279 return register_param_count_; 282 return register_param_count_;
280 } 283 }
284
285 bool initialized() const { return register_param_count_ >= 0; }
281 }; 286 };
282 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
283 295
284 class HydrogenCodeStub : public CodeStub { 296 class HydrogenCodeStub : public CodeStub {
285 public: 297 public:
286 // Retrieve the code for the stub. Generate the code if needed. 298 // Retrieve the code for the stub. Generate the code if needed.
287 virtual Handle<Code> GenerateCode() = 0; 299 virtual Handle<Code> GenerateCode() = 0;
288 300
289 virtual Code::Kind GetCodeKind() const { return Code::STUB; } 301 virtual Code::Kind GetCodeKind() const { return Code::STUB; }
290 302
291 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) { 303 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) {
292 return isolate->code_stub_interface_descriptor(MajorKey()); 304 return isolate->code_stub_interface_descriptor(MajorKey());
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 bool ReturnTrueFalseObject() const { 592 bool ReturnTrueFalseObject() const {
581 return (flags_ & kReturnTrueFalseObject) != 0; 593 return (flags_ & kReturnTrueFalseObject) != 0;
582 } 594 }
583 595
584 virtual void PrintName(StringStream* stream); 596 virtual void PrintName(StringStream* stream);
585 597
586 Flags flags_; 598 Flags flags_;
587 }; 599 };
588 600
589 601
602 class ArrayConstructorStub: public PlatformCodeStub {
603 public:
604 enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE };
605 explicit ArrayConstructorStub(Isolate* isolate, int argument_count);
606 explicit ArrayConstructorStub(Isolate* isolate);
607
608 void Generate(MacroAssembler* masm);
609
610 private:
611 virtual CodeStub::Major MajorKey() { return ArrayConstructor; }
612 virtual int MinorKey() { return argument_count_; }
613
614 ArgumentCountKey argument_count_;
615 };
616
617
590 class MathPowStub: public PlatformCodeStub { 618 class MathPowStub: public PlatformCodeStub {
591 public: 619 public:
592 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; 620 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK};
593 621
594 explicit MathPowStub(ExponentType exponent_type) 622 explicit MathPowStub(ExponentType exponent_type)
595 : exponent_type_(exponent_type) { } 623 : exponent_type_(exponent_type) { }
596 virtual void Generate(MacroAssembler* masm); 624 virtual void Generate(MacroAssembler* masm);
597 625
598 private: 626 private:
599 virtual CodeStub::Major MajorKey() { return MathPow; } 627 virtual CodeStub::Major MajorKey() { return MathPow; }
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 class ToKindBits: public BitField<ElementsKind, 0, 8> {}; 1430 class ToKindBits: public BitField<ElementsKind, 0, 8> {};
1403 uint32_t bit_field_; 1431 uint32_t bit_field_;
1404 1432
1405 Major MajorKey() { return TransitionElementsKind; } 1433 Major MajorKey() { return TransitionElementsKind; }
1406 int MinorKey() { return bit_field_; } 1434 int MinorKey() { return bit_field_; }
1407 1435
1408 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub); 1436 DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub);
1409 }; 1437 };
1410 1438
1411 1439
1412 class ArrayNoArgumentConstructorStub : public HydrogenCodeStub { 1440 class ArrayConstructorStubBase : public HydrogenCodeStub {
1413 public: 1441 public:
1414 ArrayNoArgumentConstructorStub() { 1442 ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode) {
1443 bit_field_ = ElementsKindBits::encode(kind) |
1444 AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
1445 }
1446
1447 int MinorKey() { return bit_field_; }
1448
1449 ElementsKind elements_kind() const {
1450 return ElementsKindBits::decode(bit_field_);
1451 }
1452
1453 AllocationSiteMode mode() const {
1454 return AllocationSiteModeBits::decode(bit_field_)
1455 ? TRACK_ALLOCATION_SITE
1456 : DONT_TRACK_ALLOCATION_SITE;
1457 }
1458
1459 virtual bool IsPregenerated() { return true; }
1460 static void GenerateStubsAheadOfTime(Isolate* isolate);
1461 static void InstallDescriptors(Isolate* isolate);
1462
1463 // Parameters accessed via CodeStubGraphBuilder::GetParameter()
1464 static const int kPropertyCell = 0;
1465
1466 private:
1467 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
1468 class AllocationSiteModeBits: public BitField<bool, 8, 1> {};
1469 uint32_t bit_field_;
1470
1471 DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase);
1472 };
1473
1474
1475 class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase {
1476 public:
1477 ArrayNoArgumentConstructorStub(
1478 ElementsKind kind,
1479 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
1480 ArrayConstructorStubBase(kind, mode) {
1415 } 1481 }
1416 1482
1417 Major MajorKey() { return ArrayNoArgumentConstructor; } 1483 Major MajorKey() { return ArrayNoArgumentConstructor; }
1418 int MinorKey() { return 0; }
1419 1484
1420 virtual Handle<Code> GenerateCode(); 1485 virtual Handle<Code> GenerateCode();
1421 1486
1422 virtual void InitializeInterfaceDescriptor( 1487 virtual void InitializeInterfaceDescriptor(
1423 Isolate* isolate, 1488 Isolate* isolate,
1424 CodeStubInterfaceDescriptor* descriptor); 1489 CodeStubInterfaceDescriptor* descriptor);
1425 1490
1426 private: 1491 private:
1427 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub); 1492 DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub);
1428 }; 1493 };
1429 1494
1430 1495
1431 class ArraySingleArgumentConstructorStub : public HydrogenCodeStub { 1496 class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase {
1432 public: 1497 public:
1433 ArraySingleArgumentConstructorStub() { 1498 ArraySingleArgumentConstructorStub(
1499 ElementsKind kind,
1500 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
1501 ArrayConstructorStubBase(kind, mode) {
1434 } 1502 }
1435 1503
1436 Major MajorKey() { return ArraySingleArgumentConstructor; } 1504 Major MajorKey() { return ArraySingleArgumentConstructor; }
1437 int MinorKey() { return 0; }
1438 1505
1439 virtual Handle<Code> GenerateCode(); 1506 virtual Handle<Code> GenerateCode();
1440 1507
1441 virtual void InitializeInterfaceDescriptor( 1508 virtual void InitializeInterfaceDescriptor(
1442 Isolate* isolate, 1509 Isolate* isolate,
1443 CodeStubInterfaceDescriptor* descriptor); 1510 CodeStubInterfaceDescriptor* descriptor);
1444 1511
1445 private: 1512 private:
1446 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub); 1513 DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub);
1447 }; 1514 };
1448 1515
1449 1516
1450 class ArrayNArgumentsConstructorStub : public HydrogenCodeStub { 1517 class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase {
1451 public: 1518 public:
1452 ArrayNArgumentsConstructorStub() { 1519 ArrayNArgumentsConstructorStub(
1520 ElementsKind kind,
1521 AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
1522 ArrayConstructorStubBase(kind, mode) {
1453 } 1523 }
1454 1524
1455 Major MajorKey() { return ArrayNArgumentsConstructor; } 1525 Major MajorKey() { return ArrayNArgumentsConstructor; }
1456 int MinorKey() { return 0; }
1457 1526
1458 virtual Handle<Code> GenerateCode(); 1527 virtual Handle<Code> GenerateCode();
1459 1528
1460 virtual void InitializeInterfaceDescriptor( 1529 virtual void InitializeInterfaceDescriptor(
1461 Isolate* isolate, 1530 Isolate* isolate,
1462 CodeStubInterfaceDescriptor* descriptor); 1531 CodeStubInterfaceDescriptor* descriptor);
1463 1532
1464 private: 1533 private:
1465 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); 1534 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub);
1466 }; 1535 };
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 1757
1689 // The current function entry hook. 1758 // The current function entry hook.
1690 static FunctionEntryHook entry_hook_; 1759 static FunctionEntryHook entry_hook_;
1691 1760
1692 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 1761 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
1693 }; 1762 };
1694 1763
1695 } } // namespace v8::internal 1764 } } // namespace v8::internal
1696 1765
1697 #endif // V8_CODE_STUBS_H_ 1766 #endif // V8_CODE_STUBS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698