| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Lookup the code in the (possibly custom) cache. | 186 // Lookup the code in the (possibly custom) cache. |
| 187 bool FindCodeInCache(Code** code_out, Isolate* isolate); | 187 bool FindCodeInCache(Code** code_out, Isolate* isolate); |
| 188 | 188 |
| 189 // Returns information for computing the number key. | 189 // Returns information for computing the number key. |
| 190 virtual Major MajorKey() = 0; | 190 virtual Major MajorKey() = 0; |
| 191 virtual int MinorKey() = 0; | 191 virtual int MinorKey() = 0; |
| 192 | 192 |
| 193 virtual InlineCacheState GetICState() { | 193 virtual InlineCacheState GetICState() { |
| 194 return UNINITIALIZED; | 194 return UNINITIALIZED; |
| 195 } | 195 } |
| 196 virtual Code::ExtraICState GetExtraICState() { | 196 virtual ExtraICState GetExtraICState() { |
| 197 return Code::kNoExtraICState; | 197 return kNoExtraICState; |
| 198 } | 198 } |
| 199 virtual Code::StubType GetStubType() { | 199 virtual Code::StubType GetStubType() { |
| 200 return Code::NORMAL; | 200 return Code::NORMAL; |
| 201 } | 201 } |
| 202 virtual int GetStubFlags() { | 202 virtual int GetStubFlags() { |
| 203 return -1; | 203 return -1; |
| 204 } | 204 } |
| 205 | 205 |
| 206 virtual void PrintName(StringStream* stream); | 206 virtual void PrintName(StringStream* stream); |
| 207 | 207 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 virtual CodeStub::Major MajorKey() { return StringLength; } | 839 virtual CodeStub::Major MajorKey() { return StringLength; } |
| 840 }; | 840 }; |
| 841 | 841 |
| 842 | 842 |
| 843 class StoreICStub: public ICStub { | 843 class StoreICStub: public ICStub { |
| 844 public: | 844 public: |
| 845 StoreICStub(Code::Kind kind, StrictModeFlag strict_mode) | 845 StoreICStub(Code::Kind kind, StrictModeFlag strict_mode) |
| 846 : ICStub(kind), strict_mode_(strict_mode) { } | 846 : ICStub(kind), strict_mode_(strict_mode) { } |
| 847 | 847 |
| 848 protected: | 848 protected: |
| 849 virtual Code::ExtraICState GetExtraICState() { | 849 virtual ExtraICState GetExtraICState() { |
| 850 return strict_mode_; | 850 return StoreIC::ComputeExtraICState(strict_mode_); |
| 851 } | 851 } |
| 852 | 852 |
| 853 private: | 853 private: |
| 854 STATIC_ASSERT(KindBits::kSize == 4); | 854 STATIC_ASSERT(KindBits::kSize == 4); |
| 855 class StrictModeBits: public BitField<bool, 4, 1> {}; | 855 class StrictModeBits: public BitField<bool, 4, 1> {}; |
| 856 virtual int MinorKey() { | 856 virtual int MinorKey() { |
| 857 return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); | 857 return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); |
| 858 } | 858 } |
| 859 | 859 |
| 860 StrictModeFlag strict_mode_; | 860 StrictModeFlag strict_mode_; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 975 } |
| 976 | 976 |
| 977 virtual Code::Kind kind() const { return Code::STORE_IC; } | 977 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 978 | 978 |
| 979 virtual Handle<Code> GenerateCode(Isolate* isolate); | 979 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 980 | 980 |
| 981 virtual void InitializeInterfaceDescriptor( | 981 virtual void InitializeInterfaceDescriptor( |
| 982 Isolate* isolate, | 982 Isolate* isolate, |
| 983 CodeStubInterfaceDescriptor* descriptor); | 983 CodeStubInterfaceDescriptor* descriptor); |
| 984 | 984 |
| 985 virtual Code::ExtraICState GetExtraICState() { return bit_field_; } | 985 virtual ExtraICState GetExtraICState() { return bit_field_; } |
| 986 | 986 |
| 987 bool is_constant() { | 987 bool is_constant() { |
| 988 return IsConstantBits::decode(bit_field_); | 988 return IsConstantBits::decode(bit_field_); |
| 989 } | 989 } |
| 990 void set_is_constant(bool value) { | 990 void set_is_constant(bool value) { |
| 991 bit_field_ = IsConstantBits::update(bit_field_, value); | 991 bit_field_ = IsConstantBits::update(bit_field_, value); |
| 992 } | 992 } |
| 993 | 993 |
| 994 Representation representation() { | 994 Representation representation() { |
| 995 return Representation::FromKind(RepresentationBits::decode(bit_field_)); | 995 return Representation::FromKind(RepresentationBits::decode(bit_field_)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 }; | 1029 }; |
| 1030 | 1030 |
| 1031 | 1031 |
| 1032 class KeyedArrayCallStub: public HICStub { | 1032 class KeyedArrayCallStub: public HICStub { |
| 1033 public: | 1033 public: |
| 1034 KeyedArrayCallStub(bool holey, int argc) : HICStub(), argc_(argc) { | 1034 KeyedArrayCallStub(bool holey, int argc) : HICStub(), argc_(argc) { |
| 1035 bit_field_ = ContextualBits::encode(false) | HoleyBits::encode(holey); | 1035 bit_field_ = ContextualBits::encode(false) | HoleyBits::encode(holey); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 virtual Code::Kind kind() const { return Code::KEYED_CALL_IC; } | 1038 virtual Code::Kind kind() const { return Code::KEYED_CALL_IC; } |
| 1039 virtual Code::ExtraICState GetExtraICState() { return bit_field_; } | 1039 virtual ExtraICState GetExtraICState() { return bit_field_; } |
| 1040 | 1040 |
| 1041 ElementsKind elements_kind() { | 1041 ElementsKind elements_kind() { |
| 1042 return HoleyBits::decode(bit_field_) ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; | 1042 return HoleyBits::decode(bit_field_) ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 int argc() { return argc_; } | 1045 int argc() { return argc_; } |
| 1046 virtual int GetStubFlags() { return argc(); } | 1046 virtual int GetStubFlags() { return argc(); } |
| 1047 | 1047 |
| 1048 static bool IsHoley(Handle<Code> code) { | 1048 static bool IsHoley(Handle<Code> code) { |
| 1049 Code::ExtraICState state = code->extra_ic_state(); | 1049 ExtraICState state = code->extra_ic_state(); |
| 1050 return HoleyBits::decode(state); | 1050 return HoleyBits::decode(state); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 virtual void InitializeInterfaceDescriptor( | 1053 virtual void InitializeInterfaceDescriptor( |
| 1054 Isolate* isolate, | 1054 Isolate* isolate, |
| 1055 CodeStubInterfaceDescriptor* descriptor); | 1055 CodeStubInterfaceDescriptor* descriptor); |
| 1056 | 1056 |
| 1057 virtual Handle<Code> GenerateCode(Isolate* isolate); | 1057 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 1058 | 1058 |
| 1059 private: | 1059 private: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1074 | 1074 |
| 1075 | 1075 |
| 1076 class BinaryOpStub: public HydrogenCodeStub { | 1076 class BinaryOpStub: public HydrogenCodeStub { |
| 1077 public: | 1077 public: |
| 1078 BinaryOpStub(Token::Value op, OverwriteMode mode) | 1078 BinaryOpStub(Token::Value op, OverwriteMode mode) |
| 1079 : HydrogenCodeStub(UNINITIALIZED), op_(op), mode_(mode) { | 1079 : HydrogenCodeStub(UNINITIALIZED), op_(op), mode_(mode) { |
| 1080 ASSERT(op <= LAST_TOKEN && op >= FIRST_TOKEN); | 1080 ASSERT(op <= LAST_TOKEN && op >= FIRST_TOKEN); |
| 1081 Initialize(); | 1081 Initialize(); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 explicit BinaryOpStub(Code::ExtraICState state) | 1084 explicit BinaryOpStub(ExtraICState state) |
| 1085 : op_(decode_token(OpBits::decode(state))), | 1085 : op_(decode_token(OpBits::decode(state))), |
| 1086 mode_(OverwriteModeField::decode(state)), | 1086 mode_(OverwriteModeField::decode(state)), |
| 1087 fixed_right_arg_( | 1087 fixed_right_arg_( |
| 1088 Maybe<int>(HasFixedRightArgBits::decode(state), | 1088 Maybe<int>(HasFixedRightArgBits::decode(state), |
| 1089 decode_arg_value(FixedRightArgValueBits::decode(state)))), | 1089 decode_arg_value(FixedRightArgValueBits::decode(state)))), |
| 1090 left_state_(LeftStateField::decode(state)), | 1090 left_state_(LeftStateField::decode(state)), |
| 1091 right_state_(fixed_right_arg_.has_value | 1091 right_state_(fixed_right_arg_.has_value |
| 1092 ? ((fixed_right_arg_.value <= Smi::kMaxValue) ? SMI : INT32) | 1092 ? ((fixed_right_arg_.value <= Smi::kMaxValue) ? SMI : INT32) |
| 1093 : RightStateField::decode(state)), | 1093 : RightStateField::decode(state)), |
| 1094 result_state_(ResultStateField::decode(state)) { | 1094 result_state_(ResultStateField::decode(state)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1117 return ::v8::internal::UNINITIALIZED; | 1117 return ::v8::internal::UNINITIALIZED; |
| 1118 } | 1118 } |
| 1119 if (Max(left_state_, right_state_) == GENERIC) return MEGAMORPHIC; | 1119 if (Max(left_state_, right_state_) == GENERIC) return MEGAMORPHIC; |
| 1120 return MONOMORPHIC; | 1120 return MONOMORPHIC; |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | 1123 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1124 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | 1124 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 virtual Code::ExtraICState GetExtraICState() { | 1127 virtual ExtraICState GetExtraICState() { |
| 1128 bool sse_field = Max(result_state_, Max(left_state_, right_state_)) > SMI && | 1128 bool sse_field = Max(result_state_, Max(left_state_, right_state_)) > SMI && |
| 1129 CpuFeatures::IsSafeForSnapshot(SSE2); | 1129 CpuFeatures::IsSafeForSnapshot(SSE2); |
| 1130 | 1130 |
| 1131 return OpBits::encode(encode_token(op_)) | 1131 return OpBits::encode(encode_token(op_)) |
| 1132 | LeftStateField::encode(left_state_) | 1132 | LeftStateField::encode(left_state_) |
| 1133 | RightStateField::encode(fixed_right_arg_.has_value | 1133 | RightStateField::encode(fixed_right_arg_.has_value |
| 1134 ? NONE : right_state_) | 1134 ? NONE : right_state_) |
| 1135 | ResultStateField::encode(result_state_) | 1135 | ResultStateField::encode(result_state_) |
| 1136 | HasFixedRightArgBits::encode(fixed_right_arg_.has_value) | 1136 | HasFixedRightArgBits::encode(fixed_right_arg_.has_value) |
| 1137 | FixedRightArgValueBits::encode(fixed_right_arg_.has_value | 1137 | FixedRightArgValueBits::encode(fixed_right_arg_.has_value |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 }; | 1357 }; |
| 1358 | 1358 |
| 1359 | 1359 |
| 1360 class CompareNilICStub : public HydrogenCodeStub { | 1360 class CompareNilICStub : public HydrogenCodeStub { |
| 1361 public: | 1361 public: |
| 1362 Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); | 1362 Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); |
| 1363 Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); | 1363 Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); |
| 1364 | 1364 |
| 1365 explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } | 1365 explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } |
| 1366 | 1366 |
| 1367 CompareNilICStub(Code::ExtraICState ic_state, | 1367 CompareNilICStub(ExtraICState ic_state, |
| 1368 InitializationState init_state = INITIALIZED) | 1368 InitializationState init_state = INITIALIZED) |
| 1369 : HydrogenCodeStub(init_state), | 1369 : HydrogenCodeStub(init_state), |
| 1370 nil_value_(NilValueField::decode(ic_state)), | 1370 nil_value_(NilValueField::decode(ic_state)), |
| 1371 state_(State(TypesField::decode(ic_state))) { | 1371 state_(State(TypesField::decode(ic_state))) { |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 static Handle<Code> GetUninitialized(Isolate* isolate, | 1374 static Handle<Code> GetUninitialized(Isolate* isolate, |
| 1375 NilValue nil) { | 1375 NilValue nil) { |
| 1376 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); | 1376 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); |
| 1377 } | 1377 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1394 return MONOMORPHIC; | 1394 return MONOMORPHIC; |
| 1395 } else { | 1395 } else { |
| 1396 return PREMONOMORPHIC; | 1396 return PREMONOMORPHIC; |
| 1397 } | 1397 } |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } | 1400 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } |
| 1401 | 1401 |
| 1402 virtual Handle<Code> GenerateCode(Isolate* isolate); | 1402 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 1403 | 1403 |
| 1404 virtual Code::ExtraICState GetExtraICState() { | 1404 virtual ExtraICState GetExtraICState() { |
| 1405 return NilValueField::encode(nil_value_) | | 1405 return NilValueField::encode(nil_value_) | |
| 1406 TypesField::encode(state_.ToIntegral()); | 1406 TypesField::encode(state_.ToIntegral()); |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 void UpdateStatus(Handle<Object> object); | 1409 void UpdateStatus(Handle<Object> object); |
| 1410 | 1410 |
| 1411 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } | 1411 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } |
| 1412 NilValue GetNilValue() const { return nil_value_; } | 1412 NilValue GetNilValue() const { return nil_value_; } |
| 1413 void ClearState() { state_.RemoveAll(); } | 1413 void ClearState() { state_.RemoveAll(); } |
| 1414 | 1414 |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 bool UpdateStatus(Handle<Object> object); | 2323 bool UpdateStatus(Handle<Object> object); |
| 2324 bool NeedsMap() const; | 2324 bool NeedsMap() const; |
| 2325 bool CanBeUndetectable() const; | 2325 bool CanBeUndetectable() const; |
| 2326 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } | 2326 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
| 2327 | 2327 |
| 2328 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 2328 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
| 2329 }; | 2329 }; |
| 2330 | 2330 |
| 2331 explicit ToBooleanStub(Types types = Types()) | 2331 explicit ToBooleanStub(Types types = Types()) |
| 2332 : types_(types) { } | 2332 : types_(types) { } |
| 2333 explicit ToBooleanStub(Code::ExtraICState state) | 2333 explicit ToBooleanStub(ExtraICState state) |
| 2334 : types_(static_cast<byte>(state)) { } | 2334 : types_(static_cast<byte>(state)) { } |
| 2335 | 2335 |
| 2336 bool UpdateStatus(Handle<Object> object); | 2336 bool UpdateStatus(Handle<Object> object); |
| 2337 Types GetTypes() { return types_; } | 2337 Types GetTypes() { return types_; } |
| 2338 | 2338 |
| 2339 virtual Handle<Code> GenerateCode(Isolate* isolate); | 2339 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 2340 virtual void InitializeInterfaceDescriptor( | 2340 virtual void InitializeInterfaceDescriptor( |
| 2341 Isolate* isolate, | 2341 Isolate* isolate, |
| 2342 CodeStubInterfaceDescriptor* descriptor); | 2342 CodeStubInterfaceDescriptor* descriptor); |
| 2343 | 2343 |
| 2344 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } | 2344 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } |
| 2345 virtual void PrintState(StringStream* stream); | 2345 virtual void PrintState(StringStream* stream); |
| 2346 | 2346 |
| 2347 virtual bool SometimesSetsUpAFrame() { return false; } | 2347 virtual bool SometimesSetsUpAFrame() { return false; } |
| 2348 | 2348 |
| 2349 static void InitializeForIsolate(Isolate* isolate) { | 2349 static void InitializeForIsolate(Isolate* isolate) { |
| 2350 ToBooleanStub stub; | 2350 ToBooleanStub stub; |
| 2351 stub.InitializeInterfaceDescriptor( | 2351 stub.InitializeInterfaceDescriptor( |
| 2352 isolate, | 2352 isolate, |
| 2353 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); | 2353 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); |
| 2354 } | 2354 } |
| 2355 | 2355 |
| 2356 static Handle<Code> GetUninitialized(Isolate* isolate) { | 2356 static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 2357 return ToBooleanStub(UNINITIALIZED).GetCode(isolate); | 2357 return ToBooleanStub(UNINITIALIZED).GetCode(isolate); |
| 2358 } | 2358 } |
| 2359 | 2359 |
| 2360 virtual Code::ExtraICState GetExtraICState() { | 2360 virtual ExtraICState GetExtraICState() { |
| 2361 return types_.ToIntegral(); | 2361 return types_.ToIntegral(); |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 virtual InlineCacheState GetICState() { | 2364 virtual InlineCacheState GetICState() { |
| 2365 if (types_.IsEmpty()) { | 2365 if (types_.IsEmpty()) { |
| 2366 return ::v8::internal::UNINITIALIZED; | 2366 return ::v8::internal::UNINITIALIZED; |
| 2367 } else { | 2367 } else { |
| 2368 return MONOMORPHIC; | 2368 return MONOMORPHIC; |
| 2369 } | 2369 } |
| 2370 } | 2370 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2512 int MinorKey() { return 0; } | 2512 int MinorKey() { return 0; } |
| 2513 | 2513 |
| 2514 void Generate(MacroAssembler* masm); | 2514 void Generate(MacroAssembler* masm); |
| 2515 | 2515 |
| 2516 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2516 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2517 }; | 2517 }; |
| 2518 | 2518 |
| 2519 } } // namespace v8::internal | 2519 } } // namespace v8::internal |
| 2520 | 2520 |
| 2521 #endif // V8_CODE_STUBS_H_ | 2521 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |