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

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

Issue 22852024: Track JS allocations as they arrive with no affection on performance when tracking is switched off (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Deoptimize code and generate optimized code when switching allocations tracking Created 7 years, 3 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 CHECK(map->IsHeapObject()); 63 CHECK(map->IsHeapObject());
64 #ifdef DEBUG 64 #ifdef DEBUG
65 CHECK(CcTest::heap()->Contains(map)); 65 CHECK(CcTest::heap()->Contains(map));
66 #endif 66 #endif
67 CHECK_EQ(CcTest::heap()->meta_map(), map->map()); 67 CHECK_EQ(CcTest::heap()->meta_map(), map->map());
68 CHECK_EQ(type, map->instance_type()); 68 CHECK_EQ(type, map->instance_type());
69 CHECK_EQ(instance_size, map->instance_size()); 69 CHECK_EQ(instance_size, map->instance_size());
70 } 70 }
71 71
72 72
73 TEST(HeapMaps) { 73 TEST_TRACK_ALLOCATIONS(HeapMaps) {
74 CcTest::InitializeVM(); 74 CcTest::InitializeVM();
75 Heap* heap = CcTest::heap(); 75 Heap* heap = CcTest::heap();
76 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); 76 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize);
77 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); 77 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
78 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); 78 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
79 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); 79 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel);
80 } 80 }
81 81
82 82
83 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { 83 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Code::ComputeFlags(Code::STUB), 140 Code::ComputeFlags(Code::STUB),
141 Handle<Code>())->ToObjectChecked(); 141 Handle<Code>())->ToObjectChecked();
142 CHECK(copy->IsCode()); 142 CHECK(copy->IsCode());
143 HeapObject* obj_copy = HeapObject::cast(copy); 143 HeapObject* obj_copy = HeapObject::cast(copy);
144 Object* not_right = isolate->FindCodeObject(obj_copy->address() + 144 Object* not_right = isolate->FindCodeObject(obj_copy->address() +
145 obj_copy->Size() / 2); 145 obj_copy->Size() / 2);
146 CHECK(not_right != code); 146 CHECK(not_right != code);
147 } 147 }
148 148
149 149
150 TEST(HeapObjects) { 150 TEST_TRACK_ALLOCATIONS(HeapObjects) {
151 CcTest::InitializeVM(); 151 CcTest::InitializeVM();
152 Isolate* isolate = CcTest::i_isolate(); 152 Isolate* isolate = CcTest::i_isolate();
153 Factory* factory = isolate->factory(); 153 Factory* factory = isolate->factory();
154 Heap* heap = isolate->heap(); 154 Heap* heap = isolate->heap();
155 155
156 HandleScope sc(isolate); 156 HandleScope sc(isolate);
157 Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked(); 157 Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked();
158 CHECK(value->IsHeapNumber()); 158 CHECK(value->IsHeapNumber());
159 CHECK(value->IsNumber()); 159 CHECK(value->IsNumber());
160 CHECK_EQ(1.000123, value->Number()); 160 CHECK_EQ(1.000123, value->Number());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 CheckSmi(isolate, 42, "42"); 225 CheckSmi(isolate, 42, "42");
226 CheckSmi(isolate, -42, "-42"); 226 CheckSmi(isolate, -42, "-42");
227 227
228 // Check ToString for Numbers 228 // Check ToString for Numbers
229 CheckNumber(isolate, 1.1, "1.1"); 229 CheckNumber(isolate, 1.1, "1.1");
230 230
231 CheckFindCodeObject(isolate); 231 CheckFindCodeObject(isolate);
232 } 232 }
233 233
234 234
235 TEST(Tagging) { 235 TEST_TRACK_ALLOCATIONS(Tagging) {
236 CcTest::InitializeVM(); 236 CcTest::InitializeVM();
237 int request = 24; 237 int request = 24;
238 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); 238 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request)));
239 CHECK(Smi::FromInt(42)->IsSmi()); 239 CHECK(Smi::FromInt(42)->IsSmi());
240 CHECK(Failure::RetryAfterGC(NEW_SPACE)->IsFailure()); 240 CHECK(Failure::RetryAfterGC(NEW_SPACE)->IsFailure());
241 CHECK_EQ(NEW_SPACE, 241 CHECK_EQ(NEW_SPACE,
242 Failure::RetryAfterGC(NEW_SPACE)->allocation_space()); 242 Failure::RetryAfterGC(NEW_SPACE)->allocation_space());
243 CHECK_EQ(OLD_POINTER_SPACE, 243 CHECK_EQ(OLD_POINTER_SPACE,
244 Failure::RetryAfterGC(OLD_POINTER_SPACE)->allocation_space()); 244 Failure::RetryAfterGC(OLD_POINTER_SPACE)->allocation_space());
245 CHECK(Failure::Exception()->IsFailure()); 245 CHECK(Failure::Exception()->IsFailure());
246 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); 246 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
247 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); 247 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
248 } 248 }
249 249
250 250
251 TEST(GarbageCollection) { 251 TEST_TRACK_ALLOCATIONS(GarbageCollection) {
252 CcTest::InitializeVM(); 252 CcTest::InitializeVM();
253 Isolate* isolate = CcTest::i_isolate(); 253 Isolate* isolate = CcTest::i_isolate();
254 Heap* heap = isolate->heap(); 254 Heap* heap = isolate->heap();
255 Factory* factory = isolate->factory(); 255 Factory* factory = isolate->factory();
256 256
257 HandleScope sc(isolate); 257 HandleScope sc(isolate);
258 // Check GC. 258 // Check GC.
259 heap->CollectGarbage(NEW_SPACE); 259 heap->CollectGarbage(NEW_SPACE);
260 260
261 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); 261 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 static void VerifyStringAllocation(Isolate* isolate, const char* string) { 318 static void VerifyStringAllocation(Isolate* isolate, const char* string) {
319 HandleScope scope(isolate); 319 HandleScope scope(isolate);
320 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string)); 320 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string));
321 CHECK_EQ(StrLength(string), s->length()); 321 CHECK_EQ(StrLength(string), s->length());
322 for (int index = 0; index < s->length(); index++) { 322 for (int index = 0; index < s->length(); index++) {
323 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); 323 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index));
324 } 324 }
325 } 325 }
326 326
327 327
328 TEST(String) { 328 TEST_TRACK_ALLOCATIONS(String) {
329 CcTest::InitializeVM(); 329 CcTest::InitializeVM();
330 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 330 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
331 331
332 VerifyStringAllocation(isolate, "a"); 332 VerifyStringAllocation(isolate, "a");
333 VerifyStringAllocation(isolate, "ab"); 333 VerifyStringAllocation(isolate, "ab");
334 VerifyStringAllocation(isolate, "abc"); 334 VerifyStringAllocation(isolate, "abc");
335 VerifyStringAllocation(isolate, "abcd"); 335 VerifyStringAllocation(isolate, "abcd");
336 VerifyStringAllocation(isolate, "fiskerdrengen er paa havet"); 336 VerifyStringAllocation(isolate, "fiskerdrengen er paa havet");
337 } 337 }
338 338
339 339
340 TEST(LocalHandles) { 340 TEST_TRACK_ALLOCATIONS(LocalHandles) {
341 CcTest::InitializeVM(); 341 CcTest::InitializeVM();
342 Isolate* isolate = CcTest::i_isolate(); 342 Isolate* isolate = CcTest::i_isolate();
343 Factory* factory = isolate->factory(); 343 Factory* factory = isolate->factory();
344 344
345 v8::HandleScope scope(CcTest::isolate()); 345 v8::HandleScope scope(CcTest::isolate());
346 const char* name = "Kasper the spunky"; 346 const char* name = "Kasper the spunky";
347 Handle<String> string = factory->NewStringFromAscii(CStrVector(name)); 347 Handle<String> string = factory->NewStringFromAscii(CStrVector(name));
348 CHECK_EQ(StrLength(name), string->length()); 348 CHECK_EQ(StrLength(name), string->length());
349 } 349 }
350 350
351 351
352 TEST(GlobalHandles) { 352 TEST_TRACK_ALLOCATIONS(GlobalHandles) {
353 CcTest::InitializeVM(); 353 CcTest::InitializeVM();
354 Isolate* isolate = CcTest::i_isolate(); 354 Isolate* isolate = CcTest::i_isolate();
355 Heap* heap = isolate->heap(); 355 Heap* heap = isolate->heap();
356 Factory* factory = isolate->factory(); 356 Factory* factory = isolate->factory();
357 GlobalHandles* global_handles = isolate->global_handles(); 357 GlobalHandles* global_handles = isolate->global_handles();
358 358
359 Handle<Object> h1; 359 Handle<Object> h1;
360 Handle<Object> h2; 360 Handle<Object> h2;
361 Handle<Object> h3; 361 Handle<Object> h3;
362 Handle<Object> h4; 362 Handle<Object> h4;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 static bool WeakPointerCleared = false; 394 static bool WeakPointerCleared = false;
395 395
396 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate, 396 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
397 v8::Persistent<v8::Value>* handle, 397 v8::Persistent<v8::Value>* handle,
398 void* id) { 398 void* id) {
399 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; 399 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
400 handle->Dispose(); 400 handle->Dispose();
401 } 401 }
402 402
403 403
404 TEST(WeakGlobalHandlesScavenge) { 404 TEST_TRACK_ALLOCATIONS(WeakGlobalHandlesScavenge) {
405 i::FLAG_stress_compaction = false; 405 i::FLAG_stress_compaction = false;
406 CcTest::InitializeVM(); 406 CcTest::InitializeVM();
407 Isolate* isolate = CcTest::i_isolate(); 407 Isolate* isolate = CcTest::i_isolate();
408 Heap* heap = isolate->heap(); 408 Heap* heap = isolate->heap();
409 Factory* factory = isolate->factory(); 409 Factory* factory = isolate->factory();
410 GlobalHandles* global_handles = isolate->global_handles(); 410 GlobalHandles* global_handles = isolate->global_handles();
411 411
412 WeakPointerCleared = false; 412 WeakPointerCleared = false;
413 413
414 Handle<Object> h1; 414 Handle<Object> h1;
(...skipping 21 matching lines...) Expand all
436 436
437 CHECK(!WeakPointerCleared); 437 CHECK(!WeakPointerCleared);
438 CHECK(!global_handles->IsNearDeath(h2.location())); 438 CHECK(!global_handles->IsNearDeath(h2.location()));
439 CHECK(!global_handles->IsNearDeath(h1.location())); 439 CHECK(!global_handles->IsNearDeath(h1.location()));
440 440
441 global_handles->Destroy(h1.location()); 441 global_handles->Destroy(h1.location());
442 global_handles->Destroy(h2.location()); 442 global_handles->Destroy(h2.location());
443 } 443 }
444 444
445 445
446 TEST(WeakGlobalHandlesMark) { 446 TEST_TRACK_ALLOCATIONS(WeakGlobalHandlesMark) {
447 CcTest::InitializeVM(); 447 CcTest::InitializeVM();
448 Isolate* isolate = CcTest::i_isolate(); 448 Isolate* isolate = CcTest::i_isolate();
449 Heap* heap = isolate->heap(); 449 Heap* heap = isolate->heap();
450 Factory* factory = isolate->factory(); 450 Factory* factory = isolate->factory();
451 GlobalHandles* global_handles = isolate->global_handles(); 451 GlobalHandles* global_handles = isolate->global_handles();
452 452
453 WeakPointerCleared = false; 453 WeakPointerCleared = false;
454 454
455 Handle<Object> h1; 455 Handle<Object> h1;
456 Handle<Object> h2; 456 Handle<Object> h2;
(...skipping 24 matching lines...) Expand all
481 481
482 CHECK((*h1)->IsString()); 482 CHECK((*h1)->IsString());
483 483
484 CHECK(WeakPointerCleared); 484 CHECK(WeakPointerCleared);
485 CHECK(!GlobalHandles::IsNearDeath(h1.location())); 485 CHECK(!GlobalHandles::IsNearDeath(h1.location()));
486 486
487 global_handles->Destroy(h1.location()); 487 global_handles->Destroy(h1.location());
488 } 488 }
489 489
490 490
491 TEST(DeleteWeakGlobalHandle) { 491 TEST_TRACK_ALLOCATIONS(DeleteWeakGlobalHandle) {
492 i::FLAG_stress_compaction = false; 492 i::FLAG_stress_compaction = false;
493 CcTest::InitializeVM(); 493 CcTest::InitializeVM();
494 Isolate* isolate = CcTest::i_isolate(); 494 Isolate* isolate = CcTest::i_isolate();
495 Heap* heap = isolate->heap(); 495 Heap* heap = isolate->heap();
496 Factory* factory = isolate->factory(); 496 Factory* factory = isolate->factory();
497 GlobalHandles* global_handles = isolate->global_handles(); 497 GlobalHandles* global_handles = isolate->global_handles();
498 498
499 WeakPointerCleared = false; 499 WeakPointerCleared = false;
500 500
501 Handle<Object> h; 501 Handle<Object> h;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 CHECK(a->IsInternalizedString()); 596 CHECK(a->IsInternalizedString());
597 Object* b; 597 Object* b;
598 MaybeObject* maybe_b = CcTest::heap()->InternalizeUtf8String(string); 598 MaybeObject* maybe_b = CcTest::heap()->InternalizeUtf8String(string);
599 if (!maybe_b->ToObject(&b)) continue; 599 if (!maybe_b->ToObject(&b)) continue;
600 CHECK_EQ(b, a); 600 CHECK_EQ(b, a);
601 CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string))); 601 CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string)));
602 } 602 }
603 } 603 }
604 604
605 605
606 TEST(StringTable) { 606 TEST_TRACK_ALLOCATIONS(StringTable) {
607 CcTest::InitializeVM(); 607 CcTest::InitializeVM();
608 608
609 CheckInternalizedStrings(not_so_random_string_table); 609 CheckInternalizedStrings(not_so_random_string_table);
610 CheckInternalizedStrings(not_so_random_string_table); 610 CheckInternalizedStrings(not_so_random_string_table);
611 } 611 }
612 612
613 613
614 TEST(FunctionAllocation) { 614 TEST_TRACK_ALLOCATIONS(FunctionAllocation) {
615 CcTest::InitializeVM(); 615 CcTest::InitializeVM();
616 Isolate* isolate = CcTest::i_isolate(); 616 Isolate* isolate = CcTest::i_isolate();
617 Factory* factory = isolate->factory(); 617 Factory* factory = isolate->factory();
618 618
619 v8::HandleScope sc(CcTest::isolate()); 619 v8::HandleScope sc(CcTest::isolate());
620 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 620 Handle<String> name = factory->InternalizeUtf8String("theFunction");
621 Handle<JSFunction> function = 621 Handle<JSFunction> function =
622 factory->NewFunction(name, factory->undefined_value()); 622 factory->NewFunction(name, factory->undefined_value());
623 Handle<Map> initial_map = 623 Handle<Map> initial_map =
624 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 624 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
625 function->set_initial_map(*initial_map); 625 function->set_initial_map(*initial_map);
626 626
627 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 627 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
628 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); 628 Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
629 629
630 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 630 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
631 Handle<JSObject> obj = factory->NewJSObject(function); 631 Handle<JSObject> obj = factory->NewJSObject(function);
632 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); 632 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
633 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); 633 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
634 // Check that we can add properties to function objects. 634 // Check that we can add properties to function objects.
635 JSReceiver::SetProperty(function, prop_name, twenty_four, NONE, 635 JSReceiver::SetProperty(function, prop_name, twenty_four, NONE,
636 kNonStrictMode); 636 kNonStrictMode);
637 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); 637 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name));
638 } 638 }
639 639
640 640
641 TEST(ObjectProperties) { 641 TEST_TRACK_ALLOCATIONS(ObjectProperties) {
642 CcTest::InitializeVM(); 642 CcTest::InitializeVM();
643 Isolate* isolate = CcTest::i_isolate(); 643 Isolate* isolate = CcTest::i_isolate();
644 Factory* factory = isolate->factory(); 644 Factory* factory = isolate->factory();
645 645
646 v8::HandleScope sc(CcTest::isolate()); 646 v8::HandleScope sc(CcTest::isolate());
647 String* object_string = String::cast(CcTest::heap()->Object_string()); 647 String* object_string = String::cast(CcTest::heap()->Object_string());
648 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> 648 Object* raw_object = CcTest::i_isolate()->context()->global_object()->
649 GetProperty(object_string)->ToObjectChecked(); 649 GetProperty(object_string)->ToObjectChecked();
650 JSFunction* object_function = JSFunction::cast(raw_object); 650 JSFunction* object_function = JSFunction::cast(raw_object);
651 Handle<JSFunction> constructor(object_function); 651 Handle<JSFunction> constructor(object_function);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 702
703 // check internalized string and string match 703 // check internalized string and string match
704 const char* string2 = "fugl"; 704 const char* string2 = "fugl";
705 Handle<String> s2_string = factory->InternalizeUtf8String(string2); 705 Handle<String> s2_string = factory->InternalizeUtf8String(string2);
706 JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode); 706 JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode);
707 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); 707 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
708 CHECK(JSReceiver::HasLocalProperty(obj, s2)); 708 CHECK(JSReceiver::HasLocalProperty(obj, s2));
709 } 709 }
710 710
711 711
712 TEST(JSObjectMaps) { 712 TEST_TRACK_ALLOCATIONS(JSObjectMaps) {
713 CcTest::InitializeVM(); 713 CcTest::InitializeVM();
714 Isolate* isolate = CcTest::i_isolate(); 714 Isolate* isolate = CcTest::i_isolate();
715 Factory* factory = isolate->factory(); 715 Factory* factory = isolate->factory();
716 716
717 v8::HandleScope sc(CcTest::isolate()); 717 v8::HandleScope sc(CcTest::isolate());
718 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 718 Handle<String> name = factory->InternalizeUtf8String("theFunction");
719 Handle<JSFunction> function = 719 Handle<JSFunction> function =
720 factory->NewFunction(name, factory->undefined_value()); 720 factory->NewFunction(name, factory->undefined_value());
721 Handle<Map> initial_map = 721 Handle<Map> initial_map =
722 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 722 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
723 function->set_initial_map(*initial_map); 723 function->set_initial_map(*initial_map);
724 724
725 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 725 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
726 Handle<JSObject> obj = factory->NewJSObject(function); 726 Handle<JSObject> obj = factory->NewJSObject(function);
727 727
728 // Set a propery 728 // Set a propery
729 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 729 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
730 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); 730 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
731 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); 731 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
732 732
733 // Check the map has changed 733 // Check the map has changed
734 CHECK(*initial_map != obj->map()); 734 CHECK(*initial_map != obj->map());
735 } 735 }
736 736
737 737
738 TEST(JSArray) { 738 TEST_TRACK_ALLOCATIONS(JSArray) {
739 CcTest::InitializeVM(); 739 CcTest::InitializeVM();
740 Isolate* isolate = CcTest::i_isolate(); 740 Isolate* isolate = CcTest::i_isolate();
741 Factory* factory = isolate->factory(); 741 Factory* factory = isolate->factory();
742 742
743 v8::HandleScope sc(CcTest::isolate()); 743 v8::HandleScope sc(CcTest::isolate());
744 Handle<String> name = factory->InternalizeUtf8String("Array"); 744 Handle<String> name = factory->InternalizeUtf8String("Array");
745 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> 745 Object* raw_object = CcTest::i_isolate()->context()->global_object()->
746 GetProperty(*name)->ToObjectChecked(); 746 GetProperty(*name)->ToObjectChecked();
747 Handle<JSFunction> function = Handle<JSFunction>( 747 Handle<JSFunction> function = Handle<JSFunction>(
748 JSFunction::cast(raw_object)); 748 JSFunction::cast(raw_object));
(...skipping 28 matching lines...) Expand all
777 // array[length] = name. 777 // array[length] = name.
778 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked(); 778 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked();
779 uint32_t new_int_length = 0; 779 uint32_t new_int_length = 0;
780 CHECK(array->length()->ToArrayIndex(&new_int_length)); 780 CHECK(array->length()->ToArrayIndex(&new_int_length));
781 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 781 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
782 CHECK_EQ(array->GetElement(isolate, int_length), *name); 782 CHECK_EQ(array->GetElement(isolate, int_length), *name);
783 CHECK_EQ(array->GetElement(isolate, 0), *name); 783 CHECK_EQ(array->GetElement(isolate, 0), *name);
784 } 784 }
785 785
786 786
787 TEST(JSObjectCopy) { 787 TEST_TRACK_ALLOCATIONS(JSObjectCopy) {
788 CcTest::InitializeVM(); 788 CcTest::InitializeVM();
789 Isolate* isolate = CcTest::i_isolate(); 789 Isolate* isolate = CcTest::i_isolate();
790 Factory* factory = isolate->factory(); 790 Factory* factory = isolate->factory();
791 791
792 v8::HandleScope sc(CcTest::isolate()); 792 v8::HandleScope sc(CcTest::isolate());
793 String* object_string = String::cast(CcTest::heap()->Object_string()); 793 String* object_string = String::cast(CcTest::heap()->Object_string());
794 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> 794 Object* raw_object = CcTest::i_isolate()->context()->global_object()->
795 GetProperty(object_string)->ToObjectChecked(); 795 GetProperty(object_string)->ToObjectChecked();
796 JSFunction* object_function = JSFunction::cast(raw_object); 796 JSFunction* object_function = JSFunction::cast(raw_object);
797 Handle<JSFunction> constructor(object_function); 797 Handle<JSFunction> constructor(object_function);
(...skipping 28 matching lines...) Expand all
826 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); 826 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
827 827
828 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); 828 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0));
829 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); 829 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1));
830 830
831 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); 831 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
832 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); 832 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
833 } 833 }
834 834
835 835
836 TEST(StringAllocation) { 836 TEST_TRACK_ALLOCATIONS(StringAllocation) {
837 CcTest::InitializeVM(); 837 CcTest::InitializeVM();
838 Isolate* isolate = CcTest::i_isolate(); 838 Isolate* isolate = CcTest::i_isolate();
839 Factory* factory = isolate->factory(); 839 Factory* factory = isolate->factory();
840 840
841 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; 841 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
842 for (int length = 0; length < 100; length++) { 842 for (int length = 0; length < 100; length++) {
843 v8::HandleScope scope(CcTest::isolate()); 843 v8::HandleScope scope(CcTest::isolate());
844 char* non_ascii = NewArray<char>(3 * length + 1); 844 char* non_ascii = NewArray<char>(3 * length + 1);
845 char* ascii = NewArray<char>(length + 1); 845 char* ascii = NewArray<char>(length + 1);
846 non_ascii[3 * length] = 0; 846 non_ascii[3 * length] = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 for (int i = 0; i < size; i++) { 881 for (int i = 0; i < size; i++) {
882 if (*objs[i] == obj) { 882 if (*objs[i] == obj) {
883 found_count++; 883 found_count++;
884 } 884 }
885 } 885 }
886 } 886 }
887 return found_count; 887 return found_count;
888 } 888 }
889 889
890 890
891 TEST(Iteration) { 891 TEST_TRACK_ALLOCATIONS(Iteration) {
892 CcTest::InitializeVM(); 892 CcTest::InitializeVM();
893 Isolate* isolate = CcTest::i_isolate(); 893 Isolate* isolate = CcTest::i_isolate();
894 Factory* factory = isolate->factory(); 894 Factory* factory = isolate->factory();
895 v8::HandleScope scope(CcTest::isolate()); 895 v8::HandleScope scope(CcTest::isolate());
896 896
897 // Array of objects to scan haep for. 897 // Array of objects to scan haep for.
898 const int objs_count = 6; 898 const int objs_count = 6;
899 Handle<Object> objs[objs_count]; 899 Handle<Object> objs[objs_count];
900 int next_objs_index = 0; 900 int next_objs_index = 0;
901 901
(...skipping 19 matching lines...) Expand all
921 delete[] str; 921 delete[] str;
922 922
923 // Add a Map object to look for. 923 // Add a Map object to look for.
924 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); 924 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map());
925 925
926 CHECK_EQ(objs_count, next_objs_index); 926 CHECK_EQ(objs_count, next_objs_index);
927 CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count)); 927 CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count));
928 } 928 }
929 929
930 930
931 TEST(EmptyHandleEscapeFrom) { 931 TEST_TRACK_ALLOCATIONS(EmptyHandleEscapeFrom) {
932 CcTest::InitializeVM(); 932 CcTest::InitializeVM();
933 933
934 v8::HandleScope scope(CcTest::isolate()); 934 v8::HandleScope scope(CcTest::isolate());
935 Handle<JSObject> runaway; 935 Handle<JSObject> runaway;
936 936
937 { 937 {
938 v8::HandleScope nested(CcTest::isolate()); 938 v8::HandleScope nested(CcTest::isolate());
939 Handle<JSObject> empty; 939 Handle<JSObject> empty;
940 runaway = empty.EscapeFrom(&nested); 940 runaway = empty.EscapeFrom(&nested);
941 } 941 }
942 942
943 CHECK(runaway.is_null()); 943 CHECK(runaway.is_null());
944 } 944 }
945 945
946 946
947 static int LenFromSize(int size) { 947 static int LenFromSize(int size) {
948 return (size - FixedArray::kHeaderSize) / kPointerSize; 948 return (size - FixedArray::kHeaderSize) / kPointerSize;
949 } 949 }
950 950
951 951
952 TEST(Regression39128) { 952 TEST_TRACK_ALLOCATIONS(Regression39128) {
953 // Test case for crbug.com/39128. 953 // Test case for crbug.com/39128.
954 CcTest::InitializeVM(); 954 CcTest::InitializeVM();
955 Isolate* isolate = CcTest::i_isolate(); 955 Isolate* isolate = CcTest::i_isolate();
956 Factory* factory = isolate->factory(); 956 Factory* factory = isolate->factory();
957 Heap* heap = isolate->heap(); 957 Heap* heap = isolate->heap();
958 958
959 // Increase the chance of 'bump-the-pointer' allocation in old space. 959 // Increase the chance of 'bump-the-pointer' allocation in old space.
960 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 960 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
961 961
962 v8::HandleScope scope(CcTest::isolate()); 962 v8::HandleScope scope(CcTest::isolate());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 Object* clone_obj = heap->CopyJSObject(jsobject)->ToObjectChecked(); 1020 Object* clone_obj = heap->CopyJSObject(jsobject)->ToObjectChecked();
1021 JSObject* clone = JSObject::cast(clone_obj); 1021 JSObject* clone = JSObject::cast(clone_obj);
1022 if (clone->address() != old_pointer_space_top) { 1022 if (clone->address() != old_pointer_space_top) {
1023 // Alas, got allocated from free list, we cannot do checks. 1023 // Alas, got allocated from free list, we cannot do checks.
1024 return; 1024 return;
1025 } 1025 }
1026 CHECK(heap->old_pointer_space()->Contains(clone->address())); 1026 CHECK(heap->old_pointer_space()->Contains(clone->address()));
1027 } 1027 }
1028 1028
1029 1029
1030 TEST(TestCodeFlushing) { 1030 TEST_TRACK_ALLOCATIONS(TestCodeFlushing) {
1031 // If we do not flush code this test is invalid. 1031 // If we do not flush code this test is invalid.
1032 if (!FLAG_flush_code) return; 1032 if (!FLAG_flush_code) return;
1033 i::FLAG_allow_natives_syntax = true; 1033 i::FLAG_allow_natives_syntax = true;
1034 CcTest::InitializeVM(); 1034 CcTest::InitializeVM();
1035 Isolate* isolate = CcTest::i_isolate(); 1035 Isolate* isolate = CcTest::i_isolate();
1036 Factory* factory = isolate->factory(); 1036 Factory* factory = isolate->factory();
1037 v8::HandleScope scope(CcTest::isolate()); 1037 v8::HandleScope scope(CcTest::isolate());
1038 const char* source = "function foo() {" 1038 const char* source = "function foo() {"
1039 " var x = 42;" 1039 " var x = 42;"
1040 " var y = 42;" 1040 " var y = 42;"
(...skipping 28 matching lines...) Expand all
1069 // foo should no longer be in the compilation cache 1069 // foo should no longer be in the compilation cache
1070 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1070 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1071 CHECK(!function->is_compiled() || function->IsOptimized()); 1071 CHECK(!function->is_compiled() || function->IsOptimized());
1072 // Call foo to get it recompiled. 1072 // Call foo to get it recompiled.
1073 CompileRun("foo()"); 1073 CompileRun("foo()");
1074 CHECK(function->shared()->is_compiled()); 1074 CHECK(function->shared()->is_compiled());
1075 CHECK(function->is_compiled()); 1075 CHECK(function->is_compiled());
1076 } 1076 }
1077 1077
1078 1078
1079 TEST(TestCodeFlushingIncremental) { 1079 TEST_TRACK_ALLOCATIONS(TestCodeFlushingIncremental) {
1080 // If we do not flush code this test is invalid. 1080 // If we do not flush code this test is invalid.
1081 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1081 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1082 i::FLAG_allow_natives_syntax = true; 1082 i::FLAG_allow_natives_syntax = true;
1083 CcTest::InitializeVM(); 1083 CcTest::InitializeVM();
1084 Isolate* isolate = CcTest::i_isolate(); 1084 Isolate* isolate = CcTest::i_isolate();
1085 Factory* factory = isolate->factory(); 1085 Factory* factory = isolate->factory();
1086 v8::HandleScope scope(CcTest::isolate()); 1086 v8::HandleScope scope(CcTest::isolate());
1087 const char* source = "function foo() {" 1087 const char* source = "function foo() {"
1088 " var x = 42;" 1088 " var x = 42;"
1089 " var y = 42;" 1089 " var y = 42;"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); 1137 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
1138 } 1138 }
1139 1139
1140 // Simulate one final GC to make sure the candidate queue is sane. 1140 // Simulate one final GC to make sure the candidate queue is sane.
1141 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1141 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1142 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); 1142 CHECK(function->shared()->is_compiled() || !function->IsOptimized());
1143 CHECK(function->is_compiled() || !function->IsOptimized()); 1143 CHECK(function->is_compiled() || !function->IsOptimized());
1144 } 1144 }
1145 1145
1146 1146
1147 TEST(TestCodeFlushingIncrementalScavenge) { 1147 TEST_TRACK_ALLOCATIONS(TestCodeFlushingIncrementalScavenge) {
1148 // If we do not flush code this test is invalid. 1148 // If we do not flush code this test is invalid.
1149 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1149 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1150 i::FLAG_allow_natives_syntax = true; 1150 i::FLAG_allow_natives_syntax = true;
1151 CcTest::InitializeVM(); 1151 CcTest::InitializeVM();
1152 Isolate* isolate = CcTest::i_isolate(); 1152 Isolate* isolate = CcTest::i_isolate();
1153 Factory* factory = isolate->factory(); 1153 Factory* factory = isolate->factory();
1154 v8::HandleScope scope(CcTest::isolate()); 1154 v8::HandleScope scope(CcTest::isolate());
1155 const char* source = "var foo = function() {" 1155 const char* source = "var foo = function() {"
1156 " var x = 42;" 1156 " var x = 42;"
1157 " var y = 42;" 1157 " var y = 42;"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 *function2.location() = NULL; 1205 *function2.location() = NULL;
1206 CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking"); 1206 CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking");
1207 1207
1208 // Simulate one final GC to make sure the candidate queue is sane. 1208 // Simulate one final GC to make sure the candidate queue is sane.
1209 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1209 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1210 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1210 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1211 CHECK(!function->is_compiled() || function->IsOptimized()); 1211 CHECK(!function->is_compiled() || function->IsOptimized());
1212 } 1212 }
1213 1213
1214 1214
1215 TEST(TestCodeFlushingIncrementalAbort) { 1215 TEST_TRACK_ALLOCATIONS(TestCodeFlushingIncrementalAbort) {
1216 // If we do not flush code this test is invalid. 1216 // If we do not flush code this test is invalid.
1217 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1217 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1218 i::FLAG_allow_natives_syntax = true; 1218 i::FLAG_allow_natives_syntax = true;
1219 CcTest::InitializeVM(); 1219 CcTest::InitializeVM();
1220 Isolate* isolate = CcTest::i_isolate(); 1220 Isolate* isolate = CcTest::i_isolate();
1221 Factory* factory = isolate->factory(); 1221 Factory* factory = isolate->factory();
1222 Heap* heap = isolate->heap(); 1222 Heap* heap = isolate->heap();
1223 v8::HandleScope scope(CcTest::isolate()); 1223 v8::HandleScope scope(CcTest::isolate());
1224 const char* source = "function foo() {" 1224 const char* source = "function foo() {"
1225 " var x = 42;" 1225 " var x = 42;"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 Handle<Context> icontext = v8::Utils::OpenHandle(*context); 1297 Handle<Context> icontext = v8::Utils::OpenHandle(*context);
1298 Object* object = icontext->get(Context::OPTIMIZED_FUNCTIONS_LIST); 1298 Object* object = icontext->get(Context::OPTIMIZED_FUNCTIONS_LIST);
1299 while (object->IsJSFunction() && !JSFunction::cast(object)->IsBuiltin()) { 1299 while (object->IsJSFunction() && !JSFunction::cast(object)->IsBuiltin()) {
1300 count++; 1300 count++;
1301 object = JSFunction::cast(object)->next_function_link(); 1301 object = JSFunction::cast(object)->next_function_link();
1302 } 1302 }
1303 return count; 1303 return count;
1304 } 1304 }
1305 1305
1306 1306
1307 TEST(TestInternalWeakLists) { 1307 TEST_TRACK_ALLOCATIONS(TestInternalWeakLists) {
1308 v8::V8::Initialize(); 1308 v8::V8::Initialize();
1309 1309
1310 // Some flags turn Scavenge collections into Mark-sweep collections 1310 // Some flags turn Scavenge collections into Mark-sweep collections
1311 // and hence are incompatible with this test case. 1311 // and hence are incompatible with this test case.
1312 if (FLAG_gc_global || FLAG_stress_compaction) return; 1312 if (FLAG_gc_global || FLAG_stress_compaction) return;
1313 1313
1314 static const int kNumTestContexts = 10; 1314 static const int kNumTestContexts = 10;
1315 1315
1316 Isolate* isolate = CcTest::i_isolate(); 1316 Isolate* isolate = CcTest::i_isolate();
1317 Heap* heap = isolate->heap(); 1317 Heap* heap = isolate->heap();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 count++; 1447 count++;
1448 if (count == n) isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 1448 if (count == n) isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
1449 object = Handle<Object>( 1449 object = Handle<Object>(
1450 Object::cast(JSFunction::cast(*object)->next_function_link()), 1450 Object::cast(JSFunction::cast(*object)->next_function_link()),
1451 isolate); 1451 isolate);
1452 } 1452 }
1453 return count; 1453 return count;
1454 } 1454 }
1455 1455
1456 1456
1457 TEST(TestInternalWeakListsTraverseWithGC) { 1457 TEST_TRACK_ALLOCATIONS(TestInternalWeakListsTraverseWithGC) {
1458 v8::V8::Initialize(); 1458 v8::V8::Initialize();
1459 Isolate* isolate = CcTest::i_isolate(); 1459 Isolate* isolate = CcTest::i_isolate();
1460 1460
1461 static const int kNumTestContexts = 10; 1461 static const int kNumTestContexts = 10;
1462 1462
1463 HandleScope scope(isolate); 1463 HandleScope scope(isolate);
1464 v8::Handle<v8::Context> ctx[kNumTestContexts]; 1464 v8::Handle<v8::Context> ctx[kNumTestContexts];
1465 1465
1466 CHECK_EQ(0, CountNativeContexts()); 1466 CHECK_EQ(0, CountNativeContexts());
1467 1467
(...skipping 30 matching lines...) Expand all
1498 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[0])); 1498 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[0]));
1499 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 2)); 1499 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 2));
1500 CompileRun("f5()"); 1500 CompileRun("f5()");
1501 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[0])); 1501 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[0]));
1502 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 4)); 1502 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 4));
1503 1503
1504 ctx[0]->Exit(); 1504 ctx[0]->Exit();
1505 } 1505 }
1506 1506
1507 1507
1508 TEST(TestSizeOfObjects) { 1508 TEST_TRACK_ALLOCATIONS(TestSizeOfObjects) {
1509 v8::V8::Initialize(); 1509 v8::V8::Initialize();
1510 1510
1511 // Get initial heap size after several full GCs, which will stabilize 1511 // Get initial heap size after several full GCs, which will stabilize
1512 // the heap size and return with sweeping finished completely. 1512 // the heap size and return with sweeping finished completely.
1513 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1513 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1514 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1514 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1515 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1515 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1516 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1516 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1517 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1517 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1518 CHECK(CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()); 1518 CHECK(CcTest::heap()->old_pointer_space()->IsLazySweepingComplete());
(...skipping 20 matching lines...) Expand all
1539 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); 1539 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1540 1540
1541 // Advancing the sweeper step-wise should not change the heap size. 1541 // Advancing the sweeper step-wise should not change the heap size.
1542 while (!CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()) { 1542 while (!CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()) {
1543 CcTest::heap()->old_pointer_space()->AdvanceSweeper(KB); 1543 CcTest::heap()->old_pointer_space()->AdvanceSweeper(KB);
1544 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); 1544 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1545 } 1545 }
1546 } 1546 }
1547 1547
1548 1548
1549 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { 1549 TEST_TRACK_ALLOCATIONS(TestSizeOfObjectsVsHeapIteratorPrecision) {
1550 CcTest::InitializeVM(); 1550 CcTest::InitializeVM();
1551 CcTest::heap()->EnsureHeapIsIterable(); 1551 CcTest::heap()->EnsureHeapIsIterable();
1552 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); 1552 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects();
1553 HeapIterator iterator(CcTest::heap()); 1553 HeapIterator iterator(CcTest::heap());
1554 intptr_t size_of_objects_2 = 0; 1554 intptr_t size_of_objects_2 = 0;
1555 for (HeapObject* obj = iterator.next(); 1555 for (HeapObject* obj = iterator.next();
1556 obj != NULL; 1556 obj != NULL;
1557 obj = iterator.next()) { 1557 obj = iterator.next()) {
1558 if (!obj->IsFreeSpace()) { 1558 if (!obj->IsFreeSpace()) {
1559 size_of_objects_2 += obj->Size(); 1559 size_of_objects_2 += obj->Size();
(...skipping 30 matching lines...) Expand all
1590 HandleScope scope(isolate); 1590 HandleScope scope(isolate);
1591 AlwaysAllocateScope always_allocate; 1591 AlwaysAllocateScope always_allocate;
1592 intptr_t available = new_space->EffectiveCapacity() - new_space->Size(); 1592 intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
1593 intptr_t number_of_fillers = (available / FixedArray::SizeFor(32)) - 1; 1593 intptr_t number_of_fillers = (available / FixedArray::SizeFor(32)) - 1;
1594 for (intptr_t i = 0; i < number_of_fillers; i++) { 1594 for (intptr_t i = 0; i < number_of_fillers; i++) {
1595 CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED))); 1595 CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED)));
1596 } 1596 }
1597 } 1597 }
1598 1598
1599 1599
1600 TEST(GrowAndShrinkNewSpace) { 1600 TEST_TRACK_ALLOCATIONS(GrowAndShrinkNewSpace) {
1601 CcTest::InitializeVM(); 1601 CcTest::InitializeVM();
1602 Heap* heap = CcTest::heap(); 1602 Heap* heap = CcTest::heap();
1603 NewSpace* new_space = heap->new_space(); 1603 NewSpace* new_space = heap->new_space();
1604 1604
1605 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || 1605 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() ||
1606 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { 1606 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
1607 // The max size cannot exceed the reserved size, since semispaces must be 1607 // The max size cannot exceed the reserved size, since semispaces must be
1608 // always within the reserved space. We can't test new space growing and 1608 // always within the reserved space. We can't test new space growing and
1609 // shrinking if the reserved size is the same as the minimum (initial) size. 1609 // shrinking if the reserved size is the same as the minimum (initial) size.
1610 return; 1610 return;
(...skipping 30 matching lines...) Expand all
1641 // Consecutive shrinking should not affect space capacity. 1641 // Consecutive shrinking should not affect space capacity.
1642 old_capacity = new_space->Capacity(); 1642 old_capacity = new_space->Capacity();
1643 new_space->Shrink(); 1643 new_space->Shrink();
1644 new_space->Shrink(); 1644 new_space->Shrink();
1645 new_space->Shrink(); 1645 new_space->Shrink();
1646 new_capacity = new_space->Capacity(); 1646 new_capacity = new_space->Capacity();
1647 CHECK(old_capacity == new_capacity); 1647 CHECK(old_capacity == new_capacity);
1648 } 1648 }
1649 1649
1650 1650
1651 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { 1651 TEST_TRACK_ALLOCATIONS(CollectingAllAvailableGarbageShrinksNewSpace) {
1652 CcTest::InitializeVM(); 1652 CcTest::InitializeVM();
1653 Heap* heap = CcTest::heap(); 1653 Heap* heap = CcTest::heap();
1654 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || 1654 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() ||
1655 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { 1655 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
1656 // The max size cannot exceed the reserved size, since semispaces must be 1656 // The max size cannot exceed the reserved size, since semispaces must be
1657 // always within the reserved space. We can't test new space growing and 1657 // always within the reserved space. We can't test new space growing and
1658 // shrinking if the reserved size is the same as the minimum (initial) size. 1658 // shrinking if the reserved size is the same as the minimum (initial) size.
1659 return; 1659 return;
1660 } 1660 }
1661 1661
(...skipping 16 matching lines...) Expand all
1678 HeapIterator iterator(CcTest::heap()); 1678 HeapIterator iterator(CcTest::heap());
1679 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 1679 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
1680 if (obj->IsGlobalObject()) count++; 1680 if (obj->IsGlobalObject()) count++;
1681 } 1681 }
1682 return count; 1682 return count;
1683 } 1683 }
1684 1684
1685 1685
1686 // Test that we don't embed maps from foreign contexts into 1686 // Test that we don't embed maps from foreign contexts into
1687 // optimized code. 1687 // optimized code.
1688 TEST(LeakNativeContextViaMap) { 1688 TEST_TRACK_ALLOCATIONS(LeakNativeContextViaMap) {
1689 i::FLAG_allow_natives_syntax = true; 1689 i::FLAG_allow_natives_syntax = true;
1690 v8::Isolate* isolate = CcTest::isolate(); 1690 v8::Isolate* isolate = CcTest::isolate();
1691 v8::HandleScope outer_scope(isolate); 1691 v8::HandleScope outer_scope(isolate);
1692 v8::Persistent<v8::Context> ctx1p; 1692 v8::Persistent<v8::Context> ctx1p;
1693 v8::Persistent<v8::Context> ctx2p; 1693 v8::Persistent<v8::Context> ctx2p;
1694 { 1694 {
1695 v8::HandleScope scope(isolate); 1695 v8::HandleScope scope(isolate);
1696 ctx1p.Reset(isolate, v8::Context::New(isolate)); 1696 ctx1p.Reset(isolate, v8::Context::New(isolate));
1697 ctx2p.Reset(isolate, v8::Context::New(isolate)); 1697 ctx2p.Reset(isolate, v8::Context::New(isolate));
1698 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); 1698 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
(...skipping 25 matching lines...) Expand all
1724 CcTest::heap()->CollectAllAvailableGarbage(); 1724 CcTest::heap()->CollectAllAvailableGarbage();
1725 CHECK_EQ(2, NumberOfGlobalObjects()); 1725 CHECK_EQ(2, NumberOfGlobalObjects());
1726 ctx2p.Dispose(); 1726 ctx2p.Dispose();
1727 CcTest::heap()->CollectAllAvailableGarbage(); 1727 CcTest::heap()->CollectAllAvailableGarbage();
1728 CHECK_EQ(0, NumberOfGlobalObjects()); 1728 CHECK_EQ(0, NumberOfGlobalObjects());
1729 } 1729 }
1730 1730
1731 1731
1732 // Test that we don't embed functions from foreign contexts into 1732 // Test that we don't embed functions from foreign contexts into
1733 // optimized code. 1733 // optimized code.
1734 TEST(LeakNativeContextViaFunction) { 1734 TEST_TRACK_ALLOCATIONS(LeakNativeContextViaFunction) {
1735 i::FLAG_allow_natives_syntax = true; 1735 i::FLAG_allow_natives_syntax = true;
1736 v8::Isolate* isolate = CcTest::isolate(); 1736 v8::Isolate* isolate = CcTest::isolate();
1737 v8::HandleScope outer_scope(isolate); 1737 v8::HandleScope outer_scope(isolate);
1738 v8::Persistent<v8::Context> ctx1p; 1738 v8::Persistent<v8::Context> ctx1p;
1739 v8::Persistent<v8::Context> ctx2p; 1739 v8::Persistent<v8::Context> ctx2p;
1740 { 1740 {
1741 v8::HandleScope scope(isolate); 1741 v8::HandleScope scope(isolate);
1742 ctx1p.Reset(isolate, v8::Context::New(isolate)); 1742 ctx1p.Reset(isolate, v8::Context::New(isolate));
1743 ctx2p.Reset(isolate, v8::Context::New(isolate)); 1743 ctx2p.Reset(isolate, v8::Context::New(isolate));
1744 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); 1744 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
(...skipping 23 matching lines...) Expand all
1768 v8::V8::ContextDisposedNotification(); 1768 v8::V8::ContextDisposedNotification();
1769 } 1769 }
1770 CcTest::heap()->CollectAllAvailableGarbage(); 1770 CcTest::heap()->CollectAllAvailableGarbage();
1771 CHECK_EQ(2, NumberOfGlobalObjects()); 1771 CHECK_EQ(2, NumberOfGlobalObjects());
1772 ctx2p.Dispose(); 1772 ctx2p.Dispose();
1773 CcTest::heap()->CollectAllAvailableGarbage(); 1773 CcTest::heap()->CollectAllAvailableGarbage();
1774 CHECK_EQ(0, NumberOfGlobalObjects()); 1774 CHECK_EQ(0, NumberOfGlobalObjects());
1775 } 1775 }
1776 1776
1777 1777
1778 TEST(LeakNativeContextViaMapKeyed) { 1778 TEST_TRACK_ALLOCATIONS(LeakNativeContextViaMapKeyed) {
1779 i::FLAG_allow_natives_syntax = true; 1779 i::FLAG_allow_natives_syntax = true;
1780 v8::Isolate* isolate = CcTest::isolate(); 1780 v8::Isolate* isolate = CcTest::isolate();
1781 v8::HandleScope outer_scope(isolate); 1781 v8::HandleScope outer_scope(isolate);
1782 v8::Persistent<v8::Context> ctx1p; 1782 v8::Persistent<v8::Context> ctx1p;
1783 v8::Persistent<v8::Context> ctx2p; 1783 v8::Persistent<v8::Context> ctx2p;
1784 { 1784 {
1785 v8::HandleScope scope(isolate); 1785 v8::HandleScope scope(isolate);
1786 ctx1p.Reset(isolate, v8::Context::New(isolate)); 1786 ctx1p.Reset(isolate, v8::Context::New(isolate));
1787 ctx2p.Reset(isolate, v8::Context::New(isolate)); 1787 ctx2p.Reset(isolate, v8::Context::New(isolate));
1788 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); 1788 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
(...skipping 23 matching lines...) Expand all
1812 v8::V8::ContextDisposedNotification(); 1812 v8::V8::ContextDisposedNotification();
1813 } 1813 }
1814 CcTest::heap()->CollectAllAvailableGarbage(); 1814 CcTest::heap()->CollectAllAvailableGarbage();
1815 CHECK_EQ(2, NumberOfGlobalObjects()); 1815 CHECK_EQ(2, NumberOfGlobalObjects());
1816 ctx2p.Dispose(); 1816 ctx2p.Dispose();
1817 CcTest::heap()->CollectAllAvailableGarbage(); 1817 CcTest::heap()->CollectAllAvailableGarbage();
1818 CHECK_EQ(0, NumberOfGlobalObjects()); 1818 CHECK_EQ(0, NumberOfGlobalObjects());
1819 } 1819 }
1820 1820
1821 1821
1822 TEST(LeakNativeContextViaMapProto) { 1822 TEST_TRACK_ALLOCATIONS(LeakNativeContextViaMapProto) {
1823 i::FLAG_allow_natives_syntax = true; 1823 i::FLAG_allow_natives_syntax = true;
1824 v8::Isolate* isolate = CcTest::isolate(); 1824 v8::Isolate* isolate = CcTest::isolate();
1825 v8::HandleScope outer_scope(isolate); 1825 v8::HandleScope outer_scope(isolate);
1826 v8::Persistent<v8::Context> ctx1p; 1826 v8::Persistent<v8::Context> ctx1p;
1827 v8::Persistent<v8::Context> ctx2p; 1827 v8::Persistent<v8::Context> ctx2p;
1828 { 1828 {
1829 v8::HandleScope scope(isolate); 1829 v8::HandleScope scope(isolate);
1830 ctx1p.Reset(isolate, v8::Context::New(isolate)); 1830 ctx1p.Reset(isolate, v8::Context::New(isolate));
1831 ctx2p.Reset(isolate, v8::Context::New(isolate)); 1831 ctx2p.Reset(isolate, v8::Context::New(isolate));
1832 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); 1832 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
(...skipping 27 matching lines...) Expand all
1860 v8::V8::ContextDisposedNotification(); 1860 v8::V8::ContextDisposedNotification();
1861 } 1861 }
1862 CcTest::heap()->CollectAllAvailableGarbage(); 1862 CcTest::heap()->CollectAllAvailableGarbage();
1863 CHECK_EQ(2, NumberOfGlobalObjects()); 1863 CHECK_EQ(2, NumberOfGlobalObjects());
1864 ctx2p.Dispose(); 1864 ctx2p.Dispose();
1865 CcTest::heap()->CollectAllAvailableGarbage(); 1865 CcTest::heap()->CollectAllAvailableGarbage();
1866 CHECK_EQ(0, NumberOfGlobalObjects()); 1866 CHECK_EQ(0, NumberOfGlobalObjects());
1867 } 1867 }
1868 1868
1869 1869
1870 TEST(InstanceOfStubWriteBarrier) { 1870 TEST_TRACK_ALLOCATIONS(InstanceOfStubWriteBarrier) {
1871 i::FLAG_allow_natives_syntax = true; 1871 i::FLAG_allow_natives_syntax = true;
1872 #ifdef VERIFY_HEAP 1872 #ifdef VERIFY_HEAP
1873 i::FLAG_verify_heap = true; 1873 i::FLAG_verify_heap = true;
1874 #endif 1874 #endif
1875 1875
1876 CcTest::InitializeVM(); 1876 CcTest::InitializeVM();
1877 if (!CcTest::i_isolate()->use_crankshaft()) return; 1877 if (!CcTest::i_isolate()->use_crankshaft()) return;
1878 if (i::FLAG_force_marking_deque_overflows) return; 1878 if (i::FLAG_force_marking_deque_overflows) return;
1879 v8::HandleScope outer_scope(CcTest::isolate()); 1879 v8::HandleScope outer_scope(CcTest::isolate());
1880 1880
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 v8::Handle<v8::Function> g = 1916 v8::Handle<v8::Function> g =
1917 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 1917 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
1918 g->Call(global, 0, NULL); 1918 g->Call(global, 0, NULL);
1919 } 1919 }
1920 1920
1921 CcTest::heap()->incremental_marking()->set_should_hurry(true); 1921 CcTest::heap()->incremental_marking()->set_should_hurry(true);
1922 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 1922 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
1923 } 1923 }
1924 1924
1925 1925
1926 TEST(PrototypeTransitionClearing) { 1926 TEST_TRACK_ALLOCATIONS(PrototypeTransitionClearing) {
1927 CcTest::InitializeVM(); 1927 CcTest::InitializeVM();
1928 Isolate* isolate = CcTest::i_isolate(); 1928 Isolate* isolate = CcTest::i_isolate();
1929 Factory* factory = isolate->factory(); 1929 Factory* factory = isolate->factory();
1930 v8::HandleScope scope(CcTest::isolate()); 1930 v8::HandleScope scope(CcTest::isolate());
1931 1931
1932 CompileRun( 1932 CompileRun(
1933 "var base = {};" 1933 "var base = {};"
1934 "var live = [];" 1934 "var live = [];"
1935 "for (var i = 0; i < 10; i++) {" 1935 "for (var i = 0; i < 10; i++) {"
1936 " var object = {};" 1936 " var object = {};"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 CHECK(!space->LastPage()->Contains( 1976 CHECK(!space->LastPage()->Contains(
1977 map->GetPrototypeTransitions()->address())); 1977 map->GetPrototypeTransitions()->address()));
1978 CHECK(space->LastPage()->Contains(prototype->address())); 1978 CHECK(space->LastPage()->Contains(prototype->address()));
1979 JSObject::SetPrototype(baseObject, prototype, false); 1979 JSObject::SetPrototype(baseObject, prototype, false);
1980 CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap()); 1980 CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
1981 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1981 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1982 CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap()); 1982 CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
1983 } 1983 }
1984 1984
1985 1985
1986 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { 1986 TEST_TRACK_ALLOCATIONS(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1987 i::FLAG_stress_compaction = false; 1987 i::FLAG_stress_compaction = false;
1988 i::FLAG_allow_natives_syntax = true; 1988 i::FLAG_allow_natives_syntax = true;
1989 #ifdef VERIFY_HEAP 1989 #ifdef VERIFY_HEAP
1990 i::FLAG_verify_heap = true; 1990 i::FLAG_verify_heap = true;
1991 #endif 1991 #endif
1992 1992
1993 CcTest::InitializeVM(); 1993 CcTest::InitializeVM();
1994 if (!CcTest::i_isolate()->use_crankshaft()) return; 1994 if (!CcTest::i_isolate()->use_crankshaft()) return;
1995 v8::HandleScope outer_scope(CcTest::isolate()); 1995 v8::HandleScope outer_scope(CcTest::isolate());
1996 1996
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags, 2033 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags,
2034 "Test finalizing incremental mark-sweep"); 2034 "Test finalizing incremental mark-sweep");
2035 } 2035 }
2036 2036
2037 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2037 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2038 CHECK_EQ(0, f->shared()->opt_count()); 2038 CHECK_EQ(0, f->shared()->opt_count());
2039 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2039 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2040 } 2040 }
2041 2041
2042 2042
2043 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { 2043 TEST_TRACK_ALLOCATIONS(ResetSharedFunctionInfoCountersDuringMarkSweep) {
2044 i::FLAG_stress_compaction = false; 2044 i::FLAG_stress_compaction = false;
2045 i::FLAG_allow_natives_syntax = true; 2045 i::FLAG_allow_natives_syntax = true;
2046 #ifdef VERIFY_HEAP 2046 #ifdef VERIFY_HEAP
2047 i::FLAG_verify_heap = true; 2047 i::FLAG_verify_heap = true;
2048 #endif 2048 #endif
2049 2049
2050 CcTest::InitializeVM(); 2050 CcTest::InitializeVM();
2051 if (!CcTest::i_isolate()->use_crankshaft()) return; 2051 if (!CcTest::i_isolate()->use_crankshaft()) return;
2052 v8::HandleScope outer_scope(CcTest::isolate()); 2052 v8::HandleScope outer_scope(CcTest::isolate());
2053 2053
(...skipping 23 matching lines...) Expand all
2077 v8::V8::ContextDisposedNotification(); 2077 v8::V8::ContextDisposedNotification();
2078 v8::V8::IdleNotification(kLongIdlePauseInMs); 2078 v8::V8::IdleNotification(kLongIdlePauseInMs);
2079 2079
2080 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2080 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2081 CHECK_EQ(0, f->shared()->opt_count()); 2081 CHECK_EQ(0, f->shared()->opt_count());
2082 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2082 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2083 } 2083 }
2084 2084
2085 2085
2086 // Test that HAllocateObject will always return an object in new-space. 2086 // Test that HAllocateObject will always return an object in new-space.
2087 TEST(OptimizedAllocationAlwaysInNewSpace) { 2087 TEST_TRACK_ALLOCATIONS(OptimizedAllocationAlwaysInNewSpace) {
2088 i::FLAG_allow_natives_syntax = true; 2088 i::FLAG_allow_natives_syntax = true;
2089 CcTest::InitializeVM(); 2089 CcTest::InitializeVM();
2090 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2090 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2091 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2091 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2092 v8::HandleScope scope(CcTest::isolate()); 2092 v8::HandleScope scope(CcTest::isolate());
2093 2093
2094 SimulateFullSpace(CcTest::heap()->new_space()); 2094 SimulateFullSpace(CcTest::heap()->new_space());
2095 AlwaysAllocateScope always_allocate; 2095 AlwaysAllocateScope always_allocate;
2096 v8::Local<v8::Value> res = CompileRun( 2096 v8::Local<v8::Value> res = CompileRun(
2097 "function c(x) {" 2097 "function c(x) {"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2178
2179 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); 2179 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
2180 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); 2180 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
2181 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); 2181 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
2182 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3))); 2182 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3)));
2183 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4))); 2183 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4)));
2184 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5))); 2184 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5)));
2185 } 2185 }
2186 2186
2187 2187
2188 TEST(OptimizedPretenuringObjectArrayLiterals) { 2188 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringObjectArrayLiterals) {
2189 i::FLAG_allow_natives_syntax = true; 2189 i::FLAG_allow_natives_syntax = true;
2190 CcTest::InitializeVM(); 2190 CcTest::InitializeVM();
2191 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2191 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2192 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2192 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2193 v8::HandleScope scope(CcTest::isolate()); 2193 v8::HandleScope scope(CcTest::isolate());
2194 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2194 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2195 2195
2196 v8::Local<v8::Value> res = CompileRun( 2196 v8::Local<v8::Value> res = CompileRun(
2197 "function f() {" 2197 "function f() {"
2198 " var numbers = [{}, {}, {}];" 2198 " var numbers = [{}, {}, {}];"
2199 " return numbers;" 2199 " return numbers;"
2200 "};" 2200 "};"
2201 "f(); f(); f();" 2201 "f(); f(); f();"
2202 "%OptimizeFunctionOnNextCall(f);" 2202 "%OptimizeFunctionOnNextCall(f);"
2203 "f();"); 2203 "f();");
2204 2204
2205 Handle<JSObject> o = 2205 Handle<JSObject> o =
2206 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2206 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2207 2207
2208 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); 2208 CHECK(CcTest::heap()->InOldPointerSpace(o->elements()));
2209 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2209 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2210 } 2210 }
2211 2211
2212 2212
2213 TEST(OptimizedPretenuringMixedInObjectProperties) { 2213 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringMixedInObjectProperties) {
2214 i::FLAG_allow_natives_syntax = true; 2214 i::FLAG_allow_natives_syntax = true;
2215 CcTest::InitializeVM(); 2215 CcTest::InitializeVM();
2216 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2216 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2217 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2217 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2218 v8::HandleScope scope(CcTest::isolate()); 2218 v8::HandleScope scope(CcTest::isolate());
2219 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2219 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2220 2220
2221 v8::Local<v8::Value> res = CompileRun( 2221 v8::Local<v8::Value> res = CompileRun(
2222 "function f() {" 2222 "function f() {"
2223 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" 2223 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};"
(...skipping 10 matching lines...) Expand all
2234 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); 2234 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
2235 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); 2235 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1)));
2236 2236
2237 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); 2237 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
2238 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); 2238 CHECK(CcTest::heap()->InOldPointerSpace(inner_object));
2239 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); 2239 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
2240 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); 2240 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
2241 } 2241 }
2242 2242
2243 2243
2244 TEST(OptimizedPretenuringDoubleArrayProperties) { 2244 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringDoubleArrayProperties) {
2245 i::FLAG_allow_natives_syntax = true; 2245 i::FLAG_allow_natives_syntax = true;
2246 CcTest::InitializeVM(); 2246 CcTest::InitializeVM();
2247 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2247 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2248 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2248 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2249 v8::HandleScope scope(CcTest::isolate()); 2249 v8::HandleScope scope(CcTest::isolate());
2250 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2250 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2251 2251
2252 v8::Local<v8::Value> res = CompileRun( 2252 v8::Local<v8::Value> res = CompileRun(
2253 "function f() {" 2253 "function f() {"
2254 " var numbers = {a: 1.1, b: 2.2};" 2254 " var numbers = {a: 1.1, b: 2.2};"
2255 " return numbers;" 2255 " return numbers;"
2256 "};" 2256 "};"
2257 "f(); f(); f();" 2257 "f(); f(); f();"
2258 "%OptimizeFunctionOnNextCall(f);" 2258 "%OptimizeFunctionOnNextCall(f);"
2259 "f();"); 2259 "f();");
2260 2260
2261 Handle<JSObject> o = 2261 Handle<JSObject> o =
2262 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2262 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2263 2263
2264 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2264 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2265 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); 2265 CHECK(CcTest::heap()->InOldDataSpace(o->properties()));
2266 } 2266 }
2267 2267
2268 2268
2269 TEST(OptimizedPretenuringdoubleArrayLiterals) { 2269 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringdoubleArrayLiterals) {
2270 i::FLAG_allow_natives_syntax = true; 2270 i::FLAG_allow_natives_syntax = true;
2271 CcTest::InitializeVM(); 2271 CcTest::InitializeVM();
2272 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2272 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2273 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2273 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2274 v8::HandleScope scope(CcTest::isolate()); 2274 v8::HandleScope scope(CcTest::isolate());
2275 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2275 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2276 2276
2277 v8::Local<v8::Value> res = CompileRun( 2277 v8::Local<v8::Value> res = CompileRun(
2278 "function f() {" 2278 "function f() {"
2279 " var numbers = [1.1, 2.2, 3.3];" 2279 " var numbers = [1.1, 2.2, 3.3];"
2280 " return numbers;" 2280 " return numbers;"
2281 "};" 2281 "};"
2282 "f(); f(); f();" 2282 "f(); f(); f();"
2283 "%OptimizeFunctionOnNextCall(f);" 2283 "%OptimizeFunctionOnNextCall(f);"
2284 "f();"); 2284 "f();");
2285 2285
2286 Handle<JSObject> o = 2286 Handle<JSObject> o =
2287 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2287 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2288 2288
2289 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); 2289 CHECK(CcTest::heap()->InOldDataSpace(o->elements()));
2290 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2290 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2291 } 2291 }
2292 2292
2293 2293
2294 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { 2294 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringNestedMixedArrayLiterals) {
2295 i::FLAG_allow_natives_syntax = true; 2295 i::FLAG_allow_natives_syntax = true;
2296 CcTest::InitializeVM(); 2296 CcTest::InitializeVM();
2297 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2297 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2298 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2298 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2299 v8::HandleScope scope(CcTest::isolate()); 2299 v8::HandleScope scope(CcTest::isolate());
2300 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2300 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2301 2301
2302 v8::Local<v8::Value> res = CompileRun( 2302 v8::Local<v8::Value> res = CompileRun(
2303 "function f() {" 2303 "function f() {"
2304 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" 2304 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];"
(...skipping 13 matching lines...) Expand all
2318 Handle<JSObject> o = 2318 Handle<JSObject> o =
2319 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2319 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2320 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2320 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2321 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); 2321 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle));
2322 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); 2322 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements()));
2323 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); 2323 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle));
2324 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); 2324 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements()));
2325 } 2325 }
2326 2326
2327 2327
2328 TEST(OptimizedPretenuringNestedObjectLiterals) { 2328 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringNestedObjectLiterals) {
2329 i::FLAG_allow_natives_syntax = true; 2329 i::FLAG_allow_natives_syntax = true;
2330 CcTest::InitializeVM(); 2330 CcTest::InitializeVM();
2331 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2331 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2332 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2332 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2333 v8::HandleScope scope(CcTest::isolate()); 2333 v8::HandleScope scope(CcTest::isolate());
2334 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2334 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2335 2335
2336 v8::Local<v8::Value> res = CompileRun( 2336 v8::Local<v8::Value> res = CompileRun(
2337 "function f() {" 2337 "function f() {"
2338 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" 2338 " var numbers = [[{}, {}, {}],[{}, {}, {}]];"
(...skipping 13 matching lines...) Expand all
2352 Handle<JSObject> o = 2352 Handle<JSObject> o =
2353 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2353 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2354 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2354 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2355 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); 2355 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1));
2356 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); 2356 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements()));
2357 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); 2357 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2));
2358 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); 2358 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements()));
2359 } 2359 }
2360 2360
2361 2361
2362 TEST(OptimizedPretenuringNestedDoubleLiterals) { 2362 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringNestedDoubleLiterals) {
2363 i::FLAG_allow_natives_syntax = true; 2363 i::FLAG_allow_natives_syntax = true;
2364 CcTest::InitializeVM(); 2364 CcTest::InitializeVM();
2365 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2365 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2366 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2366 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2367 v8::HandleScope scope(CcTest::isolate()); 2367 v8::HandleScope scope(CcTest::isolate());
2368 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2368 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2369 2369
2370 v8::Local<v8::Value> res = CompileRun( 2370 v8::Local<v8::Value> res = CompileRun(
2371 "function f() {" 2371 "function f() {"
2372 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" 2372 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];"
(...skipping 16 matching lines...) Expand all
2389 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2389 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2390 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2390 CHECK(CcTest::heap()->InOldPointerSpace(*o));
2391 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1)); 2391 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1));
2392 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements())); 2392 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements()));
2393 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2)); 2393 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2));
2394 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements())); 2394 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements()));
2395 } 2395 }
2396 2396
2397 2397
2398 // Test regular array literals allocation. 2398 // Test regular array literals allocation.
2399 TEST(OptimizedAllocationArrayLiterals) { 2399 TEST_TRACK_ALLOCATIONS(OptimizedAllocationArrayLiterals) {
2400 i::FLAG_allow_natives_syntax = true; 2400 i::FLAG_allow_natives_syntax = true;
2401 CcTest::InitializeVM(); 2401 CcTest::InitializeVM();
2402 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2402 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2403 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2403 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2404 v8::HandleScope scope(CcTest::isolate()); 2404 v8::HandleScope scope(CcTest::isolate());
2405 2405
2406 v8::Local<v8::Value> res = CompileRun( 2406 v8::Local<v8::Value> res = CompileRun(
2407 "function f() {" 2407 "function f() {"
2408 " var numbers = new Array(1, 2, 3);" 2408 " var numbers = new Array(1, 2, 3);"
2409 " numbers[0] = 3.14;" 2409 " numbers[0] = 3.14;"
2410 " return numbers;" 2410 " return numbers;"
2411 "};" 2411 "};"
2412 "f(); f(); f();" 2412 "f(); f(); f();"
2413 "%OptimizeFunctionOnNextCall(f);" 2413 "%OptimizeFunctionOnNextCall(f);"
2414 "f();"); 2414 "f();");
2415 CHECK_EQ(static_cast<int>(3.14), 2415 CHECK_EQ(static_cast<int>(3.14),
2416 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); 2416 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2417 2417
2418 Handle<JSObject> o = 2418 Handle<JSObject> o =
2419 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2419 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2420 2420
2421 CHECK(CcTest::heap()->InNewSpace(o->elements())); 2421 CHECK(CcTest::heap()->InNewSpace(o->elements()));
2422 } 2422 }
2423 2423
2424 2424
2425 TEST(OptimizedPretenuringCallNew) { 2425 TEST_TRACK_ALLOCATIONS(OptimizedPretenuringCallNew) {
2426 i::FLAG_allow_natives_syntax = true; 2426 i::FLAG_allow_natives_syntax = true;
2427 i::FLAG_pretenuring_call_new = true; 2427 i::FLAG_pretenuring_call_new = true;
2428 CcTest::InitializeVM(); 2428 CcTest::InitializeVM();
2429 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2429 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2430 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2430 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2431 v8::HandleScope scope(CcTest::isolate()); 2431 v8::HandleScope scope(CcTest::isolate());
2432 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); 2432 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2433 2433
2434 AlwaysAllocateScope always_allocate; 2434 AlwaysAllocateScope always_allocate;
2435 v8::Local<v8::Value> res = CompileRun( 2435 v8::Local<v8::Value> res = CompileRun(
(...skipping 11 matching lines...) Expand all
2447 } 2447 }
2448 2448
2449 2449
2450 static int CountMapTransitions(Map* map) { 2450 static int CountMapTransitions(Map* map) {
2451 return map->transitions()->number_of_transitions(); 2451 return map->transitions()->number_of_transitions();
2452 } 2452 }
2453 2453
2454 2454
2455 // Test that map transitions are cleared and maps are collected with 2455 // Test that map transitions are cleared and maps are collected with
2456 // incremental marking as well. 2456 // incremental marking as well.
2457 TEST(Regress1465) { 2457 TEST_TRACK_ALLOCATIONS(Regress1465) {
2458 i::FLAG_stress_compaction = false; 2458 i::FLAG_stress_compaction = false;
2459 i::FLAG_allow_natives_syntax = true; 2459 i::FLAG_allow_natives_syntax = true;
2460 i::FLAG_trace_incremental_marking = true; 2460 i::FLAG_trace_incremental_marking = true;
2461 CcTest::InitializeVM(); 2461 CcTest::InitializeVM();
2462 v8::HandleScope scope(CcTest::isolate()); 2462 v8::HandleScope scope(CcTest::isolate());
2463 static const int transitions_count = 256; 2463 static const int transitions_count = 256;
2464 2464
2465 { 2465 {
2466 AlwaysAllocateScope always_allocate; 2466 AlwaysAllocateScope always_allocate;
2467 for (int i = 0; i < transitions_count; i++) { 2467 for (int i = 0; i < transitions_count; i++) {
(...skipping 18 matching lines...) Expand all
2486 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2486 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2487 2487
2488 // Count number of live transitions after marking. Note that one transition 2488 // Count number of live transitions after marking. Note that one transition
2489 // is left, because 'o' still holds an instance of one transition target. 2489 // is left, because 'o' still holds an instance of one transition target.
2490 int transitions_after = CountMapTransitions(root->map()); 2490 int transitions_after = CountMapTransitions(root->map());
2491 CompileRun("%DebugPrint(root);"); 2491 CompileRun("%DebugPrint(root);");
2492 CHECK_EQ(1, transitions_after); 2492 CHECK_EQ(1, transitions_after);
2493 } 2493 }
2494 2494
2495 2495
2496 TEST(Regress2143a) { 2496 TEST_TRACK_ALLOCATIONS(Regress2143a) {
2497 i::FLAG_collect_maps = true; 2497 i::FLAG_collect_maps = true;
2498 i::FLAG_incremental_marking = true; 2498 i::FLAG_incremental_marking = true;
2499 CcTest::InitializeVM(); 2499 CcTest::InitializeVM();
2500 v8::HandleScope scope(CcTest::isolate()); 2500 v8::HandleScope scope(CcTest::isolate());
2501 2501
2502 // Prepare a map transition from the root object together with a yet 2502 // Prepare a map transition from the root object together with a yet
2503 // untransitioned root object. 2503 // untransitioned root object.
2504 CompileRun("var root = new Object;" 2504 CompileRun("var root = new Object;"
2505 "root.foo = 0;" 2505 "root.foo = 0;"
2506 "root = new Object;"); 2506 "root = new Object;");
(...skipping 19 matching lines...) Expand all
2526 v8::Utils::OpenHandle( 2526 v8::Utils::OpenHandle(
2527 *v8::Handle<v8::Object>::Cast( 2527 *v8::Handle<v8::Object>::Cast(
2528 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2528 v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
2529 2529
2530 // The root object should be in a sane state. 2530 // The root object should be in a sane state.
2531 CHECK(root->IsJSObject()); 2531 CHECK(root->IsJSObject());
2532 CHECK(root->map()->IsMap()); 2532 CHECK(root->map()->IsMap());
2533 } 2533 }
2534 2534
2535 2535
2536 TEST(Regress2143b) { 2536 TEST_TRACK_ALLOCATIONS(Regress2143b) {
2537 i::FLAG_collect_maps = true; 2537 i::FLAG_collect_maps = true;
2538 i::FLAG_incremental_marking = true; 2538 i::FLAG_incremental_marking = true;
2539 i::FLAG_allow_natives_syntax = true; 2539 i::FLAG_allow_natives_syntax = true;
2540 CcTest::InitializeVM(); 2540 CcTest::InitializeVM();
2541 v8::HandleScope scope(CcTest::isolate()); 2541 v8::HandleScope scope(CcTest::isolate());
2542 2542
2543 // Prepare a map transition from the root object together with a yet 2543 // Prepare a map transition from the root object together with a yet
2544 // untransitioned root object. 2544 // untransitioned root object.
2545 CompileRun("var root = new Object;" 2545 CompileRun("var root = new Object;"
2546 "root.foo = 0;" 2546 "root.foo = 0;"
(...skipping 23 matching lines...) Expand all
2570 v8::Utils::OpenHandle( 2570 v8::Utils::OpenHandle(
2571 *v8::Handle<v8::Object>::Cast( 2571 *v8::Handle<v8::Object>::Cast(
2572 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2572 v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
2573 2573
2574 // The root object should be in a sane state. 2574 // The root object should be in a sane state.
2575 CHECK(root->IsJSObject()); 2575 CHECK(root->IsJSObject());
2576 CHECK(root->map()->IsMap()); 2576 CHECK(root->map()->IsMap());
2577 } 2577 }
2578 2578
2579 2579
2580 TEST(ReleaseOverReservedPages) { 2580 TEST_TRACK_ALLOCATIONS(ReleaseOverReservedPages) {
2581 i::FLAG_trace_gc = true; 2581 i::FLAG_trace_gc = true;
2582 // The optimizer can allocate stuff, messing up the test. 2582 // The optimizer can allocate stuff, messing up the test.
2583 i::FLAG_crankshaft = false; 2583 i::FLAG_crankshaft = false;
2584 i::FLAG_always_opt = false; 2584 i::FLAG_always_opt = false;
2585 CcTest::InitializeVM(); 2585 CcTest::InitializeVM();
2586 Isolate* isolate = CcTest::i_isolate(); 2586 Isolate* isolate = CcTest::i_isolate();
2587 Factory* factory = isolate->factory(); 2587 Factory* factory = isolate->factory();
2588 Heap* heap = isolate->heap(); 2588 Heap* heap = isolate->heap();
2589 v8::HandleScope scope(CcTest::isolate()); 2589 v8::HandleScope scope(CcTest::isolate());
2590 static const int number_of_test_pages = 20; 2590 static const int number_of_test_pages = 20;
(...skipping 25 matching lines...) Expand all
2616 // where there are 2 pages left instead of 1, then we should increase the 2616 // where there are 2 pages left instead of 1, then we should increase the
2617 // size of the first page a little in SizeOfFirstPage in spaces.cc. The 2617 // size of the first page a little in SizeOfFirstPage in spaces.cc. The
2618 // first page should be small in order to reduce memory used when the VM 2618 // first page should be small in order to reduce memory used when the VM
2619 // boots, but if the 20 small arrays don't fit on the first page then that's 2619 // boots, but if the 20 small arrays don't fit on the first page then that's
2620 // an indication that it is too small. 2620 // an indication that it is too small.
2621 heap->CollectAllAvailableGarbage("triggered really hard"); 2621 heap->CollectAllAvailableGarbage("triggered really hard");
2622 CHECK_EQ(1, old_pointer_space->CountTotalPages()); 2622 CHECK_EQ(1, old_pointer_space->CountTotalPages());
2623 } 2623 }
2624 2624
2625 2625
2626 TEST(Regress2237) { 2626 TEST_TRACK_ALLOCATIONS(Regress2237) {
2627 i::FLAG_stress_compaction = false; 2627 i::FLAG_stress_compaction = false;
2628 CcTest::InitializeVM(); 2628 CcTest::InitializeVM();
2629 Isolate* isolate = CcTest::i_isolate(); 2629 Isolate* isolate = CcTest::i_isolate();
2630 Factory* factory = isolate->factory(); 2630 Factory* factory = isolate->factory();
2631 v8::HandleScope scope(CcTest::isolate()); 2631 v8::HandleScope scope(CcTest::isolate());
2632 Handle<String> slice(CcTest::heap()->empty_string()); 2632 Handle<String> slice(CcTest::heap()->empty_string());
2633 2633
2634 { 2634 {
2635 // Generate a parent that lives in new-space. 2635 // Generate a parent that lives in new-space.
2636 v8::HandleScope inner_scope(CcTest::isolate()); 2636 v8::HandleScope inner_scope(CcTest::isolate());
(...skipping 12 matching lines...) Expand all
2649 *slice.location() = *t.location(); 2649 *slice.location() = *t.location();
2650 } 2650 }
2651 2651
2652 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); 2652 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString());
2653 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2653 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2654 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); 2654 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString());
2655 } 2655 }
2656 2656
2657 2657
2658 #ifdef OBJECT_PRINT 2658 #ifdef OBJECT_PRINT
2659 TEST(PrintSharedFunctionInfo) { 2659 TEST_TRACK_ALLOCATIONS(PrintSharedFunctionInfo) {
2660 CcTest::InitializeVM(); 2660 CcTest::InitializeVM();
2661 v8::HandleScope scope(CcTest::isolate()); 2661 v8::HandleScope scope(CcTest::isolate());
2662 const char* source = "f = function() { return 987654321; }\n" 2662 const char* source = "f = function() { return 987654321; }\n"
2663 "g = function() { return 123456789; }\n"; 2663 "g = function() { return 123456789; }\n";
2664 CompileRun(source); 2664 CompileRun(source);
2665 Handle<JSFunction> g = 2665 Handle<JSFunction> g =
2666 v8::Utils::OpenHandle( 2666 v8::Utils::OpenHandle(
2667 *v8::Handle<v8::Function>::Cast( 2667 *v8::Handle<v8::Function>::Cast(
2668 v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); 2668 v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
2669 2669
2670 DisallowHeapAllocation no_allocation; 2670 DisallowHeapAllocation no_allocation;
2671 g->shared()->PrintLn(); 2671 g->shared()->PrintLn();
2672 } 2672 }
2673 #endif // OBJECT_PRINT 2673 #endif // OBJECT_PRINT
2674 2674
2675 2675
2676 TEST(Regress2211) { 2676 TEST_TRACK_ALLOCATIONS(Regress2211) {
2677 CcTest::InitializeVM(); 2677 CcTest::InitializeVM();
2678 v8::HandleScope scope(CcTest::isolate()); 2678 v8::HandleScope scope(CcTest::isolate());
2679 2679
2680 v8::Handle<v8::String> value = v8_str("val string"); 2680 v8::Handle<v8::String> value = v8_str("val string");
2681 Smi* hash = Smi::FromInt(321); 2681 Smi* hash = Smi::FromInt(321);
2682 Heap* heap = CcTest::heap(); 2682 Heap* heap = CcTest::heap();
2683 2683
2684 for (int i = 0; i < 2; i++) { 2684 for (int i = 0; i < 2; i++) {
2685 // Store identity hash first and common hidden property second. 2685 // Store identity hash first and common hidden property second.
2686 v8::Handle<v8::Object> obj = v8::Object::New(); 2686 v8::Handle<v8::Object> obj = v8::Object::New();
(...skipping 14 matching lines...) Expand all
2701 // Check size. 2701 // Check size.
2702 DescriptorArray* descriptors = internal_obj->map()->instance_descriptors(); 2702 DescriptorArray* descriptors = internal_obj->map()->instance_descriptors();
2703 ObjectHashTable* hashtable = ObjectHashTable::cast( 2703 ObjectHashTable* hashtable = ObjectHashTable::cast(
2704 internal_obj->RawFastPropertyAt(descriptors->GetFieldIndex(0))); 2704 internal_obj->RawFastPropertyAt(descriptors->GetFieldIndex(0)));
2705 // HashTable header (5) and 4 initial entries (8). 2705 // HashTable header (5) and 4 initial entries (8).
2706 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize); 2706 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize);
2707 } 2707 }
2708 } 2708 }
2709 2709
2710 2710
2711 TEST(IncrementalMarkingClearsTypeFeedbackCells) { 2711 TEST_TRACK_ALLOCATIONS(IncrementalMarkingClearsTypeFeedbackCells) {
2712 if (i::FLAG_always_opt) return; 2712 if (i::FLAG_always_opt) return;
2713 CcTest::InitializeVM(); 2713 CcTest::InitializeVM();
2714 v8::HandleScope scope(CcTest::isolate()); 2714 v8::HandleScope scope(CcTest::isolate());
2715 v8::Local<v8::Value> fun1, fun2; 2715 v8::Local<v8::Value> fun1, fun2;
2716 2716
2717 { 2717 {
2718 LocalContext env; 2718 LocalContext env;
2719 CompileRun("function fun() {};"); 2719 CompileRun("function fun() {};");
2720 fun1 = env->Global()->Get(v8_str("fun")); 2720 fun1 = env->Global()->Get(v8_str("fun"));
2721 } 2721 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 RelocInfo* info = it.rinfo(); 2760 RelocInfo* info = it.rinfo();
2761 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); 2761 Code* target = Code::GetCodeFromTargetAddress(info->target_address());
2762 if (target->is_inline_cache_stub() && target->kind() == kind) { 2762 if (target->is_inline_cache_stub() && target->kind() == kind) {
2763 return target; 2763 return target;
2764 } 2764 }
2765 } 2765 }
2766 return NULL; 2766 return NULL;
2767 } 2767 }
2768 2768
2769 2769
2770 TEST(IncrementalMarkingPreservesMonomorhpicIC) { 2770 TEST_TRACK_ALLOCATIONS(IncrementalMarkingPreservesMonomorhpicIC) {
2771 if (i::FLAG_always_opt) return; 2771 if (i::FLAG_always_opt) return;
2772 CcTest::InitializeVM(); 2772 CcTest::InitializeVM();
2773 v8::HandleScope scope(CcTest::isolate()); 2773 v8::HandleScope scope(CcTest::isolate());
2774 2774
2775 // Prepare function f that contains a monomorphic IC for object 2775 // Prepare function f that contains a monomorphic IC for object
2776 // originating from the same native context. 2776 // originating from the same native context.
2777 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 2777 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
2778 "function f(o) { return o.x; } f(obj); f(obj);"); 2778 "function f(o) { return o.x; } f(obj); f(obj);");
2779 Handle<JSFunction> f = 2779 Handle<JSFunction> f =
2780 v8::Utils::OpenHandle( 2780 v8::Utils::OpenHandle(
2781 *v8::Handle<v8::Function>::Cast( 2781 *v8::Handle<v8::Function>::Cast(
2782 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2782 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2783 2783
2784 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2784 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2785 CHECK(ic_before->ic_state() == MONOMORPHIC); 2785 CHECK(ic_before->ic_state() == MONOMORPHIC);
2786 2786
2787 SimulateIncrementalMarking(); 2787 SimulateIncrementalMarking();
2788 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2788 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2789 2789
2790 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2790 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2791 CHECK(ic_after->ic_state() == MONOMORPHIC); 2791 CHECK(ic_after->ic_state() == MONOMORPHIC);
2792 } 2792 }
2793 2793
2794 2794
2795 TEST(IncrementalMarkingClearsMonomorhpicIC) { 2795 TEST_TRACK_ALLOCATIONS(IncrementalMarkingClearsMonomorhpicIC) {
2796 if (i::FLAG_always_opt) return; 2796 if (i::FLAG_always_opt) return;
2797 CcTest::InitializeVM(); 2797 CcTest::InitializeVM();
2798 v8::HandleScope scope(CcTest::isolate()); 2798 v8::HandleScope scope(CcTest::isolate());
2799 v8::Local<v8::Value> obj1; 2799 v8::Local<v8::Value> obj1;
2800 2800
2801 { 2801 {
2802 LocalContext env; 2802 LocalContext env;
2803 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 2803 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
2804 obj1 = env->Global()->Get(v8_str("obj")); 2804 obj1 = env->Global()->Get(v8_str("obj"));
2805 } 2805 }
(...skipping 13 matching lines...) Expand all
2819 // Fire context dispose notification. 2819 // Fire context dispose notification.
2820 v8::V8::ContextDisposedNotification(); 2820 v8::V8::ContextDisposedNotification();
2821 SimulateIncrementalMarking(); 2821 SimulateIncrementalMarking();
2822 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2822 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2823 2823
2824 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2824 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2825 CHECK(ic_after->ic_state() == UNINITIALIZED); 2825 CHECK(ic_after->ic_state() == UNINITIALIZED);
2826 } 2826 }
2827 2827
2828 2828
2829 TEST(IncrementalMarkingClearsPolymorhpicIC) { 2829 TEST_TRACK_ALLOCATIONS(IncrementalMarkingClearsPolymorhpicIC) {
2830 if (i::FLAG_always_opt) return; 2830 if (i::FLAG_always_opt) return;
2831 CcTest::InitializeVM(); 2831 CcTest::InitializeVM();
2832 v8::HandleScope scope(CcTest::isolate()); 2832 v8::HandleScope scope(CcTest::isolate());
2833 v8::Local<v8::Value> obj1, obj2; 2833 v8::Local<v8::Value> obj1, obj2;
2834 2834
2835 { 2835 {
2836 LocalContext env; 2836 LocalContext env;
2837 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 2837 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
2838 obj1 = env->Global()->Get(v8_str("obj")); 2838 obj1 = env->Global()->Get(v8_str("obj"));
2839 } 2839 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 // supposed to (untypically) write to the receiver, not the holder. This is 2954 // supposed to (untypically) write to the receiver, not the holder. This is
2955 // to emulate the behavior of a data property. 2955 // to emulate the behavior of a data property.
2956 2956
2957 ReleaseStackTraceDataTest(source1, getter); 2957 ReleaseStackTraceDataTest(source1, getter);
2958 ReleaseStackTraceDataTest(source2, getter); 2958 ReleaseStackTraceDataTest(source2, getter);
2959 ReleaseStackTraceDataTest(source3, getter); 2959 ReleaseStackTraceDataTest(source3, getter);
2960 ReleaseStackTraceDataTest(source4, getter); 2960 ReleaseStackTraceDataTest(source4, getter);
2961 } 2961 }
2962 2962
2963 2963
2964 TEST(Regression144230) { 2964 TEST_TRACK_ALLOCATIONS(Regression144230) {
2965 i::FLAG_stress_compaction = false; 2965 i::FLAG_stress_compaction = false;
2966 CcTest::InitializeVM(); 2966 CcTest::InitializeVM();
2967 Isolate* isolate = CcTest::i_isolate(); 2967 Isolate* isolate = CcTest::i_isolate();
2968 Heap* heap = isolate->heap(); 2968 Heap* heap = isolate->heap();
2969 HandleScope scope(isolate); 2969 HandleScope scope(isolate);
2970 2970
2971 // First make sure that the uninitialized CallIC stub is on a single page 2971 // First make sure that the uninitialized CallIC stub is on a single page
2972 // that will later be selected as an evacuation candidate. 2972 // that will later be selected as an evacuation candidate.
2973 { 2973 {
2974 HandleScope inner_scope(isolate); 2974 HandleScope inner_scope(isolate);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 // Now we are ready to mess up the heap. 3017 // Now we are ready to mess up the heap.
3018 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); 3018 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
3019 3019
3020 // Either heap verification caught the problem already or we go kaboom once 3020 // Either heap verification caught the problem already or we go kaboom once
3021 // the CallIC is executed the next time. 3021 // the CallIC is executed the next time.
3022 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); 3022 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode);
3023 CompileRun("call();"); 3023 CompileRun("call();");
3024 } 3024 }
3025 3025
3026 3026
3027 TEST(Regress159140) { 3027 TEST_TRACK_ALLOCATIONS(Regress159140) {
3028 i::FLAG_allow_natives_syntax = true; 3028 i::FLAG_allow_natives_syntax = true;
3029 i::FLAG_flush_code_incrementally = true; 3029 i::FLAG_flush_code_incrementally = true;
3030 CcTest::InitializeVM(); 3030 CcTest::InitializeVM();
3031 Isolate* isolate = CcTest::i_isolate(); 3031 Isolate* isolate = CcTest::i_isolate();
3032 Heap* heap = isolate->heap(); 3032 Heap* heap = isolate->heap();
3033 HandleScope scope(isolate); 3033 HandleScope scope(isolate);
3034 3034
3035 // Perform one initial GC to enable code flushing. 3035 // Perform one initial GC to enable code flushing.
3036 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3036 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3037 3037
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 // finish the GC to complete code flushing. 3079 // finish the GC to complete code flushing.
3080 SimulateIncrementalMarking(); 3080 SimulateIncrementalMarking();
3081 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); 3081 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);");
3082 heap->CollectAllGarbage(Heap::kNoGCFlags); 3082 heap->CollectAllGarbage(Heap::kNoGCFlags);
3083 3083
3084 // Unoptimized code is missing and the deoptimizer will go ballistic. 3084 // Unoptimized code is missing and the deoptimizer will go ballistic.
3085 CompileRun("g('bozo');"); 3085 CompileRun("g('bozo');");
3086 } 3086 }
3087 3087
3088 3088
3089 TEST(Regress165495) { 3089 TEST_TRACK_ALLOCATIONS(Regress165495) {
3090 i::FLAG_allow_natives_syntax = true; 3090 i::FLAG_allow_natives_syntax = true;
3091 i::FLAG_flush_code_incrementally = true; 3091 i::FLAG_flush_code_incrementally = true;
3092 CcTest::InitializeVM(); 3092 CcTest::InitializeVM();
3093 Isolate* isolate = CcTest::i_isolate(); 3093 Isolate* isolate = CcTest::i_isolate();
3094 Heap* heap = isolate->heap(); 3094 Heap* heap = isolate->heap();
3095 HandleScope scope(isolate); 3095 HandleScope scope(isolate);
3096 3096
3097 // Perform one initial GC to enable code flushing. 3097 // Perform one initial GC to enable code flushing.
3098 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3098 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3099 3099
(...skipping 26 matching lines...) Expand all
3126 // even though it still is cached in the optimized code map. 3126 // even though it still is cached in the optimized code map.
3127 SimulateIncrementalMarking(); 3127 SimulateIncrementalMarking();
3128 heap->CollectAllGarbage(Heap::kNoGCFlags); 3128 heap->CollectAllGarbage(Heap::kNoGCFlags);
3129 3129
3130 // Make a new closure that will get code installed from the code map. 3130 // Make a new closure that will get code installed from the code map.
3131 // Unoptimized code is missing and the deoptimizer will go ballistic. 3131 // Unoptimized code is missing and the deoptimizer will go ballistic.
3132 CompileRun("var g = mkClosure(); g('bozo');"); 3132 CompileRun("var g = mkClosure(); g('bozo');");
3133 } 3133 }
3134 3134
3135 3135
3136 TEST(Regress169209) { 3136 TEST_TRACK_ALLOCATIONS(Regress169209) {
3137 i::FLAG_stress_compaction = false; 3137 i::FLAG_stress_compaction = false;
3138 i::FLAG_allow_natives_syntax = true; 3138 i::FLAG_allow_natives_syntax = true;
3139 i::FLAG_flush_code_incrementally = true; 3139 i::FLAG_flush_code_incrementally = true;
3140 3140
3141 CcTest::InitializeVM(); 3141 CcTest::InitializeVM();
3142 Isolate* isolate = CcTest::i_isolate(); 3142 Isolate* isolate = CcTest::i_isolate();
3143 Heap* heap = isolate->heap(); 3143 Heap* heap = isolate->heap();
3144 HandleScope scope(isolate); 3144 HandleScope scope(isolate);
3145 3145
3146 // Perform one initial GC to enable code flushing. 3146 // Perform one initial GC to enable code flushing.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3214 int space_remaining = static_cast<int>( 3214 int space_remaining = static_cast<int>(
3215 *space->allocation_limit_address() - *space->allocation_top_address()); 3215 *space->allocation_limit_address() - *space->allocation_top_address());
3216 CHECK(space_remaining >= extra_bytes); 3216 CHECK(space_remaining >= extra_bytes);
3217 int new_linear_size = space_remaining - extra_bytes; 3217 int new_linear_size = space_remaining - extra_bytes;
3218 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); 3218 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size);
3219 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); 3219 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe);
3220 node->set_size(space->heap(), new_linear_size); 3220 node->set_size(space->heap(), new_linear_size);
3221 } 3221 }
3222 3222
3223 3223
3224 TEST(Regress169928) { 3224 TEST_TRACK_ALLOCATIONS(Regress169928) {
3225 i::FLAG_allow_natives_syntax = true; 3225 i::FLAG_allow_natives_syntax = true;
3226 i::FLAG_crankshaft = false; 3226 i::FLAG_crankshaft = false;
3227 CcTest::InitializeVM(); 3227 CcTest::InitializeVM();
3228 Isolate* isolate = CcTest::i_isolate(); 3228 Isolate* isolate = CcTest::i_isolate();
3229 Factory* factory = isolate->factory(); 3229 Factory* factory = isolate->factory();
3230 v8::HandleScope scope(CcTest::isolate()); 3230 v8::HandleScope scope(CcTest::isolate());
3231 3231
3232 // Some flags turn Scavenge collections into Mark-sweep collections 3232 // Some flags turn Scavenge collections into Mark-sweep collections
3233 // and hence are incompatible with this test case. 3233 // and hence are incompatible with this test case.
3234 if (FLAG_gc_global || FLAG_stress_compaction) return; 3234 if (FLAG_gc_global || FLAG_stress_compaction) return;
(...skipping 10 matching lines...) Expand all
3245 "obj = fastliteralcase(get_standard_literal(), 1);" 3245 "obj = fastliteralcase(get_standard_literal(), 1);"
3246 "obj = fastliteralcase(get_standard_literal(), 1.5);" 3246 "obj = fastliteralcase(get_standard_literal(), 1.5);"
3247 "obj = fastliteralcase(get_standard_literal(), 2);"); 3247 "obj = fastliteralcase(get_standard_literal(), 2);");
3248 3248
3249 // prepare the heap 3249 // prepare the heap
3250 v8::Local<v8::String> mote_code_string = 3250 v8::Local<v8::String> mote_code_string =
3251 v8_str("fastliteralcase(mote, 2.5);"); 3251 v8_str("fastliteralcase(mote, 2.5);");
3252 3252
3253 v8::Local<v8::String> array_name = v8_str("mote"); 3253 v8::Local<v8::String> array_name = v8_str("mote");
3254 v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0)); 3254 v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0));
3255
3256 // First make sure we flip spaces 3255 // First make sure we flip spaces
3257 CcTest::heap()->CollectGarbage(NEW_SPACE); 3256 CcTest::heap()->CollectGarbage(NEW_SPACE);
3258 3257
3259 // Allocate the object. 3258 // Allocate the object.
3260 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); 3259 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
3261 array_data->set(0, Smi::FromInt(1)); 3260 array_data->set(0, Smi::FromInt(1));
3262 array_data->set(1, Smi::FromInt(2)); 3261 array_data->set(1, Smi::FromInt(2));
3263 3262
3264 AllocateAllButNBytes(CcTest::heap()->new_space(), 3263 AllocateAllButNBytes(CcTest::heap()->new_space(),
3265 JSArray::kSize + AllocationMemento::kSize + 3264 JSArray::kSize + AllocationMemento::kSize +
(...skipping 21 matching lines...) Expand all
3287 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array); 3286 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
3288 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj); 3287 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj);
3289 3288
3290 // This should crash with a protection violation if we are running a build 3289 // This should crash with a protection violation if we are running a build
3291 // with the bug. 3290 // with the bug.
3292 AlwaysAllocateScope aa_scope; 3291 AlwaysAllocateScope aa_scope;
3293 v8::Script::Compile(mote_code_string)->Run(); 3292 v8::Script::Compile(mote_code_string)->Run();
3294 } 3293 }
3295 3294
3296 3295
3297 TEST(Regress168801) { 3296 TEST_TRACK_ALLOCATIONS(Regress168801) {
3298 i::FLAG_always_compact = true; 3297 i::FLAG_always_compact = true;
3299 i::FLAG_cache_optimized_code = false; 3298 i::FLAG_cache_optimized_code = false;
3300 i::FLAG_allow_natives_syntax = true; 3299 i::FLAG_allow_natives_syntax = true;
3301 i::FLAG_flush_code_incrementally = true; 3300 i::FLAG_flush_code_incrementally = true;
3302 CcTest::InitializeVM(); 3301 CcTest::InitializeVM();
3303 Isolate* isolate = CcTest::i_isolate(); 3302 Isolate* isolate = CcTest::i_isolate();
3304 Heap* heap = isolate->heap(); 3303 Heap* heap = isolate->heap();
3305 HandleScope scope(isolate); 3304 HandleScope scope(isolate);
3306 3305
3307 // Perform one initial GC to enable code flushing. 3306 // Perform one initial GC to enable code flushing.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3343 HandleScope inner_scope(isolate); 3342 HandleScope inner_scope(isolate);
3344 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); 3343 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);");
3345 } 3344 }
3346 3345
3347 // This cycle will bust the heap and subsequent cycles will go ballistic. 3346 // This cycle will bust the heap and subsequent cycles will go ballistic.
3348 heap->CollectAllGarbage(Heap::kNoGCFlags); 3347 heap->CollectAllGarbage(Heap::kNoGCFlags);
3349 heap->CollectAllGarbage(Heap::kNoGCFlags); 3348 heap->CollectAllGarbage(Heap::kNoGCFlags);
3350 } 3349 }
3351 3350
3352 3351
3353 TEST(Regress173458) { 3352 TEST_TRACK_ALLOCATIONS(Regress173458) {
3354 i::FLAG_always_compact = true; 3353 i::FLAG_always_compact = true;
3355 i::FLAG_cache_optimized_code = false; 3354 i::FLAG_cache_optimized_code = false;
3356 i::FLAG_allow_natives_syntax = true; 3355 i::FLAG_allow_natives_syntax = true;
3357 i::FLAG_flush_code_incrementally = true; 3356 i::FLAG_flush_code_incrementally = true;
3358 CcTest::InitializeVM(); 3357 CcTest::InitializeVM();
3359 Isolate* isolate = CcTest::i_isolate(); 3358 Isolate* isolate = CcTest::i_isolate();
3360 Heap* heap = isolate->heap(); 3359 Heap* heap = isolate->heap();
3361 HandleScope scope(isolate); 3360 HandleScope scope(isolate);
3362 3361
3363 // Perform one initial GC to enable code flushing. 3362 // Perform one initial GC to enable code flushing.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3404 heap->CollectAllGarbage(Heap::kNoGCFlags); 3403 heap->CollectAllGarbage(Heap::kNoGCFlags);
3405 } 3404 }
3406 3405
3407 3406
3408 class DummyVisitor : public ObjectVisitor { 3407 class DummyVisitor : public ObjectVisitor {
3409 public: 3408 public:
3410 void VisitPointers(Object** start, Object** end) { } 3409 void VisitPointers(Object** start, Object** end) { }
3411 }; 3410 };
3412 3411
3413 3412
3414 TEST(DeferredHandles) { 3413 TEST_TRACK_ALLOCATIONS(DeferredHandles) {
3415 CcTest::InitializeVM(); 3414 CcTest::InitializeVM();
3416 Isolate* isolate = CcTest::i_isolate(); 3415 Isolate* isolate = CcTest::i_isolate();
3417 Heap* heap = isolate->heap(); 3416 Heap* heap = isolate->heap();
3418 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); 3417 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate));
3419 v8::ImplementationUtilities::HandleScopeData* data = 3418 v8::ImplementationUtilities::HandleScopeData* data =
3420 isolate->handle_scope_data(); 3419 isolate->handle_scope_data();
3421 Handle<Object> init(heap->empty_string(), isolate); 3420 Handle<Object> init(heap->empty_string(), isolate);
3422 while (data->next < data->limit) { 3421 while (data->next < data->limit) {
3423 Handle<Object> obj(heap->empty_string(), isolate); 3422 Handle<Object> obj(heap->empty_string(), isolate);
3424 } 3423 }
3425 // An entire block of handles has been filled. 3424 // An entire block of handles has been filled.
3426 // Next handle would require a new block. 3425 // Next handle would require a new block.
3427 ASSERT(data->next == data->limit); 3426 ASSERT(data->next == data->limit);
3428 3427
3429 DeferredHandleScope deferred(isolate); 3428 DeferredHandleScope deferred(isolate);
3430 DummyVisitor visitor; 3429 DummyVisitor visitor;
3431 isolate->handle_scope_implementer()->Iterate(&visitor); 3430 isolate->handle_scope_implementer()->Iterate(&visitor);
3432 deferred.Detach(); 3431 deferred.Detach();
3433 } 3432 }
3434 3433
3435 3434
3436 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { 3435 TEST_TRACK_ALLOCATIONS(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
3437 CcTest::InitializeVM(); 3436 CcTest::InitializeVM();
3438 v8::HandleScope scope(CcTest::isolate()); 3437 v8::HandleScope scope(CcTest::isolate());
3439 CompileRun("function f(n) {" 3438 CompileRun("function f(n) {"
3440 " var a = new Array(n);" 3439 " var a = new Array(n);"
3441 " for (var i = 0; i < n; i += 100) a[i] = i;" 3440 " for (var i = 0; i < n; i += 100) a[i] = i;"
3442 "};" 3441 "};"
3443 "f(10 * 1024 * 1024);"); 3442 "f(10 * 1024 * 1024);");
3444 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 3443 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
3445 if (marking->IsStopped()) marking->Start(); 3444 if (marking->IsStopped()) marking->Start();
3446 // This big step should be sufficient to mark the whole array. 3445 // This big step should be sufficient to mark the whole array.
3447 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3446 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3448 ASSERT(marking->IsComplete()); 3447 ASSERT(marking->IsComplete());
3449 } 3448 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698