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" |
11 #include "src/compiler/code-stub-assembler.h" | 11 #include "src/compiler/code-stub-assembler.h" |
12 #include "src/globals.h" | 12 #include "src/globals.h" |
13 #include "src/ic/ic-state.h" | 13 #include "src/ic/ic-state.h" |
14 #include "src/interface-descriptors.h" | 14 #include "src/interface-descriptors.h" |
15 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
16 #include "src/ostreams.h" | 16 #include "src/ostreams.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 // List of code stubs used on all platforms. | 21 // List of code stubs used on all platforms. |
22 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 22 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
23 /* PlatformCodeStubs */ \ | 23 /* PlatformCodeStubs */ \ |
24 V(ArrayConstructor) \ | 24 V(ArrayConstructor) \ |
25 V(BinaryOpICWithAllocationSite) \ | 25 V(BinaryOpICWithAllocationSite) \ |
26 V(CallApiCallback) \ | 26 V(CallApiFunction) \ |
| 27 V(CallApiAccessor) \ |
27 V(CallApiGetter) \ | 28 V(CallApiGetter) \ |
28 V(CallConstruct) \ | 29 V(CallConstruct) \ |
29 V(CallIC) \ | 30 V(CallIC) \ |
30 V(CEntry) \ | 31 V(CEntry) \ |
31 V(CompareIC) \ | 32 V(CompareIC) \ |
32 V(DoubleToI) \ | 33 V(DoubleToI) \ |
33 V(FunctionPrototype) \ | 34 V(FunctionPrototype) \ |
34 V(InstanceOf) \ | 35 V(InstanceOf) \ |
35 V(InternalArrayConstructor) \ | 36 V(InternalArrayConstructor) \ |
36 V(JSEntry) \ | 37 V(JSEntry) \ |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 private: | 1526 private: |
1526 class DepthBits : public BitField<int, 0, 4> {}; | 1527 class DepthBits : public BitField<int, 0, 4> {}; |
1527 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); | 1528 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); |
1528 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; | 1529 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; |
1529 STATIC_ASSERT(LANGUAGE_END == 3); | 1530 STATIC_ASSERT(LANGUAGE_END == 3); |
1530 | 1531 |
1531 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); | 1532 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); |
1532 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); | 1533 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); |
1533 }; | 1534 }; |
1534 | 1535 |
1535 class CallApiCallbackStub : public PlatformCodeStub { | 1536 |
| 1537 class CallApiFunctionStub : public PlatformCodeStub { |
1536 public: | 1538 public: |
1537 static const int kArgBits = 3; | 1539 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) |
1538 static const int kArgMax = (1 << kArgBits) - 1; | 1540 : PlatformCodeStub(isolate) { |
1539 | 1541 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); |
1540 // CallApiCallbackStub for regular setters and getters. | |
1541 CallApiCallbackStub(Isolate* isolate, bool is_store, bool call_data_undefined, | |
1542 bool is_lazy) | |
1543 : CallApiCallbackStub(isolate, is_store ? 1 : 0, is_store, | |
1544 call_data_undefined, is_lazy) {} | |
1545 | |
1546 // CallApiCallbackStub for callback functions. | |
1547 CallApiCallbackStub(Isolate* isolate, int argc, bool call_data_undefined) | |
1548 : CallApiCallbackStub(isolate, argc, false, call_data_undefined, false) {} | |
1549 | |
1550 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { | |
1551 return ApiCallbackDescriptorBase::ForArgs(isolate(), argc()); | |
1552 } | 1542 } |
1553 | 1543 |
1554 private: | 1544 private: |
1555 CallApiCallbackStub(Isolate* isolate, int argc, bool is_store, | 1545 bool call_data_undefined() const { |
1556 bool call_data_undefined, bool is_lazy) | 1546 return CallDataUndefinedBits::decode(minor_key_); |
| 1547 } |
| 1548 |
| 1549 class CallDataUndefinedBits : public BitField<bool, 0, 1> {}; |
| 1550 |
| 1551 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiFunction); |
| 1552 DEFINE_PLATFORM_CODE_STUB(CallApiFunction, PlatformCodeStub); |
| 1553 }; |
| 1554 |
| 1555 |
| 1556 class CallApiAccessorStub : public PlatformCodeStub { |
| 1557 public: |
| 1558 CallApiAccessorStub(Isolate* isolate, bool is_store, bool call_data_undefined, |
| 1559 bool is_lazy) |
1557 : PlatformCodeStub(isolate) { | 1560 : PlatformCodeStub(isolate) { |
1558 CHECK(0 <= argc && argc <= kArgMax); | |
1559 minor_key_ = IsStoreBits::encode(is_store) | | 1561 minor_key_ = IsStoreBits::encode(is_store) | |
1560 CallDataUndefinedBits::encode(call_data_undefined) | | 1562 CallDataUndefinedBits::encode(call_data_undefined) | |
1561 ArgumentBits::encode(argc) | | 1563 ArgumentBits::encode(is_store ? 1 : 0) | |
1562 IsLazyAccessorBits::encode(is_lazy); | 1564 IsLazyAccessorBits::encode(is_lazy); |
1563 } | 1565 } |
1564 | 1566 |
| 1567 protected: |
| 1568 // For CallApiFunctionWithFixedArgsStub, see below. |
| 1569 static const int kArgBits = 3; |
| 1570 CallApiAccessorStub(Isolate* isolate, int argc, bool call_data_undefined) |
| 1571 : PlatformCodeStub(isolate) { |
| 1572 minor_key_ = IsStoreBits::encode(false) | |
| 1573 CallDataUndefinedBits::encode(call_data_undefined) | |
| 1574 ArgumentBits::encode(argc); |
| 1575 } |
| 1576 |
| 1577 private: |
1565 bool is_store() const { return IsStoreBits::decode(minor_key_); } | 1578 bool is_store() const { return IsStoreBits::decode(minor_key_); } |
1566 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } | 1579 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } |
1567 bool call_data_undefined() const { | 1580 bool call_data_undefined() const { |
1568 return CallDataUndefinedBits::decode(minor_key_); | 1581 return CallDataUndefinedBits::decode(minor_key_); |
1569 } | 1582 } |
1570 int argc() const { return ArgumentBits::decode(minor_key_); } | 1583 int argc() const { return ArgumentBits::decode(minor_key_); } |
1571 | 1584 |
1572 class IsStoreBits: public BitField<bool, 0, 1> {}; | 1585 class IsStoreBits: public BitField<bool, 0, 1> {}; |
1573 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; | 1586 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; |
1574 class ArgumentBits : public BitField<int, 2, kArgBits> {}; | 1587 class ArgumentBits : public BitField<int, 2, kArgBits> {}; |
1575 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; | 1588 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; |
1576 | 1589 |
1577 DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub); | 1590 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiAccessor); |
| 1591 DEFINE_PLATFORM_CODE_STUB(CallApiAccessor, PlatformCodeStub); |
1578 }; | 1592 }; |
1579 | 1593 |
1580 | 1594 |
| 1595 // TODO(dcarney): see if it's possible to remove this later without performance |
| 1596 // degradation. |
| 1597 // This is not a real stub, but a way of generating the CallApiAccessorStub |
| 1598 // (which has the same abi) which makes it clear that it is not an accessor. |
| 1599 class CallApiFunctionWithFixedArgsStub : public CallApiAccessorStub { |
| 1600 public: |
| 1601 static const int kMaxFixedArgs = (1 << kArgBits) - 1; |
| 1602 CallApiFunctionWithFixedArgsStub(Isolate* isolate, int argc, |
| 1603 bool call_data_undefined) |
| 1604 : CallApiAccessorStub(isolate, argc, call_data_undefined) { |
| 1605 DCHECK(0 <= argc && argc <= kMaxFixedArgs); |
| 1606 } |
| 1607 }; |
| 1608 |
| 1609 |
| 1610 typedef ApiAccessorDescriptor ApiFunctionWithFixedArgsDescriptor; |
| 1611 |
| 1612 |
1581 class CallApiGetterStub : public PlatformCodeStub { | 1613 class CallApiGetterStub : public PlatformCodeStub { |
1582 public: | 1614 public: |
1583 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} | 1615 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
1584 | 1616 |
1585 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); | 1617 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); |
1586 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); | 1618 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); |
1587 }; | 1619 }; |
1588 | 1620 |
1589 | 1621 |
1590 class BinaryOpICStub : public HydrogenCodeStub { | 1622 class BinaryOpICStub : public HydrogenCodeStub { |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 #undef DEFINE_HYDROGEN_CODE_STUB | 2979 #undef DEFINE_HYDROGEN_CODE_STUB |
2948 #undef DEFINE_CODE_STUB | 2980 #undef DEFINE_CODE_STUB |
2949 #undef DEFINE_CODE_STUB_BASE | 2981 #undef DEFINE_CODE_STUB_BASE |
2950 | 2982 |
2951 extern Representation RepresentationFromType(Type* type); | 2983 extern Representation RepresentationFromType(Type* type); |
2952 | 2984 |
2953 } // namespace internal | 2985 } // namespace internal |
2954 } // namespace v8 | 2986 } // namespace v8 |
2955 | 2987 |
2956 #endif // V8_CODE_STUBS_H_ | 2988 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |