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

Side by Side Diff: src/objects.cc

Issue 10693100: Tiny cleanup of DescriptorArrays lookups (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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/objects.h ('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 // 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 if (*done) { 2170 if (*done) {
2171 if (strict_mode == kNonStrictMode) return value; 2171 if (strict_mode == kNonStrictMode) return value;
2172 Handle<Object> args[] = { Handle<Object>(name), Handle<Object>(this)}; 2172 Handle<Object> args[] = { Handle<Object>(name), Handle<Object>(this)};
2173 return isolate->Throw(*isolate->factory()->NewTypeError( 2173 return isolate->Throw(*isolate->factory()->NewTypeError(
2174 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)))); 2174 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))));
2175 } 2175 }
2176 return heap->the_hole_value(); 2176 return heap->the_hole_value();
2177 } 2177 }
2178 2178
2179 2179
2180 void JSObject::LookupInDescriptor(String* name, LookupResult* result) {
2181 DescriptorArray* descriptors = map()->instance_descriptors();
2182 int number = descriptors->SearchWithCache(name);
2183 if (number != DescriptorArray::kNotFound) {
2184 result->DescriptorResult(this, descriptors->GetDetails(number), number);
2185 } else {
2186 result->NotFound();
2187 }
2188 }
2189
2190
2191 void Map::LookupInDescriptors(JSObject* holder, 2180 void Map::LookupInDescriptors(JSObject* holder,
2192 String* name, 2181 String* name,
2193 LookupResult* result) { 2182 LookupResult* result) {
2194 DescriptorArray* descriptors = instance_descriptors(); 2183 DescriptorArray* descriptors = instance_descriptors();
2195 DescriptorLookupCache* cache = 2184 int number = descriptors->SearchWithCache(name);
2196 GetHeap()->isolate()->descriptor_lookup_cache(); 2185 if (number == DescriptorArray::kNotFound) {
2197 int number = cache->Lookup(descriptors, name); 2186 result->NotFound();
2198 if (number == DescriptorLookupCache::kAbsent) { 2187 } else {
2199 number = descriptors->Search(name);
2200 cache->Update(descriptors, name, number);
2201 }
2202 if (number != DescriptorArray::kNotFound) {
2203 result->DescriptorResult(holder, descriptors->GetDetails(number), number); 2188 result->DescriptorResult(holder, descriptors->GetDetails(number), number);
2204 } else {
2205 result->NotFound();
2206 } 2189 }
2207 } 2190 }
2208 2191
2209 2192
2210 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { 2193 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) {
2211 ASSERT(!map.is_null()); 2194 ASSERT(!map.is_null());
2212 for (int i = 0; i < maps->length(); ++i) { 2195 for (int i = 0; i < maps->length(); ++i) {
2213 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true; 2196 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true;
2214 } 2197 }
2215 return false; 2198 return false;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 LookupResult* result) { 2394 LookupResult* result) {
2412 if (IsJSGlobalProxy()) { 2395 if (IsJSGlobalProxy()) {
2413 Object* proto = GetPrototype(); 2396 Object* proto = GetPrototype();
2414 if (proto->IsNull()) return result->NotFound(); 2397 if (proto->IsNull()) return result->NotFound();
2415 ASSERT(proto->IsJSGlobalObject()); 2398 ASSERT(proto->IsJSGlobalObject());
2416 // A GlobalProxy's prototype should always be a proper JSObject. 2399 // A GlobalProxy's prototype should always be a proper JSObject.
2417 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); 2400 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result);
2418 } 2401 }
2419 2402
2420 if (HasFastProperties()) { 2403 if (HasFastProperties()) {
2421 LookupInDescriptor(name, result); 2404 map()->LookupInDescriptors(this, name, result);
2422 if (result->IsFound()) { 2405 if (result->IsFound()) {
2423 // A property, a map transition or a null descriptor was found. 2406 // A property, a map transition or a null descriptor was found.
2424 // We return all of these result types because 2407 // We return all of these result types because
2425 // LocalLookupRealNamedProperty is used when setting properties 2408 // LocalLookupRealNamedProperty is used when setting properties
2426 // where map transitions and null descriptors are handled. 2409 // where map transitions and null descriptors are handled.
2427 ASSERT(result->holder() == this && result->IsFastPropertyType()); 2410 ASSERT(result->holder() == this && result->IsFastPropertyType());
2428 // Disallow caching for uninitialized constants. These can only 2411 // Disallow caching for uninitialized constants. These can only
2429 // occur as fields. 2412 // occur as fields.
2430 if (result->IsField() && 2413 if (result->IsField() &&
2431 result->IsReadOnly() && 2414 result->IsReadOnly() &&
(...skipping 10945 matching lines...) Expand 10 before | Expand all | Expand 10 after
13377 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13360 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13378 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13361 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13379 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13362 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13380 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13363 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13381 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13364 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13382 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13365 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13383 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13366 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13384 } 13367 }
13385 13368
13386 } } // namespace v8::internal 13369 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698