Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace `object` function arguments in WebGL with typed arrays #20396

Merged
merged 9 commits into from Mar 23, 2018

Unify argument auto rooting in codegen

  • Loading branch information
Xanewok committed Mar 23, 2018
commit 2437a8472e3c2f9201fa4fc3fca06537ebf52d62
@@ -418,15 +418,12 @@ def pickFirstSignature(condition, filterLambda):
template = info.template
declType = info.declType

argName = "arg%d" % distinguishingIndex

testCode = instantiateJSToNativeConversionTemplate(
template,
{"val": distinguishingArg},
declType,
argName)
if type_needs_auto_root(type):
testCode.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (argName, argName)))
"arg%d" % distinguishingIndex,
needsAutoRoot=type_needs_auto_root(type))

# Indent by 4, since we need to indent further than our "do" statement
caseBody.append(CGIndenter(testCode, 4))
@@ -1215,7 +1212,8 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,


def instantiateJSToNativeConversionTemplate(templateBody, replacements,
declType, declName):
declType, declName,
needsAutoRoot=False):
"""
Take the templateBody and declType as returned by
getJSToNativeConversionInfo, a set of replacements as required by the
@@ -1240,6 +1238,8 @@ def instantiateJSToNativeConversionTemplate(templateBody, replacements,
else:
result.append(conversion)

if needsAutoRoot:
result.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (declName, declName)))
# Add an empty CGGeneric to get an extra newline after the argument
# conversion.
result.append(CGGeneric(""))
@@ -1322,11 +1322,8 @@ def __init__(self, argument, index, args, argc, descriptorProvider,
arg = "arg%d" % index

self.converter = instantiateJSToNativeConversionTemplate(
template, replacementVariables, declType, arg)

# The auto rooting is done only after the conversion is performed
if type_needs_auto_root(argument.type):
self.converter.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (arg, arg)))
template, replacementVariables, declType, arg,
needsAutoRoot=type_needs_auto_root(argument.type))

else:
assert argument.optional
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.