| 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(CallApiFunction) \ | 26 V(CallApiCallback) \ |
| 27 V(CallApiAccessor) \ | |
| 28 V(CallApiGetter) \ | 27 V(CallApiGetter) \ |
| 29 V(CallConstruct) \ | 28 V(CallConstruct) \ |
| 30 V(CallIC) \ | 29 V(CallIC) \ |
| 31 V(CEntry) \ | 30 V(CEntry) \ |
| 32 V(CompareIC) \ | 31 V(CompareIC) \ |
| 33 V(DoubleToI) \ | 32 V(DoubleToI) \ |
| 34 V(FunctionPrototype) \ | 33 V(FunctionPrototype) \ |
| 35 V(InstanceOf) \ | 34 V(InstanceOf) \ |
| 36 V(InternalArrayConstructor) \ | 35 V(InternalArrayConstructor) \ |
| 37 V(JSEntry) \ | 36 V(JSEntry) \ |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 private: | 1525 private: |
| 1527 class DepthBits : public BitField<int, 0, 4> {}; | 1526 class DepthBits : public BitField<int, 0, 4> {}; |
| 1528 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); | 1527 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); |
| 1529 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; | 1528 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; |
| 1530 STATIC_ASSERT(LANGUAGE_END == 3); | 1529 STATIC_ASSERT(LANGUAGE_END == 3); |
| 1531 | 1530 |
| 1532 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); | 1531 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); |
| 1533 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); | 1532 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); |
| 1534 }; | 1533 }; |
| 1535 | 1534 |
| 1535 class CallApiCallbackStub : public PlatformCodeStub { |
| 1536 public: |
| 1537 static const int kArgBits = 3; |
| 1538 static const int kArgMax = (1 << kArgBits) - 1; |
| 1536 | 1539 |
| 1537 class CallApiFunctionStub : public PlatformCodeStub { | 1540 // CallApiCallbackStub for regular setters and getters. |
| 1538 public: | 1541 CallApiCallbackStub(Isolate* isolate, bool is_store, bool call_data_undefined, |
| 1539 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) | 1542 bool is_lazy) |
| 1540 : PlatformCodeStub(isolate) { | 1543 : CallApiCallbackStub(isolate, is_store ? 1 : 0, is_store, |
| 1541 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); | 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()); |
| 1542 } | 1552 } |
| 1543 | 1553 |
| 1544 private: | 1554 private: |
| 1545 bool call_data_undefined() const { | 1555 CallApiCallbackStub(Isolate* isolate, int argc, bool is_store, |
| 1546 return CallDataUndefinedBits::decode(minor_key_); | 1556 bool call_data_undefined, bool is_lazy) |
| 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) | |
| 1560 : PlatformCodeStub(isolate) { | 1557 : PlatformCodeStub(isolate) { |
| 1558 CHECK(0 <= argc && argc <= kArgMax); |
| 1561 minor_key_ = IsStoreBits::encode(is_store) | | 1559 minor_key_ = IsStoreBits::encode(is_store) | |
| 1562 CallDataUndefinedBits::encode(call_data_undefined) | | 1560 CallDataUndefinedBits::encode(call_data_undefined) | |
| 1563 ArgumentBits::encode(is_store ? 1 : 0) | | 1561 ArgumentBits::encode(argc) | |
| 1564 IsLazyAccessorBits::encode(is_lazy); | 1562 IsLazyAccessorBits::encode(is_lazy); |
| 1565 } | 1563 } |
| 1566 | 1564 |
| 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: | |
| 1578 bool is_store() const { return IsStoreBits::decode(minor_key_); } | 1565 bool is_store() const { return IsStoreBits::decode(minor_key_); } |
| 1579 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } | 1566 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } |
| 1580 bool call_data_undefined() const { | 1567 bool call_data_undefined() const { |
| 1581 return CallDataUndefinedBits::decode(minor_key_); | 1568 return CallDataUndefinedBits::decode(minor_key_); |
| 1582 } | 1569 } |
| 1583 int argc() const { return ArgumentBits::decode(minor_key_); } | 1570 int argc() const { return ArgumentBits::decode(minor_key_); } |
| 1584 | 1571 |
| 1585 class IsStoreBits: public BitField<bool, 0, 1> {}; | 1572 class IsStoreBits: public BitField<bool, 0, 1> {}; |
| 1586 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; | 1573 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; |
| 1587 class ArgumentBits : public BitField<int, 2, kArgBits> {}; | 1574 class ArgumentBits : public BitField<int, 2, kArgBits> {}; |
| 1588 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; | 1575 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; |
| 1589 | 1576 |
| 1590 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiAccessor); | 1577 DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub); |
| 1591 DEFINE_PLATFORM_CODE_STUB(CallApiAccessor, PlatformCodeStub); | |
| 1592 }; | 1578 }; |
| 1593 | 1579 |
| 1594 | 1580 |
| 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 | |
| 1613 class CallApiGetterStub : public PlatformCodeStub { | 1581 class CallApiGetterStub : public PlatformCodeStub { |
| 1614 public: | 1582 public: |
| 1615 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} | 1583 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 1616 | 1584 |
| 1617 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); | 1585 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); |
| 1618 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); | 1586 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); |
| 1619 }; | 1587 }; |
| 1620 | 1588 |
| 1621 | 1589 |
| 1622 class BinaryOpICStub : public HydrogenCodeStub { | 1590 class BinaryOpICStub : public HydrogenCodeStub { |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2979 #undef DEFINE_HYDROGEN_CODE_STUB | 2947 #undef DEFINE_HYDROGEN_CODE_STUB |
| 2980 #undef DEFINE_CODE_STUB | 2948 #undef DEFINE_CODE_STUB |
| 2981 #undef DEFINE_CODE_STUB_BASE | 2949 #undef DEFINE_CODE_STUB_BASE |
| 2982 | 2950 |
| 2983 extern Representation RepresentationFromType(Type* type); | 2951 extern Representation RepresentationFromType(Type* type); |
| 2984 | 2952 |
| 2985 } // namespace internal | 2953 } // namespace internal |
| 2986 } // namespace v8 | 2954 } // namespace v8 |
| 2987 | 2955 |
| 2988 #endif // V8_CODE_STUBS_H_ | 2956 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |