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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 virtual int MinorKey() = 0; | 187 virtual int MinorKey() = 0; |
188 | 188 |
189 // BinaryOpStub needs to override this. | 189 // BinaryOpStub needs to override this. |
190 virtual int GetCodeKind(); | 190 virtual int GetCodeKind(); |
191 | 191 |
192 // BinaryOpStub needs to override this. | 192 // BinaryOpStub needs to override this. |
193 virtual InlineCacheState GetICState() { | 193 virtual InlineCacheState GetICState() { |
194 return UNINITIALIZED; | 194 return UNINITIALIZED; |
195 } | 195 } |
196 | 196 |
| 197 // Add the code to a specialized cache, specific to an individual |
| 198 // stub type. Please note, this method must add the code object to a |
| 199 // roots object, otherwise we will remove the code during GC. |
| 200 virtual void AddToSpecialCache(Handle<Code> new_object) { } |
| 201 |
| 202 // Find code in a specialized cache, work is delegated to the specific stub. |
| 203 virtual bool FindCodeInSpecialCache(Code** code_out) { return false; } |
| 204 |
| 205 // If a stub uses a special cache override this. |
| 206 virtual bool UseSpecialCache() { return false; } |
| 207 |
197 // Returns a name for logging/debugging purposes. | 208 // Returns a name for logging/debugging purposes. |
198 SmartArrayPointer<const char> GetName(); | 209 SmartArrayPointer<const char> GetName(); |
199 virtual void PrintName(StringStream* stream); | 210 virtual void PrintName(StringStream* stream); |
200 | 211 |
201 // Returns whether the code generated for this stub needs to be allocated as | 212 // Returns whether the code generated for this stub needs to be allocated as |
202 // a fixed (non-moveable) code object. | 213 // a fixed (non-moveable) code object. |
203 virtual bool NeedsImmovableCode() { return false; } | 214 virtual bool NeedsImmovableCode() { return false; } |
204 | 215 |
205 // Computes the key based on major and minor. | 216 // Computes the key based on major and minor. |
206 uint32_t GetKey() { | 217 uint32_t GetKey() { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 469 |
459 class ICCompareStub: public CodeStub { | 470 class ICCompareStub: public CodeStub { |
460 public: | 471 public: |
461 ICCompareStub(Token::Value op, CompareIC::State state) | 472 ICCompareStub(Token::Value op, CompareIC::State state) |
462 : op_(op), state_(state) { | 473 : op_(op), state_(state) { |
463 ASSERT(Token::IsCompareOp(op)); | 474 ASSERT(Token::IsCompareOp(op)); |
464 } | 475 } |
465 | 476 |
466 virtual void Generate(MacroAssembler* masm); | 477 virtual void Generate(MacroAssembler* masm); |
467 | 478 |
| 479 void set_known_map(Handle<Map> map) { known_map_ = map; } |
| 480 |
468 private: | 481 private: |
469 class OpField: public BitField<int, 0, 3> { }; | 482 class OpField: public BitField<int, 0, 3> { }; |
470 class StateField: public BitField<int, 3, 5> { }; | 483 class StateField: public BitField<int, 3, 5> { }; |
471 | 484 |
472 virtual void FinishCode(Handle<Code> code) { | 485 virtual void FinishCode(Handle<Code> code) { |
473 code->set_compare_state(state_); | 486 code->set_compare_state(state_); |
474 } | 487 } |
475 | 488 |
476 virtual CodeStub::Major MajorKey() { return CompareIC; } | 489 virtual CodeStub::Major MajorKey() { return CompareIC; } |
477 virtual int MinorKey(); | 490 virtual int MinorKey(); |
478 | 491 |
479 virtual int GetCodeKind() { return Code::COMPARE_IC; } | 492 virtual int GetCodeKind() { return Code::COMPARE_IC; } |
480 | 493 |
481 void GenerateSmis(MacroAssembler* masm); | 494 void GenerateSmis(MacroAssembler* masm); |
482 void GenerateHeapNumbers(MacroAssembler* masm); | 495 void GenerateHeapNumbers(MacroAssembler* masm); |
483 void GenerateSymbols(MacroAssembler* masm); | 496 void GenerateSymbols(MacroAssembler* masm); |
484 void GenerateStrings(MacroAssembler* masm); | 497 void GenerateStrings(MacroAssembler* masm); |
485 void GenerateObjects(MacroAssembler* masm); | 498 void GenerateObjects(MacroAssembler* masm); |
486 void GenerateMiss(MacroAssembler* masm); | 499 void GenerateMiss(MacroAssembler* masm); |
| 500 void GenerateKnownObjects(MacroAssembler* masm); |
487 | 501 |
488 bool strict() const { return op_ == Token::EQ_STRICT; } | 502 bool strict() const { return op_ == Token::EQ_STRICT; } |
489 Condition GetCondition() const { return CompareIC::ComputeCondition(op_); } | 503 Condition GetCondition() const { return CompareIC::ComputeCondition(op_); } |
490 | 504 |
| 505 virtual void AddToSpecialCache(Handle<Code> new_object); |
| 506 virtual bool FindCodeInSpecialCache(Code** code_out); |
| 507 virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECTS; } |
| 508 |
491 Token::Value op_; | 509 Token::Value op_; |
492 CompareIC::State state_; | 510 CompareIC::State state_; |
| 511 Handle<Map> known_map_; |
493 }; | 512 }; |
494 | 513 |
495 | 514 |
496 // Flags that control the compare stub code generation. | 515 // Flags that control the compare stub code generation. |
497 enum CompareFlags { | 516 enum CompareFlags { |
498 NO_COMPARE_FLAGS = 0, | 517 NO_COMPARE_FLAGS = 0, |
499 NO_SMI_COMPARE_IN_STUB = 1 << 0, | 518 NO_SMI_COMPARE_IN_STUB = 1 << 0, |
500 NO_NUMBER_COMPARE_IN_STUB = 1 << 1, | 519 NO_NUMBER_COMPARE_IN_STUB = 1 << 1, |
501 CANT_BOTH_BE_NAN = 1 << 2 | 520 CANT_BOTH_BE_NAN = 1 << 2 |
502 }; | 521 }; |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 int MinorKey() { return 0; } | 1109 int MinorKey() { return 0; } |
1091 | 1110 |
1092 void Generate(MacroAssembler* masm); | 1111 void Generate(MacroAssembler* masm); |
1093 | 1112 |
1094 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); | 1113 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); |
1095 }; | 1114 }; |
1096 | 1115 |
1097 } } // namespace v8::internal | 1116 } } // namespace v8::internal |
1098 | 1117 |
1099 #endif // V8_CODE_STUBS_H_ | 1118 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |