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

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

Issue 7172030: Revert "Merge arguments branch to bleeding merge." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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/mjsunit/arguments.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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 Handle<JSArray> array = Handle<JSArray>::cast(object); 668 Handle<JSArray> array = Handle<JSArray>::cast(object);
669 // We just initialized the VM, no heap allocation failure yet. 669 // We just initialized the VM, no heap allocation failure yet.
670 Object* ok = array->Initialize(0)->ToObjectChecked(); 670 Object* ok = array->Initialize(0)->ToObjectChecked();
671 671
672 // Set array length to 0. 672 // Set array length to 0.
673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); 673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked();
674 CHECK_EQ(Smi::FromInt(0), array->length()); 674 CHECK_EQ(Smi::FromInt(0), array->length());
675 CHECK(array->HasFastElements()); // Must be in fast mode. 675 CHECK(array->HasFastElements()); // Must be in fast mode.
676 676
677 // array[length] = name. 677 // array[length] = name.
678 ok = array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked(); 678 ok = array->SetElement(0, *name, kNonStrictMode)->ToObjectChecked();
679 CHECK_EQ(Smi::FromInt(1), array->length()); 679 CHECK_EQ(Smi::FromInt(1), array->length());
680 CHECK_EQ(array->GetElement(0), *name); 680 CHECK_EQ(array->GetElement(0), *name);
681 681
682 // Set array length with larger than smi value. 682 // Set array length with larger than smi value.
683 Handle<Object> length = 683 Handle<Object> length =
684 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 684 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
685 ok = array->SetElementsLength(*length)->ToObjectChecked(); 685 ok = array->SetElementsLength(*length)->ToObjectChecked();
686 686
687 uint32_t int_length = 0; 687 uint32_t int_length = 0;
688 CHECK(length->ToArrayIndex(&int_length)); 688 CHECK(length->ToArrayIndex(&int_length));
689 CHECK_EQ(*length, array->length()); 689 CHECK_EQ(*length, array->length());
690 CHECK(array->HasDictionaryElements()); // Must be in slow mode. 690 CHECK(array->HasDictionaryElements()); // Must be in slow mode.
691 691
692 // array[length] = name. 692 // array[length] = name.
693 ok = array->SetElement( 693 ok = array->SetElement(int_length, *name, kNonStrictMode)->ToObjectChecked();
694 int_length, *name, kNonStrictMode, true)->ToObjectChecked();
695 uint32_t new_int_length = 0; 694 uint32_t new_int_length = 0;
696 CHECK(array->length()->ToArrayIndex(&new_int_length)); 695 CHECK(array->length()->ToArrayIndex(&new_int_length));
697 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 696 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
698 CHECK_EQ(array->GetElement(int_length), *name); 697 CHECK_EQ(array->GetElement(int_length), *name);
699 CHECK_EQ(array->GetElement(0), *name); 698 CHECK_EQ(array->GetElement(0), *name);
700 } 699 }
701 700
702 701
703 TEST(JSObjectCopy) { 702 TEST(JSObjectCopy) {
704 InitializeVM(); 703 InitializeVM();
705 704
706 v8::HandleScope sc; 705 v8::HandleScope sc;
707 String* object_symbol = String::cast(HEAP->Object_symbol()); 706 String* object_symbol = String::cast(HEAP->Object_symbol());
708 Object* raw_object = Isolate::Current()->context()->global()-> 707 Object* raw_object = Isolate::Current()->context()->global()->
709 GetProperty(object_symbol)->ToObjectChecked(); 708 GetProperty(object_symbol)->ToObjectChecked();
710 JSFunction* object_function = JSFunction::cast(raw_object); 709 JSFunction* object_function = JSFunction::cast(raw_object);
711 Handle<JSFunction> constructor(object_function); 710 Handle<JSFunction> constructor(object_function);
712 Handle<JSObject> obj = FACTORY->NewJSObject(constructor); 711 Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
713 Handle<String> first = FACTORY->LookupAsciiSymbol("first"); 712 Handle<String> first = FACTORY->LookupAsciiSymbol("first");
714 Handle<String> second = FACTORY->LookupAsciiSymbol("second"); 713 Handle<String> second = FACTORY->LookupAsciiSymbol("second");
715 714
716 obj->SetProperty( 715 obj->SetProperty(
717 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 716 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
718 obj->SetProperty( 717 obj->SetProperty(
719 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 718 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
720 719
721 Object* ok = 720 Object* ok = obj->SetElement(0, *first, kNonStrictMode)->ToObjectChecked();
722 obj->SetElement(0, *first, kNonStrictMode, true)->ToObjectChecked();
723 721
724 ok = obj->SetElement(1, *second, kNonStrictMode, true)->ToObjectChecked(); 722 ok = obj->SetElement(1, *second, kNonStrictMode)->ToObjectChecked();
725 723
726 // Make the clone. 724 // Make the clone.
727 Handle<JSObject> clone = Copy(obj); 725 Handle<JSObject> clone = Copy(obj);
728 CHECK(!clone.is_identical_to(obj)); 726 CHECK(!clone.is_identical_to(obj));
729 727
730 CHECK_EQ(obj->GetElement(0), clone->GetElement(0)); 728 CHECK_EQ(obj->GetElement(0), clone->GetElement(0));
731 CHECK_EQ(obj->GetElement(1), clone->GetElement(1)); 729 CHECK_EQ(obj->GetElement(1), clone->GetElement(1));
732 730
733 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); 731 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first));
734 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); 732 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
735 733
736 // Flip the values. 734 // Flip the values.
737 clone->SetProperty( 735 clone->SetProperty(
738 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 736 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
739 clone->SetProperty( 737 clone->SetProperty(
740 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 738 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
741 739
742 ok = clone->SetElement(0, *second, kNonStrictMode, true)->ToObjectChecked(); 740 ok = clone->SetElement(0, *second, kNonStrictMode)->ToObjectChecked();
743 ok = clone->SetElement(1, *first, kNonStrictMode, true)->ToObjectChecked(); 741 ok = clone->SetElement(1, *first, kNonStrictMode)->ToObjectChecked();
744 742
745 CHECK_EQ(obj->GetElement(1), clone->GetElement(0)); 743 CHECK_EQ(obj->GetElement(1), clone->GetElement(0));
746 CHECK_EQ(obj->GetElement(0), clone->GetElement(1)); 744 CHECK_EQ(obj->GetElement(0), clone->GetElement(1));
747 745
748 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); 746 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
749 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); 747 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
750 } 748 }
751 749
752 750
753 TEST(StringAllocation) { 751 TEST(StringAllocation) {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 CHECK(helper.b_found()); 1318 CHECK(helper.b_found());
1321 } 1319 }
1322 // ...but is now unreachable. 1320 // ...but is now unreachable.
1323 { 1321 {
1324 HeapIteratorTestHelper helper(a_saved, *b); 1322 HeapIteratorTestHelper helper(a_saved, *b);
1325 helper.IterateHeap(HeapIterator::kFilterUnreachable); 1323 helper.IterateHeap(HeapIterator::kFilterUnreachable);
1326 CHECK(!helper.a_found()); 1324 CHECK(!helper.a_found());
1327 CHECK(helper.b_found()); 1325 CHECK(helper.b_found());
1328 } 1326 }
1329 } 1327 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698