Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1938)

Side by Side Diff: cgen/templates/inlined/PyLong_Type

Issue 14757: INCA: Inline Caching meets Quickening in Python 3.3
Patch Set: Created 1 year ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cgen/templates/inlined/PyFloat_Type ('k') | cgen/templates/inlined/PyRangeIter_Type » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 %if instr.function_id in ['nb_add', 'nb_multiply', 'nb_subtract']:
2 <% inlined= True %>
3 <%text>\
4 #define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject*)x)->ob_digit[ 0] : \
5 (Py_SIZE(x) == 0 ? (sdigit)0 : \
6 (sdigit)((PyLongObject*)x)->ob_digit[0]))
7
8 #define ABS(x) ((x) < 0 ? -(x) : (x))
9 </%text>\
10
11 % if instr.function_id == 'nb_add':
12 if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1)
13 x = PyLong_FromLong(MEDIUM_VALUE(v) +
14 MEDIUM_VALUE(w));
15 else
16 x= PyLong_Type.tp_as_number->nb_add(v, w);
17 % elif instr.function_id == 'nb_multiply':
18 if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) {
19 stwodigits temp = (stwodigits)(MEDIUM_VALUE(v)) * MEDIUM_VALUE(w);
20 #ifdef HAVE_LONG_LONG
21 x= PyLong_FromLongLong((PY_LONG_LONG)temp);
22 #else
23 if (temp >= LONG_MIN && temp <= LONG_MAX)
24 x= PyLong_FromLong((long)temp);
25 #endif
26 }
27 else
28 x= PyLong_Type.tp_as_number->nb_multiply(v, w);
29 % elif instr.function_id == 'nb_subtract':
30 if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1)
31 x = PyLong_FromLong(MEDIUM_VALUE(v)-MEDIUM_VALUE(w));
32 else
33 x= PyLong_Type.tp_as_number->nb_subtract(v, w);
34 % endif
35
36 #undef MEDIUM_VALUE
37 #undef ABS
38 % elif instr.function_id in ['nb_true_divide']:
39 x= PyLong_Type.tp_as_number->nb_true_divide(v, w);
40 %endif
OLDNEW
« no previous file with comments | « cgen/templates/inlined/PyFloat_Type ('k') | cgen/templates/inlined/PyRangeIter_Type » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7