| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 Handle<JSObject> receiver) { | 170 Handle<JSObject> receiver) { |
| 171 // If no global objects are present in the prototype chain, the load | 171 // If no global objects are present in the prototype chain, the load |
| 172 // nonexistent IC stub can be shared for all names for a given map | 172 // nonexistent IC stub can be shared for all names for a given map |
| 173 // and we use the empty string for the map cache in that case. If | 173 // and we use the empty string for the map cache in that case. If |
| 174 // there are global objects involved, we need to check global | 174 // there are global objects involved, we need to check global |
| 175 // property cells in the stub and therefore the stub will be | 175 // property cells in the stub and therefore the stub will be |
| 176 // specific to the name. | 176 // specific to the name. |
| 177 Handle<Name> cache_name = factory()->empty_string(); | 177 Handle<Name> cache_name = factory()->empty_string(); |
| 178 Handle<JSObject> current; | 178 Handle<JSObject> current; |
| 179 Handle<Object> next = receiver; | 179 Handle<Object> next = receiver; |
| 180 Handle<GlobalObject> global; | 180 Handle<JSGlobalObject> global; |
| 181 do { | 181 do { |
| 182 current = Handle<JSObject>::cast(next); | 182 current = Handle<JSObject>::cast(next); |
| 183 next = Handle<Object>(current->GetPrototype(), isolate_); | 183 next = Handle<Object>(current->GetPrototype(), isolate_); |
| 184 if (current->IsGlobalObject()) { | 184 if (current->IsJSGlobalObject()) { |
| 185 global = Handle<GlobalObject>::cast(current); | 185 global = Handle<JSGlobalObject>::cast(current); |
| 186 cache_name = name; | 186 cache_name = name; |
| 187 } else if (!current->HasFastProperties()) { | 187 } else if (!current->HasFastProperties()) { |
| 188 cache_name = name; | 188 cache_name = name; |
| 189 } | 189 } |
| 190 } while (!next->IsNull()); | 190 } while (!next->IsNull()); |
| 191 | 191 |
| 192 // Compile the stub that is either shared for all names or | 192 // Compile the stub that is either shared for all names or |
| 193 // name specific if there are global objects involved. | 193 // name specific if there are global objects involved. |
| 194 Handle<Code> handler = FindHandler(cache_name, receiver, Code::LOAD_IC); | 194 Handle<Code> handler = FindHandler(cache_name, receiver, Code::LOAD_IC); |
| 195 if (!handler.is_null()) return handler; | 195 if (!handler.is_null()) return handler; |
| 196 | 196 |
| 197 LoadStubCompiler compiler(isolate_); | 197 LoadStubCompiler compiler(isolate_); |
| 198 handler = | 198 handler = |
| 199 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); | 199 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); |
| 200 HeapObject::UpdateMapCodeCache(receiver, cache_name, handler); | 200 HeapObject::UpdateMapCodeCache(receiver, cache_name, handler); |
| 201 return handler; | 201 return handler; |
| 202 } | 202 } |
| 203 | 203 |
| 204 | 204 |
| 205 Handle<Code> StubCache::ComputeLoadGlobal(Handle<Name> name, | |
| 206 Handle<JSObject> receiver, | |
| 207 Handle<GlobalObject> holder, | |
| 208 Handle<PropertyCell> cell, | |
| 209 bool is_dont_delete) { | |
| 210 Handle<Code> stub = FindIC(name, receiver, Code::LOAD_IC); | |
| 211 if (!stub.is_null()) return stub; | |
| 212 | |
| 213 LoadStubCompiler compiler(isolate_); | |
| 214 Handle<Code> ic = | |
| 215 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); | |
| 216 HeapObject::UpdateMapCodeCache(receiver, name, ic); | |
| 217 return ic; | |
| 218 } | |
| 219 | |
| 220 | |
| 221 Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { | 205 Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { |
| 222 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); | 206 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); |
| 223 Handle<Name> name = | 207 Handle<Name> name = |
| 224 isolate()->factory()->KeyedLoadElementMonomorphic_string(); | 208 isolate()->factory()->KeyedLoadElementMonomorphic_string(); |
| 225 | 209 |
| 226 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); | 210 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); |
| 227 if (probe->IsCode()) return Handle<Code>::cast(probe); | 211 if (probe->IsCode()) return Handle<Code>::cast(probe); |
| 228 | 212 |
| 229 KeyedLoadStubCompiler compiler(isolate()); | 213 KeyedLoadStubCompiler compiler(isolate()); |
| 230 Handle<Code> code = compiler.CompileLoadElement(receiver_map); | 214 Handle<Code> code = compiler.CompileLoadElement(receiver_map); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 255 | 239 |
| 256 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); | 240 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); |
| 257 Handle<Code> code = compiler.CompileStoreElement(receiver_map); | 241 Handle<Code> code = compiler.CompileStoreElement(receiver_map); |
| 258 | 242 |
| 259 Map::UpdateCodeCache(receiver_map, name, code); | 243 Map::UpdateCodeCache(receiver_map, name, code); |
| 260 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); | 244 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); |
| 261 return code; | 245 return code; |
| 262 } | 246 } |
| 263 | 247 |
| 264 | 248 |
| 265 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, | |
| 266 Handle<GlobalObject> receiver, | |
| 267 Handle<PropertyCell> cell, | |
| 268 Handle<Object> value, | |
| 269 StrictModeFlag strict_mode) { | |
| 270 Handle<Type> union_type = PropertyCell::UpdatedType(cell, value); | |
| 271 bool is_constant = union_type->IsConstant(); | |
| 272 StoreGlobalStub stub(strict_mode, is_constant); | |
| 273 | |
| 274 Handle<Code> code = FindIC( | |
| 275 name, Handle<JSObject>::cast(receiver), | |
| 276 Code::STORE_IC, stub.GetExtraICState()); | |
| 277 if (!code.is_null()) return code; | |
| 278 | |
| 279 // Replace the placeholder cell and global object map with the actual global | |
| 280 // cell and receiver map. | |
| 281 Handle<Map> meta_map(isolate_->heap()->meta_map()); | |
| 282 Handle<Object> receiver_map(receiver->map(), isolate_); | |
| 283 code = stub.GetCodeCopyFromTemplate(isolate_); | |
| 284 code->ReplaceNthObject(1, *meta_map, *receiver_map); | |
| 285 Handle<Map> cell_map(isolate_->heap()->global_property_cell_map()); | |
| 286 code->ReplaceNthObject(1, *cell_map, *cell); | |
| 287 | |
| 288 HeapObject::UpdateMapCodeCache(receiver, name, code); | |
| 289 | |
| 290 return code; | |
| 291 } | |
| 292 | |
| 293 | |
| 294 #define CALL_LOGGER_TAG(kind, type) \ | 249 #define CALL_LOGGER_TAG(kind, type) \ |
| 295 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 250 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
| 296 | 251 |
| 297 Handle<Code> StubCache::ComputeCallConstant(int argc, | 252 Handle<Code> StubCache::ComputeCallConstant(int argc, |
| 298 Code::Kind kind, | 253 Code::Kind kind, |
| 299 Code::ExtraICState extra_state, | 254 Code::ExtraICState extra_state, |
| 300 Handle<Name> name, | 255 Handle<Name> name, |
| 301 Handle<Object> object, | 256 Handle<Object> object, |
| 302 Handle<JSObject> holder, | 257 Handle<JSObject> holder, |
| 303 Handle<JSFunction> function) { | 258 Handle<JSFunction> function) { |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 #undef CALL_LOGGER_TAG | 1089 #undef CALL_LOGGER_TAG |
| 1135 | 1090 |
| 1136 | 1091 |
| 1137 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, | 1092 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
| 1138 const char* name) { | 1093 const char* name) { |
| 1139 // Create code object in the heap. | 1094 // Create code object in the heap. |
| 1140 CodeDesc desc; | 1095 CodeDesc desc; |
| 1141 masm_.GetCode(&desc); | 1096 masm_.GetCode(&desc); |
| 1142 Handle<Code> code = factory()->NewCode(desc, flags, masm_.CodeObject()); | 1097 Handle<Code> code = factory()->NewCode(desc, flags, masm_.CodeObject()); |
| 1143 #ifdef ENABLE_DISASSEMBLER | 1098 #ifdef ENABLE_DISASSEMBLER |
| 1144 if (FLAG_print_code_stubs) code->Disassemble(name); | 1099 if (FLAG_print_code_stubs) { |
| 1100 CodeTracer::Scope trace_scope(isolate()->GetCodeTracer()); |
| 1101 code->Disassemble(name, trace_scope.file()); |
| 1102 } |
| 1145 #endif | 1103 #endif |
| 1146 return code; | 1104 return code; |
| 1147 } | 1105 } |
| 1148 | 1106 |
| 1149 | 1107 |
| 1150 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, | 1108 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
| 1151 Handle<Name> name) { | 1109 Handle<Name> name) { |
| 1152 return (FLAG_print_code_stubs && !name.is_null() && name->IsString()) | 1110 return (FLAG_print_code_stubs && !name.is_null() && name->IsString()) |
| 1153 ? GetCodeWithFlags(flags, *Handle<String>::cast(name)->ToCString()) | 1111 ? GetCodeWithFlags(flags, *Handle<String>::cast(name)->ToCString()) |
| 1154 : GetCodeWithFlags(flags, NULL); | 1112 : GetCodeWithFlags(flags, NULL); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 Label* success) { | 1159 Label* success) { |
| 1202 Label miss; | 1160 Label miss; |
| 1203 | 1161 |
| 1204 Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); | 1162 Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); |
| 1205 | 1163 |
| 1206 HandlerFrontendFooter(name, success, &miss); | 1164 HandlerFrontendFooter(name, success, &miss); |
| 1207 return reg; | 1165 return reg; |
| 1208 } | 1166 } |
| 1209 | 1167 |
| 1210 | 1168 |
| 1169 void LoadStubCompiler::NonexistentHandlerFrontend( |
| 1170 Handle<JSObject> object, |
| 1171 Handle<JSObject> last, |
| 1172 Handle<Name> name, |
| 1173 Label* success, |
| 1174 Handle<JSGlobalObject> global) { |
| 1175 Label miss; |
| 1176 |
| 1177 Register holder = |
| 1178 HandlerFrontendHeader(object, receiver(), last, name, &miss); |
| 1179 |
| 1180 if (!last->HasFastProperties() && |
| 1181 !last->IsJSGlobalObject() && |
| 1182 !last->IsJSGlobalProxy()) { |
| 1183 if (!name->IsUniqueName()) { |
| 1184 ASSERT(name->IsString()); |
| 1185 name = factory()->InternalizeString(Handle<String>::cast(name)); |
| 1186 } |
| 1187 ASSERT(last->property_dictionary()->FindEntry(*name) == |
| 1188 NameDictionary::kNotFound); |
| 1189 GenerateDictionaryNegativeLookup(masm(), &miss, holder, name, |
| 1190 scratch2(), scratch3()); |
| 1191 } |
| 1192 |
| 1193 // If the last object in the prototype chain is a global object, |
| 1194 // check that the global property cell is empty. |
| 1195 if (!global.is_null()) { |
| 1196 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); |
| 1197 } |
| 1198 |
| 1199 HandlerFrontendFooter(name, success, &miss); |
| 1200 } |
| 1201 |
| 1202 |
| 1211 Handle<Code> LoadStubCompiler::CompileLoadField( | 1203 Handle<Code> LoadStubCompiler::CompileLoadField( |
| 1212 Handle<JSObject> object, | 1204 Handle<JSObject> object, |
| 1213 Handle<JSObject> holder, | 1205 Handle<JSObject> holder, |
| 1214 Handle<Name> name, | 1206 Handle<Name> name, |
| 1215 PropertyIndex field, | 1207 PropertyIndex field, |
| 1216 Representation representation) { | 1208 Representation representation) { |
| 1217 Label miss; | 1209 Label miss; |
| 1218 | 1210 |
| 1219 Register reg = HandlerFrontendHeader(object, receiver(), holder, name, &miss); | 1211 Register reg = HandlerFrontendHeader(object, receiver(), holder, name, &miss); |
| 1220 | 1212 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 Handle<Code> code = GetCodeWithFlags(flags, name); | 1547 Handle<Code> code = GetCodeWithFlags(flags, name); |
| 1556 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1548 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
| 1557 JitEvent(name, code); | 1549 JitEvent(name, code); |
| 1558 return code; | 1550 return code; |
| 1559 } | 1551 } |
| 1560 | 1552 |
| 1561 | 1553 |
| 1562 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, | 1554 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, |
| 1563 Code::StubType type, | 1555 Code::StubType type, |
| 1564 Handle<Name> name) { | 1556 Handle<Name> name) { |
| 1565 ASSERT(type != Code::NORMAL); | |
| 1566 Code::Flags flags = Code::ComputeFlags( | 1557 Code::Flags flags = Code::ComputeFlags( |
| 1567 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); | 1558 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); |
| 1568 Handle<Code> code = GetCodeWithFlags(flags, name); | 1559 Handle<Code> code = GetCodeWithFlags(flags, name); |
| 1569 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1560 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
| 1570 JitEvent(name, code); | 1561 JitEvent(name, code); |
| 1571 return code; | 1562 return code; |
| 1572 } | 1563 } |
| 1573 | 1564 |
| 1574 | 1565 |
| 1575 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, | 1566 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 Handle<FunctionTemplateInfo>( | 1808 Handle<FunctionTemplateInfo>( |
| 1818 FunctionTemplateInfo::cast(signature->receiver())); | 1809 FunctionTemplateInfo::cast(signature->receiver())); |
| 1819 } | 1810 } |
| 1820 } | 1811 } |
| 1821 | 1812 |
| 1822 is_simple_api_call_ = true; | 1813 is_simple_api_call_ = true; |
| 1823 } | 1814 } |
| 1824 | 1815 |
| 1825 | 1816 |
| 1826 } } // namespace v8::internal | 1817 } } // namespace v8::internal |
| OLD | NEW |