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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Isolate* isolate = cell->GetIsolate(); | |
271 Handle<Type> union_type(PropertyCell::UpdateType(cell, value), isolate); | |
272 bool is_constant = union_type->IsConstant(); | |
273 StoreGlobalStub stub(strict_mode, is_constant); | |
274 | |
275 Handle<Code> code = FindIC( | |
276 name, Handle<JSObject>::cast(receiver), | |
277 Code::STORE_IC, stub.GetExtraICState()); | |
278 if (!code.is_null()) return code; | |
279 | |
280 // Replace the placeholder cell and global object map with the actual global | |
281 // cell and receiver map. | |
282 Handle<Map> meta_map(isolate_->heap()->meta_map()); | |
283 Handle<Object> receiver_map(receiver->map(), isolate_); | |
284 code = stub.GetCodeCopyFromTemplate(isolate_); | |
285 code->ReplaceNthObject(1, *meta_map, *receiver_map); | |
286 Handle<Map> cell_map(isolate_->heap()->global_property_cell_map()); | |
287 code->ReplaceNthObject(1, *cell_map, *cell); | |
288 | |
289 HeapObject::UpdateMapCodeCache(receiver, name, code); | |
290 | |
291 return code; | |
292 } | |
293 | |
294 | |
295 #define CALL_LOGGER_TAG(kind, type) \ | 249 #define CALL_LOGGER_TAG(kind, type) \ |
296 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 250 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
297 | 251 |
298 Handle<Code> StubCache::ComputeCallConstant(int argc, | 252 Handle<Code> StubCache::ComputeCallConstant(int argc, |
299 Code::Kind kind, | 253 Code::Kind kind, |
300 Code::ExtraICState extra_state, | 254 Code::ExtraICState extra_state, |
301 Handle<Name> name, | 255 Handle<Name> name, |
302 Handle<Object> object, | 256 Handle<Object> object, |
303 Handle<JSObject> holder, | 257 Handle<JSObject> holder, |
304 Handle<JSFunction> function) { | 258 Handle<JSFunction> function) { |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 Handle<Code> code = GetCodeWithFlags(flags, name); | 1510 Handle<Code> code = GetCodeWithFlags(flags, name); |
1557 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1511 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1558 JitEvent(name, code); | 1512 JitEvent(name, code); |
1559 return code; | 1513 return code; |
1560 } | 1514 } |
1561 | 1515 |
1562 | 1516 |
1563 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, | 1517 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, |
1564 Code::StubType type, | 1518 Code::StubType type, |
1565 Handle<Name> name) { | 1519 Handle<Name> name) { |
1566 ASSERT(type != Code::NORMAL); | |
1567 Code::Flags flags = Code::ComputeFlags( | 1520 Code::Flags flags = Code::ComputeFlags( |
1568 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); | 1521 Code::HANDLER, MONOMORPHIC, extra_state(), type, kind); |
1569 Handle<Code> code = GetCodeWithFlags(flags, name); | 1522 Handle<Code> code = GetCodeWithFlags(flags, name); |
1570 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1523 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1571 JitEvent(name, code); | 1524 JitEvent(name, code); |
1572 return code; | 1525 return code; |
1573 } | 1526 } |
1574 | 1527 |
1575 | 1528 |
1576 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, | 1529 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 Handle<FunctionTemplateInfo>( | 1771 Handle<FunctionTemplateInfo>( |
1819 FunctionTemplateInfo::cast(signature->receiver())); | 1772 FunctionTemplateInfo::cast(signature->receiver())); |
1820 } | 1773 } |
1821 } | 1774 } |
1822 | 1775 |
1823 is_simple_api_call_ = true; | 1776 is_simple_api_call_ = true; |
1824 } | 1777 } |
1825 | 1778 |
1826 | 1779 |
1827 } } // namespace v8::internal | 1780 } } // namespace v8::internal |
OLD | NEW |