Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 // Operand type information determined at runtime. | 124 // Operand type information determined at runtime. |
| 125 BinaryOpIC::TypeInfo runtime_operands_type_; | 125 BinaryOpIC::TypeInfo runtime_operands_type_; |
| 126 | 126 |
| 127 char* name_; | 127 char* name_; |
| 128 | 128 |
| 129 const char* GetName(); | 129 const char* GetName(); |
| 130 | 130 |
| 131 #ifdef DEBUG | 131 #ifdef DEBUG |
| 132 void Print() { | 132 void Print() { |
| 133 PrintF("GenericBinaryOpStub %d (op %s), " | 133 PrintF("GenericBinaryOpStub %d (op %s), " |
| 134 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", | 134 "(mode %d, flags %d, registers %d, reversed %d, type_info %s)\n", |
| 135 MinorKey(), | 135 MinorKey(), |
| 136 Token::String(op_), | 136 Token::String(op_), |
| 137 static_cast<int>(mode_), | 137 static_cast<int>(mode_), |
| 138 static_cast<int>(flags_), | 138 static_cast<int>(flags_), |
| 139 static_cast<int>(args_in_registers_), | 139 static_cast<int>(args_in_registers_), |
| 140 static_cast<int>(args_reversed_), | 140 static_cast<int>(args_reversed_), |
| 141 static_operands_type_.ToString()); | 141 static_operands_type_.ToString()); |
| 142 } | 142 } |
| 143 #endif | 143 #endif |
| 144 | 144 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 | 193 |
| 194 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | 194 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
| 195 | 195 |
| 196 virtual InlineCacheState GetICState() { | 196 virtual InlineCacheState GetICState() { |
| 197 return BinaryOpIC::ToState(runtime_operands_type_); | 197 return BinaryOpIC::ToState(runtime_operands_type_); |
| 198 } | 198 } |
| 199 | 199 |
| 200 friend class CodeGenerator; | 200 friend class CodeGenerator; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 | |
| 204 class TypeRecordingBinaryOpStub: public CodeStub { | |
| 205 public: | |
| 206 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) | |
| 207 : op_(op), | |
| 208 mode_(mode), | |
| 209 operands_type_(TRBinaryOpIC::UNINITIALIZED), | |
| 210 result_type_(TRBinaryOpIC::UNINITIALIZED), | |
| 211 name_(NULL) { | |
| 212 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | |
| 213 } | |
| 214 | |
| 215 TypeRecordingBinaryOpStub( | |
| 216 int key, | |
| 217 TRBinaryOpIC::TypeInfo operands_type, | |
| 218 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED) | |
| 219 : op_(OpBits::decode(key)), | |
| 220 mode_(ModeBits::decode(key)), | |
| 221 operands_type_(operands_type), | |
| 222 result_type_(result_type), | |
| 223 name_(NULL) { } | |
| 224 | |
| 225 // Generate code to call the stub with the supplied arguments. This will add | |
| 226 // code at the call site to prepare arguments either in registers or on the | |
| 227 // stack together with the actual call. | |
| 228 void GenerateCall(MacroAssembler* masm, Register left, Register right); | |
| 229 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); | |
| 230 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); | |
| 231 | |
| 232 private: | |
| 233 enum SmiCodeGenerateHeapNumberResults { | |
| 234 ALLOW_HEAPNUMBER_RESULTS, | |
| 235 NO_HEAPNUMBER_RESULTS | |
| 236 }; | |
| 237 | |
| 238 Token::Value op_; | |
| 239 OverwriteMode mode_; | |
| 240 | |
| 241 // Operand type information determined at runtime. | |
| 242 TRBinaryOpIC::TypeInfo operands_type_; | |
| 243 TRBinaryOpIC::TypeInfo result_type_; | |
| 244 | |
| 245 char* name_; | |
| 246 | |
| 247 const char* GetName(); | |
| 248 | |
| 249 #ifdef DEBUG | |
| 250 void Print() { | |
| 251 PrintF("TypeRecordingBinaryOpStub %d (op %s), " | |
| 252 "(mode %d, runtime_type_info %s)\n", | |
| 253 MinorKey(), | |
| 254 Token::String(op_), | |
| 255 static_cast<int>(mode_), | |
| 256 TRBinaryOpIC::GetName(operands_type_)); | |
| 257 } | |
| 258 #endif | |
| 259 | |
| 260 // Minor key encoding in 15 bits RRRTTTOOOOOOOMM. | |
| 261 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | |
| 262 class OpBits: public BitField<Token::Value, 2, 7> {}; | |
| 263 class OperandTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 9, 3> {}; | |
| 264 class ResultTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 12, 3> {}; | |
| 265 | |
| 266 Major MajorKey() { return TypeRecordingBinaryOp; } | |
| 267 int MinorKey() { | |
| 268 return OpBits::encode(op_) | |
| 269 | ModeBits::encode(mode_) | |
| 270 | OperandTypeInfoBits::encode(operands_type_) | |
| 271 | ResultTypeInfoBits::encode(result_type_); | |
| 272 } | |
| 273 | |
| 274 void Generate(MacroAssembler* masm); | |
| 275 void GenerateGeneric(MacroAssembler* masm); | |
| 276 void GenerateSmiCode(MacroAssembler* masm, | |
| 277 Label* slow, | |
| 278 SmiCodeGenerateHeapNumberResults heapnumber_results); | |
| 279 void GenerateLoadArguments(MacroAssembler* masm); | |
| 280 void GenerateReturn(MacroAssembler* masm); | |
| 281 void GenerateUninitializedStub(MacroAssembler* masm); | |
| 282 void GenerateSmiStub(MacroAssembler* masm); | |
| 283 void GenerateInt32Stub(MacroAssembler* masm); | |
| 284 void GenerateHeapNumberStub(MacroAssembler* masm); | |
| 285 void GenerateStringStub(MacroAssembler* masm); | |
| 286 void GenerateGenericStub(MacroAssembler* masm); | |
| 287 | |
| 288 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); | |
| 289 void GenerateRegisterArgsPush(MacroAssembler* masm); | |
| 290 void GenerateTypeTransition(MacroAssembler* masm); | |
| 291 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); | |
| 292 | |
| 293 bool IsOperationCommutative() { | |
| 294 return (op_ == Token::ADD) || (op_ == Token::MUL); | |
|
Lasse Reichstein
2011/01/05 11:48:46
Are bit-ops not handled by this stub?
William Hesse
2011/01/05 12:29:06
This function is never used, and the functions Gen
| |
| 295 } | |
| 296 | |
| 297 virtual int GetCodeKind() { return Code::TYPE_RECORDING_BINARY_OP_IC; } | |
| 298 | |
| 299 virtual InlineCacheState GetICState() { | |
| 300 return TRBinaryOpIC::ToState(operands_type_); | |
| 301 } | |
| 302 | |
| 303 virtual void FinishCode(Code* code) { | |
| 304 code->set_type_recording_binary_op_type(operands_type_); | |
| 305 code->set_type_recording_binary_op_result_type(result_type_); | |
| 306 } | |
| 307 | |
| 308 friend class CodeGenerator; | |
| 309 }; | |
| 310 | |
| 311 | |
| 203 class StringHelper : public AllStatic { | 312 class StringHelper : public AllStatic { |
| 204 public: | 313 public: |
| 205 // Generate code for copying characters using a simple loop. This should only | 314 // Generate code for copying characters using a simple loop. This should only |
| 206 // be used in places where the number of characters is small and the | 315 // be used in places where the number of characters is small and the |
| 207 // additional setup and checking in GenerateCopyCharactersREP adds too much | 316 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 208 // overhead. Copying of overlapping regions is not supported. | 317 // overhead. Copying of overlapping regions is not supported. |
| 209 static void GenerateCopyCharacters(MacroAssembler* masm, | 318 static void GenerateCopyCharacters(MacroAssembler* masm, |
| 210 Register dest, | 319 Register dest, |
| 211 Register src, | 320 Register src, |
| 212 Register count, | 321 Register count, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 void Print() { | 453 void Print() { |
| 345 PrintF("NumberToStringStub\n"); | 454 PrintF("NumberToStringStub\n"); |
| 346 } | 455 } |
| 347 #endif | 456 #endif |
| 348 }; | 457 }; |
| 349 | 458 |
| 350 | 459 |
| 351 } } // namespace v8::internal | 460 } } // namespace v8::internal |
| 352 | 461 |
| 353 #endif // V8_X64_CODE_STUBS_X64_H_ | 462 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |