OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "macro-assembler.h" | 35 #include "macro-assembler.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 // List of code stubs used on all platforms. | 40 // List of code stubs used on all platforms. |
41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
42 V(CallFunction) \ | 42 V(CallFunction) \ |
43 V(CallConstruct) \ | 43 V(CallConstruct) \ |
44 V(BinaryOpIC) \ | 44 V(BinaryOpIC) \ |
45 V(BinaryOpICWithAllocationSite) \ | |
46 V(BinaryOpWithAllocationSite) \ | |
47 V(StringAdd) \ | 45 V(StringAdd) \ |
48 V(NewStringAdd) \ | 46 V(NewStringAdd) \ |
49 V(SubString) \ | 47 V(SubString) \ |
50 V(StringCompare) \ | 48 V(StringCompare) \ |
51 V(Compare) \ | 49 V(Compare) \ |
52 V(CompareIC) \ | 50 V(CompareIC) \ |
53 V(CompareNilIC) \ | 51 V(CompareNilIC) \ |
54 V(MathPow) \ | 52 V(MathPow) \ |
55 V(StringLength) \ | 53 V(StringLength) \ |
56 V(FunctionPrototype) \ | 54 V(FunctionPrototype) \ |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 STATIC_ASSERT(CallICBase::Contextual::kSize == ContextualBits::kSize); | 1055 STATIC_ASSERT(CallICBase::Contextual::kSize == ContextualBits::kSize); |
1058 class HoleyBits: public BitField<bool, 1, 1> {}; | 1056 class HoleyBits: public BitField<bool, 1, 1> {}; |
1059 STATIC_ASSERT(Code::kArgumentsBits <= kStubMinorKeyBits - 2); | 1057 STATIC_ASSERT(Code::kArgumentsBits <= kStubMinorKeyBits - 2); |
1060 class ArgcBits: public BitField<int, 2, Code::kArgumentsBits> {}; | 1058 class ArgcBits: public BitField<int, 2, Code::kArgumentsBits> {}; |
1061 virtual CodeStub::Major MajorKey() { return KeyedArrayCall; } | 1059 virtual CodeStub::Major MajorKey() { return KeyedArrayCall; } |
1062 int bit_field_; | 1060 int bit_field_; |
1063 int argc_; | 1061 int argc_; |
1064 }; | 1062 }; |
1065 | 1063 |
1066 | 1064 |
1067 class BinaryOpICStub : public HydrogenCodeStub { | 1065 class BinaryOpICStub V8_FINAL : public HydrogenCodeStub { |
1068 public: | 1066 public: |
1069 BinaryOpICStub(Token::Value op, OverwriteMode mode) | 1067 BinaryOpICStub(Token::Value op, OverwriteMode mode) |
1070 : HydrogenCodeStub(UNINITIALIZED), state_(op, mode) {} | 1068 : HydrogenCodeStub(UNINITIALIZED), state_(op, mode) {} |
1071 | 1069 |
1072 explicit BinaryOpICStub(const BinaryOpIC::State& state) : state_(state) {} | 1070 explicit BinaryOpICStub(const BinaryOpIC::State& state) : state_(state) {} |
1073 | 1071 |
1074 static void GenerateAheadOfTime(Isolate* isolate); | 1072 static void GenerateAheadOfTime(Isolate* isolate); |
1075 | 1073 |
1076 virtual void InitializeInterfaceDescriptor( | 1074 virtual void InitializeInterfaceDescriptor( |
1077 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1075 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
1078 | 1076 |
1079 static void InstallDescriptors(Isolate* isolate); | 1077 static void InstallDescriptors(Isolate* isolate); |
1080 | 1078 |
1081 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { | 1079 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
1082 return Code::BINARY_OP_IC; | 1080 return Code::BINARY_OP_IC; |
1083 } | 1081 } |
1084 | 1082 |
1085 virtual InlineCacheState GetICState() V8_FINAL V8_OVERRIDE { | 1083 virtual InlineCacheState GetICState() V8_OVERRIDE { |
1086 return state_.GetICState(); | 1084 return state_.GetICState(); |
1087 } | 1085 } |
1088 | 1086 |
1089 virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE { | 1087 virtual ExtraICState GetExtraICState() V8_OVERRIDE { |
1090 return state_.GetExtraICState(); | 1088 return state_.GetExtraICState(); |
1091 } | 1089 } |
1092 | 1090 |
1093 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_FINAL V8_OVERRIDE { | 1091 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
1094 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | 1092 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
1095 } | 1093 } |
1096 | 1094 |
1097 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; | 1095 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
1098 | 1096 |
1099 const BinaryOpIC::State& state() const { return state_; } | 1097 const BinaryOpIC::State& state() const { return state_; } |
1100 | 1098 |
1101 virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE; | 1099 virtual void PrintState(StringStream* stream) V8_OVERRIDE; |
1102 | |
1103 virtual Major MajorKey() V8_OVERRIDE { return BinaryOpIC; } | |
1104 virtual int NotMissMinorKey() V8_FINAL V8_OVERRIDE { | |
1105 return GetExtraICState(); | |
1106 } | |
1107 | 1100 |
1108 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 1101 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
1109 static const int kLeft = 0; | 1102 static const int kLeft = 0; |
1110 static const int kRight = 1; | 1103 static const int kRight = 1; |
1111 | 1104 |
1112 private: | 1105 private: |
1113 static void GenerateAheadOfTime(Isolate* isolate, | 1106 static void GenerateAheadOfTime(Isolate* isolate, |
1114 const BinaryOpIC::State& state); | 1107 const BinaryOpIC::State& state); |
1115 | 1108 |
| 1109 virtual Major MajorKey() V8_OVERRIDE { return BinaryOpIC; } |
| 1110 virtual int NotMissMinorKey() V8_OVERRIDE { return GetExtraICState(); } |
| 1111 |
1116 BinaryOpIC::State state_; | 1112 BinaryOpIC::State state_; |
1117 | 1113 |
1118 DISALLOW_COPY_AND_ASSIGN(BinaryOpICStub); | 1114 DISALLOW_COPY_AND_ASSIGN(BinaryOpICStub); |
1119 }; | 1115 }; |
1120 | 1116 |
1121 | 1117 |
1122 // TODO(bmeurer): Merge this into the BinaryOpICStub once we have proper tail | |
1123 // call support for stubs in Hydrogen. | |
1124 class BinaryOpICWithAllocationSiteStub V8_FINAL : public PlatformCodeStub { | |
1125 public: | |
1126 explicit BinaryOpICWithAllocationSiteStub(const BinaryOpIC::State& state) | |
1127 : state_(state) {} | |
1128 | |
1129 static void GenerateAheadOfTime(Isolate* isolate); | |
1130 | |
1131 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, | |
1132 Handle<AllocationSite> allocation_site) { | |
1133 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); | |
1134 // Replace the placeholder oddball with the actual allocation site. | |
1135 code->ReplaceNthObject(1, isolate->heap()->oddball_map(), *allocation_site); | |
1136 return code; | |
1137 } | |
1138 | |
1139 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { | |
1140 return Code::BINARY_OP_IC; | |
1141 } | |
1142 | |
1143 virtual InlineCacheState GetICState() V8_OVERRIDE { | |
1144 return state_.GetICState(); | |
1145 } | |
1146 | |
1147 virtual ExtraICState GetExtraICState() V8_OVERRIDE { | |
1148 return state_.GetExtraICState(); | |
1149 } | |
1150 | |
1151 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | |
1152 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | |
1153 } | |
1154 | |
1155 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; | |
1156 | |
1157 virtual void PrintState(StringStream* stream) V8_OVERRIDE; | |
1158 | |
1159 virtual Major MajorKey() V8_OVERRIDE { return BinaryOpICWithAllocationSite; } | |
1160 virtual int MinorKey() V8_OVERRIDE { return GetExtraICState(); } | |
1161 | |
1162 private: | |
1163 static void GenerateAheadOfTime(Isolate* isolate, | |
1164 const BinaryOpIC::State& state); | |
1165 | |
1166 BinaryOpIC::State state_; | |
1167 | |
1168 DISALLOW_COPY_AND_ASSIGN(BinaryOpICWithAllocationSiteStub); | |
1169 }; | |
1170 | |
1171 | |
1172 class BinaryOpWithAllocationSiteStub V8_FINAL : public BinaryOpICStub { | |
1173 public: | |
1174 explicit BinaryOpWithAllocationSiteStub(const BinaryOpIC::State& state) | |
1175 : BinaryOpICStub(state) {} | |
1176 | |
1177 virtual void InitializeInterfaceDescriptor( | |
1178 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | |
1179 | |
1180 static void InstallDescriptors(Isolate* isolate); | |
1181 | |
1182 virtual Code::Kind GetCodeKind() const V8_FINAL V8_OVERRIDE { | |
1183 return Code::STUB; | |
1184 } | |
1185 | |
1186 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; | |
1187 | |
1188 virtual Major MajorKey() V8_OVERRIDE { | |
1189 return BinaryOpWithAllocationSite; | |
1190 } | |
1191 | |
1192 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | |
1193 static const int kAllocationSite = 0; | |
1194 static const int kLeft = 1; | |
1195 static const int kRight = 2; | |
1196 }; | |
1197 | |
1198 | |
1199 // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub. | 1118 // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub. |
1200 class NewStringAddStub V8_FINAL : public HydrogenCodeStub { | 1119 class NewStringAddStub V8_FINAL : public HydrogenCodeStub { |
1201 public: | 1120 public: |
1202 NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag) | 1121 NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag) |
1203 : bit_field_(StringAddFlagsBits::encode(flags) | | 1122 : bit_field_(StringAddFlagsBits::encode(flags) | |
1204 PretenureFlagBits::encode(pretenure_flag)) {} | 1123 PretenureFlagBits::encode(pretenure_flag)) {} |
1205 | 1124 |
1206 StringAddFlags flags() const { | 1125 StringAddFlags flags() const { |
1207 return StringAddFlagsBits::decode(bit_field_); | 1126 return StringAddFlagsBits::decode(bit_field_); |
1208 } | 1127 } |
1209 | 1128 |
1210 PretenureFlag pretenure_flag() const { | 1129 PretenureFlag pretenure_flag() const { |
1211 return PretenureFlagBits::decode(bit_field_); | 1130 return PretenureFlagBits::decode(bit_field_); |
1212 } | 1131 } |
1213 | 1132 |
1214 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | |
1215 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | |
1216 } | |
1217 | |
1218 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; | 1133 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
1219 | 1134 |
1220 virtual void InitializeInterfaceDescriptor( | 1135 virtual void InitializeInterfaceDescriptor( |
1221 Isolate* isolate, | 1136 Isolate* isolate, |
1222 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1137 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
1223 | 1138 |
1224 static void InstallDescriptors(Isolate* isolate); | 1139 static void InstallDescriptors(Isolate* isolate); |
1225 | 1140 |
1226 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 1141 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
1227 static const int kLeft = 0; | 1142 static const int kLeft = 0; |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 int MinorKey() { return 0; } | 2362 int MinorKey() { return 0; } |
2448 | 2363 |
2449 void Generate(MacroAssembler* masm); | 2364 void Generate(MacroAssembler* masm); |
2450 | 2365 |
2451 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2366 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
2452 }; | 2367 }; |
2453 | 2368 |
2454 } } // namespace v8::internal | 2369 } } // namespace v8::internal |
2455 | 2370 |
2456 #endif // V8_CODE_STUBS_H_ | 2371 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |