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

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

Issue 6624085: [Isolates] Merge 7051:7083 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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/es5conform/es5conform.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 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)->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(int_length, *name)->ToObjectChecked(); 693 ok = array->SetElement(int_length, *name, kNonStrictMode)->ToObjectChecked();
694 uint32_t new_int_length = 0; 694 uint32_t new_int_length = 0;
695 CHECK(array->length()->ToArrayIndex(&new_int_length)); 695 CHECK(array->length()->ToArrayIndex(&new_int_length));
696 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 696 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
697 CHECK_EQ(array->GetElement(int_length), *name); 697 CHECK_EQ(array->GetElement(int_length), *name);
698 CHECK_EQ(array->GetElement(0), *name); 698 CHECK_EQ(array->GetElement(0), *name);
699 } 699 }
700 700
701 701
702 TEST(JSObjectCopy) { 702 TEST(JSObjectCopy) {
703 InitializeVM(); 703 InitializeVM();
704 704
705 v8::HandleScope sc; 705 v8::HandleScope sc;
706 String* object_symbol = String::cast(HEAP->Object_symbol()); 706 String* object_symbol = String::cast(HEAP->Object_symbol());
707 Object* raw_object = Isolate::Current()->context()->global()-> 707 Object* raw_object = Isolate::Current()->context()->global()->
708 GetProperty(object_symbol)->ToObjectChecked(); 708 GetProperty(object_symbol)->ToObjectChecked();
709 JSFunction* object_function = JSFunction::cast(raw_object); 709 JSFunction* object_function = JSFunction::cast(raw_object);
710 Handle<JSFunction> constructor(object_function); 710 Handle<JSFunction> constructor(object_function);
711 Handle<JSObject> obj = FACTORY->NewJSObject(constructor); 711 Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
712 Handle<String> first = FACTORY->LookupAsciiSymbol("first"); 712 Handle<String> first = FACTORY->LookupAsciiSymbol("first");
713 Handle<String> second = FACTORY->LookupAsciiSymbol("second"); 713 Handle<String> second = FACTORY->LookupAsciiSymbol("second");
714 714
715 obj->SetProperty( 715 obj->SetProperty(
716 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 716 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
717 obj->SetProperty( 717 obj->SetProperty(
718 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 718 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
719 719
720 Object* ok = obj->SetElement(0, *first)->ToObjectChecked(); 720 Object* ok = obj->SetElement(0, *first, kNonStrictMode)->ToObjectChecked();
721 721
722 ok = obj->SetElement(1, *second)->ToObjectChecked(); 722 ok = obj->SetElement(1, *second, 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 ok = clone->SetElement(0, *second)->ToObjectChecked(); 740 ok = clone->SetElement(0, *second, kNonStrictMode)->ToObjectChecked();
741 ok = clone->SetElement(1, *first)->ToObjectChecked(); 741 ok = clone->SetElement(1, *first, 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 CHECK(helper.b_found()); 1318 CHECK(helper.b_found());
1319 } 1319 }
1320 // ...but is now unreachable. 1320 // ...but is now unreachable.
1321 { 1321 {
1322 HeapIteratorTestHelper helper(a_saved, *b); 1322 HeapIteratorTestHelper helper(a_saved, *b);
1323 helper.IterateHeap(HeapIterator::kFilterUnreachable); 1323 helper.IterateHeap(HeapIterator::kFilterUnreachable);
1324 CHECK(!helper.a_found()); 1324 CHECK(!helper.a_found());
1325 CHECK(helper.b_found()); 1325 CHECK(helper.b_found());
1326 } 1326 }
1327 } 1327 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/es5conform/es5conform.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698