| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ASSERT(type != Code::NORMAL); | 158 ASSERT(type != Code::NORMAL); |
| 159 Code::Flags flags = Code::ComputeMonomorphicFlags( | 159 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 160 Code::HANDLER, extra_ic_state, type, kind); | 160 Code::HANDLER, extra_ic_state, type, kind); |
| 161 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags), | 161 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags), |
| 162 isolate_); | 162 isolate_); |
| 163 if (probe->IsCode()) return Handle<Code>::cast(probe); | 163 if (probe->IsCode()) return Handle<Code>::cast(probe); |
| 164 return Handle<Code>::null(); | 164 return Handle<Code>::null(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 Handle<Code> StubCache::ComputeMonomorphicLoadIC(Handle<HeapObject> receiver, | 168 Handle<Code> StubCache::ComputeMonomorphicIC(Handle<HeapObject> receiver, |
| 169 Handle<Code> handler, | 169 Handle<Code> handler, |
| 170 Handle<Name> name) { | 170 Handle<Name> name, |
| 171 StrictModeFlag strict_mode) { |
| 172 Code::Kind kind = handler->handler_kind(); |
| 171 Handle<Map> map(receiver->map()); | 173 Handle<Map> map(receiver->map()); |
| 172 Handle<Code> ic = FindIC(name, map, Code::LOAD_IC, handler->type()); | 174 Handle<Code> ic = FindIC(name, map, kind, handler->type(), strict_mode); |
| 173 if (!ic.is_null()) return ic; | 175 if (!ic.is_null()) return ic; |
| 174 | 176 |
| 175 LoadStubCompiler ic_compiler(isolate()); | 177 if (kind == Code::LOAD_IC) { |
| 176 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); | 178 LoadStubCompiler ic_compiler(isolate()); |
| 179 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); |
| 180 } else if (kind == Code::KEYED_LOAD_IC) { |
| 181 KeyedLoadStubCompiler ic_compiler(isolate()); |
| 182 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); |
| 183 } else if (kind == Code::STORE_IC) { |
| 184 StoreStubCompiler ic_compiler(isolate(), strict_mode); |
| 185 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); |
| 186 } else { |
| 187 ASSERT(kind == Code::KEYED_STORE_IC); |
| 188 KeyedStoreStubCompiler ic_compiler(isolate(), strict_mode, STANDARD_STORE); |
| 189 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); |
| 190 } |
| 177 | 191 |
| 178 HeapObject::UpdateMapCodeCache(receiver, name, ic); | 192 HeapObject::UpdateMapCodeCache(receiver, name, ic); |
| 179 return ic; | 193 return ic; |
| 180 } | |
| 181 | |
| 182 | |
| 183 Handle<Code> StubCache::ComputeMonomorphicKeyedLoadIC( | |
| 184 Handle<HeapObject> receiver, | |
| 185 Handle<Code> handler, | |
| 186 Handle<Name> name) { | |
| 187 Handle<Map> map(receiver->map()); | |
| 188 Handle<Code> ic = FindIC(name, map, Code::KEYED_LOAD_IC, handler->type()); | |
| 189 if (!ic.is_null()) return ic; | |
| 190 | |
| 191 KeyedLoadStubCompiler ic_compiler(isolate()); | |
| 192 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); | |
| 193 | |
| 194 HeapObject::UpdateMapCodeCache(receiver, name, ic); | |
| 195 return ic; | |
| 196 } | |
| 197 | |
| 198 | |
| 199 Handle<Code> StubCache::ComputeMonomorphicStoreIC(Handle<HeapObject> receiver, | |
| 200 Handle<Code> handler, | |
| 201 Handle<Name> name, | |
| 202 StrictModeFlag strict_mode) { | |
| 203 Handle<Map> map(receiver->map()); | |
| 204 Handle<Code> ic = FindIC( | |
| 205 name, map, Code::STORE_IC, handler->type(), strict_mode); | |
| 206 if (!ic.is_null()) return ic; | |
| 207 | |
| 208 StoreStubCompiler ic_compiler(isolate(), strict_mode); | |
| 209 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); | |
| 210 | |
| 211 HeapObject::UpdateMapCodeCache(receiver, name, ic); | |
| 212 return ic; | |
| 213 } | |
| 214 | |
| 215 | |
| 216 Handle<Code> StubCache::ComputeMonomorphicKeyedStoreIC( | |
| 217 Handle<HeapObject> receiver, | |
| 218 Handle<Code> handler, | |
| 219 Handle<Name> name, | |
| 220 StrictModeFlag strict_mode) { | |
| 221 Handle<Map> map(receiver->map()); | |
| 222 Handle<Code> ic = FindIC( | |
| 223 name, map, Code::KEYED_STORE_IC, handler->type(), strict_mode); | |
| 224 if (!ic.is_null()) return ic; | |
| 225 | |
| 226 KeyedStoreStubCompiler ic_compiler(isolate(), strict_mode, STANDARD_STORE); | |
| 227 ic = ic_compiler.CompileMonomorphicIC(map, handler, name); | |
| 228 | |
| 229 HeapObject::UpdateMapCodeCache(receiver, name, ic); | |
| 230 return ic; | |
| 231 } | 194 } |
| 232 | 195 |
| 233 | 196 |
| 234 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, | 197 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, |
| 235 Handle<JSObject> receiver) { | 198 Handle<JSObject> receiver) { |
| 236 // If no global objects are present in the prototype chain, the load | 199 // If no global objects are present in the prototype chain, the load |
| 237 // nonexistent IC stub can be shared for all names for a given map | 200 // nonexistent IC stub can be shared for all names for a given map |
| 238 // and we use the empty string for the map cache in that case. If | 201 // and we use the empty string for the map cache in that case. If |
| 239 // there are global objects involved, we need to check global | 202 // there are global objects involved, we need to check global |
| 240 // property cells in the stub and therefore the stub will be | 203 // property cells in the stub and therefore the stub will be |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 receiver_maps, &handlers, factory()->empty_string(), | 1028 receiver_maps, &handlers, factory()->empty_string(), |
| 1066 Code::NORMAL, ELEMENT); | 1029 Code::NORMAL, ELEMENT); |
| 1067 | 1030 |
| 1068 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); | 1031 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); |
| 1069 | 1032 |
| 1070 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); | 1033 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); |
| 1071 return code; | 1034 return code; |
| 1072 } | 1035 } |
| 1073 | 1036 |
| 1074 | 1037 |
| 1075 Handle<Code> StubCache::ComputePolymorphicLoadIC(MapHandleList* receiver_maps, | 1038 Handle<Code> StubCache::ComputePolymorphicIC(MapHandleList* receiver_maps, |
| 1076 CodeHandleList* handlers, | 1039 CodeHandleList* handlers, |
| 1077 int number_of_valid_maps, | 1040 int number_of_valid_maps, |
| 1078 Handle<Name> name) { | 1041 Handle<Name> name, |
| 1079 LoadStubCompiler ic_compiler(isolate_); | 1042 StrictModeFlag strict_mode) { |
| 1080 Code::StubType type = number_of_valid_maps == 1 ? handlers->at(0)->type() | 1043 Handle<Code> handler = handlers->at(0); |
| 1044 Code::Kind kind = handler->handler_kind(); |
| 1045 Code::StubType type = number_of_valid_maps == 1 ? handler->type() |
| 1081 : Code::NORMAL; | 1046 : Code::NORMAL; |
| 1082 Handle<Code> ic = ic_compiler.CompilePolymorphicIC( | 1047 if (kind == Code::LOAD_IC) { |
| 1083 receiver_maps, handlers, name, type, PROPERTY); | 1048 LoadStubCompiler ic_compiler(isolate_); |
| 1084 return ic; | 1049 return ic_compiler.CompilePolymorphicIC( |
| 1050 receiver_maps, handlers, name, type, PROPERTY); |
| 1051 } else { |
| 1052 ASSERT(kind == Code::STORE_IC); |
| 1053 StoreStubCompiler ic_compiler(isolate_, strict_mode); |
| 1054 return ic_compiler.CompilePolymorphicIC( |
| 1055 receiver_maps, handlers, name, type, PROPERTY); |
| 1056 } |
| 1085 } | 1057 } |
| 1086 | 1058 |
| 1087 | 1059 |
| 1088 Handle<Code> StubCache::ComputePolymorphicStoreIC(MapHandleList* receiver_maps, | |
| 1089 CodeHandleList* handlers, | |
| 1090 int number_of_valid_maps, | |
| 1091 Handle<Name> name, | |
| 1092 StrictModeFlag strict_mode) { | |
| 1093 StoreStubCompiler ic_compiler(isolate_, strict_mode); | |
| 1094 Code::StubType type = number_of_valid_maps == 1 ? handlers->at(0)->type() | |
| 1095 : Code::NORMAL; | |
| 1096 Handle<Code> ic = ic_compiler.CompilePolymorphicIC( | |
| 1097 receiver_maps, handlers, name, type, PROPERTY); | |
| 1098 return ic; | |
| 1099 } | |
| 1100 | |
| 1101 | |
| 1102 Handle<Code> StubCache::ComputeStoreElementPolymorphic( | 1060 Handle<Code> StubCache::ComputeStoreElementPolymorphic( |
| 1103 MapHandleList* receiver_maps, | 1061 MapHandleList* receiver_maps, |
| 1104 KeyedAccessStoreMode store_mode, | 1062 KeyedAccessStoreMode store_mode, |
| 1105 StrictModeFlag strict_mode) { | 1063 StrictModeFlag strict_mode) { |
| 1106 ASSERT(store_mode == STANDARD_STORE || | 1064 ASSERT(store_mode == STANDARD_STORE || |
| 1107 store_mode == STORE_AND_GROW_NO_TRANSITION || | 1065 store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 1108 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 1066 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 1109 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 1067 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
| 1110 Handle<PolymorphicCodeCache> cache = | 1068 Handle<PolymorphicCodeCache> cache = |
| 1111 isolate_->factory()->polymorphic_code_cache(); | 1069 isolate_->factory()->polymorphic_code_cache(); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 | 1924 |
| 1967 void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | 1925 void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
| 1968 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); | 1926 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); |
| 1969 } | 1927 } |
| 1970 | 1928 |
| 1971 | 1929 |
| 1972 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, | 1930 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, |
| 1973 Code::StubType type, | 1931 Code::StubType type, |
| 1974 Handle<Name> name, | 1932 Handle<Name> name, |
| 1975 InlineCacheState state) { | 1933 InlineCacheState state) { |
| 1976 Code::Flags flags = Code::ComputeFlags( | 1934 Code::Flags flags = Code::ComputeFlags(kind, state, extra_state(), type); |
| 1977 kind, state, extra_state(), type); | |
| 1978 Handle<Code> code = GetCodeWithFlags(flags, name); | 1935 Handle<Code> code = GetCodeWithFlags(flags, name); |
| 1979 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1936 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
| 1980 JitEvent(name, code); | 1937 JitEvent(name, code); |
| 1981 return code; | 1938 return code; |
| 1982 } | 1939 } |
| 1983 | 1940 |
| 1984 | 1941 |
| 1985 Handle<Code> BaseLoadStubCompiler::GetCode(Code::Kind kind, | 1942 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, |
| 1986 Code::StubType type, | 1943 Code::StubType type, |
| 1987 Handle<Name> name) { | 1944 Handle<Name> name) { |
| 1988 ASSERT(type != Code::NORMAL); | |
| 1989 Code::Flags flags = Code::ComputeFlags( | |
| 1990 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, type, kind); | |
| 1991 Handle<Code> code = GetCodeWithFlags(flags, name); | |
| 1992 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | |
| 1993 JitEvent(name, code); | |
| 1994 return code; | |
| 1995 } | |
| 1996 | |
| 1997 | |
| 1998 Handle<Code> BaseStoreStubCompiler::GetCode(Code::Kind kind, | |
| 1999 Code::StubType type, | |
| 2000 Handle<Name> name) { | |
| 2001 ASSERT(type != Code::NORMAL); | 1945 ASSERT(type != Code::NORMAL); |
| 2002 Code::Flags flags = Code::ComputeFlags( | 1946 Code::Flags flags = Code::ComputeFlags( |
| 2003 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); | 1947 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); |
| 2004 Handle<Code> code = GetCodeWithFlags(flags, name); | 1948 Handle<Code> code = GetCodeWithFlags(flags, name); |
| 2005 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1949 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
| 2006 JitEvent(name, code); | 1950 JitEvent(name, code); |
| 2007 return code; | 1951 return code; |
| 2008 } | 1952 } |
| 2009 | 1953 |
| 2010 | 1954 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 Handle<FunctionTemplateInfo>( | 2197 Handle<FunctionTemplateInfo>( |
| 2254 FunctionTemplateInfo::cast(signature->receiver())); | 2198 FunctionTemplateInfo::cast(signature->receiver())); |
| 2255 } | 2199 } |
| 2256 } | 2200 } |
| 2257 | 2201 |
| 2258 is_simple_api_call_ = true; | 2202 is_simple_api_call_ = true; |
| 2259 } | 2203 } |
| 2260 | 2204 |
| 2261 | 2205 |
| 2262 } } // namespace v8::internal | 2206 } } // namespace v8::internal |
| OLD | NEW |