OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const ParameterCount& actual, | 119 const ParameterCount& actual, |
120 InvokeFlag flag); | 120 InvokeFlag flag); |
121 | 121 |
122 // Invoke specified builtin JavaScript function. Adds an entry to | 122 // Invoke specified builtin JavaScript function. Adds an entry to |
123 // the unresolved list if the name does not resolve. | 123 // the unresolved list if the name does not resolve. |
124 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); | 124 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); |
125 | 125 |
126 // Store the code object for the given builtin in the target register. | 126 // Store the code object for the given builtin in the target register. |
127 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 127 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
128 | 128 |
| 129 |
| 130 // --------------------------------------------------------------------------- |
| 131 // Smi tagging, untagging and operations on tagged smis. |
| 132 |
| 133 // Conversions between tagged smi values and non-tagged integer values. |
| 134 |
| 135 // Tag an integer value. The result must be known to be a valid smi value. |
| 136 // Only uses the low 32 bits of the src register. |
| 137 void Integer32ToSmi(Register dst, Register src); |
| 138 |
| 139 // Tag an integer value if possible, or jump the integer value cannot be |
| 140 // represented as a smi. Only uses the low 32 bit of the src registers. |
| 141 void Integer32ToSmi(Register dst, Register src, Label* on_overflow); |
| 142 |
| 143 // Adds constant to src and tags the result as a smi. |
| 144 // Result must be a valid smi. |
| 145 void Integer64AddToSmi(Register dst, Register src, int constant); |
| 146 |
| 147 // Convert smi to 32-bit integer. I.e., not sign extended into |
| 148 // high 32 bits of destination. |
| 149 void SmiToInteger32(Register dst, Register src); |
| 150 |
| 151 // Convert smi to 64-bit integer (sign extended if necessary). |
| 152 void SmiToInteger64(Register dst, Register src); |
| 153 |
| 154 // Multiply a positive smi's integer value by a power of two. |
| 155 // Provides result as 64-bit integer value. |
| 156 void PositiveSmiTimesPowerOfTwoToInteger64(Register dst, |
| 157 Register src, |
| 158 int power); |
| 159 |
| 160 // Functions performing a check on a known or potential smi. Returns |
| 161 // a condition that is satisfied if the check is successful. |
| 162 |
| 163 // Is the value a tagged smi. |
| 164 Condition CheckSmi(Register src); |
| 165 |
| 166 // Is the value not a tagged smi. |
| 167 Condition CheckNotSmi(Register src); |
| 168 |
| 169 // Is the value a positive tagged smi. |
| 170 Condition CheckPositiveSmi(Register src); |
| 171 |
| 172 // Is the value not a positive tagged smi. |
| 173 Condition CheckNotPositiveSmi(Register src); |
| 174 |
| 175 // Are both values are tagged smis. |
| 176 Condition CheckBothSmi(Register first, Register second); |
| 177 |
| 178 // Is one of the values not a tagged smi. |
| 179 Condition CheckNotBothSmi(Register first, Register second); |
| 180 |
| 181 // Is the value the minimum smi value (since we are using |
| 182 // two's complement numbers, negating the value is known to yield |
| 183 // a non-smi value). |
| 184 Condition CheckIsMinSmi(Register src); |
| 185 |
| 186 // Check whether a tagged smi is equal to a constant. |
| 187 Condition CheckSmiEqualsConstant(Register src, int constant); |
| 188 |
| 189 // Checks whether an 32-bit integer value is a valid for conversion |
| 190 // to a smi. |
| 191 Condition CheckInteger32ValidSmiValue(Register src); |
| 192 |
| 193 // Test-and-jump functions. Typically combines a check function |
| 194 // above with a conditional jump. |
| 195 |
| 196 // Jump if the value cannot be represented by a smi. |
| 197 void JumpIfNotValidSmiValue(Register src, Label* on_invalid); |
| 198 |
| 199 // Jump to label if the value is a tagged smi. |
| 200 void JumpIfSmi(Register src, Label* on_smi); |
| 201 |
| 202 // Jump to label if the value is not a tagged smi. |
| 203 void JumpIfNotSmi(Register src, Label* on_not_smi); |
| 204 |
| 205 // Jump to label if the value is not a positive tagged smi. |
| 206 void JumpIfNotPositiveSmi(Register src, Label* on_not_smi); |
| 207 |
| 208 // Jump to label if the value is a tagged smi with value equal |
| 209 // to the constant. |
| 210 void JumpIfSmiEqualsConstant(Register src, int constant, Label* on_equals); |
| 211 |
| 212 // Jump if either or both register are not smi values. |
| 213 void JumpIfNotBothSmi(Register src1, Register src2, Label* on_not_both_smi); |
| 214 |
| 215 // Operations on tagged smi values. |
| 216 |
| 217 // Smis represent a subset of integers. The subset is always equivalent to |
| 218 // a two's complement interpretation of a fixed number of bits. |
| 219 |
| 220 // Optimistically adds an integer constant to a supposed smi. |
| 221 // If the src is not a smi, or the result is not a smi, jump to |
| 222 // the label. |
| 223 void SmiTryAddConstant(Register dst, |
| 224 Register src, |
| 225 int32_t constant, |
| 226 Label* on_not_smi_result); |
| 227 |
| 228 // Add an integer constant to a tagged smi, giving a tagged smi as result, |
| 229 // or jumping to a label if the result cannot be represented by a smi. |
| 230 // If the label is NULL, no testing on the result is done. |
| 231 void SmiAddConstant(Register dst, |
| 232 Register src, |
| 233 int32_t constant, |
| 234 Label* on_not_smi_result); |
| 235 |
| 236 // Subtract an integer constant from a tagged smi, giving a tagged smi as |
| 237 // result, or jumping to a label if the result cannot be represented by a smi. |
| 238 // If the label is NULL, no testing on the result is done. |
| 239 void SmiSubConstant(Register dst, |
| 240 Register src, |
| 241 int32_t constant, |
| 242 Label* on_not_smi_result); |
| 243 |
| 244 // Negating a smi can give a negative zero or too larget positive value. |
| 245 void SmiNeg(Register dst, |
| 246 Register src, |
| 247 Label* on_not_smi_result); |
| 248 |
| 249 // Adds smi values and return the result as a smi. |
| 250 // If dst is src1, then src1 will be destroyed, even if |
| 251 // the operation is unsuccessful. |
| 252 void SmiAdd(Register dst, |
| 253 Register src1, |
| 254 Register src2, |
| 255 Label* on_not_smi_result); |
| 256 // Subtracts smi values and return the result as a smi. |
| 257 // If dst is src1, then src1 will be destroyed, even if |
| 258 // the operation is unsuccessful. |
| 259 void SmiSub(Register dst, |
| 260 Register src1, |
| 261 Register src2, |
| 262 Label* on_not_smi_result); |
| 263 // Multiplies smi values and return the result as a smi, |
| 264 // if possible. |
| 265 // If dst is src1, then src1 will be destroyed, even if |
| 266 // the operation is unsuccessful. |
| 267 void SmiMul(Register dst, |
| 268 Register src1, |
| 269 Register src2, |
| 270 Label* on_not_smi_result); |
| 271 |
| 272 // Divides one smi by another and returns the quotient. |
| 273 // Clobbers rax and rdx registers. |
| 274 void SmiDiv(Register dst, |
| 275 Register src1, |
| 276 Register src2, |
| 277 Label* on_not_smi_result); |
| 278 |
| 279 // Divides one smi by another and returns the remainder. |
| 280 // Clobbers rax and rdx registers. |
| 281 void SmiMod(Register dst, |
| 282 Register src1, |
| 283 Register src2, |
| 284 Label* on_not_smi_result); |
| 285 |
| 286 // Bitwise operations. |
| 287 void SmiNot(Register dst, Register src); |
| 288 void SmiAnd(Register dst, Register src1, Register src2); |
| 289 void SmiOr(Register dst, Register src1, Register src2); |
| 290 void SmiXor(Register dst, Register src1, Register src2); |
| 291 void SmiAndConstant(Register dst, Register src1, int constant); |
| 292 void SmiOrConstant(Register dst, Register src1, int constant); |
| 293 void SmiXorConstant(Register dst, Register src1, int constant); |
| 294 |
| 295 void SmiShiftLeftConstant(Register dst, |
| 296 Register src, |
| 297 int shift_value, |
| 298 Label* on_not_smi_result); |
| 299 void SmiShiftLogicRightConstant(Register dst, |
| 300 Register src, |
| 301 int shift_value, |
| 302 Label* on_not_smi_result); |
| 303 void SmiShiftArithmeticRightConstant(Register dst, |
| 304 Register src, |
| 305 int shift_value); |
| 306 |
| 307 // Shifts a smi value to the left, and returns the result if that is a smi. |
| 308 // Uses and clobbers rcx, so dst may not be rcx. |
| 309 void SmiShiftLeft(Register dst, |
| 310 Register src1, |
| 311 Register src2, |
| 312 Label* on_not_smi_result); |
| 313 // Shifts a smi value to the right, shifting in zero bits at the top, and |
| 314 // returns the unsigned intepretation of the result if that is a smi. |
| 315 // Uses and clobbers rcx, so dst may not be rcx. |
| 316 void SmiShiftLogicRight(Register dst, |
| 317 Register src1, |
| 318 Register src2, |
| 319 Label* on_not_smi_result); |
| 320 // Shifts a smi value to the right, sign extending the top, and |
| 321 // returns the signed intepretation of the result. That will always |
| 322 // be a valid smi value, since it's numerically smaller than the |
| 323 // original. |
| 324 // Uses and clobbers rcx, so dst may not be rcx. |
| 325 void SmiShiftArithmeticRight(Register dst, |
| 326 Register src1, |
| 327 Register src2); |
| 328 |
| 329 // Specialized operations |
| 330 |
| 331 // Select the non-smi register of two registers where exactly one is a |
| 332 // smi. If neither are smis, jump to the failure label. |
| 333 void SelectNonSmi(Register dst, |
| 334 Register src1, |
| 335 Register src2, |
| 336 Label* on_not_smis); |
| 337 |
129 // --------------------------------------------------------------------------- | 338 // --------------------------------------------------------------------------- |
130 // Macro instructions | 339 // Macro instructions |
131 | 340 |
132 // Expression support | 341 // Expression support |
133 void Set(Register dst, int64_t x); | 342 void Set(Register dst, int64_t x); |
134 void Set(const Operand& dst, int64_t x); | 343 void Set(const Operand& dst, int64_t x); |
135 | 344 |
136 // Handle support | 345 // Handle support |
137 bool IsUnsafeSmi(Smi* value); | 346 bool IsUnsafeSmi(Smi* value); |
138 bool IsUnsafeSmi(Handle<Object> value) { | 347 bool IsUnsafeSmi(Handle<Object> value) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } \ | 645 } \ |
437 masm-> | 646 masm-> |
438 #else | 647 #else |
439 #define ACCESS_MASM(masm) masm-> | 648 #define ACCESS_MASM(masm) masm-> |
440 #endif | 649 #endif |
441 | 650 |
442 | 651 |
443 } } // namespace v8::internal | 652 } } // namespace v8::internal |
444 | 653 |
445 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 654 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |