OLD | NEW |
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 4343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4354 !args[0]->IsAccessCheckNeeded() && | 4354 !args[0]->IsAccessCheckNeeded() && |
4355 args[1]->IsName()) { | 4355 args[1]->IsName()) { |
4356 JSObject* receiver = JSObject::cast(args[0]); | 4356 JSObject* receiver = JSObject::cast(args[0]); |
4357 Name* key = Name::cast(args[1]); | 4357 Name* key = Name::cast(args[1]); |
4358 if (receiver->HasFastProperties()) { | 4358 if (receiver->HasFastProperties()) { |
4359 // Attempt to use lookup cache. | 4359 // Attempt to use lookup cache. |
4360 Map* receiver_map = receiver->map(); | 4360 Map* receiver_map = receiver->map(); |
4361 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache(); | 4361 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache(); |
4362 int offset = keyed_lookup_cache->Lookup(receiver_map, key); | 4362 int offset = keyed_lookup_cache->Lookup(receiver_map, key); |
4363 if (offset != -1) { | 4363 if (offset != -1) { |
4364 Object* value = receiver->FastPropertyAt(offset); | 4364 // Doubles are not cached, so raw read the value. |
| 4365 Object* value = receiver->RawFastPropertyAt(offset); |
4365 return value->IsTheHole() | 4366 return value->IsTheHole() |
4366 ? isolate->heap()->undefined_value() | 4367 ? isolate->heap()->undefined_value() |
4367 : value; | 4368 : value; |
4368 } | 4369 } |
4369 // Lookup cache miss. Perform lookup and update the cache if | 4370 // Lookup cache miss. Perform lookup and update the cache if |
4370 // appropriate. | 4371 // appropriate. |
4371 LookupResult result(isolate); | 4372 LookupResult result(isolate); |
4372 receiver->LocalLookup(key, &result); | 4373 receiver->LocalLookup(key, &result); |
4373 if (result.IsField()) { | 4374 if (result.IsField()) { |
4374 int offset = result.GetFieldIndex().field_index(); | 4375 int offset = result.GetFieldIndex().field_index(); |
4375 keyed_lookup_cache->Update(receiver_map, key, offset); | 4376 // Do not track double fields in the keyed lookup cache. Reading |
4376 return receiver->FastPropertyAt(offset); | 4377 // double values requires boxing. |
| 4378 if (!FLAG_track_double_fields || |
| 4379 !result.representation().IsDouble()) { |
| 4380 keyed_lookup_cache->Update(receiver_map, key, offset); |
| 4381 } |
| 4382 return receiver->FastPropertyAt(result.representation(), offset); |
4377 } | 4383 } |
4378 } else { | 4384 } else { |
4379 // Attempt dictionary lookup. | 4385 // Attempt dictionary lookup. |
4380 NameDictionary* dictionary = receiver->property_dictionary(); | 4386 NameDictionary* dictionary = receiver->property_dictionary(); |
4381 int entry = dictionary->FindEntry(key); | 4387 int entry = dictionary->FindEntry(key); |
4382 if ((entry != NameDictionary::kNotFound) && | 4388 if ((entry != NameDictionary::kNotFound) && |
4383 (dictionary->DetailsAt(entry).type() == NORMAL)) { | 4389 (dictionary->DetailsAt(entry).type() == NORMAL)) { |
4384 Object* value = dictionary->ValueAt(entry); | 4390 Object* value = dictionary->ValueAt(entry); |
4385 if (!receiver->IsGlobalObject()) return value; | 4391 if (!receiver->IsGlobalObject()) return value; |
4386 value = JSGlobalPropertyCell::cast(value)->value(); | 4392 value = JSGlobalPropertyCell::cast(value)->value(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4542 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 4548 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
4543 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 4549 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
4544 LookupResult lookup(isolate); | 4550 LookupResult lookup(isolate); |
4545 object->LookupRealNamedProperty(*key, &lookup); | 4551 object->LookupRealNamedProperty(*key, &lookup); |
4546 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); | 4552 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); |
4547 switch (lookup.type()) { | 4553 switch (lookup.type()) { |
4548 case NORMAL: | 4554 case NORMAL: |
4549 return lookup.holder()->GetNormalizedProperty(&lookup); | 4555 return lookup.holder()->GetNormalizedProperty(&lookup); |
4550 case FIELD: | 4556 case FIELD: |
4551 return lookup.holder()->FastPropertyAt( | 4557 return lookup.holder()->FastPropertyAt( |
| 4558 lookup.representation(), |
4552 lookup.GetFieldIndex().field_index()); | 4559 lookup.GetFieldIndex().field_index()); |
4553 case CONSTANT_FUNCTION: | 4560 case CONSTANT_FUNCTION: |
4554 return lookup.GetConstantFunction(); | 4561 return lookup.GetConstantFunction(); |
4555 case CALLBACKS: | 4562 case CALLBACKS: |
4556 case HANDLER: | 4563 case HANDLER: |
4557 case INTERCEPTOR: | 4564 case INTERCEPTOR: |
4558 case TRANSITION: | 4565 case TRANSITION: |
4559 return isolate->heap()->undefined_value(); | 4566 return isolate->heap()->undefined_value(); |
4560 case NONEXISTENT: | 4567 case NONEXISTENT: |
4561 UNREACHABLE(); | 4568 UNREACHABLE(); |
(...skipping 5496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10058 LookupResult* result, | 10065 LookupResult* result, |
10059 bool* caught_exception) { | 10066 bool* caught_exception) { |
10060 Object* value; | 10067 Object* value; |
10061 switch (result->type()) { | 10068 switch (result->type()) { |
10062 case NORMAL: | 10069 case NORMAL: |
10063 value = result->holder()->GetNormalizedProperty(result); | 10070 value = result->holder()->GetNormalizedProperty(result); |
10064 if (value->IsTheHole()) { | 10071 if (value->IsTheHole()) { |
10065 return heap->undefined_value(); | 10072 return heap->undefined_value(); |
10066 } | 10073 } |
10067 return value; | 10074 return value; |
10068 case FIELD: | 10075 case FIELD: { |
10069 value = | 10076 Object* value; |
| 10077 MaybeObject* maybe_value = |
10070 JSObject::cast(result->holder())->FastPropertyAt( | 10078 JSObject::cast(result->holder())->FastPropertyAt( |
| 10079 result->representation(), |
10071 result->GetFieldIndex().field_index()); | 10080 result->GetFieldIndex().field_index()); |
| 10081 if (!maybe_value->To(&value)) return maybe_value; |
10072 if (value->IsTheHole()) { | 10082 if (value->IsTheHole()) { |
10073 return heap->undefined_value(); | 10083 return heap->undefined_value(); |
10074 } | 10084 } |
10075 return value; | 10085 return value; |
| 10086 } |
10076 case CONSTANT_FUNCTION: | 10087 case CONSTANT_FUNCTION: |
10077 return result->GetConstantFunction(); | 10088 return result->GetConstantFunction(); |
10078 case CALLBACKS: { | 10089 case CALLBACKS: { |
10079 Object* structure = result->GetCallbackObject(); | 10090 Object* structure = result->GetCallbackObject(); |
10080 if (structure->IsForeign() || structure->IsAccessorInfo()) { | 10091 if (structure->IsForeign() || structure->IsAccessorInfo()) { |
10081 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( | 10092 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( |
10082 receiver, structure, name); | 10093 receiver, structure, name); |
10083 if (!maybe_value->ToObject(&value)) { | 10094 if (!maybe_value->ToObject(&value)) { |
10084 if (maybe_value->IsRetryAfterGC()) return maybe_value; | 10095 if (maybe_value->IsRetryAfterGC()) return maybe_value; |
10085 ASSERT(maybe_value->IsException()); | 10096 ASSERT(maybe_value->IsException()); |
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13394 // Handle last resort GC and make sure to allow future allocations | 13405 // Handle last resort GC and make sure to allow future allocations |
13395 // to grow the heap without causing GCs (if possible). | 13406 // to grow the heap without causing GCs (if possible). |
13396 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13407 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13397 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13408 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13398 "Runtime::PerformGC"); | 13409 "Runtime::PerformGC"); |
13399 } | 13410 } |
13400 } | 13411 } |
13401 | 13412 |
13402 | 13413 |
13403 } } // namespace v8::internal | 13414 } } // namespace v8::internal |
OLD | NEW |