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 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 private: | 1419 private: |
1421 class DepthBits : public BitField<int, 0, 4> {}; | 1420 class DepthBits : public BitField<int, 0, 4> {}; |
1422 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); | 1421 STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); |
1423 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; | 1422 class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; |
1424 STATIC_ASSERT(LANGUAGE_END == 3); | 1423 STATIC_ASSERT(LANGUAGE_END == 3); |
1425 | 1424 |
1426 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); | 1425 DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); |
1427 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); | 1426 DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); |
1428 }; | 1427 }; |
1429 | 1428 |
| 1429 class CallApiCallbackStub : public PlatformCodeStub { |
| 1430 public: |
| 1431 static const int kArgBits = 3; |
| 1432 static const int kArgMax = (1 << kArgBits) - 1; |
1430 | 1433 |
1431 class CallApiFunctionStub : public PlatformCodeStub { | 1434 // CallApiCallbackStub for regular setters and getters. |
1432 public: | 1435 CallApiCallbackStub(Isolate* isolate, bool is_store, bool call_data_undefined, |
1433 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) | 1436 bool is_lazy) |
1434 : PlatformCodeStub(isolate) { | 1437 : CallApiCallbackStub(isolate, is_store ? 1 : 0, is_store, |
1435 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); | 1438 call_data_undefined, is_lazy) {} |
| 1439 |
| 1440 // CallApiCallbackStub for callback functions. |
| 1441 CallApiCallbackStub(Isolate* isolate, int argc, bool call_data_undefined) |
| 1442 : CallApiCallbackStub(isolate, argc, false, call_data_undefined, false) {} |
| 1443 |
| 1444 CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 1445 return ApiCallbackDescriptorBase::ForArgs(isolate(), argc()); |
1436 } | 1446 } |
1437 | 1447 |
1438 private: | 1448 private: |
1439 bool call_data_undefined() const { | 1449 CallApiCallbackStub(Isolate* isolate, int argc, bool is_store, |
1440 return CallDataUndefinedBits::decode(minor_key_); | 1450 bool call_data_undefined, bool is_lazy) |
1441 } | |
1442 | |
1443 class CallDataUndefinedBits : public BitField<bool, 0, 1> {}; | |
1444 | |
1445 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiFunction); | |
1446 DEFINE_PLATFORM_CODE_STUB(CallApiFunction, PlatformCodeStub); | |
1447 }; | |
1448 | |
1449 | |
1450 class CallApiAccessorStub : public PlatformCodeStub { | |
1451 public: | |
1452 CallApiAccessorStub(Isolate* isolate, bool is_store, bool call_data_undefined, | |
1453 bool is_lazy) | |
1454 : PlatformCodeStub(isolate) { | 1451 : PlatformCodeStub(isolate) { |
| 1452 CHECK(0 <= argc && argc <= kArgMax); |
1455 minor_key_ = IsStoreBits::encode(is_store) | | 1453 minor_key_ = IsStoreBits::encode(is_store) | |
1456 CallDataUndefinedBits::encode(call_data_undefined) | | 1454 CallDataUndefinedBits::encode(call_data_undefined) | |
1457 ArgumentBits::encode(is_store ? 1 : 0) | | 1455 ArgumentBits::encode(argc) | |
1458 IsLazyAccessorBits::encode(is_lazy); | 1456 IsLazyAccessorBits::encode(is_lazy); |
1459 } | 1457 } |
1460 | 1458 |
1461 protected: | |
1462 // For CallApiFunctionWithFixedArgsStub, see below. | |
1463 static const int kArgBits = 3; | |
1464 CallApiAccessorStub(Isolate* isolate, int argc, bool call_data_undefined) | |
1465 : PlatformCodeStub(isolate) { | |
1466 minor_key_ = IsStoreBits::encode(false) | | |
1467 CallDataUndefinedBits::encode(call_data_undefined) | | |
1468 ArgumentBits::encode(argc); | |
1469 } | |
1470 | |
1471 private: | |
1472 bool is_store() const { return IsStoreBits::decode(minor_key_); } | 1459 bool is_store() const { return IsStoreBits::decode(minor_key_); } |
1473 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } | 1460 bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } |
1474 bool call_data_undefined() const { | 1461 bool call_data_undefined() const { |
1475 return CallDataUndefinedBits::decode(minor_key_); | 1462 return CallDataUndefinedBits::decode(minor_key_); |
1476 } | 1463 } |
1477 int argc() const { return ArgumentBits::decode(minor_key_); } | 1464 int argc() const { return ArgumentBits::decode(minor_key_); } |
1478 | 1465 |
1479 class IsStoreBits: public BitField<bool, 0, 1> {}; | 1466 class IsStoreBits: public BitField<bool, 0, 1> {}; |
1480 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; | 1467 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; |
1481 class ArgumentBits : public BitField<int, 2, kArgBits> {}; | 1468 class ArgumentBits : public BitField<int, 2, kArgBits> {}; |
1482 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; | 1469 class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; |
1483 | 1470 |
1484 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiAccessor); | 1471 DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub); |
1485 DEFINE_PLATFORM_CODE_STUB(CallApiAccessor, PlatformCodeStub); | |
1486 }; | 1472 }; |
1487 | 1473 |
1488 | 1474 |
1489 // TODO(dcarney): see if it's possible to remove this later without performance | |
1490 // degradation. | |
1491 // This is not a real stub, but a way of generating the CallApiAccessorStub | |
1492 // (which has the same abi) which makes it clear that it is not an accessor. | |
1493 class CallApiFunctionWithFixedArgsStub : public CallApiAccessorStub { | |
1494 public: | |
1495 static const int kMaxFixedArgs = (1 << kArgBits) - 1; | |
1496 CallApiFunctionWithFixedArgsStub(Isolate* isolate, int argc, | |
1497 bool call_data_undefined) | |
1498 : CallApiAccessorStub(isolate, argc, call_data_undefined) { | |
1499 DCHECK(0 <= argc && argc <= kMaxFixedArgs); | |
1500 } | |
1501 }; | |
1502 | |
1503 | |
1504 typedef ApiAccessorDescriptor ApiFunctionWithFixedArgsDescriptor; | |
1505 | |
1506 | |
1507 class CallApiGetterStub : public PlatformCodeStub { | 1475 class CallApiGetterStub : public PlatformCodeStub { |
1508 public: | 1476 public: |
1509 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} | 1477 explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
1510 | 1478 |
1511 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); | 1479 DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); |
1512 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); | 1480 DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); |
1513 }; | 1481 }; |
1514 | 1482 |
1515 | 1483 |
1516 class BinaryOpICStub : public HydrogenCodeStub { | 1484 class BinaryOpICStub : public HydrogenCodeStub { |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 #undef DEFINE_HYDROGEN_CODE_STUB | 2849 #undef DEFINE_HYDROGEN_CODE_STUB |
2882 #undef DEFINE_CODE_STUB | 2850 #undef DEFINE_CODE_STUB |
2883 #undef DEFINE_CODE_STUB_BASE | 2851 #undef DEFINE_CODE_STUB_BASE |
2884 | 2852 |
2885 extern Representation RepresentationFromType(Type* type); | 2853 extern Representation RepresentationFromType(Type* type); |
2886 | 2854 |
2887 } // namespace internal | 2855 } // namespace internal |
2888 } // namespace v8 | 2856 } // namespace v8 |
2889 | 2857 |
2890 #endif // V8_CODE_STUBS_H_ | 2858 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |