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

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

Issue 9496010: Fix secondary stub cache and add a test for the stub cache lookups. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 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
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // masked out. 83 // masked out.
84 ASSERT(Code::ExtractICStateFromFlags(flags) == MONOMORPHIC); 84 ASSERT(Code::ExtractICStateFromFlags(flags) == MONOMORPHIC);
85 STATIC_ASSERT((Code::ICStateField::kMask & 1) == 1); 85 STATIC_ASSERT((Code::ICStateField::kMask & 1) == 1);
86 86
87 // Make sure that the code type is not included in the hash. 87 // Make sure that the code type is not included in the hash.
88 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); 88 ASSERT(Code::ExtractTypeFromFlags(flags) == 0);
89 89
90 // Compute the primary entry. 90 // Compute the primary entry.
91 int primary_offset = PrimaryOffset(name, flags, map); 91 int primary_offset = PrimaryOffset(name, flags, map);
92 Entry* primary = entry(primary_, primary_offset); 92 Entry* primary = entry(primary_, primary_offset);
93 Code* hit = primary->value; 93 Code* old_code = primary->value;
94 94
95 // If the primary entry has useful data in it, we retire it to the 95 // If the primary entry has useful data in it, we retire it to the
96 // secondary cache before overwriting it. 96 // secondary cache before overwriting it.
97 if (hit != isolate_->builtins()->builtin(Builtins::kIllegal)) { 97 if (old_code != isolate_->builtins()->builtin(Builtins::kIllegal)) {
98 Code::Flags primary_flags = Code::RemoveTypeFromFlags(hit->flags()); 98 Map* old_map = primary->map;
99 int secondary_offset = 99 Code::Flags old_flags = Code::RemoveTypeFromFlags(old_code->flags());
100 SecondaryOffset(primary->key, primary_flags, primary_offset); 100 int seed = PrimaryOffset(primary->key, old_flags, old_map);
101 int secondary_offset = SecondaryOffset(primary->key, old_flags, seed);
101 Entry* secondary = entry(secondary_, secondary_offset); 102 Entry* secondary = entry(secondary_, secondary_offset);
102 *secondary = *primary; 103 *secondary = *primary;
103 } 104 }
104 105
105 // Update primary cache. 106 // Update primary cache.
106 primary->key = name; 107 primary->key = name;
107 primary->value = code; 108 primary->value = code;
109 primary->map = map;
110 isolate()->counters()->megamorphic_stub_cache_updates()->Increment();
108 return code; 111 return code;
109 } 112 }
110 113
111 114
112 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<String> name, 115 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<String> name,
113 Handle<JSObject> receiver) { 116 Handle<JSObject> receiver) {
114 ASSERT(receiver->IsGlobalObject() || receiver->HasFastProperties()); 117 ASSERT(receiver->IsGlobalObject() || receiver->HasFastProperties());
115 // If no global objects are present in the prototype chain, the load 118 // If no global objects are present in the prototype chain, the load
116 // nonexistent IC stub can be shared for all names for a given map 119 // nonexistent IC stub can be shared for all names for a given map
117 // and we use the empty string for the map cache in that case. If 120 // and we use the empty string for the map cache in that case. If
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 Handle<FunctionTemplateInfo>( 1536 Handle<FunctionTemplateInfo>(
1534 FunctionTemplateInfo::cast(signature->receiver())); 1537 FunctionTemplateInfo::cast(signature->receiver()));
1535 } 1538 }
1536 } 1539 }
1537 1540
1538 is_simple_api_call_ = true; 1541 is_simple_api_call_ = true;
1539 } 1542 }
1540 1543
1541 1544
1542 } } // namespace v8::internal 1545 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698