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

Side by Side Diff: src/ic.cc

Issue 9837109: Improve performance of keyed loads/stores which have a HeapNumber index. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 8 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/ia32/stub-cache-ia32.cc ('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 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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 KeyedLoadStubCompiler compiler(isolate()); 1046 KeyedLoadStubCompiler compiler(isolate());
1047 Handle<Code> code = compiler.CompileLoadPolymorphic( 1047 Handle<Code> code = compiler.CompileLoadPolymorphic(
1048 receiver_maps, &handler_ics); 1048 receiver_maps, &handler_ics);
1049 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); 1049 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment();
1050 PROFILE(isolate(), 1050 PROFILE(isolate(),
1051 CodeCreateEvent(Logger::KEYED_LOAD_MEGAMORPHIC_IC_TAG, *code, 0)); 1051 CodeCreateEvent(Logger::KEYED_LOAD_MEGAMORPHIC_IC_TAG, *code, 0));
1052 return code; 1052 return code;
1053 } 1053 }
1054 1054
1055 1055
1056 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) {
1057 // This helper implements a few common fast cases for converting
1058 // non-smi keys of keyed loads/stores to a smi or a string.
1059 if (key->IsHeapNumber()) {
1060 double value = Handle<HeapNumber>::cast(key)->value();
1061 if (isnan(value)) {
1062 key = isolate->factory()->nan_symbol();
1063 } else {
1064 int int_value = FastD2I(value);
1065 if (value == int_value && Smi::IsValid(int_value)) {
1066 key = Handle<Smi>(Smi::FromInt(int_value));
1067 }
1068 }
1069 } else if (key->IsUndefined()) {
1070 key = isolate->factory()->undefined_symbol();
1071 }
1072 return key;
1073 }
1074
1075
1056 MaybeObject* KeyedLoadIC::Load(State state, 1076 MaybeObject* KeyedLoadIC::Load(State state,
1057 Handle<Object> object, 1077 Handle<Object> object,
1058 Handle<Object> key, 1078 Handle<Object> key,
1059 bool force_generic_stub) { 1079 bool force_generic_stub) {
1060 // Check for values that can be converted into a symbol. 1080 // Check for values that can be converted into a symbol directly or
1061 // TODO(1295): Remove this code. 1081 // is representable as a smi.
1062 if (key->IsHeapNumber() && 1082 key = TryConvertKey(key, isolate());
1063 isnan(Handle<HeapNumber>::cast(key)->value())) {
1064 key = isolate()->factory()->nan_symbol();
1065 } else if (key->IsUndefined()) {
1066 key = isolate()->factory()->undefined_symbol();
1067 }
1068 1083
1069 if (key->IsSymbol()) { 1084 if (key->IsSymbol()) {
1070 Handle<String> name = Handle<String>::cast(key); 1085 Handle<String> name = Handle<String>::cast(key);
1071 1086
1072 // If the object is undefined or null it's illegal to try to get any 1087 // If the object is undefined or null it's illegal to try to get any
1073 // of its properties; throw a TypeError in that case. 1088 // of its properties; throw a TypeError in that case.
1074 if (object->IsUndefined() || object->IsNull()) { 1089 if (object->IsUndefined() || object->IsNull()) {
1075 return TypeError("non_object_property_load", object, name); 1090 return TypeError("non_object_property_load", object, name);
1076 } 1091 }
1077 1092
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 } 1769 }
1755 } 1770 }
1756 1771
1757 1772
1758 MaybeObject* KeyedStoreIC::Store(State state, 1773 MaybeObject* KeyedStoreIC::Store(State state,
1759 StrictModeFlag strict_mode, 1774 StrictModeFlag strict_mode,
1760 Handle<Object> object, 1775 Handle<Object> object,
1761 Handle<Object> key, 1776 Handle<Object> key,
1762 Handle<Object> value, 1777 Handle<Object> value,
1763 bool force_generic) { 1778 bool force_generic) {
1779 // Check for values that can be converted into a symbol directly or
1780 // is representable as a smi.
1781 key = TryConvertKey(key, isolate());
1782
1764 if (key->IsSymbol()) { 1783 if (key->IsSymbol()) {
1765 Handle<String> name = Handle<String>::cast(key); 1784 Handle<String> name = Handle<String>::cast(key);
1766 1785
1767 // Handle proxies. 1786 // Handle proxies.
1768 if (object->IsJSProxy()) { 1787 if (object->IsJSProxy()) {
1769 return JSProxy::cast(*object)->SetProperty( 1788 return JSProxy::cast(*object)->SetProperty(
1770 *name, *value, NONE, strict_mode); 1789 *name, *value, NONE, strict_mode);
1771 } 1790 }
1772 1791
1773 // If the object is undefined or null it's illegal to try to set any 1792 // If the object is undefined or null it's illegal to try to set any
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 #undef ADDR 2582 #undef ADDR
2564 }; 2583 };
2565 2584
2566 2585
2567 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2586 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2568 return IC_utilities[id]; 2587 return IC_utilities[id];
2569 } 2588 }
2570 2589
2571 2590
2572 } } // namespace v8::internal 2591 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698