| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 ToBooleanStub() { } | 64 ToBooleanStub() { } |
| 65 | 65 |
| 66 void Generate(MacroAssembler* masm); | 66 void Generate(MacroAssembler* masm); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 Major MajorKey() { return ToBoolean; } | 69 Major MajorKey() { return ToBoolean; } |
| 70 int MinorKey() { return 0; } | 70 int MinorKey() { return 0; } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 | 73 |
| 74 class TypeRecordingUnaryOpStub: public CodeStub { | 74 class UnaryOpStub: public CodeStub { |
| 75 public: | 75 public: |
| 76 TypeRecordingUnaryOpStub(Token::Value op, UnaryOverwriteMode mode) | 76 UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) |
| 77 : op_(op), | 77 : op_(op), |
| 78 mode_(mode), | 78 mode_(mode), |
| 79 operand_type_(TRUnaryOpIC::UNINITIALIZED), | 79 operand_type_(UnaryOpIC::UNINITIALIZED), |
| 80 name_(NULL) { | 80 name_(NULL) { |
| 81 } | 81 } |
| 82 | 82 |
| 83 TypeRecordingUnaryOpStub( | 83 UnaryOpStub( |
| 84 int key, | 84 int key, |
| 85 TRUnaryOpIC::TypeInfo operand_type) | 85 UnaryOpIC::TypeInfo operand_type) |
| 86 : op_(OpBits::decode(key)), | 86 : op_(OpBits::decode(key)), |
| 87 mode_(ModeBits::decode(key)), | 87 mode_(ModeBits::decode(key)), |
| 88 operand_type_(operand_type), | 88 operand_type_(operand_type), |
| 89 name_(NULL) { | 89 name_(NULL) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 Token::Value op_; | 93 Token::Value op_; |
| 94 UnaryOverwriteMode mode_; | 94 UnaryOverwriteMode mode_; |
| 95 | 95 |
| 96 // Operand type information determined at runtime. | 96 // Operand type information determined at runtime. |
| 97 TRUnaryOpIC::TypeInfo operand_type_; | 97 UnaryOpIC::TypeInfo operand_type_; |
| 98 | 98 |
| 99 char* name_; | 99 char* name_; |
| 100 | 100 |
| 101 const char* GetName(); | 101 const char* GetName(); |
| 102 | 102 |
| 103 #ifdef DEBUG | 103 #ifdef DEBUG |
| 104 void Print() { | 104 void Print() { |
| 105 PrintF("TypeRecordingUnaryOpStub %d (op %s), " | 105 PrintF("UnaryOpStub %d (op %s), " |
| 106 "(mode %d, runtime_type_info %s)\n", | 106 "(mode %d, runtime_type_info %s)\n", |
| 107 MinorKey(), | 107 MinorKey(), |
| 108 Token::String(op_), | 108 Token::String(op_), |
| 109 static_cast<int>(mode_), | 109 static_cast<int>(mode_), |
| 110 TRUnaryOpIC::GetName(operand_type_)); | 110 UnaryOpIC::GetName(operand_type_)); |
| 111 } | 111 } |
| 112 #endif | 112 #endif |
| 113 | 113 |
| 114 class ModeBits: public BitField<UnaryOverwriteMode, 0, 1> {}; | 114 class ModeBits: public BitField<UnaryOverwriteMode, 0, 1> {}; |
| 115 class OpBits: public BitField<Token::Value, 1, 7> {}; | 115 class OpBits: public BitField<Token::Value, 1, 7> {}; |
| 116 class OperandTypeInfoBits: public BitField<TRUnaryOpIC::TypeInfo, 8, 3> {}; | 116 class OperandTypeInfoBits: public BitField<UnaryOpIC::TypeInfo, 8, 3> {}; |
| 117 | 117 |
| 118 Major MajorKey() { return TypeRecordingUnaryOp; } | 118 Major MajorKey() { return UnaryOp; } |
| 119 int MinorKey() { | 119 int MinorKey() { |
| 120 return ModeBits::encode(mode_) | 120 return ModeBits::encode(mode_) |
| 121 | OpBits::encode(op_) | 121 | OpBits::encode(op_) |
| 122 | OperandTypeInfoBits::encode(operand_type_); | 122 | OperandTypeInfoBits::encode(operand_type_); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Note: A lot of the helper functions below will vanish when we use virtual | 125 // Note: A lot of the helper functions below will vanish when we use virtual |
| 126 // function instead of switch more often. | 126 // function instead of switch more often. |
| 127 void Generate(MacroAssembler* masm); | 127 void Generate(MacroAssembler* masm); |
| 128 | 128 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 144 void GenerateHeapNumberStubSub(MacroAssembler* masm); | 144 void GenerateHeapNumberStubSub(MacroAssembler* masm); |
| 145 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); | 145 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); |
| 146 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); | 146 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); |
| 147 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); | 147 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); |
| 148 | 148 |
| 149 void GenerateGenericStub(MacroAssembler* masm); | 149 void GenerateGenericStub(MacroAssembler* masm); |
| 150 void GenerateGenericStubSub(MacroAssembler* masm); | 150 void GenerateGenericStubSub(MacroAssembler* masm); |
| 151 void GenerateGenericStubBitNot(MacroAssembler* masm); | 151 void GenerateGenericStubBitNot(MacroAssembler* masm); |
| 152 void GenerateGenericCodeFallback(MacroAssembler* masm); | 152 void GenerateGenericCodeFallback(MacroAssembler* masm); |
| 153 | 153 |
| 154 virtual int GetCodeKind() { return Code::TYPE_RECORDING_UNARY_OP_IC; } | 154 virtual int GetCodeKind() { return Code::UNARY_OP_IC; } |
| 155 | 155 |
| 156 virtual InlineCacheState GetICState() { | 156 virtual InlineCacheState GetICState() { |
| 157 return TRUnaryOpIC::ToState(operand_type_); | 157 return UnaryOpIC::ToState(operand_type_); |
| 158 } | 158 } |
| 159 | 159 |
| 160 virtual void FinishCode(Code* code) { | 160 virtual void FinishCode(Code* code) { |
| 161 code->set_type_recording_unary_op_type(operand_type_); | 161 code->set_unary_op_type(operand_type_); |
| 162 } | 162 } |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 | 165 |
| 166 class TypeRecordingBinaryOpStub: public CodeStub { | 166 class BinaryOpStub: public CodeStub { |
| 167 public: | 167 public: |
| 168 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) | 168 BinaryOpStub(Token::Value op, OverwriteMode mode) |
| 169 : op_(op), | 169 : op_(op), |
| 170 mode_(mode), | 170 mode_(mode), |
| 171 operands_type_(TRBinaryOpIC::UNINITIALIZED), | 171 operands_type_(BinaryOpIC::UNINITIALIZED), |
| 172 result_type_(TRBinaryOpIC::UNINITIALIZED), | 172 result_type_(BinaryOpIC::UNINITIALIZED), |
| 173 name_(NULL) { | 173 name_(NULL) { |
| 174 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 174 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 TypeRecordingBinaryOpStub( | 177 BinaryOpStub( |
| 178 int key, | 178 int key, |
| 179 TRBinaryOpIC::TypeInfo operands_type, | 179 BinaryOpIC::TypeInfo operands_type, |
| 180 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED) | 180 BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED) |
| 181 : op_(OpBits::decode(key)), | 181 : op_(OpBits::decode(key)), |
| 182 mode_(ModeBits::decode(key)), | 182 mode_(ModeBits::decode(key)), |
| 183 operands_type_(operands_type), | 183 operands_type_(operands_type), |
| 184 result_type_(result_type), | 184 result_type_(result_type), |
| 185 name_(NULL) { } | 185 name_(NULL) { } |
| 186 | 186 |
| 187 private: | 187 private: |
| 188 enum SmiCodeGenerateHeapNumberResults { | 188 enum SmiCodeGenerateHeapNumberResults { |
| 189 ALLOW_HEAPNUMBER_RESULTS, | 189 ALLOW_HEAPNUMBER_RESULTS, |
| 190 NO_HEAPNUMBER_RESULTS | 190 NO_HEAPNUMBER_RESULTS |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 Token::Value op_; | 193 Token::Value op_; |
| 194 OverwriteMode mode_; | 194 OverwriteMode mode_; |
| 195 | 195 |
| 196 // Operand type information determined at runtime. | 196 // Operand type information determined at runtime. |
| 197 TRBinaryOpIC::TypeInfo operands_type_; | 197 BinaryOpIC::TypeInfo operands_type_; |
| 198 TRBinaryOpIC::TypeInfo result_type_; | 198 BinaryOpIC::TypeInfo result_type_; |
| 199 | 199 |
| 200 char* name_; | 200 char* name_; |
| 201 | 201 |
| 202 const char* GetName(); | 202 const char* GetName(); |
| 203 | 203 |
| 204 #ifdef DEBUG | 204 #ifdef DEBUG |
| 205 void Print() { | 205 void Print() { |
| 206 PrintF("TypeRecordingBinaryOpStub %d (op %s), " | 206 PrintF("BinaryOpStub %d (op %s), " |
| 207 "(mode %d, runtime_type_info %s)\n", | 207 "(mode %d, runtime_type_info %s)\n", |
| 208 MinorKey(), | 208 MinorKey(), |
| 209 Token::String(op_), | 209 Token::String(op_), |
| 210 static_cast<int>(mode_), | 210 static_cast<int>(mode_), |
| 211 TRBinaryOpIC::GetName(operands_type_)); | 211 BinaryOpIC::GetName(operands_type_)); |
| 212 } | 212 } |
| 213 #endif | 213 #endif |
| 214 | 214 |
| 215 // Minor key encoding in 15 bits RRRTTTOOOOOOOMM. | 215 // Minor key encoding in 15 bits RRRTTTOOOOOOOMM. |
| 216 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 216 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
| 217 class OpBits: public BitField<Token::Value, 2, 7> {}; | 217 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 218 class OperandTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 9, 3> {}; | 218 class OperandTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 9, 3> {}; |
| 219 class ResultTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 12, 3> {}; | 219 class ResultTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 12, 3> {}; |
| 220 | 220 |
| 221 Major MajorKey() { return TypeRecordingBinaryOp; } | 221 Major MajorKey() { return BinaryOp; } |
| 222 int MinorKey() { | 222 int MinorKey() { |
| 223 return OpBits::encode(op_) | 223 return OpBits::encode(op_) |
| 224 | ModeBits::encode(mode_) | 224 | ModeBits::encode(mode_) |
| 225 | OperandTypeInfoBits::encode(operands_type_) | 225 | OperandTypeInfoBits::encode(operands_type_) |
| 226 | ResultTypeInfoBits::encode(result_type_); | 226 | ResultTypeInfoBits::encode(result_type_); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void Generate(MacroAssembler* masm); | 229 void Generate(MacroAssembler* masm); |
| 230 void GenerateGeneric(MacroAssembler* masm); | 230 void GenerateGeneric(MacroAssembler* masm); |
| 231 void GenerateSmiCode(MacroAssembler* masm, | 231 void GenerateSmiCode(MacroAssembler* masm, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 245 void GenerateOddballStub(MacroAssembler* masm); | 245 void GenerateOddballStub(MacroAssembler* masm); |
| 246 void GenerateStringStub(MacroAssembler* masm); | 246 void GenerateStringStub(MacroAssembler* masm); |
| 247 void GenerateBothStringStub(MacroAssembler* masm); | 247 void GenerateBothStringStub(MacroAssembler* masm); |
| 248 void GenerateGenericStub(MacroAssembler* masm); | 248 void GenerateGenericStub(MacroAssembler* masm); |
| 249 | 249 |
| 250 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); | 250 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); |
| 251 void GenerateRegisterArgsPush(MacroAssembler* masm); | 251 void GenerateRegisterArgsPush(MacroAssembler* masm); |
| 252 void GenerateTypeTransition(MacroAssembler* masm); | 252 void GenerateTypeTransition(MacroAssembler* masm); |
| 253 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); | 253 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); |
| 254 | 254 |
| 255 virtual int GetCodeKind() { return Code::TYPE_RECORDING_BINARY_OP_IC; } | 255 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
| 256 | 256 |
| 257 virtual InlineCacheState GetICState() { | 257 virtual InlineCacheState GetICState() { |
| 258 return TRBinaryOpIC::ToState(operands_type_); | 258 return BinaryOpIC::ToState(operands_type_); |
| 259 } | 259 } |
| 260 | 260 |
| 261 virtual void FinishCode(Code* code) { | 261 virtual void FinishCode(Code* code) { |
| 262 code->set_type_recording_binary_op_type(operands_type_); | 262 code->set_binary_op_type(operands_type_); |
| 263 code->set_type_recording_binary_op_result_type(result_type_); | 263 code->set_binary_op_result_type(result_type_); |
| 264 } | 264 } |
| 265 | 265 |
| 266 friend class CodeGenerator; | 266 friend class CodeGenerator; |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 | 269 |
| 270 class StringHelper : public AllStatic { | 270 class StringHelper : public AllStatic { |
| 271 public: | 271 public: |
| 272 // Generate code for copying characters using a simple loop. This should only | 272 // Generate code for copying characters using a simple loop. This should only |
| 273 // be used in places where the number of characters is small and the | 273 // be used in places where the number of characters is small and the |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 Register dictionary_; | 505 Register dictionary_; |
| 506 Register result_; | 506 Register result_; |
| 507 Register index_; | 507 Register index_; |
| 508 LookupMode mode_; | 508 LookupMode mode_; |
| 509 }; | 509 }; |
| 510 | 510 |
| 511 | 511 |
| 512 } } // namespace v8::internal | 512 } } // namespace v8::internal |
| 513 | 513 |
| 514 #endif // V8_X64_CODE_STUBS_X64_H_ | 514 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |