Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/stub-cache.cc

Issue 136643008: A64: Synchronize with r18256. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.h ('k') | src/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (!ic.is_null()) return ic; 145 if (!ic.is_null()) return ic;
146 } 146 }
147 147
148 if (kind == Code::LOAD_IC) { 148 if (kind == Code::LOAD_IC) {
149 LoadStubCompiler ic_compiler(isolate(), flag); 149 LoadStubCompiler ic_compiler(isolate(), flag);
150 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 150 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
151 } else if (kind == Code::KEYED_LOAD_IC) { 151 } else if (kind == Code::KEYED_LOAD_IC) {
152 KeyedLoadStubCompiler ic_compiler(isolate(), flag); 152 KeyedLoadStubCompiler ic_compiler(isolate(), flag);
153 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 153 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
154 } else if (kind == Code::STORE_IC) { 154 } else if (kind == Code::STORE_IC) {
155 StrictModeFlag strict_mode = StoreIC::GetStrictMode(extra_ic_state); 155 StoreStubCompiler ic_compiler(isolate(), extra_ic_state);
156 StoreStubCompiler ic_compiler(isolate(), strict_mode);
157 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 156 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
158 } else { 157 } else {
159 ASSERT(kind == Code::KEYED_STORE_IC); 158 ASSERT(kind == Code::KEYED_STORE_IC);
160 StrictModeFlag strict_mode = StoreIC::GetStrictMode(extra_ic_state); 159 ASSERT(STANDARD_STORE ==
161 KeyedStoreStubCompiler ic_compiler(isolate(), strict_mode, STANDARD_STORE); 160 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state));
161 KeyedStoreStubCompiler ic_compiler(isolate(), extra_ic_state);
162 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 162 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
163 } 163 }
164 164
165 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); 165 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic);
166 return ic; 166 return ic;
167 } 167 }
168 168
169 169
170 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, 170 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
171 Handle<Type> type) { 171 Handle<Type> type) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ASSERT(store_mode == STANDARD_STORE || 229 ASSERT(store_mode == STANDARD_STORE ||
230 store_mode == STORE_AND_GROW_NO_TRANSITION || 230 store_mode == STORE_AND_GROW_NO_TRANSITION ||
231 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || 231 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
232 store_mode == STORE_NO_TRANSITION_HANDLE_COW); 232 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
233 233
234 Handle<String> name = 234 Handle<String> name =
235 isolate()->factory()->KeyedStoreElementMonomorphic_string(); 235 isolate()->factory()->KeyedStoreElementMonomorphic_string();
236 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); 236 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_);
237 if (probe->IsCode()) return Handle<Code>::cast(probe); 237 if (probe->IsCode()) return Handle<Code>::cast(probe);
238 238
239 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); 239 KeyedStoreStubCompiler compiler(isolate(), extra_state);
240 Handle<Code> code = compiler.CompileStoreElement(receiver_map); 240 Handle<Code> code = compiler.CompileStoreElement(receiver_map);
241 241
242 Map::UpdateCodeCache(receiver_map, name, code); 242 Map::UpdateCodeCache(receiver_map, name, code);
243 ASSERT(KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()) 243 ASSERT(KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state())
244 == store_mode); 244 == store_mode);
245 return code; 245 return code;
246 } 246 }
247 247
248 248
249 #define CALL_LOGGER_TAG(kind, type) \ 249 #define CALL_LOGGER_TAG(kind, type) \
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 store_mode == STORE_NO_TRANSITION_HANDLE_COW); 640 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
641 Handle<PolymorphicCodeCache> cache = 641 Handle<PolymorphicCodeCache> cache =
642 isolate_->factory()->polymorphic_code_cache(); 642 isolate_->factory()->polymorphic_code_cache();
643 ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState( 643 ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState(
644 strict_mode, store_mode); 644 strict_mode, store_mode);
645 Code::Flags flags = 645 Code::Flags flags =
646 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); 646 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state);
647 Handle<Object> probe = cache->Lookup(receiver_maps, flags); 647 Handle<Object> probe = cache->Lookup(receiver_maps, flags);
648 if (probe->IsCode()) return Handle<Code>::cast(probe); 648 if (probe->IsCode()) return Handle<Code>::cast(probe);
649 649
650 KeyedStoreStubCompiler compiler(isolate_, strict_mode, store_mode); 650 KeyedStoreStubCompiler compiler(isolate_, extra_state);
651 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps); 651 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps);
652 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); 652 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
653 return code; 653 return code;
654 } 654 }
655 655
656 656
657 #ifdef ENABLE_DEBUGGER_SUPPORT 657 #ifdef ENABLE_DEBUGGER_SUPPORT
658 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, 658 Handle<Code> StubCache::ComputeCallDebugBreak(int argc,
659 Code::Kind kind) { 659 Code::Kind kind) {
660 // Extra IC state is irrelevant for debug break ICs. They jump to 660 // Extra IC state is irrelevant for debug break ICs. They jump to
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 holder->LocalLookupRealNamedProperty(*name, lookup); 1121 holder->LocalLookupRealNamedProperty(*name, lookup);
1122 if (lookup->IsFound()) return; 1122 if (lookup->IsFound()) return;
1123 if (holder->GetPrototype()->IsNull()) return; 1123 if (holder->GetPrototype()->IsNull()) return;
1124 holder->GetPrototype()->Lookup(*name, lookup); 1124 holder->GetPrototype()->Lookup(*name, lookup);
1125 } 1125 }
1126 1126
1127 1127
1128 #define __ ACCESS_MASM(masm()) 1128 #define __ ACCESS_MASM(masm())
1129 1129
1130 1130
1131 CallKind CallStubCompiler::call_kind() {
1132 return CallICBase::Contextual::decode(extra_state())
1133 ? CALL_AS_FUNCTION
1134 : CALL_AS_METHOD;
1135 }
1136
1137
1131 void CallStubCompiler::HandlerFrontendFooter(Label* miss) { 1138 void CallStubCompiler::HandlerFrontendFooter(Label* miss) {
1132 __ bind(miss); 1139 __ bind(miss);
1133 GenerateMissBranch(); 1140 GenerateMissBranch();
1134 } 1141 }
1135 1142
1136 1143
1144 void CallStubCompiler::GenerateJumpFunctionIgnoreReceiver(
1145 Handle<JSFunction> function) {
1146 ParameterCount expected(function);
1147 __ InvokeFunction(function, expected, arguments(),
1148 JUMP_FUNCTION, NullCallWrapper(), call_kind());
1149 }
1150
1151
1152 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
1153 Handle<JSFunction> function) {
1154 PatchGlobalProxy(object);
1155 GenerateJumpFunctionIgnoreReceiver(function);
1156 }
1157
1158
1159 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
1160 Register actual_closure,
1161 Handle<JSFunction> function) {
1162 PatchGlobalProxy(object);
1163 ParameterCount expected(function);
1164 __ InvokeFunction(actual_closure, expected, arguments(),
1165 JUMP_FUNCTION, NullCallWrapper(), call_kind());
1166 }
1167
1168
1169 Handle<Code> CallStubCompiler::CompileCallConstant(
1170 Handle<Object> object,
1171 Handle<JSObject> holder,
1172 Handle<Name> name,
1173 CheckType check,
1174 Handle<JSFunction> function) {
1175 if (HasCustomCallGenerator(function)) {
1176 Handle<Code> code = CompileCustomCall(object, holder,
1177 Handle<Cell>::null(),
1178 function, Handle<String>::cast(name),
1179 Code::FAST);
1180 // A null handle means bail out to the regular compiler code below.
1181 if (!code.is_null()) return code;
1182 }
1183
1184 Label miss;
1185 HandlerFrontendHeader(object, holder, name, check, &miss);
1186 GenerateJumpFunction(object, function);
1187 HandlerFrontendFooter(&miss);
1188
1189 // Return the generated code.
1190 return GetCode(function);
1191 }
1192
1193
1137 Register LoadStubCompiler::HandlerFrontendHeader( 1194 Register LoadStubCompiler::HandlerFrontendHeader(
1138 Handle<Type> type, 1195 Handle<Type> type,
1139 Register object_reg, 1196 Register object_reg,
1140 Handle<JSObject> holder, 1197 Handle<JSObject> holder,
1141 Handle<Name> name, 1198 Handle<Name> name,
1142 Label* miss) { 1199 Label* miss) {
1143 PrototypeCheckType check_type = CHECK_ALL_MAPS; 1200 PrototypeCheckType check_type = CHECK_ALL_MAPS;
1144 int function_index = -1; 1201 int function_index = -1;
1145 if (type->Is(Type::String())) { 1202 if (type->Is(Type::String())) {
1146 function_index = Context::STRING_FUNCTION_INDEX; 1203 function_index = Context::STRING_FUNCTION_INDEX;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement( 1570 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
1514 Handle<Map> receiver_map) { 1571 Handle<Map> receiver_map) {
1515 ElementsKind elements_kind = receiver_map->elements_kind(); 1572 ElementsKind elements_kind = receiver_map->elements_kind();
1516 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; 1573 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
1517 Handle<Code> stub; 1574 Handle<Code> stub;
1518 if (receiver_map->has_fast_elements() || 1575 if (receiver_map->has_fast_elements() ||
1519 receiver_map->has_external_array_elements()) { 1576 receiver_map->has_external_array_elements()) {
1520 stub = KeyedStoreFastElementStub( 1577 stub = KeyedStoreFastElementStub(
1521 is_jsarray, 1578 is_jsarray,
1522 elements_kind, 1579 elements_kind,
1523 store_mode_).GetCode(isolate()); 1580 store_mode()).GetCode(isolate());
1524 } else { 1581 } else {
1525 stub = KeyedStoreElementStub(is_jsarray, 1582 stub = KeyedStoreElementStub(is_jsarray,
1526 elements_kind, 1583 elements_kind,
1527 store_mode_).GetCode(isolate()); 1584 store_mode()).GetCode(isolate());
1528 } 1585 }
1529 1586
1530 __ DispatchMap(receiver(), scratch1(), receiver_map, stub, DO_SMI_CHECK); 1587 __ DispatchMap(receiver(), scratch1(), receiver_map, stub, DO_SMI_CHECK);
1531 1588
1532 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); 1589 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss);
1533 1590
1534 // Return the generated code. 1591 // Return the generated code.
1535 return GetICCode(kind(), Code::NORMAL, factory()->empty_string()); 1592 return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
1536 } 1593 }
1537 1594
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 // Tracking to do a better job of ensuring the data types are what they need 1700 // Tracking to do a better job of ensuring the data types are what they need
1644 // to be. Not all the elements are in place yet, pessimistic elements 1701 // to be. Not all the elements are in place yet, pessimistic elements
1645 // transitions are still important for performance. 1702 // transitions are still important for performance.
1646 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; 1703 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
1647 ElementsKind elements_kind = receiver_map->elements_kind(); 1704 ElementsKind elements_kind = receiver_map->elements_kind();
1648 if (!transitioned_map.is_null()) { 1705 if (!transitioned_map.is_null()) {
1649 cached_stub = ElementsTransitionAndStoreStub( 1706 cached_stub = ElementsTransitionAndStoreStub(
1650 elements_kind, 1707 elements_kind,
1651 transitioned_map->elements_kind(), 1708 transitioned_map->elements_kind(),
1652 is_js_array, 1709 is_js_array,
1653 store_mode_).GetCode(isolate()); 1710 store_mode()).GetCode(isolate());
1654 } else { 1711 } else {
1655 if (receiver_map->has_fast_elements() || 1712 if (receiver_map->has_fast_elements() ||
1656 receiver_map->has_external_array_elements()) { 1713 receiver_map->has_external_array_elements()) {
1657 cached_stub = KeyedStoreFastElementStub( 1714 cached_stub = KeyedStoreFastElementStub(
1658 is_js_array, 1715 is_js_array,
1659 elements_kind, 1716 elements_kind,
1660 store_mode_).GetCode(isolate()); 1717 store_mode()).GetCode(isolate());
1661 } else { 1718 } else {
1662 cached_stub = KeyedStoreElementStub( 1719 cached_stub = KeyedStoreElementStub(
1663 is_js_array, 1720 is_js_array,
1664 elements_kind, 1721 elements_kind,
1665 store_mode_).GetCode(isolate()); 1722 store_mode()).GetCode(isolate());
1666 } 1723 }
1667 } 1724 }
1668 ASSERT(!cached_stub.is_null()); 1725 ASSERT(!cached_stub.is_null());
1669 handlers.Add(cached_stub); 1726 handlers.Add(cached_stub);
1670 transitioned_maps.Add(transitioned_map); 1727 transitioned_maps.Add(transitioned_map);
1671 } 1728 }
1672 Handle<Code> code = 1729 Handle<Code> code =
1673 CompileStorePolymorphic(receiver_maps, &handlers, &transitioned_maps); 1730 CompileStorePolymorphic(receiver_maps, &handlers, &transitioned_maps);
1674 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); 1731 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment();
1675 PROFILE(isolate(), 1732 PROFILE(isolate(),
1676 CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code, 0)); 1733 CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code, 0));
1677 return code; 1734 return code;
1678 } 1735 }
1679 1736
1680 1737
1681 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement( 1738 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement(
1682 MacroAssembler* masm) { 1739 MacroAssembler* masm) {
1683 KeyedStoreIC::GenerateSlow(masm); 1740 KeyedStoreIC::GenerateSlow(masm);
1684 } 1741 }
1685 1742
1686 1743
1687 CallStubCompiler::CallStubCompiler(Isolate* isolate, 1744 CallStubCompiler::CallStubCompiler(Isolate* isolate,
1688 int argc, 1745 int argc,
1689 Code::Kind kind, 1746 Code::Kind kind,
1690 ExtraICState extra_state, 1747 ExtraICState extra_state,
1691 InlineCacheHolderFlag cache_holder) 1748 InlineCacheHolderFlag cache_holder)
1692 : StubCompiler(isolate), 1749 : StubCompiler(isolate, extra_state),
1693 arguments_(argc), 1750 arguments_(argc),
1694 kind_(kind), 1751 kind_(kind),
1695 extra_state_(extra_state),
1696 cache_holder_(cache_holder) { 1752 cache_holder_(cache_holder) {
1697 } 1753 }
1698 1754
1699 1755
1700 bool CallStubCompiler::HasCustomCallGenerator(Handle<JSFunction> function) { 1756 bool CallStubCompiler::HasCustomCallGenerator(Handle<JSFunction> function) {
1701 if (function->shared()->HasBuiltinFunctionId()) { 1757 if (function->shared()->HasBuiltinFunctionId()) {
1702 BuiltinFunctionId id = function->shared()->builtin_function_id(); 1758 BuiltinFunctionId id = function->shared()->builtin_function_id();
1703 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; 1759 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true;
1704 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) 1760 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE)
1705 #undef CALL_GENERATOR_CASE 1761 #undef CALL_GENERATOR_CASE
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 cell, 1809 cell,
1754 function, 1810 function,
1755 fname); 1811 fname);
1756 } 1812 }
1757 1813
1758 1814
1759 Handle<Code> CallStubCompiler::GetCode(Code::StubType type, 1815 Handle<Code> CallStubCompiler::GetCode(Code::StubType type,
1760 Handle<Name> name) { 1816 Handle<Name> name) {
1761 int argc = arguments_.immediate(); 1817 int argc = arguments_.immediate();
1762 Code::Flags flags = Code::ComputeMonomorphicFlags( 1818 Code::Flags flags = Code::ComputeMonomorphicFlags(
1763 kind_, extra_state_, cache_holder_, type, argc); 1819 kind_, extra_state(), cache_holder_, type, argc);
1764 return GetCodeWithFlags(flags, name); 1820 return GetCodeWithFlags(flags, name);
1765 } 1821 }
1766 1822
1767 1823
1768 Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) { 1824 Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) {
1769 Handle<String> function_name; 1825 Handle<String> function_name;
1770 if (function->shared()->name()->IsString()) { 1826 if (function->shared()->name()->IsString()) {
1771 function_name = Handle<String>(String::cast(function->shared()->name())); 1827 function_name = Handle<String>(String::cast(function->shared()->name()));
1772 } 1828 }
1773 return GetCode(Code::FAST, function_name); 1829 return GetCode(Code::FAST, function_name);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 Handle<FunctionTemplateInfo>( 1897 Handle<FunctionTemplateInfo>(
1842 FunctionTemplateInfo::cast(signature->receiver())); 1898 FunctionTemplateInfo::cast(signature->receiver()));
1843 } 1899 }
1844 } 1900 }
1845 1901
1846 is_simple_api_call_ = true; 1902 is_simple_api_call_ = true;
1847 } 1903 }
1848 1904
1849 1905
1850 } } // namespace v8::internal 1906 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698