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

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

Issue 7044083: Refactor platform-specific code for determining shared stub for keyed load/stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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/x64/stub-cache-x64.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "api.h" 30 #include "api.h"
31 #include "arguments.h" 31 #include "arguments.h"
32 #include "code-stubs.h"
32 #include "gdb-jit.h" 33 #include "gdb-jit.h"
33 #include "ic-inl.h" 34 #include "ic-inl.h"
34 #include "stub-cache.h" 35 #include "stub-cache.h"
35 #include "vm-state-inl.h" 36 #include "vm-state-inl.h"
36 37
37 namespace v8 { 38 namespace v8 {
38 namespace internal { 39 namespace internal {
39 40
40 // ----------------------------------------------------------------------- 41 // -----------------------------------------------------------------------
41 // StubCache implementation. 42 // StubCache implementation.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 Code::KEYED_LOAD_IC, 496 Code::KEYED_LOAD_IC,
496 NORMAL, 497 NORMAL,
497 strict_mode); 498 strict_mode);
498 String* name = is_store 499 String* name = is_store
499 ? isolate()->heap()->KeyedStoreElementMonomorphic_symbol() 500 ? isolate()->heap()->KeyedStoreElementMonomorphic_symbol()
500 : isolate()->heap()->KeyedLoadElementMonomorphic_symbol(); 501 : isolate()->heap()->KeyedLoadElementMonomorphic_symbol();
501 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags); 502 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags);
502 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code); 503 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code);
503 504
504 MaybeObject* maybe_new_code = NULL; 505 MaybeObject* maybe_new_code = NULL;
506 Map* receiver_map = receiver->map();
505 if (is_store) { 507 if (is_store) {
506 KeyedStoreStubCompiler compiler(strict_mode); 508 KeyedStoreStubCompiler compiler(strict_mode);
507 maybe_new_code = compiler.CompileStoreElement(receiver->map()); 509 maybe_new_code = compiler.CompileStoreElement(receiver_map);
508 } else { 510 } else {
509 KeyedLoadStubCompiler compiler; 511 KeyedLoadStubCompiler compiler;
510 maybe_new_code = compiler.CompileLoadElement(receiver->map()); 512 maybe_new_code = compiler.CompileLoadElement(receiver_map);
511 } 513 }
512 Code* code; 514 Code* code;
513 if (!maybe_new_code->To(&code)) return maybe_new_code; 515 if (!maybe_new_code->To(&code)) return maybe_new_code;
514 if (is_store) { 516 if (is_store) {
515 PROFILE(isolate_, 517 PROFILE(isolate_,
516 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, 518 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
517 Code::cast(code), 0)); 519 Code::cast(code), 0));
518 } else { 520 } else {
519 PROFILE(isolate_, 521 PROFILE(isolate_,
520 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, 522 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG,
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 Code::cast(result->ToObjectUnchecked()), 1640 Code::cast(result->ToObjectUnchecked()),
1639 name)); 1641 name));
1640 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, 1642 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1641 name, 1643 name,
1642 Code::cast(result->ToObjectUnchecked()))); 1644 Code::cast(result->ToObjectUnchecked())));
1643 } 1645 }
1644 return result; 1646 return result;
1645 } 1647 }
1646 1648
1647 1649
1650 MaybeObject* KeyedLoadStubCompiler::ComputeSharedKeyedLoadElementStub(
1651 Map* receiver_map) {
1652 MaybeObject* maybe_stub = NULL;
1653 if (receiver_map->has_fast_elements()) {
1654 maybe_stub = KeyedLoadFastElementStub().TryGetCode();
1655 } else if (receiver_map->has_external_array_elements()) {
1656 JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
1657 maybe_stub = KeyedLoadExternalArrayStub(elements_kind).TryGetCode();
1658 } else {
1659 UNREACHABLE();
1660 }
1661 return maybe_stub;
1662 }
1663
1664
1648 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { 1665 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
1649 Code::Flags flags = Code::ComputeMonomorphicFlags( 1666 Code::Flags flags = Code::ComputeMonomorphicFlags(
1650 Code::STORE_IC, type, strict_mode_); 1667 Code::STORE_IC, type, strict_mode_);
1651 MaybeObject* result = GetCodeWithFlags(flags, name); 1668 MaybeObject* result = GetCodeWithFlags(flags, name);
1652 if (!result->IsFailure()) { 1669 if (!result->IsFailure()) {
1653 PROFILE(isolate(), 1670 PROFILE(isolate(),
1654 CodeCreateEvent(Logger::STORE_IC_TAG, 1671 CodeCreateEvent(Logger::STORE_IC_TAG,
1655 Code::cast(result->ToObjectUnchecked()), 1672 Code::cast(result->ToObjectUnchecked()),
1656 name)); 1673 name));
1657 GDBJIT(AddCode(GDBJITInterface::STORE_IC, 1674 GDBJIT(AddCode(GDBJITInterface::STORE_IC,
(...skipping 16 matching lines...) Expand all
1674 Code::cast(result->ToObjectUnchecked()), 1691 Code::cast(result->ToObjectUnchecked()),
1675 name)); 1692 name));
1676 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, 1693 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
1677 name, 1694 name,
1678 Code::cast(result->ToObjectUnchecked()))); 1695 Code::cast(result->ToObjectUnchecked())));
1679 } 1696 }
1680 return result; 1697 return result;
1681 } 1698 }
1682 1699
1683 1700
1701 MaybeObject* KeyedStoreStubCompiler::ComputeSharedKeyedStoreElementStub(
1702 Map* receiver_map) {
1703 MaybeObject* maybe_stub = NULL;
1704 if (receiver_map->has_fast_elements()) {
1705 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
1706 maybe_stub = KeyedStoreFastElementStub(is_js_array).TryGetCode();
1707 } else if (receiver_map->has_external_array_elements()) {
1708 JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
1709 maybe_stub = KeyedStoreExternalArrayStub(elements_kind).TryGetCode();
1710 } else {
1711 UNREACHABLE();
1712 }
1713 return maybe_stub;
1714 }
1715
1716
1684 CallStubCompiler::CallStubCompiler(int argc, 1717 CallStubCompiler::CallStubCompiler(int argc,
1685 InLoopFlag in_loop, 1718 InLoopFlag in_loop,
1686 Code::Kind kind, 1719 Code::Kind kind,
1687 Code::ExtraICState extra_ic_state, 1720 Code::ExtraICState extra_ic_state,
1688 InlineCacheHolderFlag cache_holder) 1721 InlineCacheHolderFlag cache_holder)
1689 : arguments_(argc), 1722 : arguments_(argc),
1690 in_loop_(in_loop), 1723 in_loop_(in_loop),
1691 kind_(kind), 1724 kind_(kind),
1692 extra_ic_state_(extra_ic_state), 1725 extra_ic_state_(extra_ic_state),
1693 cache_holder_(cache_holder) { 1726 cache_holder_(cache_holder) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 expected_receiver_type_ = 1871 expected_receiver_type_ =
1839 FunctionTemplateInfo::cast(signature->receiver()); 1872 FunctionTemplateInfo::cast(signature->receiver());
1840 } 1873 }
1841 } 1874 }
1842 1875
1843 is_simple_api_call_ = true; 1876 is_simple_api_call_ = true;
1844 } 1877 }
1845 1878
1846 1879
1847 } } // namespace v8::internal 1880 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698