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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 KeyedLoadStubCompiler compiler(isolate()); | 422 KeyedLoadStubCompiler compiler(isolate()); |
423 Handle<Code> code = compiler.CompileLoadElement(receiver_map); | 423 Handle<Code> code = compiler.CompileLoadElement(receiver_map); |
424 | 424 |
425 Map::UpdateCodeCache(receiver_map, name, code); | 425 Map::UpdateCodeCache(receiver_map, name, code); |
426 return code; | 426 return code; |
427 } | 427 } |
428 | 428 |
429 | 429 |
430 Handle<Code> StubCache::ComputeKeyedStoreElement( | 430 Handle<Code> StubCache::ComputeKeyedStoreElement( |
431 Handle<Map> receiver_map, | 431 Handle<Map> receiver_map, |
432 KeyedStoreIC::StubKind stub_kind, | |
433 StrictModeFlag strict_mode, | 432 StrictModeFlag strict_mode, |
434 KeyedAccessGrowMode grow_mode) { | 433 KeyedAccessStoreMode store_mode) { |
435 Code::ExtraICState extra_state = | 434 Code::ExtraICState extra_state = |
436 Code::ComputeExtraICState(grow_mode, strict_mode); | 435 Code::ComputeExtraICState(store_mode, strict_mode); |
437 Code::Flags flags = Code::ComputeMonomorphicFlags( | 436 Code::Flags flags = Code::ComputeMonomorphicFlags( |
438 Code::KEYED_STORE_IC, extra_state); | 437 Code::KEYED_STORE_IC, extra_state); |
439 | 438 |
440 ASSERT(stub_kind == KeyedStoreIC::STORE_NO_TRANSITION || | 439 ASSERT(store_mode == STANDARD_STORE || |
441 stub_kind == KeyedStoreIC::STORE_AND_GROW_NO_TRANSITION); | 440 store_mode == STORE_AND_GROW_NO_TRANSITION); |
442 | 441 |
443 Handle<Name> name = stub_kind == KeyedStoreIC::STORE_NO_TRANSITION | 442 Handle<String> name = |
444 ? isolate()->factory()->KeyedStoreElementMonomorphic_string() | 443 isolate()->factory()->KeyedStoreElementMonomorphic_string(); |
445 : isolate()->factory()->KeyedStoreAndGrowElementMonomorphic_string(); | |
446 | |
447 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); | 444 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); |
448 if (probe->IsCode()) return Handle<Code>::cast(probe); | 445 if (probe->IsCode()) return Handle<Code>::cast(probe); |
449 | 446 |
450 KeyedStoreStubCompiler compiler(isolate(), strict_mode, grow_mode); | 447 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); |
451 Handle<Code> code = compiler.CompileStoreElement(receiver_map); | 448 Handle<Code> code = compiler.CompileStoreElement(receiver_map); |
452 | 449 |
453 Map::UpdateCodeCache(receiver_map, name, code); | 450 Map::UpdateCodeCache(receiver_map, name, code); |
| 451 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); |
454 return code; | 452 return code; |
455 } | 453 } |
456 | 454 |
457 | 455 |
458 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { | 456 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { |
459 return (strict_mode == kStrictMode) | 457 return (strict_mode == kStrictMode) |
460 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() | 458 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() |
461 : isolate_->builtins()->Builtins::StoreIC_Normal(); | 459 : isolate_->builtins()->Builtins::StoreIC_Normal(); |
462 } | 460 } |
463 | 461 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 Handle<Map> transition, | 538 Handle<Map> transition, |
541 StrictModeFlag strict_mode) { | 539 StrictModeFlag strict_mode) { |
542 Code::StubType type = | 540 Code::StubType type = |
543 (transition.is_null()) ? Code::FIELD : Code::MAP_TRANSITION; | 541 (transition.is_null()) ? Code::FIELD : Code::MAP_TRANSITION; |
544 Code::Flags flags = Code::ComputeMonomorphicFlags( | 542 Code::Flags flags = Code::ComputeMonomorphicFlags( |
545 Code::KEYED_STORE_IC, strict_mode, type); | 543 Code::KEYED_STORE_IC, strict_mode, type); |
546 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags), | 544 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags), |
547 isolate_); | 545 isolate_); |
548 if (probe->IsCode()) return Handle<Code>::cast(probe); | 546 if (probe->IsCode()) return Handle<Code>::cast(probe); |
549 | 547 |
550 KeyedStoreStubCompiler compiler(isolate(), strict_mode, | 548 KeyedStoreStubCompiler compiler(isolate(), strict_mode, STANDARD_STORE); |
551 DO_NOT_ALLOW_JSARRAY_GROWTH); | |
552 Handle<Code> code = | 549 Handle<Code> code = |
553 compiler.CompileStoreField(receiver, field_index, transition, name); | 550 compiler.CompileStoreField(receiver, field_index, transition, name); |
554 JSObject::UpdateMapCodeCache(receiver, name, code); | 551 JSObject::UpdateMapCodeCache(receiver, name, code); |
555 return code; | 552 return code; |
556 } | 553 } |
557 | 554 |
558 | 555 |
559 #define CALL_LOGGER_TAG(kind, type) \ | 556 #define CALL_LOGGER_TAG(kind, type) \ |
560 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 557 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
561 | 558 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 Handle<Name> name) { | 893 Handle<Name> name) { |
897 LoadStubCompiler ic_compiler(isolate_); | 894 LoadStubCompiler ic_compiler(isolate_); |
898 Handle<Code> ic = ic_compiler.CompilePolymorphicIC( | 895 Handle<Code> ic = ic_compiler.CompilePolymorphicIC( |
899 receiver_maps, handlers, name, Code::NORMAL, PROPERTY); | 896 receiver_maps, handlers, name, Code::NORMAL, PROPERTY); |
900 return ic; | 897 return ic; |
901 } | 898 } |
902 | 899 |
903 | 900 |
904 Handle<Code> StubCache::ComputeStoreElementPolymorphic( | 901 Handle<Code> StubCache::ComputeStoreElementPolymorphic( |
905 MapHandleList* receiver_maps, | 902 MapHandleList* receiver_maps, |
906 KeyedAccessGrowMode grow_mode, | 903 KeyedAccessStoreMode store_mode, |
907 StrictModeFlag strict_mode) { | 904 StrictModeFlag strict_mode) { |
| 905 ASSERT(store_mode == STANDARD_STORE || |
| 906 store_mode == STORE_AND_GROW_NO_TRANSITION); |
908 Handle<PolymorphicCodeCache> cache = | 907 Handle<PolymorphicCodeCache> cache = |
909 isolate_->factory()->polymorphic_code_cache(); | 908 isolate_->factory()->polymorphic_code_cache(); |
910 Code::ExtraICState extra_state = Code::ComputeExtraICState(grow_mode, | 909 Code::ExtraICState extra_state = Code::ComputeExtraICState(store_mode, |
911 strict_mode); | 910 strict_mode); |
912 Code::Flags flags = | 911 Code::Flags flags = |
913 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); | 912 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); |
914 Handle<Object> probe = cache->Lookup(receiver_maps, flags); | 913 Handle<Object> probe = cache->Lookup(receiver_maps, flags); |
915 if (probe->IsCode()) return Handle<Code>::cast(probe); | 914 if (probe->IsCode()) return Handle<Code>::cast(probe); |
916 | 915 |
917 KeyedStoreStubCompiler compiler(isolate_, strict_mode, grow_mode); | 916 KeyedStoreStubCompiler compiler(isolate_, strict_mode, store_mode); |
918 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps); | 917 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps); |
919 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); | 918 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); |
920 return code; | 919 return code; |
921 } | 920 } |
922 | 921 |
923 | 922 |
924 #ifdef ENABLE_DEBUGGER_SUPPORT | 923 #ifdef ENABLE_DEBUGGER_SUPPORT |
925 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, | 924 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, |
926 Code::Kind kind) { | 925 Code::Kind kind) { |
927 // Extra IC state is irrelevant for debug break ICs. They jump to | 926 // Extra IC state is irrelevant for debug break ICs. They jump to |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 1631 PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
1633 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 1632 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
1634 return code; | 1633 return code; |
1635 } | 1634 } |
1636 | 1635 |
1637 | 1636 |
1638 Handle<Code> KeyedStoreStubCompiler::GetCode(Code::StubType type, | 1637 Handle<Code> KeyedStoreStubCompiler::GetCode(Code::StubType type, |
1639 Handle<Name> name, | 1638 Handle<Name> name, |
1640 InlineCacheState state) { | 1639 InlineCacheState state) { |
1641 Code::ExtraICState extra_state = | 1640 Code::ExtraICState extra_state = |
1642 Code::ComputeExtraICState(grow_mode_, strict_mode_); | 1641 Code::ComputeExtraICState(store_mode_, strict_mode_); |
1643 Code::Flags flags = | 1642 Code::Flags flags = |
1644 Code::ComputeFlags(Code::KEYED_STORE_IC, state, extra_state, type); | 1643 Code::ComputeFlags(Code::KEYED_STORE_IC, state, extra_state, type); |
1645 Handle<Code> code = GetCodeWithFlags(flags, name); | 1644 Handle<Code> code = GetCodeWithFlags(flags, name); |
1646 PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name)); | 1645 PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name)); |
1647 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); | 1646 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); |
1648 return code; | 1647 return code; |
1649 } | 1648 } |
1650 | 1649 |
1651 | 1650 |
1652 Handle<Code> KeyedStoreStubCompiler::CompileStoreElementPolymorphic( | 1651 Handle<Code> KeyedStoreStubCompiler::CompileStoreElementPolymorphic( |
(...skipping 13 matching lines...) Expand all Loading... |
1666 // to be. Not all the elements are in place yet, pessimistic elements | 1665 // to be. Not all the elements are in place yet, pessimistic elements |
1667 // transitions are still important for performance. | 1666 // transitions are still important for performance. |
1668 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 1667 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
1669 ElementsKind elements_kind = receiver_map->elements_kind(); | 1668 ElementsKind elements_kind = receiver_map->elements_kind(); |
1670 if (!transitioned_map.is_null()) { | 1669 if (!transitioned_map.is_null()) { |
1671 cached_stub = ElementsTransitionAndStoreStub( | 1670 cached_stub = ElementsTransitionAndStoreStub( |
1672 elements_kind, | 1671 elements_kind, |
1673 transitioned_map->elements_kind(), | 1672 transitioned_map->elements_kind(), |
1674 is_js_array, | 1673 is_js_array, |
1675 strict_mode_, | 1674 strict_mode_, |
1676 grow_mode_).GetCode(isolate()); | 1675 store_mode_).GetCode(isolate()); |
1677 } else { | 1676 } else { |
1678 cached_stub = KeyedStoreElementStub( | 1677 cached_stub = KeyedStoreElementStub( |
1679 is_js_array, | 1678 is_js_array, |
1680 elements_kind, | 1679 elements_kind, |
1681 grow_mode_).GetCode(isolate()); | 1680 store_mode_).GetCode(isolate()); |
1682 } | 1681 } |
1683 ASSERT(!cached_stub.is_null()); | 1682 ASSERT(!cached_stub.is_null()); |
1684 handlers.Add(cached_stub); | 1683 handlers.Add(cached_stub); |
1685 transitioned_maps.Add(transitioned_map); | 1684 transitioned_maps.Add(transitioned_map); |
1686 } | 1685 } |
1687 Handle<Code> code = | 1686 Handle<Code> code = |
1688 CompileStorePolymorphic(receiver_maps, &handlers, &transitioned_maps); | 1687 CompileStorePolymorphic(receiver_maps, &handlers, &transitioned_maps); |
1689 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); | 1688 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); |
1690 PROFILE(isolate(), | 1689 PROFILE(isolate(), |
1691 CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code, 0)); | 1690 CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code, 0)); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 Handle<FunctionTemplateInfo>( | 1852 Handle<FunctionTemplateInfo>( |
1854 FunctionTemplateInfo::cast(signature->receiver())); | 1853 FunctionTemplateInfo::cast(signature->receiver())); |
1855 } | 1854 } |
1856 } | 1855 } |
1857 | 1856 |
1858 is_simple_api_call_ = true; | 1857 is_simple_api_call_ = true; |
1859 } | 1858 } |
1860 | 1859 |
1861 | 1860 |
1862 } } // namespace v8::internal | 1861 } } // namespace v8::internal |
OLD | NEW |