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

Unified Diff: src/code-stubs.h

Issue 1748123003: Rework CallApi*Stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor fixes and make Win compiler happy. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 48c65c8e3818f22a2906678902bc5cfeb3e6bb21..199f24312173af5b1996987f402b845a415fa7f3 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -23,8 +23,7 @@ namespace internal {
/* PlatformCodeStubs */ \
V(ArrayConstructor) \
V(BinaryOpICWithAllocationSite) \
- V(CallApiFunction) \
- V(CallApiAccessor) \
+ V(CallApiCallback) \
V(CallApiGetter) \
V(CallConstruct) \
V(CallIC) \
@@ -1533,48 +1532,36 @@ class StoreGlobalViaContextStub final : public PlatformCodeStub {
DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub);
};
-
-class CallApiFunctionStub : public PlatformCodeStub {
+class CallApiCallbackStub : public PlatformCodeStub {
public:
- explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined)
- : PlatformCodeStub(isolate) {
- minor_key_ = CallDataUndefinedBits::encode(call_data_undefined);
- }
-
- private:
- bool call_data_undefined() const {
- return CallDataUndefinedBits::decode(minor_key_);
- }
+ static const int kArgBits = 3;
+ static const int kArgMax = (1 << kArgBits) - 1;
- class CallDataUndefinedBits : public BitField<bool, 0, 1> {};
+ // CallApiCallbackStub for regular setters and getters.
+ CallApiCallbackStub(Isolate* isolate, bool is_store, bool call_data_undefined,
+ bool is_lazy)
+ : CallApiCallbackStub(isolate, is_store ? 1 : 0, is_store,
+ call_data_undefined, is_lazy) {}
- DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiFunction);
- DEFINE_PLATFORM_CODE_STUB(CallApiFunction, PlatformCodeStub);
-};
+ // CallApiCallbackStub for callback functions.
+ CallApiCallbackStub(Isolate* isolate, int argc, bool call_data_undefined)
+ : CallApiCallbackStub(isolate, argc, false, call_data_undefined, false) {}
+ CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
+ return ApiCallbackDescriptorBase::ForArgs(isolate(), argc());
+ }
-class CallApiAccessorStub : public PlatformCodeStub {
- public:
- CallApiAccessorStub(Isolate* isolate, bool is_store, bool call_data_undefined,
- bool is_lazy)
+ private:
+ CallApiCallbackStub(Isolate* isolate, int argc, bool is_store,
+ bool call_data_undefined, bool is_lazy)
: PlatformCodeStub(isolate) {
+ CHECK(0 <= argc && argc <= kArgMax);
minor_key_ = IsStoreBits::encode(is_store) |
CallDataUndefinedBits::encode(call_data_undefined) |
- ArgumentBits::encode(is_store ? 1 : 0) |
+ ArgumentBits::encode(argc) |
IsLazyAccessorBits::encode(is_lazy);
}
- protected:
- // For CallApiFunctionWithFixedArgsStub, see below.
- static const int kArgBits = 3;
- CallApiAccessorStub(Isolate* isolate, int argc, bool call_data_undefined)
- : PlatformCodeStub(isolate) {
- minor_key_ = IsStoreBits::encode(false) |
- CallDataUndefinedBits::encode(call_data_undefined) |
- ArgumentBits::encode(argc);
- }
-
- private:
bool is_store() const { return IsStoreBits::decode(minor_key_); }
bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); }
bool call_data_undefined() const {
@@ -1587,29 +1574,10 @@ class CallApiAccessorStub : public PlatformCodeStub {
class ArgumentBits : public BitField<int, 2, kArgBits> {};
class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {};
- DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiAccessor);
- DEFINE_PLATFORM_CODE_STUB(CallApiAccessor, PlatformCodeStub);
+ DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub);
};
-// TODO(dcarney): see if it's possible to remove this later without performance
-// degradation.
-// This is not a real stub, but a way of generating the CallApiAccessorStub
-// (which has the same abi) which makes it clear that it is not an accessor.
-class CallApiFunctionWithFixedArgsStub : public CallApiAccessorStub {
- public:
- static const int kMaxFixedArgs = (1 << kArgBits) - 1;
- CallApiFunctionWithFixedArgsStub(Isolate* isolate, int argc,
- bool call_data_undefined)
- : CallApiAccessorStub(isolate, argc, call_data_undefined) {
- DCHECK(0 <= argc && argc <= kMaxFixedArgs);
- }
-};
-
-
-typedef ApiAccessorDescriptor ApiFunctionWithFixedArgsDescriptor;
-
-
class CallApiGetterStub : public PlatformCodeStub {
public:
explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {}

Powered by Google App Engine
This is Rietveld 408576698