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

Side by Side Diff: src/runtime.cc

Issue 264563003: Public interface of KeyedLookupCache handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes Created 6 years, 7 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/heap.cc ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after
5076 // for objects that require access checks. 5076 // for objects that require access checks.
5077 if (receiver_obj->IsJSObject()) { 5077 if (receiver_obj->IsJSObject()) {
5078 if (!receiver_obj->IsJSGlobalProxy() && 5078 if (!receiver_obj->IsJSGlobalProxy() &&
5079 !receiver_obj->IsAccessCheckNeeded() && 5079 !receiver_obj->IsAccessCheckNeeded() &&
5080 key_obj->IsName()) { 5080 key_obj->IsName()) {
5081 DisallowHeapAllocation no_allocation; 5081 DisallowHeapAllocation no_allocation;
5082 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj); 5082 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj);
5083 Handle<Name> key = Handle<Name>::cast(key_obj); 5083 Handle<Name> key = Handle<Name>::cast(key_obj);
5084 if (receiver->HasFastProperties()) { 5084 if (receiver->HasFastProperties()) {
5085 // Attempt to use lookup cache. 5085 // Attempt to use lookup cache.
5086 Map* receiver_map = receiver->map(); 5086 Handle<Map> receiver_map(receiver->map(), isolate);
5087 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache(); 5087 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache();
5088 int offset = keyed_lookup_cache->Lookup(receiver_map, *key); 5088 int offset = keyed_lookup_cache->Lookup(receiver_map, key);
5089 if (offset != -1) { 5089 if (offset != -1) {
5090 // Doubles are not cached, so raw read the value. 5090 // Doubles are not cached, so raw read the value.
5091 Object* value = receiver->RawFastPropertyAt(offset); 5091 Object* value = receiver->RawFastPropertyAt(offset);
5092 return value->IsTheHole() 5092 return value->IsTheHole()
5093 ? isolate->heap()->undefined_value() 5093 ? isolate->heap()->undefined_value()
5094 : value; 5094 : value;
5095 } 5095 }
5096 // Lookup cache miss. Perform lookup and update the cache if 5096 // Lookup cache miss. Perform lookup and update the cache if
5097 // appropriate. 5097 // appropriate.
5098 LookupResult result(isolate); 5098 LookupResult result(isolate);
5099 receiver->LocalLookup(key, &result); 5099 receiver->LocalLookup(key, &result);
5100 if (result.IsField()) { 5100 if (result.IsField()) {
5101 int offset = result.GetFieldIndex().field_index(); 5101 int offset = result.GetFieldIndex().field_index();
5102 // Do not track double fields in the keyed lookup cache. Reading 5102 // Do not track double fields in the keyed lookup cache. Reading
5103 // double values requires boxing. 5103 // double values requires boxing.
5104 if (!result.representation().IsDouble()) { 5104 if (!result.representation().IsDouble()) {
5105 keyed_lookup_cache->Update(receiver_map, *key, offset); 5105 keyed_lookup_cache->Update(receiver_map, key, offset);
5106 } 5106 }
5107 AllowHeapAllocation allow_allocation; 5107 AllowHeapAllocation allow_allocation;
5108 return *JSObject::FastPropertyAt( 5108 return *JSObject::FastPropertyAt(
5109 receiver, result.representation(), offset); 5109 receiver, result.representation(), offset);
5110 } 5110 }
5111 } else { 5111 } else {
5112 // Attempt dictionary lookup. 5112 // Attempt dictionary lookup.
5113 NameDictionary* dictionary = receiver->property_dictionary(); 5113 NameDictionary* dictionary = receiver->property_dictionary();
5114 int entry = dictionary->FindEntry(key); 5114 int entry = dictionary->FindEntry(key);
5115 if ((entry != NameDictionary::kNotFound) && 5115 if ((entry != NameDictionary::kNotFound) &&
(...skipping 10023 matching lines...) Expand 10 before | Expand all | Expand 10 after
15139 } 15139 }
15140 return NULL; 15140 return NULL;
15141 } 15141 }
15142 15142
15143 15143
15144 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15144 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15145 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15145 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15146 } 15146 }
15147 15147
15148 } } // namespace v8::internal 15148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698