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

Side by Side Diff: src/code-stubs.h

Issue 13728002: Add an IC for CompareNil operations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix SunSpider regression Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.cc ('k') | src/code-stubs.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 29 matching lines...) Expand all
40 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ 40 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \
41 V(CallFunction) \ 41 V(CallFunction) \
42 V(CallConstruct) \ 42 V(CallConstruct) \
43 V(UnaryOp) \ 43 V(UnaryOp) \
44 V(BinaryOp) \ 44 V(BinaryOp) \
45 V(StringAdd) \ 45 V(StringAdd) \
46 V(SubString) \ 46 V(SubString) \
47 V(StringCompare) \ 47 V(StringCompare) \
48 V(Compare) \ 48 V(Compare) \
49 V(CompareIC) \ 49 V(CompareIC) \
50 V(CompareNilIC) \
50 V(MathPow) \ 51 V(MathPow) \
51 V(StringLength) \ 52 V(StringLength) \
52 V(FunctionPrototype) \ 53 V(FunctionPrototype) \
53 V(StoreArrayLength) \ 54 V(StoreArrayLength) \
54 V(RecordWrite) \ 55 V(RecordWrite) \
55 V(StoreBufferOverflow) \ 56 V(StoreBufferOverflow) \
56 V(RegExpExec) \ 57 V(RegExpExec) \
57 V(TranscendentalCache) \ 58 V(TranscendentalCache) \
58 V(Instanceof) \ 59 V(Instanceof) \
59 V(ConvertToDouble) \ 60 V(ConvertToDouble) \
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 CODE_STUB_IS_NOT_MISS, 287 CODE_STUB_IS_NOT_MISS,
287 CODE_STUB_IS_MISS 288 CODE_STUB_IS_MISS
288 }; 289 };
289 290
290 explicit HydrogenCodeStub(InitializationState state) { 291 explicit HydrogenCodeStub(InitializationState state) {
291 is_miss_ = (state == CODE_STUB_IS_MISS); 292 is_miss_ = (state == CODE_STUB_IS_MISS);
292 } 293 }
293 294
294 virtual Code::Kind GetCodeKind() const { return Code::STUB; } 295 virtual Code::Kind GetCodeKind() const { return Code::STUB; }
295 296
296 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) { 297 CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
298 Isolate* isolate) {
297 return isolate->code_stub_interface_descriptor(MajorKey()); 299 return isolate->code_stub_interface_descriptor(MajorKey());
298 } 300 }
299 301
300 bool IsMiss() { return is_miss_; } 302 bool IsMiss() { return is_miss_; }
301 303
302 template<class SubClass> 304 template<class SubClass>
303 static Handle<Code> GetUninitialized(Isolate* isolate) { 305 static Handle<Code> GetUninitialized(Isolate* isolate) {
304 SubClass::GenerateAheadOfTime(isolate); 306 SubClass::GenerateAheadOfTime(isolate);
305 return SubClass().GetCode(isolate); 307 return SubClass().GetCode(isolate);
306 } 308 }
307 309
308 virtual void InitializeInterfaceDescriptor( 310 virtual void InitializeInterfaceDescriptor(
309 Isolate* isolate, 311 Isolate* isolate,
310 CodeStubInterfaceDescriptor* descriptor) = 0; 312 CodeStubInterfaceDescriptor* descriptor) = 0;
311 313
312 // Retrieve the code for the stub. Generate the code if needed. 314 // Retrieve the code for the stub. Generate the code if needed.
313 virtual Handle<Code> GenerateCode() = 0; 315 virtual Handle<Code> GenerateCode() = 0;
314 316
315 virtual int NotMissMinorKey() = 0; 317 virtual int NotMissMinorKey() = 0;
316 318
317 Handle<Code> GenerateLightweightMissCode(Isolate* isolate); 319 Handle<Code> GenerateLightweightMissCode(Isolate* isolate);
318 320
319 private: 321 private:
320 class MinorKeyBits: public BitField<int, 0, kStubMinorKeyBits - 1> {}; 322 class MinorKeyBits: public BitField<int, 0, kStubMinorKeyBits - 1> {};
321 class IsMissBits: public BitField<bool, kStubMinorKeyBits - 1, 1> {}; 323 class IsMissBits: public BitField<bool, kStubMinorKeyBits - 1, 1> {};
322 324
323 void GenerateLightweightMiss(MacroAssembler* masm); 325 void GenerateLightweightMiss(MacroAssembler* masm);
326
324 virtual int MinorKey() { 327 virtual int MinorKey() {
325 return IsMissBits::encode(is_miss_) | 328 return IsMissBits::encode(is_miss_) |
326 MinorKeyBits::encode(NotMissMinorKey()); 329 MinorKeyBits::encode(NotMissMinorKey());
327 } 330 }
328 331
329 bool is_miss_; 332 bool is_miss_;
330 }; 333 };
331 334
332 335
333 // Helper interface to prepare to/restore after making runtime calls. 336 // Helper interface to prepare to/restore after making runtime calls.
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECT; } 942 virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECT; }
940 943
941 Token::Value op_; 944 Token::Value op_;
942 CompareIC::State left_; 945 CompareIC::State left_;
943 CompareIC::State right_; 946 CompareIC::State right_;
944 CompareIC::State state_; 947 CompareIC::State state_;
945 Handle<Map> known_map_; 948 Handle<Map> known_map_;
946 }; 949 };
947 950
948 951
952 class CompareNilICStub : public HydrogenCodeStub {
953 public:
954 CompareNilICStub() : HydrogenCodeStub(CODE_STUB_IS_MISS), bit_field_(0) {}
955
956 enum Types {
957 kCompareAgainstNull = 1 << 0,
958 kCompareAgainstUndefined = 1 << 1,
959 kCompareAgainstMonomorphicMap = 1 << 2,
960 kCompareAgainstUndetectable = 1 << 3,
961 kFullCompare = kCompareAgainstNull | kCompareAgainstUndefined |
962 kCompareAgainstUndetectable
963 };
964
965 CompareNilICStub(EqualityKind kind, Types types)
966 : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS), bit_field_(0) {
967 bit_field_ = EqualityKindBits::encode(kind) | TypesBits::encode(types);
968 }
969
970 virtual InlineCacheState GetICState() {
971 Types types = GetTypes();
972 if (types == kFullCompare) {
973 return MEGAMORPHIC;
974 } else if ((types & kCompareAgainstMonomorphicMap) != 0) {
975 return MONOMORPHIC;
976 } else {
977 return PREMONOMORPHIC;
978 }
979 }
980
981 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; }
982
983 Handle<Code> GenerateCode();
984
985 virtual void InitializeInterfaceDescriptor(
986 Isolate* isolate,
987 CodeStubInterfaceDescriptor* descriptor);
988
989 virtual Code::ExtraICState GetExtraICState() {
990 return TypesBits::decode(bit_field_);
991 }
992
993 static Types TypesFromExtraICState(Code::ExtraICState state) {
994 return static_cast<Types>(state);
995 }
996
997 EqualityKind Kind() { return EqualityKindBits::decode(bit_field_); }
998 Types GetTypes() { return TypesBits::decode(bit_field_); }
999
1000 static Types GetPatchedICFlags(Code* code,
1001 EqualityKind kind,
1002 NilValue nil,
1003 Handle<Object> object,
1004 bool* already_monomorphic);
1005
1006 private:
1007 class EqualityKindBits : public BitField<EqualityKind, 0, 1> {};
1008 class TypesBits : public BitField<Types, 2, 4> {};
1009
1010 virtual CodeStub::Major MajorKey() { return CompareNilIC; }
1011 virtual int NotMissMinorKey() { return bit_field_; }
1012
1013 int bit_field_;
1014
1015 DISALLOW_COPY_AND_ASSIGN(CompareNilICStub);
1016 };
1017
1018
949 class CEntryStub : public PlatformCodeStub { 1019 class CEntryStub : public PlatformCodeStub {
950 public: 1020 public:
951 explicit CEntryStub(int result_size, 1021 explicit CEntryStub(int result_size,
952 SaveFPRegsMode save_doubles = kDontSaveFPRegs) 1022 SaveFPRegsMode save_doubles = kDontSaveFPRegs)
953 : result_size_(result_size), save_doubles_(save_doubles) { } 1023 : result_size_(result_size), save_doubles_(save_doubles) { }
954 1024
955 void Generate(MacroAssembler* masm); 1025 void Generate(MacroAssembler* masm);
956 1026
957 // The version of this stub that doesn't save doubles is generated ahead of 1027 // The version of this stub that doesn't save doubles is generated ahead of
958 // time, so it's OK to call it from other stubs that can't cope with GC during 1028 // time, so it's OK to call it from other stubs that can't cope with GC during
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1797
1728 // The current function entry hook. 1798 // The current function entry hook.
1729 static FunctionEntryHook entry_hook_; 1799 static FunctionEntryHook entry_hook_;
1730 1800
1731 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 1801 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
1732 }; 1802 };
1733 1803
1734 } } // namespace v8::internal 1804 } } // namespace v8::internal
1735 1805
1736 #endif // V8_CODE_STUBS_H_ 1806 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698