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

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

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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-debug.cc ('k') | test/cctest/test-heap-profiler.cc » ('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 // 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Object* code = heap->CreateCode( 120 Object* code = heap->CreateCode(
121 desc, 121 desc,
122 Code::ComputeFlags(Code::STUB), 122 Code::ComputeFlags(Code::STUB),
123 Handle<Code>())->ToObjectChecked(); 123 Handle<Code>())->ToObjectChecked();
124 CHECK(code->IsCode()); 124 CHECK(code->IsCode());
125 125
126 HeapObject* obj = HeapObject::cast(code); 126 HeapObject* obj = HeapObject::cast(code);
127 Address obj_addr = obj->address(); 127 Address obj_addr = obj->address();
128 128
129 for (int i = 0; i < obj->Size(); i += kPointerSize) { 129 for (int i = 0; i < obj->Size(); i += kPointerSize) {
130 Object* found = heap->FindCodeObject(obj_addr + i); 130 Object* found = isolate->FindCodeObject(obj_addr + i);
131 CHECK_EQ(code, found); 131 CHECK_EQ(code, found);
132 } 132 }
133 133
134 Object* copy = heap->CreateCode( 134 Object* copy = heap->CreateCode(
135 desc, 135 desc,
136 Code::ComputeFlags(Code::STUB), 136 Code::ComputeFlags(Code::STUB),
137 Handle<Code>())->ToObjectChecked(); 137 Handle<Code>())->ToObjectChecked();
138 CHECK(copy->IsCode()); 138 CHECK(copy->IsCode());
139 HeapObject* obj_copy = HeapObject::cast(copy); 139 HeapObject* obj_copy = HeapObject::cast(copy);
140 Object* not_right = heap->FindCodeObject(obj_copy->address() + 140 Object* not_right = isolate->FindCodeObject(obj_copy->address() +
141 obj_copy->Size() / 2); 141 obj_copy->Size() / 2);
142 CHECK(not_right != code); 142 CHECK(not_right != code);
143 } 143 }
144 144
145 145
146 TEST(HeapObjects) { 146 TEST(HeapObjects) {
147 CcTest::InitializeVM(); 147 CcTest::InitializeVM();
148 Isolate* isolate = Isolate::Current(); 148 Isolate* isolate = Isolate::Current();
149 Factory* factory = isolate->factory(); 149 Factory* factory = isolate->factory();
150 Heap* heap = isolate->heap(); 150 Heap* heap = isolate->heap();
151 151
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 654
655 // check for empty 655 // check for empty
656 CHECK(!obj->HasLocalProperty(*first)); 656 CHECK(!obj->HasLocalProperty(*first));
657 657
658 // add first 658 // add first
659 obj->SetProperty( 659 obj->SetProperty(
660 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 660 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
661 CHECK(obj->HasLocalProperty(*first)); 661 CHECK(obj->HasLocalProperty(*first));
662 662
663 // delete first 663 // delete first
664 CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION)); 664 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
665 CHECK(!obj->HasLocalProperty(*first)); 665 CHECK(!obj->HasLocalProperty(*first));
666 666
667 // add first and then second 667 // add first and then second
668 obj->SetProperty( 668 obj->SetProperty(
669 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 669 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
670 obj->SetProperty( 670 obj->SetProperty(
671 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 671 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
672 CHECK(obj->HasLocalProperty(*first)); 672 CHECK(obj->HasLocalProperty(*first));
673 CHECK(obj->HasLocalProperty(*second)); 673 CHECK(obj->HasLocalProperty(*second));
674 674
675 // delete first and then second 675 // delete first and then second
676 CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION)); 676 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
677 CHECK(obj->HasLocalProperty(*second)); 677 CHECK(obj->HasLocalProperty(*second));
678 CHECK(obj->DeleteProperty(*second, JSObject::NORMAL_DELETION)); 678 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
679 CHECK(!obj->HasLocalProperty(*first)); 679 CHECK(!obj->HasLocalProperty(*first));
680 CHECK(!obj->HasLocalProperty(*second)); 680 CHECK(!obj->HasLocalProperty(*second));
681 681
682 // add first and then second 682 // add first and then second
683 obj->SetProperty( 683 obj->SetProperty(
684 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 684 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
685 obj->SetProperty( 685 obj->SetProperty(
686 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 686 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
687 CHECK(obj->HasLocalProperty(*first)); 687 CHECK(obj->HasLocalProperty(*first));
688 CHECK(obj->HasLocalProperty(*second)); 688 CHECK(obj->HasLocalProperty(*second));
689 689
690 // delete second and then first 690 // delete second and then first
691 CHECK(obj->DeleteProperty(*second, JSObject::NORMAL_DELETION)); 691 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
692 CHECK(obj->HasLocalProperty(*first)); 692 CHECK(obj->HasLocalProperty(*first));
693 CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION)); 693 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
694 CHECK(!obj->HasLocalProperty(*first)); 694 CHECK(!obj->HasLocalProperty(*first));
695 CHECK(!obj->HasLocalProperty(*second)); 695 CHECK(!obj->HasLocalProperty(*second));
696 696
697 // check string and internalized string match 697 // check string and internalized string match
698 const char* string1 = "fisk"; 698 const char* string1 = "fisk";
699 Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1)); 699 Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
700 obj->SetProperty( 700 obj->SetProperty(
701 *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 701 *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
702 Handle<String> s1_string = factory->InternalizeUtf8String(string1); 702 Handle<String> s1_string = factory->InternalizeUtf8String(string1);
703 CHECK(obj->HasLocalProperty(*s1_string)); 703 CHECK(obj->HasLocalProperty(*s1_string));
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 " if (i >= 3) live.push(object, prototype);" 1941 " if (i >= 3) live.push(object, prototype);"
1942 "}"); 1942 "}");
1943 1943
1944 Handle<JSObject> baseObject = 1944 Handle<JSObject> baseObject =
1945 v8::Utils::OpenHandle( 1945 v8::Utils::OpenHandle(
1946 *v8::Handle<v8::Object>::Cast( 1946 *v8::Handle<v8::Object>::Cast(
1947 v8::Context::GetCurrent()->Global()->Get(v8_str("base")))); 1947 v8::Context::GetCurrent()->Global()->Get(v8_str("base"))));
1948 1948
1949 // Verify that only dead prototype transitions are cleared. 1949 // Verify that only dead prototype transitions are cleared.
1950 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); 1950 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
1951 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1951 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1952 const int transitions = 10 - 3; 1952 const int transitions = 10 - 3;
1953 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); 1953 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
1954 1954
1955 // Verify that prototype transitions array was compacted. 1955 // Verify that prototype transitions array was compacted.
1956 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); 1956 FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
1957 for (int i = 0; i < transitions; i++) { 1957 for (int i = 0; i < transitions; i++) {
1958 int j = Map::kProtoTransitionHeaderSize + 1958 int j = Map::kProtoTransitionHeaderSize +
1959 i * Map::kProtoTransitionElementsPerEntry; 1959 i * Map::kProtoTransitionElementsPerEntry;
1960 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 1960 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
1961 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); 1961 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 3163
3164 // First make sure we flip spaces 3164 // First make sure we flip spaces
3165 HEAP->CollectGarbage(NEW_SPACE); 3165 HEAP->CollectGarbage(NEW_SPACE);
3166 3166
3167 // Allocate the object. 3167 // Allocate the object.
3168 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); 3168 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
3169 array_data->set(0, Smi::FromInt(1)); 3169 array_data->set(0, Smi::FromInt(1));
3170 array_data->set(1, Smi::FromInt(2)); 3170 array_data->set(1, Smi::FromInt(2));
3171 3171
3172 AllocateAllButNBytes(HEAP->new_space(), 3172 AllocateAllButNBytes(HEAP->new_space(),
3173 JSArray::kSize + AllocationSiteInfo::kSize + 3173 JSArray::kSize + AllocationMemento::kSize +
3174 kPointerSize); 3174 kPointerSize);
3175 3175
3176 Handle<JSArray> array = factory->NewJSArrayWithElements(array_data, 3176 Handle<JSArray> array = factory->NewJSArrayWithElements(array_data,
3177 FAST_SMI_ELEMENTS, 3177 FAST_SMI_ELEMENTS,
3178 NOT_TENURED); 3178 NOT_TENURED);
3179 3179
3180 CHECK_EQ(Smi::FromInt(2), array->length()); 3180 CHECK_EQ(Smi::FromInt(2), array->length());
3181 CHECK(array->HasFastSmiOrObjectElements()); 3181 CHECK(array->HasFastSmiOrObjectElements());
3182 3182
3183 // We need filler the size of AllocationSiteInfo object, plus an extra 3183 // We need filler the size of AllocationMemento object, plus an extra
3184 // fill pointer value. 3184 // fill pointer value.
3185 MaybeObject* maybe_object = HEAP->AllocateRaw( 3185 MaybeObject* maybe_object = HEAP->AllocateRaw(
3186 AllocationSiteInfo::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE); 3186 AllocationMemento::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE);
3187 Object* obj = NULL; 3187 Object* obj = NULL;
3188 CHECK(maybe_object->ToObject(&obj)); 3188 CHECK(maybe_object->ToObject(&obj));
3189 Address addr_obj = reinterpret_cast<Address>( 3189 Address addr_obj = reinterpret_cast<Address>(
3190 reinterpret_cast<byte*>(obj - kHeapObjectTag)); 3190 reinterpret_cast<byte*>(obj - kHeapObjectTag));
3191 HEAP->CreateFillerObjectAt(addr_obj, 3191 HEAP->CreateFillerObjectAt(addr_obj,
3192 AllocationSiteInfo::kSize + kPointerSize); 3192 AllocationMemento::kSize + kPointerSize);
3193 3193
3194 // Give the array a name, making sure not to allocate strings. 3194 // Give the array a name, making sure not to allocate strings.
3195 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array); 3195 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
3196 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj); 3196 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj);
3197 3197
3198 // This should crash with a protection violation if we are running a build 3198 // This should crash with a protection violation if we are running a build
3199 // with the bug. 3199 // with the bug.
3200 AlwaysAllocateScope aa_scope; 3200 AlwaysAllocateScope aa_scope;
3201 v8::Script::Compile(mote_code_string)->Run(); 3201 v8::Script::Compile(mote_code_string)->Run();
3202 } 3202 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 " var a = new Array(n);" 3348 " var a = new Array(n);"
3349 " for (var i = 0; i < n; i += 100) a[i] = i;" 3349 " for (var i = 0; i < n; i += 100) a[i] = i;"
3350 "};" 3350 "};"
3351 "f(10 * 1024 * 1024);"); 3351 "f(10 * 1024 * 1024);");
3352 IncrementalMarking* marking = HEAP->incremental_marking(); 3352 IncrementalMarking* marking = HEAP->incremental_marking();
3353 if (marking->IsStopped()) marking->Start(); 3353 if (marking->IsStopped()) marking->Start();
3354 // This big step should be sufficient to mark the whole array. 3354 // This big step should be sufficient to mark the whole array.
3355 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3355 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3356 ASSERT(marking->IsComplete()); 3356 ASSERT(marking->IsComplete());
3357 } 3357 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698