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

Side by Side Diff: src/runtime.cc

Issue 155212: Fixed and exposure to the_hole from Runtime_KeyedGetProperty.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | « no previous file | test/mjsunit/global-deleted-property-keyed.js » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 JSObject* receiver = JSObject::cast(args[0]); 2591 JSObject* receiver = JSObject::cast(args[0]);
2592 String* key = String::cast(args[1]); 2592 String* key = String::cast(args[1]);
2593 if (receiver->HasFastProperties()) { 2593 if (receiver->HasFastProperties()) {
2594 // Attempt to use lookup cache. 2594 // Attempt to use lookup cache.
2595 Map* receiver_map = receiver->map(); 2595 Map* receiver_map = receiver->map();
2596 int offset = KeyedLookupCache::Lookup(receiver_map, key); 2596 int offset = KeyedLookupCache::Lookup(receiver_map, key);
2597 if (offset != -1) { 2597 if (offset != -1) {
2598 Object* value = receiver->FastPropertyAt(offset); 2598 Object* value = receiver->FastPropertyAt(offset);
2599 return value->IsTheHole() ? Heap::undefined_value() : value; 2599 return value->IsTheHole() ? Heap::undefined_value() : value;
2600 } 2600 }
2601 // Lookup cache miss. Perform lookup and update the cache if 2601 // Lookup cache miss. Perform lookup and update the cache if appropriate.
2602 // appropriate.
2603 LookupResult result; 2602 LookupResult result;
2604 receiver->LocalLookup(key, &result); 2603 receiver->LocalLookup(key, &result);
2605 if (result.IsProperty() && result.IsLoaded() && result.type() == FIELD) { 2604 if (result.IsProperty() && result.IsLoaded() && result.type() == FIELD) {
2606 int offset = result.GetFieldIndex(); 2605 int offset = result.GetFieldIndex();
2607 KeyedLookupCache::Update(receiver_map, key, offset); 2606 KeyedLookupCache::Update(receiver_map, key, offset);
2608 Object* value = receiver->FastPropertyAt(offset); 2607 return receiver->FastPropertyAt(offset);
2609 return value->IsTheHole() ? Heap::undefined_value() : value;
2610 } 2608 }
2611 } else { 2609 } else {
2612 // Attempt dictionary lookup. 2610 // Attempt dictionary lookup.
2613 StringDictionary* dictionary = receiver->property_dictionary(); 2611 StringDictionary* dictionary = receiver->property_dictionary();
2614 int entry = dictionary->FindEntry(key); 2612 int entry = dictionary->FindEntry(key);
2615 if ((entry != StringDictionary::kNotFound) && 2613 if ((entry != StringDictionary::kNotFound) &&
2616 (dictionary->DetailsAt(entry).type() == NORMAL)) { 2614 (dictionary->DetailsAt(entry).type() == NORMAL)) {
2617 Object* value = dictionary->ValueAt(entry); 2615 Object* value = dictionary->ValueAt(entry);
2618 if (receiver->IsGlobalObject()) { 2616 if (!receiver->IsGlobalObject()) return value;
2619 value = JSGlobalPropertyCell::cast(value)->value(); 2617 value = JSGlobalPropertyCell::cast(value)->value();
2620 } 2618 if (!value->IsTheHole()) return value;
2621 return value; 2619 // If value is the hole do the general lookup.
2622 } 2620 }
2623 } 2621 }
2624 } 2622 }
2625 2623
2626 // Fall back to GetObjectProperty. 2624 // Fall back to GetObjectProperty.
2627 return Runtime::GetObjectProperty(args.at<Object>(0), 2625 return Runtime::GetObjectProperty(args.at<Object>(0),
2628 args.at<Object>(1)); 2626 args.at<Object>(1));
2629 } 2627 }
2630 2628
2631 2629
(...skipping 4929 matching lines...) Expand 10 before | Expand all | Expand 10 after
7561 } else { 7559 } else {
7562 // Handle last resort GC and make sure to allow future allocations 7560 // Handle last resort GC and make sure to allow future allocations
7563 // to grow the heap without causing GCs (if possible). 7561 // to grow the heap without causing GCs (if possible).
7564 Counters::gc_last_resort_from_js.Increment(); 7562 Counters::gc_last_resort_from_js.Increment();
7565 Heap::CollectAllGarbage(); 7563 Heap::CollectAllGarbage();
7566 } 7564 }
7567 } 7565 }
7568 7566
7569 7567
7570 } } // namespace v8::internal 7568 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/global-deleted-property-keyed.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698