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

Side by Side Diff: test/cctest/test-heap.cc

Issue 9443014: Fix redefinition of aliased elements in arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 8 years, 10 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 | « test/cctest/test-api.cc ('k') | test/test262/test262.status » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // We just initialized the VM, no heap allocation failure yet. 669 // We just initialized the VM, no heap allocation failure yet.
670 array->Initialize(0)->ToObjectChecked(); 670 array->Initialize(0)->ToObjectChecked();
671 671
672 // Set array length to 0. 672 // Set array length to 0.
673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); 673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked();
674 CHECK_EQ(Smi::FromInt(0), array->length()); 674 CHECK_EQ(Smi::FromInt(0), array->length());
675 // Must be in fast mode. 675 // Must be in fast mode.
676 CHECK(array->HasFastTypeElements()); 676 CHECK(array->HasFastTypeElements());
677 677
678 // array[length] = name. 678 // array[length] = name.
679 array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked(); 679 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked();
680 CHECK_EQ(Smi::FromInt(1), array->length()); 680 CHECK_EQ(Smi::FromInt(1), array->length());
681 CHECK_EQ(array->GetElement(0), *name); 681 CHECK_EQ(array->GetElement(0), *name);
682 682
683 // Set array length with larger than smi value. 683 // Set array length with larger than smi value.
684 Handle<Object> length = 684 Handle<Object> length =
685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
686 array->SetElementsLength(*length)->ToObjectChecked(); 686 array->SetElementsLength(*length)->ToObjectChecked();
687 687
688 uint32_t int_length = 0; 688 uint32_t int_length = 0;
689 CHECK(length->ToArrayIndex(&int_length)); 689 CHECK(length->ToArrayIndex(&int_length));
690 CHECK_EQ(*length, array->length()); 690 CHECK_EQ(*length, array->length());
691 CHECK(array->HasDictionaryElements()); // Must be in slow mode. 691 CHECK(array->HasDictionaryElements()); // Must be in slow mode.
692 692
693 // array[length] = name. 693 // array[length] = name.
694 array->SetElement(int_length, *name, kNonStrictMode, true)->ToObjectChecked(); 694 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked();
695 uint32_t new_int_length = 0; 695 uint32_t new_int_length = 0;
696 CHECK(array->length()->ToArrayIndex(&new_int_length)); 696 CHECK(array->length()->ToArrayIndex(&new_int_length));
697 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 697 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
698 CHECK_EQ(array->GetElement(int_length), *name); 698 CHECK_EQ(array->GetElement(int_length), *name);
699 CHECK_EQ(array->GetElement(0), *name); 699 CHECK_EQ(array->GetElement(0), *name);
700 } 700 }
701 701
702 702
703 TEST(JSObjectCopy) { 703 TEST(JSObjectCopy) {
704 InitializeVM(); 704 InitializeVM();
705 705
706 v8::HandleScope sc; 706 v8::HandleScope sc;
707 String* object_symbol = String::cast(HEAP->Object_symbol()); 707 String* object_symbol = String::cast(HEAP->Object_symbol());
708 Object* raw_object = Isolate::Current()->context()->global()-> 708 Object* raw_object = Isolate::Current()->context()->global()->
709 GetProperty(object_symbol)->ToObjectChecked(); 709 GetProperty(object_symbol)->ToObjectChecked();
710 JSFunction* object_function = JSFunction::cast(raw_object); 710 JSFunction* object_function = JSFunction::cast(raw_object);
711 Handle<JSFunction> constructor(object_function); 711 Handle<JSFunction> constructor(object_function);
712 Handle<JSObject> obj = FACTORY->NewJSObject(constructor); 712 Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
713 Handle<String> first = FACTORY->LookupAsciiSymbol("first"); 713 Handle<String> first = FACTORY->LookupAsciiSymbol("first");
714 Handle<String> second = FACTORY->LookupAsciiSymbol("second"); 714 Handle<String> second = FACTORY->LookupAsciiSymbol("second");
715 715
716 obj->SetProperty( 716 obj->SetProperty(
717 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 717 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
718 obj->SetProperty( 718 obj->SetProperty(
719 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 719 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
720 720
721 obj->SetElement(0, *first, kNonStrictMode, true)->ToObjectChecked(); 721 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked();
722 obj->SetElement(1, *second, kNonStrictMode, true)->ToObjectChecked(); 722 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked();
723 723
724 // Make the clone. 724 // Make the clone.
725 Handle<JSObject> clone = Copy(obj); 725 Handle<JSObject> clone = Copy(obj);
726 CHECK(!clone.is_identical_to(obj)); 726 CHECK(!clone.is_identical_to(obj));
727 727
728 CHECK_EQ(obj->GetElement(0), clone->GetElement(0)); 728 CHECK_EQ(obj->GetElement(0), clone->GetElement(0));
729 CHECK_EQ(obj->GetElement(1), clone->GetElement(1)); 729 CHECK_EQ(obj->GetElement(1), clone->GetElement(1));
730 730
731 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); 731 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first));
732 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); 732 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
733 733
734 // Flip the values. 734 // Flip the values.
735 clone->SetProperty( 735 clone->SetProperty(
736 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 736 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
737 clone->SetProperty( 737 clone->SetProperty(
738 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 738 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
739 739
740 clone->SetElement(0, *second, kNonStrictMode, true)->ToObjectChecked(); 740 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked();
741 clone->SetElement(1, *first, kNonStrictMode, true)->ToObjectChecked(); 741 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
742 742
743 CHECK_EQ(obj->GetElement(1), clone->GetElement(0)); 743 CHECK_EQ(obj->GetElement(1), clone->GetElement(0));
744 CHECK_EQ(obj->GetElement(0), clone->GetElement(1)); 744 CHECK_EQ(obj->GetElement(0), clone->GetElement(1));
745 745
746 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); 746 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
747 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); 747 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
748 } 748 }
749 749
750 750
751 TEST(StringAllocation) { 751 TEST(StringAllocation) {
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 // clearing correctly records slots in prototype transition array. 1590 // clearing correctly records slots in prototype transition array.
1591 i::FLAG_always_compact = true; 1591 i::FLAG_always_compact = true;
1592 Handle<Map> map(baseObject->map()); 1592 Handle<Map> map(baseObject->map());
1593 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); 1593 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address()));
1594 CHECK(space->LastPage()->Contains(prototype->address())); 1594 CHECK(space->LastPage()->Contains(prototype->address()));
1595 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); 1595 baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
1596 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1596 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1597 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1597 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1598 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1598 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1599 } 1599 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698