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

Side by Side Diff: src/macros.py

Issue 596122: Some string optimizations: (Closed)
Patch Set: Undo unnecessary optimizations. Created 10 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 unified diff | Download patch
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/mips/codegen-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2006-2009 the V8 project authors. All rights reserved. 1 # Copyright 2006-2009 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1). 68 # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1).
69 const kInvalidDate = 'Invalid Date'; 69 const kInvalidDate = 'Invalid Date';
70 const kDayZeroInJulianDay = 2440588; 70 const kDayZeroInJulianDay = 2440588;
71 const kMonthMask = 0x1e0; 71 const kMonthMask = 0x1e0;
72 const kDayMask = 0x01f; 72 const kDayMask = 0x01f;
73 const kYearShift = 9; 73 const kYearShift = 9;
74 const kMonthShift = 5; 74 const kMonthShift = 5;
75 75
76 # Type query macros. 76 # Type query macros.
77 #
78 # Note: We have special support for typeof(foo) === 'bar' in the compiler.
79 # It will *not* generate a runtime typeof call for the most important
80 # values of 'bar'.
77 macro IS_NULL(arg) = (arg === null); 81 macro IS_NULL(arg) = (arg === null);
78 macro IS_NULL_OR_UNDEFINED(arg) = (arg == null); 82 macro IS_NULL_OR_UNDEFINED(arg) = (arg == null);
79 macro IS_UNDEFINED(arg) = (typeof(arg) === 'undefined'); 83 macro IS_UNDEFINED(arg) = (typeof(arg) === 'undefined');
80 macro IS_NUMBER(arg) = (typeof(arg) === 'number'); 84 macro IS_NUMBER(arg) = (typeof(arg) === 'number');
81 macro IS_STRING(arg) = (typeof(arg) === 'string'); 85 macro IS_STRING(arg) = (typeof(arg) === 'string');
82 macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean'); 86 macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean');
83 macro IS_OBJECT(arg) = (%_IsObject(arg)); 87 macro IS_OBJECT(arg) = (%_IsObject(arg));
84 macro IS_ARRAY(arg) = (%_IsArray(arg)); 88 macro IS_ARRAY(arg) = (%_IsArray(arg));
85 macro IS_FUNCTION(arg) = (%_IsFunction(arg)); 89 macro IS_FUNCTION(arg) = (%_IsFunction(arg));
86 macro IS_REGEXP(arg) = (%_ClassOf(arg) === 'RegExp'); 90 macro IS_REGEXP(arg) = (%_IsRegExp(arg));
87 macro IS_DATE(arg) = (%_ClassOf(arg) === 'Date'); 91 macro IS_DATE(arg) = (%_ClassOf(arg) === 'Date');
88 macro IS_NUMBER_WRAPPER(arg) = (%_ClassOf(arg) === 'Number'); 92 macro IS_NUMBER_WRAPPER(arg) = (%_ClassOf(arg) === 'Number');
89 macro IS_STRING_WRAPPER(arg) = (%_ClassOf(arg) === 'String'); 93 macro IS_STRING_WRAPPER(arg) = (%_ClassOf(arg) === 'String');
90 macro IS_BOOLEAN_WRAPPER(arg) = (%_ClassOf(arg) === 'Boolean'); 94 macro IS_BOOLEAN_WRAPPER(arg) = (%_ClassOf(arg) === 'Boolean');
91 macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error'); 95 macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error');
92 macro IS_SCRIPT(arg) = (%_ClassOf(arg) === 'Script'); 96 macro IS_SCRIPT(arg) = (%_ClassOf(arg) === 'Script');
93 macro IS_ARGUMENTS(arg) = (%_ClassOf(arg) === 'Arguments'); 97 macro IS_ARGUMENTS(arg) = (%_ClassOf(arg) === 'Arguments');
94 macro IS_GLOBAL(arg) = (%_ClassOf(arg) === 'global'); 98 macro IS_GLOBAL(arg) = (%_ClassOf(arg) === 'global');
95 macro IS_UNDETECTABLE(arg) = (%_IsUndetectableObject(arg)); 99 macro IS_UNDETECTABLE(arg) = (%_IsUndetectableObject(arg));
96 macro FLOOR(arg) = $floor(arg); 100 macro FLOOR(arg) = $floor(arg);
97 101
98 # Inline macros. Use %IS_VAR to make sure arg is evaluated only once. 102 # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
99 macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg)); 103 macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
100 macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg)); 104 macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg));
101 macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0)); 105 macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0));
102 macro TO_UINT32(arg) = (arg >>> 0); 106 macro TO_UINT32(arg) = (arg >>> 0);
107 macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToSt ring(arg));
Mads Ager (chromium) 2010/02/19 09:56:29 Remove extra spaces before '=' on this line. I wo
Vitaly Repeshko 2010/02/19 13:12:35 Done.
108
103 109
104 # Macros implemented in Python. 110 # Macros implemented in Python.
105 python macro CHAR_CODE(str) = ord(str[1]); 111 python macro CHAR_CODE(str) = ord(str[1]);
106 112
107 # Accessors for original global properties that ensure they have been loaded. 113 # Accessors for original global properties that ensure they have been loaded.
108 const ORIGINAL_REGEXP = (global.RegExp, $RegExp); 114 const ORIGINAL_REGEXP = (global.RegExp, $RegExp);
109 const ORIGINAL_DATE = (global.Date, $Date); 115 const ORIGINAL_DATE = (global.Date, $Date);
110 116
111 # Constants used on an array to implement the properties of the RegExp object. 117 # Constants used on an array to implement the properties of the RegExp object.
112 const REGEXP_NUMBER_OF_CAPTURES = 0; 118 const REGEXP_NUMBER_OF_CAPTURES = 0;
(...skipping 16 matching lines...) Expand all
129 macro MS_FROM_TIME(time) = (Modulo(time, 1000)); 135 macro MS_FROM_TIME(time) = (Modulo(time, 1000));
130 136
131 # Last input and last subject of regexp matches. 137 # Last input and last subject of regexp matches.
132 macro LAST_SUBJECT(array) = ((array)[1]); 138 macro LAST_SUBJECT(array) = ((array)[1]);
133 macro LAST_INPUT(array) = ((array)[2]); 139 macro LAST_INPUT(array) = ((array)[2]);
134 140
135 # REGEXP_FIRST_CAPTURE 141 # REGEXP_FIRST_CAPTURE
136 macro CAPTURE(index) = (3 + (index)); 142 macro CAPTURE(index) = (3 + (index));
137 const CAPTURE0 = 3; 143 const CAPTURE0 = 3;
138 const CAPTURE1 = 4; 144 const CAPTURE1 = 4;
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/mips/codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698