aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@gmail.com>2015-10-16 02:04:37 -0400
committerNathan Froyd <froydnj@gmail.com>2015-10-27 15:09:32 -0400
commit4f649ac6dde24f0d70791ca94ae8abe2538149e1 (patch)
tree4029e5bd2bc94bd69070179d87c2a92ea1a4508c /components/script/dom/bindings/codegen/CodegenRust.py
parentdd74572dc0c0d34124ef8cbcd7ffa0dc62935d94 (diff)
downloadservo-4f649ac6dde24f0d70791ca94ae8abe2538149e1.tar.gz
servo-4f649ac6dde24f0d70791ca94ae8abe2538149e1.zip
generate JIT argument type information for methods
Fixes #6904.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 452dde13149..c7684807fa3 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1445,7 +1445,11 @@ class MethodDefiner(PropertyDefiner):
selfHostedName = "0 as *const i8"
if m.get("methodInfo", True):
identifier = m.get("nativeName", m["name"])
- jitinfo = "&%s_methodinfo" % identifier
+ # Go through an intermediate type here, because it's not
+ # easy to tell whether the methodinfo is a JSJitInfo or
+ # a JSTypedMethodJitInfo here. The compiler knows, though,
+ # so let it do the work.
+ jitinfo = "&%s_methodinfo as *const _ as *const JSJitInfo" % identifier
accessor = "Some(generic_method)"
else:
jitinfo = "0 as *const JSJitInfo"
@@ -3085,6 +3089,26 @@ class CGMemberJITInfo(CGThing):
slotIndex=slotIndex)
return initializer.rstrip()
+ if args is not None:
+ argTypes = "%s_argTypes" % infoName
+ args = [CGMemberJITInfo.getJSArgType(arg.type) for arg in args]
+ args.append("ArgType::ArgTypeListEnd as i32")
+ argTypesDecl = (
+ "const %s: [i32; %d] = [ %s ];\n" %
+ (argTypes, len(args), ", ".join(args)))
+ return fill(
+ """
+ $*{argTypesDecl}
+ const ${infoName}: JSTypedMethodJitInfo = JSTypedMethodJitInfo {
+ base: ${jitInfo},
+ argTypes: &${argTypes} as *const _ as *const ArgType,
+ };
+ """,
+ argTypesDecl=argTypesDecl,
+ infoName=infoName,
+ jitInfo=indent(jitInfoInitializer(True)),
+ argTypes=argTypes)
+
return ("\n"
"const %s: JSJitInfo = %s;\n"
% (infoName, jitInfoInitializer(False)))
@@ -5149,7 +5173,7 @@ class CGBindingRoot(CGThing):
'js::jsapi::{RootedValue, JSNativeWrapper, JSNative, JSObject, JSPropertyDescriptor}',
'js::jsapi::{RootedId, JS_InternString, RootedString, INTERNED_STRING_TO_JSID}',
'js::jsapi::{JSPropertySpec}',
- 'js::jsapi::{JSString, JSTracer, JSJitInfo, OpType, AliasSet}',
+ 'js::jsapi::{JSString, JSTracer, JSJitInfo, JSTypedMethodJitInfo, OpType, AliasSet, ArgType}',
'js::jsapi::{MutableHandle, Handle, HandleId, JSType, JSValueType}',
'js::jsapi::{SymbolCode, ObjectOpResult, HandleValueArray}',
'js::jsapi::{JSJitGetterCallArgs, JSJitSetterCallArgs, JSJitMethodCallArgs, CallArgs}',