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

Side by Side Diff: src/handles.cc

Issue 214051: Pushed 1.3.12 to trunk. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 3 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/handles.h ('k') | src/heap.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 { 520 {
521 // Leaving JavaScript. 521 // Leaving JavaScript.
522 VMState state(EXTERNAL); 522 VMState state(EXTERNAL);
523 result = enum_fun(info); 523 result = enum_fun(info);
524 } 524 }
525 } 525 }
526 return result; 526 return result;
527 } 527 }
528 528
529 529
530 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object) { 530 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object,
531 KeyCollectionType type) {
531 Handle<FixedArray> content = Factory::empty_fixed_array(); 532 Handle<FixedArray> content = Factory::empty_fixed_array();
532 533
533 JSObject* arguments_boilerplate = 534 // Only collect keys if access is permitted.
534 Top::context()->global_context()->arguments_boilerplate(); 535 for (Handle<Object> p = object;
535 JSFunction* arguments_function = 536 *p != Heap::null_value();
536 JSFunction::cast(arguments_boilerplate->map()->constructor()); 537 p = Handle<Object>(p->GetPrototype())) {
537 bool allow_enumeration = (object->map()->constructor() != arguments_function); 538 Handle<JSObject> current(JSObject::cast(*p));
538 539
539 // Only collect keys if access is permitted. 540 // Check access rights if required.
540 if (allow_enumeration) { 541 if (current->IsAccessCheckNeeded() &&
541 for (Handle<Object> p = object; 542 !Top::MayNamedAccess(*current, Heap::undefined_value(),
542 *p != Heap::null_value(); 543 v8::ACCESS_KEYS)) {
543 p = Handle<Object>(p->GetPrototype())) { 544 Top::ReportFailedAccessCheck(*current, v8::ACCESS_KEYS);
544 Handle<JSObject> current(JSObject::cast(*p)); 545 break;
546 }
545 547
546 // Check access rights if required. 548 // Compute the element keys.
547 if (current->IsAccessCheckNeeded() && 549 Handle<FixedArray> element_keys =
548 !Top::MayNamedAccess(*current, Heap::undefined_value(), 550 Factory::NewFixedArray(current->NumberOfEnumElements());
549 v8::ACCESS_KEYS)) { 551 current->GetEnumElementKeys(*element_keys);
550 Top::ReportFailedAccessCheck(*current, v8::ACCESS_KEYS); 552 content = UnionOfKeys(content, element_keys);
551 break;
552 }
553 553
554 // Compute the element keys. 554 // Add the element keys from the interceptor.
555 Handle<FixedArray> element_keys = 555 if (current->HasIndexedInterceptor()) {
556 Factory::NewFixedArray(current->NumberOfEnumElements()); 556 v8::Handle<v8::Array> result =
557 current->GetEnumElementKeys(*element_keys); 557 GetKeysForIndexedInterceptor(object, current);
558 content = UnionOfKeys(content, element_keys); 558 if (!result.IsEmpty())
559 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result));
560 }
559 561
560 // Add the element keys from the interceptor. 562 // Compute the property keys.
561 if (current->HasIndexedInterceptor()) { 563 content = UnionOfKeys(content, GetEnumPropertyKeys(current));
562 v8::Handle<v8::Array> result =
563 GetKeysForIndexedInterceptor(object, current);
564 if (!result.IsEmpty())
565 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result));
566 }
567 564
568 // Compute the property keys. 565 // Add the property keys from the interceptor.
569 content = UnionOfKeys(content, GetEnumPropertyKeys(current)); 566 if (current->HasNamedInterceptor()) {
567 v8::Handle<v8::Array> result =
568 GetKeysForNamedInterceptor(object, current);
569 if (!result.IsEmpty())
570 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result));
571 }
570 572
571 // Add the property keys from the interceptor. 573 // If we only want local properties we bail out after the first
572 if (current->HasNamedInterceptor()) { 574 // iteration.
573 v8::Handle<v8::Array> result = 575 if (type == LOCAL_ONLY)
574 GetKeysForNamedInterceptor(object, current); 576 break;
575 if (!result.IsEmpty())
576 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result));
577 }
578 }
579 } 577 }
580 return content; 578 return content;
581 } 579 }
582 580
583 581
584 Handle<JSArray> GetKeysFor(Handle<JSObject> object) { 582 Handle<JSArray> GetKeysFor(Handle<JSObject> object) {
585 Counters::for_in.Increment(); 583 Counters::for_in.Increment();
586 Handle<FixedArray> elements = GetKeysInFixedArrayFor(object); 584 Handle<FixedArray> elements = GetKeysInFixedArrayFor(object,
585 INCLUDE_PROTOS);
587 return Factory::NewJSArrayWithElements(elements); 586 return Factory::NewJSArrayWithElements(elements);
588 } 587 }
589 588
590 589
591 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object) { 590 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object) {
592 int index = 0; 591 int index = 0;
593 if (object->HasFastProperties()) { 592 if (object->HasFastProperties()) {
594 if (object->map()->instance_descriptors()->HasEnumCache()) { 593 if (object->map()->instance_descriptors()->HasEnumCache()) {
595 Counters::enum_cache_hits.Increment(); 594 Counters::enum_cache_hits.Increment();
596 DescriptorArray* desc = object->map()->instance_descriptors(); 595 DescriptorArray* desc = object->map()->instance_descriptors();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 757 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
759 obj->set_map(*new_map); 758 obj->set_map(*new_map);
760 new_map->set_needs_loading(true); 759 new_map->set_needs_loading(true);
761 // Store the lazy loading info in the constructor field. We'll 760 // Store the lazy loading info in the constructor field. We'll
762 // reestablish the constructor from the fixed array after loading. 761 // reestablish the constructor from the fixed array after loading.
763 new_map->set_constructor(*arr); 762 new_map->set_constructor(*arr);
764 ASSERT(!obj->IsLoaded()); 763 ASSERT(!obj->IsLoaded());
765 } 764 }
766 765
767 } } // namespace v8::internal 766 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698