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

Unified Diff: src/interface-descriptors.cc

Issue 1748123003: Rework CallApi*Stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/interface-descriptors.cc
diff --git a/src/interface-descriptors.cc b/src/interface-descriptors.cc
index cc46a56d94a2155103aea7978c216c5b973e8166..f3dee70200062016517b30b06e243013194e0ae7 100644
--- a/src/interface-descriptors.cc
+++ b/src/interface-descriptors.cc
@@ -494,31 +494,61 @@ ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
return function;
}
-FunctionType* ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
- Isolate* isolate, int paramater_count) {
- Zone* zone = isolate->interface_descriptor_zone();
- FunctionType* function =
- Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction();
- function->InitParameter(0, AnyTagged(zone)); // callee
- function->InitParameter(1, AnyTagged(zone)); // call_data
- function->InitParameter(2, AnyTagged(zone)); // holder
- function->InitParameter(3, ExternalPointer(zone)); // api_function_address
- function->InitParameter(4, UntaggedIntegral32(zone)); // actual #arguments
- return function;
+CallInterfaceDescriptor ApiCallbackDescriptorBase::ForArgs(Isolate* isolate,
+ int argc) {
+ switch (argc) {
+ case 0:
+ return ApiCallbackWith0ArgsDescriptor(isolate);
+ case 1:
+ return ApiCallbackWith1ArgsDescriptor(isolate);
+ case 2:
+ return ApiCallbackWith2ArgsDescriptor(isolate);
+ case 3:
+ return ApiCallbackWith3ArgsDescriptor(isolate);
+ case 4:
+ return ApiCallbackWith4ArgsDescriptor(isolate);
+ case 5:
+ return ApiCallbackWith5ArgsDescriptor(isolate);
+ case 6:
+ return ApiCallbackWith6ArgsDescriptor(isolate);
+ case 7:
+ return ApiCallbackWith7ArgsDescriptor(isolate);
danno 2016/03/04 18:07:42 Shouldn't you have a default case that is also unr
vogelheim 2016/03/08 12:59:27 Done. I'm honestly a bit confused at this feedbac
danno 2016/03/09 10:23:38 I looked at the C/C++ spec, and you're right. With
+ }
+ UNREACHABLE();
}
-FunctionType* ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
- Isolate* isolate, int paramater_count) {
+FunctionType* BuildFunctionTypeForCallback(Isolate* isolate,
+ int accessor_parameter_count) {
Zone* zone = isolate->interface_descriptor_zone();
- FunctionType* function =
- Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction();
+ FunctionType* function = Type::Function(AnyTagged(zone), Type::Undefined(),
+ 4 + accessor_parameter_count, zone)
+ ->AsFunction();
function->InitParameter(0, AnyTagged(zone)); // callee
function->InitParameter(1, AnyTagged(zone)); // call_data
function->InitParameter(2, AnyTagged(zone)); // holder
function->InitParameter(3, ExternalPointer(zone)); // api_function_address
+ for (int i = 0; i < accessor_parameter_count; i++) {
+ function->InitParameter(i, AnyTagged(zone));
+ }
return function;
}
+template <int argc>
+FunctionType*
+ApiCallbackWithArgsBase<argc>::BuildCallInterfaceDescriptorFunctionType(
+ Isolate* isolate, int parameter_count) {
+ return BuildFunctionTypeForCallback(isolate, argc);
+}
+
+template class ApiCallbackWithArgsBase<0>;
+template class ApiCallbackWithArgsBase<1>;
+template class ApiCallbackWithArgsBase<2>;
+template class ApiCallbackWithArgsBase<3>;
+template class ApiCallbackWithArgsBase<4>;
+template class ApiCallbackWithArgsBase<5>;
+template class ApiCallbackWithArgsBase<6>;
+template class ApiCallbackWithArgsBase<7>;
+
FunctionType*
InterpreterDispatchDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int parameter_count) {

Powered by Google App Engine
This is Rietveld 408576698