OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 761 |
762 // Set array length to 0. | 762 // Set array length to 0. |
763 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); | 763 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); |
764 CHECK_EQ(Smi::FromInt(0), array->length()); | 764 CHECK_EQ(Smi::FromInt(0), array->length()); |
765 // Must be in fast mode. | 765 // Must be in fast mode. |
766 CHECK(array->HasFastSmiOrObjectElements()); | 766 CHECK(array->HasFastSmiOrObjectElements()); |
767 | 767 |
768 // array[length] = name. | 768 // array[length] = name. |
769 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); | 769 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); |
770 CHECK_EQ(Smi::FromInt(1), array->length()); | 770 CHECK_EQ(Smi::FromInt(1), array->length()); |
771 CHECK_EQ(array->GetElement(0), *name); | 771 CHECK_EQ(array->GetElement(isolate, 0), *name); |
772 | 772 |
773 // Set array length with larger than smi value. | 773 // Set array length with larger than smi value. |
774 Handle<Object> length = | 774 Handle<Object> length = |
775 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); | 775 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
776 array->SetElementsLength(*length)->ToObjectChecked(); | 776 array->SetElementsLength(*length)->ToObjectChecked(); |
777 | 777 |
778 uint32_t int_length = 0; | 778 uint32_t int_length = 0; |
779 CHECK(length->ToArrayIndex(&int_length)); | 779 CHECK(length->ToArrayIndex(&int_length)); |
780 CHECK_EQ(*length, array->length()); | 780 CHECK_EQ(*length, array->length()); |
781 CHECK(array->HasDictionaryElements()); // Must be in slow mode. | 781 CHECK(array->HasDictionaryElements()); // Must be in slow mode. |
782 | 782 |
783 // array[length] = name. | 783 // array[length] = name. |
784 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked(); | 784 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked(); |
785 uint32_t new_int_length = 0; | 785 uint32_t new_int_length = 0; |
786 CHECK(array->length()->ToArrayIndex(&new_int_length)); | 786 CHECK(array->length()->ToArrayIndex(&new_int_length)); |
787 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); | 787 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); |
788 CHECK_EQ(array->GetElement(int_length), *name); | 788 CHECK_EQ(array->GetElement(isolate, int_length), *name); |
789 CHECK_EQ(array->GetElement(0), *name); | 789 CHECK_EQ(array->GetElement(isolate, 0), *name); |
790 } | 790 } |
791 | 791 |
792 | 792 |
793 TEST(JSObjectCopy) { | 793 TEST(JSObjectCopy) { |
794 CcTest::InitializeVM(); | 794 CcTest::InitializeVM(); |
795 Isolate* isolate = Isolate::Current(); | 795 Isolate* isolate = Isolate::Current(); |
796 Factory* factory = isolate->factory(); | 796 Factory* factory = isolate->factory(); |
797 | 797 |
798 v8::HandleScope sc(CcTest::isolate()); | 798 v8::HandleScope sc(CcTest::isolate()); |
799 String* object_string = String::cast(HEAP->Object_string()); | 799 String* object_string = String::cast(HEAP->Object_string()); |
(...skipping 10 matching lines...) Expand all Loading... |
810 obj->SetProperty( | 810 obj->SetProperty( |
811 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | 811 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); |
812 | 812 |
813 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); | 813 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); |
814 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); | 814 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); |
815 | 815 |
816 // Make the clone. | 816 // Make the clone. |
817 Handle<JSObject> clone = Copy(obj); | 817 Handle<JSObject> clone = Copy(obj); |
818 CHECK(!clone.is_identical_to(obj)); | 818 CHECK(!clone.is_identical_to(obj)); |
819 | 819 |
820 CHECK_EQ(obj->GetElement(0), clone->GetElement(0)); | 820 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0)); |
821 CHECK_EQ(obj->GetElement(1), clone->GetElement(1)); | 821 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 1)); |
822 | 822 |
823 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); | 823 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); |
824 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); | 824 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); |
825 | 825 |
826 // Flip the values. | 826 // Flip the values. |
827 clone->SetProperty( | 827 clone->SetProperty( |
828 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | 828 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); |
829 clone->SetProperty( | 829 clone->SetProperty( |
830 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | 830 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); |
831 | 831 |
832 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); | 832 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); |
833 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); | 833 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); |
834 | 834 |
835 CHECK_EQ(obj->GetElement(1), clone->GetElement(0)); | 835 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); |
836 CHECK_EQ(obj->GetElement(0), clone->GetElement(1)); | 836 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); |
837 | 837 |
838 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); | 838 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); |
839 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); | 839 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); |
840 } | 840 } |
841 | 841 |
842 | 842 |
843 TEST(StringAllocation) { | 843 TEST(StringAllocation) { |
844 CcTest::InitializeVM(); | 844 CcTest::InitializeVM(); |
845 Isolate* isolate = Isolate::Current(); | 845 Isolate* isolate = Isolate::Current(); |
846 Factory* factory = isolate->factory(); | 846 Factory* factory = isolate->factory(); |
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 " var a = new Array(n);" | 3447 " var a = new Array(n);" |
3448 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3448 " for (var i = 0; i < n; i += 100) a[i] = i;" |
3449 "};" | 3449 "};" |
3450 "f(10 * 1024 * 1024);"); | 3450 "f(10 * 1024 * 1024);"); |
3451 IncrementalMarking* marking = HEAP->incremental_marking(); | 3451 IncrementalMarking* marking = HEAP->incremental_marking(); |
3452 if (marking->IsStopped()) marking->Start(); | 3452 if (marking->IsStopped()) marking->Start(); |
3453 // This big step should be sufficient to mark the whole array. | 3453 // This big step should be sufficient to mark the whole array. |
3454 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3454 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
3455 ASSERT(marking->IsComplete()); | 3455 ASSERT(marking->IsComplete()); |
3456 } | 3456 } |
OLD | NEW |