# US 2014/0196005 A1 · High performance php

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2014/0196005 A1
- Document ID: US20140196005A1
- Status: Published application
- Kind: A1
- Application number: 14/202,809
- Filed: 2014-03-10
- Published: 2014-07-10
- Earliest claimed: 2009-09-30
- Assignees: Facebook, Inc.
- Applicants: Facebook, Inc.
- Inventors: Iain Andrew Russell Proctor; Minghui Yang; Haiping Zhao
- Web page: https://patentgrep.com/patent/US20140196005A1

## CPC

- G06F 40/143: Markup, e.g. Standard Generalized Markup Language [SGML] or Document Type Definition [DTD]
- G06F 8/31: {Programming languages or programming paradigms}
- G06F 8/51: Source to source
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Markup language documents including server side scripting code using PHP syntax are executed efficiently in response to requests received by a server. The processing of the markup language document results in generation of a transformed markup language document that is returned in response to the request. The server side script code is input to a compiler that generates C++ code (or code in any object-based language based on C language) implementing the functionality of the server side script code. The C++ code is compiled to generated object code which is executed in order to process the markup language document. The generated C++ code includes functionality supported by PHP language including redeclaration of functions, dynamic variables, global variables, and the like. The generated C++ code invokes memory allocation code that allocates and deallocates objects obtained by instantiating the generated C++ classes.

## Claims

### Claim 1

A computer-implemented method comprising:
retrieving a markup language document including server side script code specified using personal home page (PHP) syntax, wherein the server side script code is for execution on a server in response to a request for the markup language document, the server side code specifying statements using one or more untyped variables;
generating C++ code from the server side script code, wherein the generated C++ code comprises one or more C++ classes comprising code corresponding to the server side script code, the generating comprising:
associating the untyped variable with a first type based on a first usage of the untyped variable in the script code,
associating the untyped variable with a second type based on a second usage of the untyped variable in the script code, and
inferring a type of the untyped variable to be an ancestor of both the first type and the second type in a hierarchy of types of variables; and
compiling the generated C++ code to object code, wherein the object code is invoked for processing the markup language document.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the type of the untyped variable is inferred to be the least common ancestor of the first type and the second type in the hierarchy of types.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, wherein generating C++ code firth comprises:
mapping the type of the untyped variable to a C++ type; and
defining a variable in the generated C++ code corresponding to the untyped variable, the defined variable having the mapped C++ type.

### Claim 4 (depends on 3)

The computer-implemented method of claim 3, wherein a primitive type of PUP is mapped to a primitive type of C++.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the generating comprises executing multiple passes through the script code, each pass inferring types of variables based on variable types inferred in a previous pass.

### Claim 6 (depends on 5)

The computer-implemented method of claim 5, wherein the generating further comprises stopping the execution of passes through the script code responsive to determining that a current pass inferred no new types compared to a previous pass.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, wherein the first usage comprises assigning the untyped variable to a constant, wherein the first type is determined to be the type of the constant.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein the first usage comprises assigning the untyped variable to variable of a known type, wherein the first type is determined to be the known type.

### Claim 9 (depends on 1)

The computer-implemented method of claim 1, wherein the untyped variable is a parameter of a function and the first usage comprises an invocation of the function, wherein the type of the untyped variable is inferred to be a type of an argument passed to the function corresponding to the parameter.

### Claim 10 (depends on 1)

The computer-implemented method of claim 1, wherein the hierarchy of types organizes the types such that a least common ancestor of a numeric type and a string type is a variant type.

### Claim 11

The computer-implemented method of claim, wherein the hierarchy of types organizes the types such that a least common ancestor of an array type and an object type is a variant type.

### Claim 12

A computer program product for storing object code on a non-transitory computer readable medium, the computer program product implementing functionality for efficiently executing server side script code, the computer program product comprising instructions for:
retrieving a markup language document including server side script code specified using personal home page (PHP) syntax, wherein the server side script code is for execution on a server in response to a request for the markup language document, the server side code specifying statements using one or more untyped variables;
generating C++ code from the server side script code, wherein the generated C++ code comprises one or more C++ classes comprising code corresponding to the server side script code, the generating comprising:
associating the untyped variable with a first type based on a first usage of the untyped variable in the script code,
associating the untyped variable with a second type based on a second usage of the untyped variable in the script code, and
inferring a type of the untyped variable to be an ancestor of both the first type and the second type in a hierarchy of types of variables; and
compiling the generated C++ code to object code, wherein the object code is invoked for processing the markup language document.

### Claim 13 (depends on 12)

The computer program product of claim 12, wherein the type of the untyped variable is inferred to be the least common ancestor of the first type and the second type in the hierarchy of types.

### Claim 14 (depends on 12)

The computer program product of claim 12, wherein instructions for generating C++ code further comprise instructions for:
mapping the type of the untyped variable to a C++ type; and
defining a variable in the generated C++ code corresponding to the untyped variable, the defined variable having the mapped C++ type.

### Claim 15 (depends on 14)

The computer program product of claim 14, wherein a primitive type of PHP is mapped to a primitive type of C++.

### Claim 16 (depends on 12)

The computer program product of claim 12, wherein the generating comprises executing multiple passes through the script code, each pass inferring types of variables based on variable types inferred in a previous pass.

### Claim 17 (depends on 16)

The computer program product of claim 16, wherein the generating further comprises stopping the execution of passes through the script code responsive to determining that a current pass inferred no new types compared to a previous pass.

### Claim 18 (depends on 12)

The computer program product of claim 12, wherein the first usage comprises assigning the untyped variable to a constant, wherein the first type is determined to be the type of the constant.

### Claim 19 (depends on 12)

The computer program product of claim 12, wherein the first usage comprises assigning the untyped variable to variable of a known type, wherein the first type is determined to be the known type.

### Claim 20 (depends on 12)

The computer program product of claim 12, wherein the untyped variable is a parameter of a function and the first usage comprises an invocation of the function, wherein the type of the untyped variable is inferred to be a type of an argument passed to the function corresponding to the parameter.
