Revision f230a1cf deps/v8/test/cctest/test-heap.cc

View differences:

deps/v8/test/cctest/test-heap.cc
42 42

  
43 43
// Go through all incremental marking steps in one swoop.
44 44
static void SimulateIncrementalMarking() {
45
  MarkCompactCollector* collector = HEAP->mark_compact_collector();
46
  IncrementalMarking* marking = HEAP->incremental_marking();
45
  MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
46
  IncrementalMarking* marking = CcTest::heap()->incremental_marking();
47 47
  if (collector->IsConcurrentSweepingInProgress()) {
48 48
    collector->WaitUntilSweepingCompleted();
49 49
  }
......
62 62
static void CheckMap(Map* map, int type, int instance_size) {
63 63
  CHECK(map->IsHeapObject());
64 64
#ifdef DEBUG
65
  CHECK(HEAP->Contains(map));
65
  CHECK(CcTest::heap()->Contains(map));
66 66
#endif
67
  CHECK_EQ(HEAP->meta_map(), map->map());
67
  CHECK_EQ(CcTest::heap()->meta_map(), map->map());
68 68
  CHECK_EQ(type, map->instance_type());
69 69
  CHECK_EQ(instance_size, map->instance_size());
70 70
}
......
72 72

  
73 73
TEST(HeapMaps) {
74 74
  CcTest::InitializeVM();
75
  CheckMap(HEAP->meta_map(), MAP_TYPE, Map::kSize);
76
  CheckMap(HEAP->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
77
  CheckMap(HEAP->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
78
  CheckMap(HEAP->string_map(), STRING_TYPE, kVariableSizeSentinel);
75
  Heap* heap = CcTest::heap();
76
  CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize);
77
  CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
78
  CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
79
  CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel);
79 80
}
80 81

  
81 82

  
......
99 100

  
100 101

  
101 102
static void CheckNumber(Isolate* isolate, double value, const char* string) {
102
  Object* obj = HEAP->NumberFromDouble(value)->ToObjectChecked();
103
  Object* obj = CcTest::heap()->NumberFromDouble(value)->ToObjectChecked();
103 104
  CHECK(obj->IsNumber());
104 105
  bool exc;
105 106
  Handle<Object> handle(obj, isolate);
......
148 149

  
149 150
TEST(HeapObjects) {
150 151
  CcTest::InitializeVM();
151
  Isolate* isolate = Isolate::Current();
152
  Isolate* isolate = CcTest::i_isolate();
152 153
  Factory* factory = isolate->factory();
153 154
  Heap* heap = isolate->heap();
154 155

  
......
209 210
  CHECK(s->IsString());
210 211
  CHECK_EQ(10, s->length());
211 212

  
212
  String* object_string = String::cast(heap->Object_string());
213
  CHECK(
214
      Isolate::Current()->context()->global_object()->HasLocalProperty(
215
          object_string));
213
  Handle<String> object_string = Handle<String>::cast(factory->Object_string());
214
  Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object());
215
  CHECK(JSReceiver::HasLocalProperty(global, object_string));
216 216

  
217 217
  // Check ToString for oddballs
218 218
  CheckOddball(isolate, heap->true_value(), "true");
......
250 250

  
251 251
TEST(GarbageCollection) {
252 252
  CcTest::InitializeVM();
253
  Isolate* isolate = Isolate::Current();
253
  Isolate* isolate = CcTest::i_isolate();
254 254
  Heap* heap = isolate->heap();
255 255
  Factory* factory = isolate->factory();
256 256

  
......
258 258
  // Check GC.
259 259
  heap->CollectGarbage(NEW_SPACE);
260 260

  
261
  Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object());
261 262
  Handle<String> name = factory->InternalizeUtf8String("theFunction");
262 263
  Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
263 264
  Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx");
264 265
  Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
266
  Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
267
  Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
265 268

  
266 269
  {
267 270
    HandleScope inner_scope(isolate);
......
271 274
    Handle<Map> initial_map =
272 275
        factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
273 276
    function->set_initial_map(*initial_map);
274
    Isolate::Current()->context()->global_object()->SetProperty(
275
        *name, *function, NONE, kNonStrictMode)->ToObjectChecked();
277
    JSReceiver::SetProperty(global, name, function, NONE, kNonStrictMode);
276 278
    // Allocate an object.  Unrooted after leaving the scope.
277 279
    Handle<JSObject> obj = factory->NewJSObject(function);
278
    obj->SetProperty(
279
        *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
280
    obj->SetProperty(
281
        *prop_namex, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked();
280
    JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
281
    JSReceiver::SetProperty(obj, prop_namex, twenty_four, NONE, kNonStrictMode);
282 282

  
283 283
    CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
284 284
    CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex));
......
287 287
  heap->CollectGarbage(NEW_SPACE);
288 288

  
289 289
  // Function should be alive.
290
  CHECK(Isolate::Current()->context()->global_object()->
291
        HasLocalProperty(*name));
290
  CHECK(JSReceiver::HasLocalProperty(global, name));
292 291
  // Check function is retained.
293
  Object* func_value = Isolate::Current()->context()->global_object()->
292
  Object* func_value = CcTest::i_isolate()->context()->global_object()->
294 293
      GetProperty(*name)->ToObjectChecked();
295 294
  CHECK(func_value->IsJSFunction());
296 295
  Handle<JSFunction> function(JSFunction::cast(func_value));
......
299 298
    HandleScope inner_scope(isolate);
300 299
    // Allocate another object, make it reachable from global.
301 300
    Handle<JSObject> obj = factory->NewJSObject(function);
302
    Isolate::Current()->context()->global_object()->SetProperty(
303
        *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked();
304
    obj->SetProperty(
305
        *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
301
    JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode);
302
    JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
306 303
  }
307 304

  
308 305
  // After gc, it should survive.
309 306
  heap->CollectGarbage(NEW_SPACE);
310 307

  
311
  CHECK(Isolate::Current()->context()->global_object()->
312
        HasLocalProperty(*obj_name));
313
  CHECK(Isolate::Current()->context()->global_object()->
308
  CHECK(JSReceiver::HasLocalProperty(global, obj_name));
309
  CHECK(CcTest::i_isolate()->context()->global_object()->
314 310
        GetProperty(*obj_name)->ToObjectChecked()->IsJSObject());
315
  Object* obj = Isolate::Current()->context()->global_object()->
311
  Object* obj = CcTest::i_isolate()->context()->global_object()->
316 312
      GetProperty(*obj_name)->ToObjectChecked();
317 313
  JSObject* js_obj = JSObject::cast(obj);
318 314
  CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name));
......
343 339

  
344 340
TEST(LocalHandles) {
345 341
  CcTest::InitializeVM();
346
  Isolate* isolate = Isolate::Current();
342
  Isolate* isolate = CcTest::i_isolate();
347 343
  Factory* factory = isolate->factory();
348 344

  
349 345
  v8::HandleScope scope(CcTest::isolate());
......
355 351

  
356 352
TEST(GlobalHandles) {
357 353
  CcTest::InitializeVM();
358
  Isolate* isolate = Isolate::Current();
354
  Isolate* isolate = CcTest::i_isolate();
359 355
  Heap* heap = isolate->heap();
360 356
  Factory* factory = isolate->factory();
361 357
  GlobalHandles* global_handles = isolate->global_handles();
......
408 404
TEST(WeakGlobalHandlesScavenge) {
409 405
  i::FLAG_stress_compaction = false;
410 406
  CcTest::InitializeVM();
411
  Isolate* isolate = Isolate::Current();
407
  Isolate* isolate = CcTest::i_isolate();
412 408
  Heap* heap = isolate->heap();
413 409
  Factory* factory = isolate->factory();
414 410
  GlobalHandles* global_handles = isolate->global_handles();
......
449 445

  
450 446
TEST(WeakGlobalHandlesMark) {
451 447
  CcTest::InitializeVM();
452
  Isolate* isolate = Isolate::Current();
448
  Isolate* isolate = CcTest::i_isolate();
453 449
  Heap* heap = isolate->heap();
454 450
  Factory* factory = isolate->factory();
455 451
  GlobalHandles* global_handles = isolate->global_handles();
......
495 491
TEST(DeleteWeakGlobalHandle) {
496 492
  i::FLAG_stress_compaction = false;
497 493
  CcTest::InitializeVM();
498
  Isolate* isolate = Isolate::Current();
494
  Isolate* isolate = CcTest::i_isolate();
499 495
  Heap* heap = isolate->heap();
500 496
  Factory* factory = isolate->factory();
501 497
  GlobalHandles* global_handles = isolate->global_handles();
......
594 590
static void CheckInternalizedStrings(const char** strings) {
595 591
  for (const char* string = *strings; *strings != 0; string = *strings++) {
596 592
    Object* a;
597
    MaybeObject* maybe_a = HEAP->InternalizeUtf8String(string);
593
    MaybeObject* maybe_a = CcTest::heap()->InternalizeUtf8String(string);
598 594
    // InternalizeUtf8String may return a failure if a GC is needed.
599 595
    if (!maybe_a->ToObject(&a)) continue;
600 596
    CHECK(a->IsInternalizedString());
601 597
    Object* b;
602
    MaybeObject* maybe_b = HEAP->InternalizeUtf8String(string);
598
    MaybeObject* maybe_b = CcTest::heap()->InternalizeUtf8String(string);
603 599
    if (!maybe_b->ToObject(&b)) continue;
604 600
    CHECK_EQ(b, a);
605 601
    CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string)));
......
617 613

  
618 614
TEST(FunctionAllocation) {
619 615
  CcTest::InitializeVM();
620
  Isolate* isolate = Isolate::Current();
616
  Isolate* isolate = CcTest::i_isolate();
621 617
  Factory* factory = isolate->factory();
622 618

  
623 619
  v8::HandleScope sc(CcTest::isolate());
......
628 624
      factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
629 625
  function->set_initial_map(*initial_map);
630 626

  
627
  Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
628
  Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
629

  
631 630
  Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
632 631
  Handle<JSObject> obj = factory->NewJSObject(function);
633
  obj->SetProperty(
634
      *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
632
  JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
635 633
  CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
636 634
  // Check that we can add properties to function objects.
637
  function->SetProperty(
638
      *prop_name, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked();
635
  JSReceiver::SetProperty(function, prop_name, twenty_four, NONE,
636
                          kNonStrictMode);
639 637
  CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name));
640 638
}
641 639

  
642 640

  
643 641
TEST(ObjectProperties) {
644 642
  CcTest::InitializeVM();
645
  Isolate* isolate = Isolate::Current();
643
  Isolate* isolate = CcTest::i_isolate();
646 644
  Factory* factory = isolate->factory();
647 645

  
648 646
  v8::HandleScope sc(CcTest::isolate());
649
  String* object_string = String::cast(HEAP->Object_string());
650
  Object* raw_object = Isolate::Current()->context()->global_object()->
647
  String* object_string = String::cast(CcTest::heap()->Object_string());
648
  Object* raw_object = CcTest::i_isolate()->context()->global_object()->
651 649
      GetProperty(object_string)->ToObjectChecked();
652 650
  JSFunction* object_function = JSFunction::cast(raw_object);
653 651
  Handle<JSFunction> constructor(object_function);
......
655 653
  Handle<String> first = factory->InternalizeUtf8String("first");
656 654
  Handle<String> second = factory->InternalizeUtf8String("second");
657 655

  
656
  Handle<Smi> one(Smi::FromInt(1), isolate);
657
  Handle<Smi> two(Smi::FromInt(2), isolate);
658

  
658 659
  // check for empty
659
  CHECK(!obj->HasLocalProperty(*first));
660
  CHECK(!JSReceiver::HasLocalProperty(obj, first));
660 661

  
661 662
  // add first
662
  obj->SetProperty(
663
      *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
664
  CHECK(obj->HasLocalProperty(*first));
663
  JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
664
  CHECK(JSReceiver::HasLocalProperty(obj, first));
665 665

  
666 666
  // delete first
667 667
  JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
668
  CHECK(!obj->HasLocalProperty(*first));
668
  CHECK(!JSReceiver::HasLocalProperty(obj, first));
669 669

  
670 670
  // add first and then second
671
  obj->SetProperty(
672
      *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
673
  obj->SetProperty(
674
      *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
675
  CHECK(obj->HasLocalProperty(*first));
676
  CHECK(obj->HasLocalProperty(*second));
671
  JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
672
  JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
673
  CHECK(JSReceiver::HasLocalProperty(obj, first));
674
  CHECK(JSReceiver::HasLocalProperty(obj, second));
677 675

  
678 676
  // delete first and then second
679 677
  JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
680
  CHECK(obj->HasLocalProperty(*second));
678
  CHECK(JSReceiver::HasLocalProperty(obj, second));
681 679
  JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
682
  CHECK(!obj->HasLocalProperty(*first));
683
  CHECK(!obj->HasLocalProperty(*second));
680
  CHECK(!JSReceiver::HasLocalProperty(obj, first));
681
  CHECK(!JSReceiver::HasLocalProperty(obj, second));
684 682

  
685 683
  // add first and then second
686
  obj->SetProperty(
687
      *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
688
  obj->SetProperty(
689
      *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
690
  CHECK(obj->HasLocalProperty(*first));
691
  CHECK(obj->HasLocalProperty(*second));
684
  JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
685
  JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
686
  CHECK(JSReceiver::HasLocalProperty(obj, first));
687
  CHECK(JSReceiver::HasLocalProperty(obj, second));
692 688

  
693 689
  // delete second and then first
694 690
  JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
695
  CHECK(obj->HasLocalProperty(*first));
691
  CHECK(JSReceiver::HasLocalProperty(obj, first));
696 692
  JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
697
  CHECK(!obj->HasLocalProperty(*first));
698
  CHECK(!obj->HasLocalProperty(*second));
693
  CHECK(!JSReceiver::HasLocalProperty(obj, first));
694
  CHECK(!JSReceiver::HasLocalProperty(obj, second));
699 695

  
700 696
  // check string and internalized string match
701 697
  const char* string1 = "fisk";
702 698
  Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
703
  obj->SetProperty(
704
      *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
699
  JSReceiver::SetProperty(obj, s1, one, NONE, kNonStrictMode);
705 700
  Handle<String> s1_string = factory->InternalizeUtf8String(string1);
706
  CHECK(obj->HasLocalProperty(*s1_string));
701
  CHECK(JSReceiver::HasLocalProperty(obj, s1_string));
707 702

  
708 703
  // check internalized string and string match
709 704
  const char* string2 = "fugl";
710 705
  Handle<String> s2_string = factory->InternalizeUtf8String(string2);
711
  obj->SetProperty(
712
      *s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
706
  JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode);
713 707
  Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
714
  CHECK(obj->HasLocalProperty(*s2));
708
  CHECK(JSReceiver::HasLocalProperty(obj, s2));
715 709
}
716 710

  
717 711

  
718 712
TEST(JSObjectMaps) {
719 713
  CcTest::InitializeVM();
720
  Isolate* isolate = Isolate::Current();
714
  Isolate* isolate = CcTest::i_isolate();
721 715
  Factory* factory = isolate->factory();
722 716

  
723 717
  v8::HandleScope sc(CcTest::isolate());
......
732 726
  Handle<JSObject> obj = factory->NewJSObject(function);
733 727

  
734 728
  // Set a propery
735
  obj->SetProperty(
736
      *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
729
  Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
730
  JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
737 731
  CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
738 732

  
739 733
  // Check the map has changed
......
743 737

  
744 738
TEST(JSArray) {
745 739
  CcTest::InitializeVM();
746
  Isolate* isolate = Isolate::Current();
740
  Isolate* isolate = CcTest::i_isolate();
747 741
  Factory* factory = isolate->factory();
748 742

  
749 743
  v8::HandleScope sc(CcTest::isolate());
750 744
  Handle<String> name = factory->InternalizeUtf8String("Array");
751
  Object* raw_object = Isolate::Current()->context()->global_object()->
745
  Object* raw_object = CcTest::i_isolate()->context()->global_object()->
752 746
      GetProperty(*name)->ToObjectChecked();
753 747
  Handle<JSFunction> function = Handle<JSFunction>(
754 748
      JSFunction::cast(raw_object));
......
792 786

  
793 787
TEST(JSObjectCopy) {
794 788
  CcTest::InitializeVM();
795
  Isolate* isolate = Isolate::Current();
789
  Isolate* isolate = CcTest::i_isolate();
796 790
  Factory* factory = isolate->factory();
797 791

  
798 792
  v8::HandleScope sc(CcTest::isolate());
799
  String* object_string = String::cast(HEAP->Object_string());
800
  Object* raw_object = Isolate::Current()->context()->global_object()->
793
  String* object_string = String::cast(CcTest::heap()->Object_string());
794
  Object* raw_object = CcTest::i_isolate()->context()->global_object()->
801 795
      GetProperty(object_string)->ToObjectChecked();
802 796
  JSFunction* object_function = JSFunction::cast(raw_object);
803 797
  Handle<JSFunction> constructor(object_function);
......
805 799
  Handle<String> first = factory->InternalizeUtf8String("first");
806 800
  Handle<String> second = factory->InternalizeUtf8String("second");
807 801

  
808
  obj->SetProperty(
809
      *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
810
  obj->SetProperty(
811
      *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
802
  Handle<Smi> one(Smi::FromInt(1), isolate);
803
  Handle<Smi> two(Smi::FromInt(2), isolate);
804

  
805
  JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
806
  JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
812 807

  
813 808
  obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked();
814 809
  obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked();
815 810

  
816 811
  // Make the clone.
817
  Handle<JSObject> clone = Copy(obj);
812
  Handle<JSObject> clone = JSObject::Copy(obj);
818 813
  CHECK(!clone.is_identical_to(obj));
819 814

  
820 815
  CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0));
......
824 819
  CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
825 820

  
826 821
  // Flip the values.
827
  clone->SetProperty(
828
      *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
829
  clone->SetProperty(
830
      *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
822
  JSReceiver::SetProperty(clone, first, two, NONE, kNonStrictMode);
823
  JSReceiver::SetProperty(clone, second, one, NONE, kNonStrictMode);
831 824

  
832 825
  clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked();
833 826
  clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
......
842 835

  
843 836
TEST(StringAllocation) {
844 837
  CcTest::InitializeVM();
845
  Isolate* isolate = Isolate::Current();
838
  Isolate* isolate = CcTest::i_isolate();
846 839
  Factory* factory = isolate->factory();
847 840

  
848 841
  const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
......
897 890

  
898 891
TEST(Iteration) {
899 892
  CcTest::InitializeVM();
900
  Isolate* isolate = Isolate::Current();
893
  Isolate* isolate = CcTest::i_isolate();
901 894
  Factory* factory = isolate->factory();
902 895
  v8::HandleScope scope(CcTest::isolate());
903 896

  
......
931 924
  objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map());
932 925

  
933 926
  CHECK_EQ(objs_count, next_objs_index);
934
  CHECK_EQ(objs_count, ObjectsFoundInHeap(HEAP, objs, objs_count));
927
  CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count));
935 928
}
936 929

  
937 930

  
......
959 952
TEST(Regression39128) {
960 953
  // Test case for crbug.com/39128.
961 954
  CcTest::InitializeVM();
962
  Isolate* isolate = Isolate::Current();
955
  Isolate* isolate = CcTest::i_isolate();
963 956
  Factory* factory = isolate->factory();
957
  Heap* heap = isolate->heap();
964 958

  
965 959
  // Increase the chance of 'bump-the-pointer' allocation in old space.
966
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
960
  heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
967 961

  
968 962
  v8::HandleScope scope(CcTest::isolate());
969 963

  
......
973 967

  
974 968
  // Step 1: prepare a map for the object.  We add 1 inobject property to it.
975 969
  Handle<JSFunction> object_ctor(
976
      Isolate::Current()->native_context()->object_function());
970
      CcTest::i_isolate()->native_context()->object_function());
977 971
  CHECK(object_ctor->has_initial_map());
978 972
  Handle<Map> object_map(object_ctor->initial_map());
979 973
  // Create a map with single inobject property.
......
989 983
  int allocation_amount = Min(FixedArray::kMaxSize,
990 984
                              Page::kMaxNonCodeHeapObjectSize + kPointerSize);
991 985
  int allocation_len = LenFromSize(allocation_amount);
992
  NewSpace* new_space = HEAP->new_space();
986
  NewSpace* new_space = heap->new_space();
993 987
  Address* top_addr = new_space->allocation_top_address();
994 988
  Address* limit_addr = new_space->allocation_limit_address();
995 989
  while ((*limit_addr - *top_addr) > allocation_amount) {
996
    CHECK(!HEAP->always_allocate());
997
    Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked();
990
    CHECK(!heap->always_allocate());
991
    Object* array = heap->AllocateFixedArray(allocation_len)->ToObjectChecked();
998 992
    CHECK(!array->IsFailure());
999 993
    CHECK(new_space->Contains(array));
1000 994
  }
......
1004 998
  int fixed_array_len = LenFromSize(to_fill);
1005 999
  CHECK(fixed_array_len < FixedArray::kMaxLength);
1006 1000

  
1007
  CHECK(!HEAP->always_allocate());
1008
  Object* array = HEAP->AllocateFixedArray(fixed_array_len)->ToObjectChecked();
1001
  CHECK(!heap->always_allocate());
1002
  Object* array = heap->AllocateFixedArray(fixed_array_len)->ToObjectChecked();
1009 1003
  CHECK(!array->IsFailure());
1010 1004
  CHECK(new_space->Contains(array));
1011 1005

  
1012
  Object* object = HEAP->AllocateJSObjectFromMap(*my_map)->ToObjectChecked();
1006
  Object* object = heap->AllocateJSObjectFromMap(*my_map)->ToObjectChecked();
1013 1007
  CHECK(new_space->Contains(object));
1014 1008
  JSObject* jsobject = JSObject::cast(object);
1015 1009
  CHECK_EQ(0, FixedArray::cast(jsobject->elements())->length());
......
1021 1015

  
1022 1016
  // Step 4: clone jsobject, but force always allocate first to create a clone
1023 1017
  // in old pointer space.
1024
  Address old_pointer_space_top = HEAP->old_pointer_space()->top();
1018
  Address old_pointer_space_top = heap->old_pointer_space()->top();
1025 1019
  AlwaysAllocateScope aa_scope;
1026
  Object* clone_obj = HEAP->CopyJSObject(jsobject)->ToObjectChecked();
1020
  Object* clone_obj = heap->CopyJSObject(jsobject)->ToObjectChecked();
1027 1021
  JSObject* clone = JSObject::cast(clone_obj);
1028 1022
  if (clone->address() != old_pointer_space_top) {
1029 1023
    // Alas, got allocated from free list, we cannot do checks.
1030 1024
    return;
1031 1025
  }
1032
  CHECK(HEAP->old_pointer_space()->Contains(clone->address()));
1026
  CHECK(heap->old_pointer_space()->Contains(clone->address()));
1033 1027
}
1034 1028

  
1035 1029

  
......
1037 1031
  // If we do not flush code this test is invalid.
1038 1032
  if (!FLAG_flush_code) return;
1039 1033
  i::FLAG_allow_natives_syntax = true;
1034
  i::FLAG_optimize_for_size = false;
1040 1035
  CcTest::InitializeVM();
1041
  Isolate* isolate = Isolate::Current();
1036
  Isolate* isolate = CcTest::i_isolate();
1042 1037
  Factory* factory = isolate->factory();
1043 1038
  v8::HandleScope scope(CcTest::isolate());
1044 1039
  const char* source = "function foo() {"
......
1055 1050
  }
1056 1051

  
1057 1052
  // Check function is compiled.
1058
  Object* func_value = Isolate::Current()->context()->global_object()->
1053
  Object* func_value = CcTest::i_isolate()->context()->global_object()->
1059 1054
      GetProperty(*foo_name)->ToObjectChecked();
1060 1055
  CHECK(func_value->IsJSFunction());
1061 1056
  Handle<JSFunction> function(JSFunction::cast(func_value));
1062 1057
  CHECK(function->shared()->is_compiled());
1063 1058

  
1064 1059
  // The code will survive at least two GCs.
1065
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1066
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1060
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1061
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1062
  CHECK(function->shared()->is_compiled());
1063

  
1064
  // Simulate several GCs that use full marking.
1065
  const int kAgingThreshold = 6;
1066
  for (int i = 0; i < kAgingThreshold; i++) {
1067
    CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1068
  }
1069

  
1070
  // foo should no longer be in the compilation cache
1071
  CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1072
  CHECK(!function->is_compiled() || function->IsOptimized());
1073
  // Call foo to get it recompiled.
1074
  CompileRun("foo()");
1075
  CHECK(function->shared()->is_compiled());
1076
  CHECK(function->is_compiled());
1077
}
1078

  
1079

  
1080
TEST(TestCodeFlushingPreAged) {
1081
  // If we do not flush code this test is invalid.
1082
  if (!FLAG_flush_code) return;
1083
  i::FLAG_allow_natives_syntax = true;
1084
  i::FLAG_optimize_for_size = true;
1085
  CcTest::InitializeVM();
1086
  Isolate* isolate = Isolate::Current();
1087
  Factory* factory = isolate->factory();
1088
  v8::HandleScope scope(CcTest::isolate());
1089
  const char* source = "function foo() {"
1090
                       "  var x = 42;"
1091
                       "  var y = 42;"
1092
                       "  var z = x + y;"
1093
                       "};"
1094
                       "foo()";
1095
  Handle<String> foo_name = factory->InternalizeUtf8String("foo");
1096

  
1097
  // Compile foo, but don't run it.
1098
  { v8::HandleScope scope(CcTest::isolate());
1099
    CompileRun(source);
1100
  }
1101

  
1102
  // Check function is compiled.
1103
  Object* func_value = Isolate::Current()->context()->global_object()->
1104
      GetProperty(*foo_name)->ToObjectChecked();
1105
  CHECK(func_value->IsJSFunction());
1106
  Handle<JSFunction> function(JSFunction::cast(func_value));
1107
  CHECK(function->shared()->is_compiled());
1108

  
1109
  // The code has been run so will survive at least one GC.
1110
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1111
  CHECK(function->shared()->is_compiled());
1112

  
1113
  // The code was only run once, so it should be pre-aged and collected on the
1114
  // next GC.
1115
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1116
  CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1117

  
1118
  // Execute the function again twice, and ensure it is reset to the young age.
1119
  { v8::HandleScope scope(CcTest::isolate());
1120
    CompileRun("foo();"
1121
               "foo();");
1122
  }
1123

  
1124
  // The code will survive at least two GC now that it is young again.
1125
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1126
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1067 1127
  CHECK(function->shared()->is_compiled());
1068 1128

  
1069 1129
  // Simulate several GCs that use full marking.
1070 1130
  const int kAgingThreshold = 6;
1071 1131
  for (int i = 0; i < kAgingThreshold; i++) {
1072
    HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1132
    CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1073 1133
  }
1074 1134

  
1075 1135
  // foo should no longer be in the compilation cache
......
1086 1146
  // If we do not flush code this test is invalid.
1087 1147
  if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1088 1148
  i::FLAG_allow_natives_syntax = true;
1149
  i::FLAG_optimize_for_size = false;
1089 1150
  CcTest::InitializeVM();
1090
  Isolate* isolate = Isolate::Current();
1151
  Isolate* isolate = CcTest::i_isolate();
1091 1152
  Factory* factory = isolate->factory();
1092 1153
  v8::HandleScope scope(CcTest::isolate());
1093 1154
  const char* source = "function foo() {"
......
1104 1165
  }
1105 1166

  
1106 1167
  // Check function is compiled.
1107
  Object* func_value = Isolate::Current()->context()->global_object()->
1168
  Object* func_value = CcTest::i_isolate()->context()->global_object()->
1108 1169
      GetProperty(*foo_name)->ToObjectChecked();
1109 1170
  CHECK(func_value->IsJSFunction());
1110 1171
  Handle<JSFunction> function(JSFunction::cast(func_value));
1111 1172
  CHECK(function->shared()->is_compiled());
1112 1173

  
1113 1174
  // The code will survive at least two GCs.
1114
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1115
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1175
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1176
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1116 1177
  CHECK(function->shared()->is_compiled());
1117 1178

  
1118 1179
  // Simulate several GCs that use incremental marking.
1119 1180
  const int kAgingThreshold = 6;
1120 1181
  for (int i = 0; i < kAgingThreshold; i++) {
1121 1182
    SimulateIncrementalMarking();
1122
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1183
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1123 1184
  }
1124 1185
  CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1125 1186
  CHECK(!function->is_compiled() || function->IsOptimized());
......
1134 1195
  for (int i = 0; i < kAgingThreshold; i++) {
1135 1196
    SimulateIncrementalMarking();
1136 1197
    if (!function->next_function_link()->IsUndefined()) break;
1137
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1198
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1138 1199
  }
1139 1200

  
1140 1201
  // Force optimization while incremental marking is active and while
......
1144 1205
  }
1145 1206

  
1146 1207
  // Simulate one final GC to make sure the candidate queue is sane.
1147
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1208
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1148 1209
  CHECK(function->shared()->is_compiled() || !function->IsOptimized());
1149 1210
  CHECK(function->is_compiled() || !function->IsOptimized());
1150 1211
}
......
1154 1215
  // If we do not flush code this test is invalid.
1155 1216
  if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1156 1217
  i::FLAG_allow_natives_syntax = true;
1218
  i::FLAG_optimize_for_size = false;
1157 1219
  CcTest::InitializeVM();
1158
  Isolate* isolate = Isolate::Current();
1220
  Isolate* isolate = CcTest::i_isolate();
1159 1221
  Factory* factory = isolate->factory();
1160 1222
  v8::HandleScope scope(CcTest::isolate());
1161 1223
  const char* source = "var foo = function() {"
......
1172 1234
  Handle<String> bar_name = factory->InternalizeUtf8String("bar");
1173 1235

  
1174 1236
  // Perfrom one initial GC to enable code flushing.
1175
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1237
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1176 1238

  
1177 1239
  // This compile will add the code to the compilation cache.
1178 1240
  { v8::HandleScope scope(CcTest::isolate());
......
1180 1242
  }
1181 1243

  
1182 1244
  // Check functions are compiled.
1183
  Object* func_value = Isolate::Current()->context()->global_object()->
1245
  Object* func_value = CcTest::i_isolate()->context()->global_object()->
1184 1246
      GetProperty(*foo_name)->ToObjectChecked();
1185 1247
  CHECK(func_value->IsJSFunction());
1186 1248
  Handle<JSFunction> function(JSFunction::cast(func_value));
1187 1249
  CHECK(function->shared()->is_compiled());
1188
  Object* func_value2 = Isolate::Current()->context()->global_object()->
1250
  Object* func_value2 = CcTest::i_isolate()->context()->global_object()->
1189 1251
      GetProperty(*bar_name)->ToObjectChecked();
1190 1252
  CHECK(func_value2->IsJSFunction());
1191 1253
  Handle<JSFunction> function2(JSFunction::cast(func_value2));
......
1209 1271
  // perform a scavenge while incremental marking is still running.
1210 1272
  SimulateIncrementalMarking();
1211 1273
  *function2.location() = NULL;
1212
  HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking");
1274
  CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking");
1213 1275

  
1214 1276
  // Simulate one final GC to make sure the candidate queue is sane.
1215
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1277
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1216 1278
  CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1217 1279
  CHECK(!function->is_compiled() || function->IsOptimized());
1218 1280
}
......
1222 1284
  // If we do not flush code this test is invalid.
1223 1285
  if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1224 1286
  i::FLAG_allow_natives_syntax = true;
1287
  i::FLAG_optimize_for_size = false;
1225 1288
  CcTest::InitializeVM();
1226
  Isolate* isolate = Isolate::Current();
1289
  Isolate* isolate = CcTest::i_isolate();
1227 1290
  Factory* factory = isolate->factory();
1228 1291
  Heap* heap = isolate->heap();
1229 1292
  v8::HandleScope scope(CcTest::isolate());
......
1241 1304
  }
1242 1305

  
1243 1306
  // Check function is compiled.
1244
  Object* func_value = Isolate::Current()->context()->global_object()->
1307
  Object* func_value = CcTest::i_isolate()->context()->global_object()->
1245 1308
      GetProperty(*foo_name)->ToObjectChecked();
1246 1309
  CHECK(func_value->IsJSFunction());
1247 1310
  Handle<JSFunction> function(JSFunction::cast(func_value));
......
1287 1350
// Count the number of native contexts in the weak list of native contexts.
1288 1351
int CountNativeContexts() {
1289 1352
  int count = 0;
1290
  Object* object = HEAP->native_contexts_list();
1353
  Object* object = CcTest::heap()->native_contexts_list();
1291 1354
  while (!object->IsUndefined()) {
1292 1355
    count++;
1293 1356
    object = Context::cast(object)->get(Context::NEXT_CONTEXT_LINK);
......
1319 1382

  
1320 1383
  static const int kNumTestContexts = 10;
1321 1384

  
1322
  Isolate* isolate = Isolate::Current();
1385
  Isolate* isolate = CcTest::i_isolate();
1323 1386
  Heap* heap = isolate->heap();
1324 1387
  HandleScope scope(isolate);
1325 1388
  v8::Handle<v8::Context> ctx[kNumTestContexts];
......
1328 1391

  
1329 1392
  // Create a number of global contests which gets linked together.
1330 1393
  for (int i = 0; i < kNumTestContexts; i++) {
1331
    ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1394
    ctx[i] = v8::Context::New(CcTest::isolate());
1332 1395

  
1333 1396
    // Collect garbage that might have been created by one of the
1334 1397
    // installed extensions.
......
1367 1430

  
1368 1431
    // Scavenge treats these references as strong.
1369 1432
    for (int j = 0; j < 10; j++) {
1370
      HEAP->PerformScavenge();
1433
      CcTest::heap()->PerformScavenge();
1371 1434
      CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i]));
1372 1435
    }
1373 1436

  
......
1379 1442
    // Get rid of f3 and f5 in the same way.
1380 1443
    CompileRun("f3=null");
1381 1444
    for (int j = 0; j < 10; j++) {
1382
      HEAP->PerformScavenge();
1445
      CcTest::heap()->PerformScavenge();
1383 1446
      CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1384 1447
    }
1385
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1448
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1386 1449
    CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i]));
1387 1450
    CompileRun("f5=null");
1388 1451
    for (int j = 0; j < 10; j++) {
1389
      HEAP->PerformScavenge();
1452
      CcTest::heap()->PerformScavenge();
1390 1453
      CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i]));
1391 1454
    }
1392
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1455
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1393 1456
    CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i]));
1394 1457

  
1395 1458
    ctx[i]->Exit();
1396 1459
  }
1397 1460

  
1398 1461
  // Force compilation cache cleanup.
1399
  HEAP->NotifyContextDisposed();
1400
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1462
  CcTest::heap()->NotifyContextDisposed();
1463
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1401 1464

  
1402 1465
  // Dispose the native contexts one by one.
1403 1466
  for (int i = 0; i < kNumTestContexts; i++) {
1404 1467
    // TODO(dcarney): is there a better way to do this?
1405 1468
    i::Object** unsafe = reinterpret_cast<i::Object**>(*ctx[i]);
1406
    *unsafe = HEAP->undefined_value();
1469
    *unsafe = CcTest::heap()->undefined_value();
1407 1470
    ctx[i].Clear();
1408 1471

  
1409 1472
    // Scavenge treats these references as strong.
1410 1473
    for (int j = 0; j < 10; j++) {
1411
      HEAP->PerformScavenge();
1474
      CcTest::heap()->PerformScavenge();
1412 1475
      CHECK_EQ(kNumTestContexts - i, CountNativeContexts());
1413 1476
    }
1414 1477

  
1415 1478
    // Mark compact handles the weak references.
1416
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1479
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1417 1480
    CHECK_EQ(kNumTestContexts - i - 1, CountNativeContexts());
1418 1481
  }
1419 1482

  
......
1462 1525

  
1463 1526
TEST(TestInternalWeakListsTraverseWithGC) {
1464 1527
  v8::V8::Initialize();
1465
  Isolate* isolate = Isolate::Current();
1528
  Isolate* isolate = CcTest::i_isolate();
1466 1529

  
1467 1530
  static const int kNumTestContexts = 10;
1468 1531

  
......
1474 1537
  // Create an number of contexts and check the length of the weak list both
1475 1538
  // with and without GCs while iterating the list.
1476 1539
  for (int i = 0; i < kNumTestContexts; i++) {
1477
    ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1540
    ctx[i] = v8::Context::New(CcTest::isolate());
1478 1541
    CHECK_EQ(i + 1, CountNativeContexts());
1479 1542
    CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1));
1480 1543
  }
......
1516 1579

  
1517 1580
  // Get initial heap size after several full GCs, which will stabilize
1518 1581
  // the heap size and return with sweeping finished completely.
1519
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1520
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1521
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1522
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1523
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1524
  CHECK(HEAP->old_pointer_space()->IsLazySweepingComplete());
1525
  int initial_size = static_cast<int>(HEAP->SizeOfObjects());
1582
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1583
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1584
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1585
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1586
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1587
  CHECK(CcTest::heap()->old_pointer_space()->IsLazySweepingComplete());
1588
  int initial_size = static_cast<int>(CcTest::heap()->SizeOfObjects());
1526 1589

  
1527 1590
  {
1528 1591
    // Allocate objects on several different old-space pages so that
......
1530 1593
    AlwaysAllocateScope always_allocate;
1531 1594
    int filler_size = static_cast<int>(FixedArray::SizeFor(8192));
1532 1595
    for (int i = 1; i <= 100; i++) {
1533
      HEAP->AllocateFixedArray(8192, TENURED)->ToObjectChecked();
1596
      CcTest::heap()->AllocateFixedArray(8192, TENURED)->ToObjectChecked();
1534 1597
      CHECK_EQ(initial_size + i * filler_size,
1535
               static_cast<int>(HEAP->SizeOfObjects()));
1598
               static_cast<int>(CcTest::heap()->SizeOfObjects()));
1536 1599
    }
1537 1600
  }
1538 1601

  
1539 1602
  // The heap size should go back to initial size after a full GC, even
1540 1603
  // though sweeping didn't finish yet.
1541
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1604
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1542 1605

  
1543 1606
  // Normally sweeping would not be complete here, but no guarantees.
1544 1607

  
1545
  CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
1608
  CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1546 1609

  
1547 1610
  // Advancing the sweeper step-wise should not change the heap size.
1548
  while (!HEAP->old_pointer_space()->IsLazySweepingComplete()) {
1549
    HEAP->old_pointer_space()->AdvanceSweeper(KB);
1550
    CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
1611
  while (!CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()) {
1612
    CcTest::heap()->old_pointer_space()->AdvanceSweeper(KB);
1613
    CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1551 1614
  }
1552 1615
}
1553 1616

  
1554 1617

  
1555 1618
TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
1556 1619
  CcTest::InitializeVM();
1557
  HEAP->EnsureHeapIsIterable();
1558
  intptr_t size_of_objects_1 = HEAP->SizeOfObjects();
1559
  HeapIterator iterator(HEAP);
1620
  CcTest::heap()->EnsureHeapIsIterable();
1621
  intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects();
1622
  HeapIterator iterator(CcTest::heap());
1560 1623
  intptr_t size_of_objects_2 = 0;
1561 1624
  for (HeapObject* obj = iterator.next();
1562 1625
       obj != NULL;
......
1605 1668

  
1606 1669
TEST(GrowAndShrinkNewSpace) {
1607 1670
  CcTest::InitializeVM();
1608
  NewSpace* new_space = HEAP->new_space();
1671
  Heap* heap = CcTest::heap();
1672
  NewSpace* new_space = heap->new_space();
1609 1673

  
1610
  if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() ||
1611
      HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1674
  if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() ||
1675
      heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
1612 1676
    // The max size cannot exceed the reserved size, since semispaces must be
1613 1677
    // always within the reserved space.  We can't test new space growing and
1614 1678
    // shrinking if the reserved size is the same as the minimum (initial) size.
......
1634 1698
  CHECK(old_capacity == new_capacity);
1635 1699

  
1636 1700
  // Let the scavenger empty the new space.
1637
  HEAP->CollectGarbage(NEW_SPACE);
1701
  heap->CollectGarbage(NEW_SPACE);
1638 1702
  CHECK_LE(new_space->Size(), old_capacity);
1639 1703

  
1640 1704
  // Explicitly shrinking should halve the space capacity.
......
1655 1719

  
1656 1720
TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
1657 1721
  CcTest::InitializeVM();
1658

  
1659
  if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() ||
1660
      HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1722
  Heap* heap = CcTest::heap();
1723
  if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() ||
1724
      heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
1661 1725
    // The max size cannot exceed the reserved size, since semispaces must be
1662 1726
    // always within the reserved space.  We can't test new space growing and
1663 1727
    // shrinking if the reserved size is the same as the minimum (initial) size.
......
1665 1729
  }
1666 1730

  
1667 1731
  v8::HandleScope scope(CcTest::isolate());
1668
  NewSpace* new_space = HEAP->new_space();
1732
  NewSpace* new_space = heap->new_space();
1669 1733
  intptr_t old_capacity, new_capacity;
1670 1734
  old_capacity = new_space->Capacity();
1671 1735
  new_space->Grow();
1672 1736
  new_capacity = new_space->Capacity();
1673 1737
  CHECK(2 * old_capacity == new_capacity);
1674 1738
  FillUpNewSpace(new_space);
1675
  HEAP->CollectAllAvailableGarbage();
1739
  heap->CollectAllAvailableGarbage();
1676 1740
  new_capacity = new_space->Capacity();
1677 1741
  CHECK(old_capacity == new_capacity);
1678 1742
}
......
1680 1744

  
1681 1745
static int NumberOfGlobalObjects() {
1682 1746
  int count = 0;
1683
  HeapIterator iterator(HEAP);
1747
  HeapIterator iterator(CcTest::heap());
1684 1748
  for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
1685 1749
    if (obj->IsGlobalObject()) count++;
1686 1750
  }
......
1692 1756
// optimized code.
1693 1757
TEST(LeakNativeContextViaMap) {
1694 1758
  i::FLAG_allow_natives_syntax = true;
1695
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
1759
  v8::Isolate* isolate = CcTest::isolate();
1696 1760
  v8::HandleScope outer_scope(isolate);
1697 1761
  v8::Persistent<v8::Context> ctx1p;
1698 1762
  v8::Persistent<v8::Context> ctx2p;
......
1703 1767
    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
1704 1768
  }
1705 1769

  
1706
  HEAP->CollectAllAvailableGarbage();
1770
  CcTest::heap()->CollectAllAvailableGarbage();
1707 1771
  CHECK_EQ(4, NumberOfGlobalObjects());
1708 1772

  
1709 1773
  {
......
1726 1790
    ctx1p.Dispose();
1727 1791
    v8::V8::ContextDisposedNotification();
1728 1792
  }
1729
  HEAP->CollectAllAvailableGarbage();
1793
  CcTest::heap()->CollectAllAvailableGarbage();
1730 1794
  CHECK_EQ(2, NumberOfGlobalObjects());
1731 1795
  ctx2p.Dispose();
1732
  HEAP->CollectAllAvailableGarbage();
1796
  CcTest::heap()->CollectAllAvailableGarbage();
1733 1797
  CHECK_EQ(0, NumberOfGlobalObjects());
1734 1798
}
1735 1799

  
......
1738 1802
// optimized code.
1739 1803
TEST(LeakNativeContextViaFunction) {
1740 1804
  i::FLAG_allow_natives_syntax = true;
1741
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
1805
  v8::Isolate* isolate = CcTest::isolate();
1742 1806
  v8::HandleScope outer_scope(isolate);
1743 1807
  v8::Persistent<v8::Context> ctx1p;
1744 1808
  v8::Persistent<v8::Context> ctx2p;
......
1749 1813
    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
1750 1814
  }
1751 1815

  
1752
  HEAP->CollectAllAvailableGarbage();
1816
  CcTest::heap()->CollectAllAvailableGarbage();
1753 1817
  CHECK_EQ(4, NumberOfGlobalObjects());
1754 1818

  
1755 1819
  {
......
1772 1836
    ctx1p.Dispose();
1773 1837
    v8::V8::ContextDisposedNotification();
1774 1838
  }
1775
  HEAP->CollectAllAvailableGarbage();
1839
  CcTest::heap()->CollectAllAvailableGarbage();
1776 1840
  CHECK_EQ(2, NumberOfGlobalObjects());
1777 1841
  ctx2p.Dispose();
1778
  HEAP->CollectAllAvailableGarbage();
1842
  CcTest::heap()->CollectAllAvailableGarbage();
1779 1843
  CHECK_EQ(0, NumberOfGlobalObjects());
1780 1844
}
1781 1845

  
1782 1846

  
1783 1847
TEST(LeakNativeContextViaMapKeyed) {
1784 1848
  i::FLAG_allow_natives_syntax = true;
1785
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
1849
  v8::Isolate* isolate = CcTest::isolate();
1786 1850
  v8::HandleScope outer_scope(isolate);
1787 1851
  v8::Persistent<v8::Context> ctx1p;
1788 1852
  v8::Persistent<v8::Context> ctx2p;
......
1793 1857
    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
1794 1858
  }
1795 1859

  
1796
  HEAP->CollectAllAvailableGarbage();
1860
  CcTest::heap()->CollectAllAvailableGarbage();
1797 1861
  CHECK_EQ(4, NumberOfGlobalObjects());
1798 1862

  
1799 1863
  {
......
1816 1880
    ctx1p.Dispose();
1817 1881
    v8::V8::ContextDisposedNotification();
1818 1882
  }
1819
  HEAP->CollectAllAvailableGarbage();
1883
  CcTest::heap()->CollectAllAvailableGarbage();
1820 1884
  CHECK_EQ(2, NumberOfGlobalObjects());
1821 1885
  ctx2p.Dispose();
1822
  HEAP->CollectAllAvailableGarbage();
1886
  CcTest::heap()->CollectAllAvailableGarbage();
1823 1887
  CHECK_EQ(0, NumberOfGlobalObjects());
1824 1888
}
1825 1889

  
1826 1890

  
1827 1891
TEST(LeakNativeContextViaMapProto) {
1828 1892
  i::FLAG_allow_natives_syntax = true;
1829
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
1893
  v8::Isolate* isolate = CcTest::isolate();
1830 1894
  v8::HandleScope outer_scope(isolate);
1831 1895
  v8::Persistent<v8::Context> ctx1p;
1832 1896
  v8::Persistent<v8::Context> ctx2p;
......
1837 1901
    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
1838 1902
  }
1839 1903

  
1840
  HEAP->CollectAllAvailableGarbage();
1904
  CcTest::heap()->CollectAllAvailableGarbage();
1841 1905
  CHECK_EQ(4, NumberOfGlobalObjects());
1842 1906

  
1843 1907
  {
......
1864 1928
    ctx1p.Dispose();
1865 1929
    v8::V8::ContextDisposedNotification();
1866 1930
  }
1867
  HEAP->CollectAllAvailableGarbage();
1931
  CcTest::heap()->CollectAllAvailableGarbage();
1868 1932
  CHECK_EQ(2, NumberOfGlobalObjects());
1869 1933
  ctx2p.Dispose();
1870
  HEAP->CollectAllAvailableGarbage();
1934
  CcTest::heap()->CollectAllAvailableGarbage();
1871 1935
  CHECK_EQ(0, NumberOfGlobalObjects());
1872 1936
}
1873 1937

  
......
1879 1943
#endif
1880 1944

  
1881 1945
  CcTest::InitializeVM();
1882
  if (!i::Isolate::Current()->use_crankshaft()) return;
1946
  if (!CcTest::i_isolate()->use_crankshaft()) return;
1883 1947
  if (i::FLAG_force_marking_deque_overflows) return;
1884
  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1948
  v8::HandleScope outer_scope(CcTest::isolate());
1885 1949

  
1886 1950
  {
1887
    v8::HandleScope scope(v8::Isolate::GetCurrent());
1951
    v8::HandleScope scope(CcTest::isolate());
1888 1952
    CompileRun(
1889 1953
        "function foo () { }"
1890 1954
        "function mkbar () { return new (new Function(\"\")) (); }"
......
1895 1959
        "f(new foo()); g();");
1896 1960
  }
1897 1961

  
1898
  IncrementalMarking* marking = HEAP->incremental_marking();
1962
  IncrementalMarking* marking = CcTest::heap()->incremental_marking();
1899 1963
  marking->Abort();
1900 1964
  marking->Start();
1901 1965

  
1902 1966
  Handle<JSFunction> f =
1903 1967
      v8::Utils::OpenHandle(
1904 1968
          *v8::Handle<v8::Function>::Cast(
1905
              v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
1969
              CcTest::global()->Get(v8_str("f"))));
1906 1970

  
1907 1971
  CHECK(f->IsOptimized());
1908 1972

  
......
1916 1980
  CHECK(marking->IsMarking());
1917 1981

  
1918 1982
  {
1919
    v8::HandleScope scope(v8::Isolate::GetCurrent());
1920
    v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global();
1983
    v8::HandleScope scope(CcTest::isolate());
1984
    v8::Handle<v8::Object> global = CcTest::global();
1921 1985
    v8::Handle<v8::Function> g =
1922 1986
        v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
1923 1987
    g->Call(global, 0, NULL);
1924 1988
  }
1925 1989

  
1926
  HEAP->incremental_marking()->set_should_hurry(true);
1927
  HEAP->CollectGarbage(OLD_POINTER_SPACE);
1990
  CcTest::heap()->incremental_marking()->set_should_hurry(true);
1991
  CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
1928 1992
}
1929 1993

  
1930 1994

  
1931 1995
TEST(PrototypeTransitionClearing) {
1932 1996
  CcTest::InitializeVM();
1933
  Isolate* isolate = Isolate::Current();
1997
  Isolate* isolate = CcTest::i_isolate();
1934 1998
  Factory* factory = isolate->factory();
1935 1999
  v8::HandleScope scope(CcTest::isolate());
1936 2000

  
......
1947 2011
  Handle<JSObject> baseObject =
1948 2012
      v8::Utils::OpenHandle(
1949 2013
          *v8::Handle<v8::Object>::Cast(
1950
              v8::Context::GetCurrent()->Global()->Get(v8_str("base"))));
2014
              CcTest::global()->Get(v8_str("base"))));
1951 2015

  
1952 2016
  // Verify that only dead prototype transitions are cleared.
1953 2017
  CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
1954
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2018
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1955 2019
  const int transitions = 10 - 3;
1956 2020
  CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
1957 2021

  
......
1967 2031

  
1968 2032
  // Make sure next prototype is placed on an old-space evacuation candidate.
1969 2033
  Handle<JSObject> prototype;
1970
  PagedSpace* space = HEAP->old_pointer_space();
2034
  PagedSpace* space = CcTest::heap()->old_pointer_space();
1971 2035
  {
1972 2036
    AlwaysAllocateScope always_allocate;
1973 2037
    SimulateFullSpace(space);
......
1983 2047
  CHECK(space->LastPage()->Contains(prototype->address()));
1984 2048
  JSObject::SetPrototype(baseObject, prototype, false);
1985 2049
  CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
1986
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2050
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1987 2051
  CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
1988 2052
}
1989 2053

  
......
1996 2060
#endif
1997 2061

  
1998 2062
  CcTest::InitializeVM();
1999
  if (!i::Isolate::Current()->use_crankshaft()) return;
2000
  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
2063
  if (!CcTest::i_isolate()->use_crankshaft()) return;
2064
  v8::HandleScope outer_scope(CcTest::isolate());
2001 2065

  
2002 2066
  {
2003
    v8::HandleScope scope(v8::Isolate::GetCurrent());
2067
    v8::HandleScope scope(CcTest::isolate());
2004 2068
    CompileRun(
2005 2069
        "function f () {"
2006 2070
        "  var s = 0;"
......
2014 2078
  Handle<JSFunction> f =
2015 2079
      v8::Utils::OpenHandle(
2016 2080
          *v8::Handle<v8::Function>::Cast(
2017
              v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2081
              CcTest::global()->Get(v8_str("f"))));
2018 2082
  CHECK(f->IsOptimized());
2019 2083

  
2020
  IncrementalMarking* marking = HEAP->incremental_marking();
2084
  IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2021 2085
  marking->Abort();
2022 2086
  marking->Start();
2023 2087

  
2024
  // The following two calls will increment HEAP->global_ic_age().
2088
  // The following two calls will increment CcTest::heap()->global_ic_age().
2025 2089
  const int kLongIdlePauseInMs = 1000;
2026 2090
  v8::V8::ContextDisposedNotification();
2027 2091
  v8::V8::IdleNotification(kLongIdlePauseInMs);
......
2035 2099
    // guard interrupt.  But here we didn't ask for that, and there is no
2036 2100
    // JS code running to trigger the interrupt, so we explicitly finalize
2037 2101
    // here.
2038
    HEAP->CollectAllGarbage(Heap::kNoGCFlags,
2102
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags,
2039 2103
                            "Test finalizing incremental mark-sweep");
2040 2104
  }
2041 2105

  
2042
  CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
2106
  CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2043 2107
  CHECK_EQ(0, f->shared()->opt_count());
2044 2108
  CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2045 2109
}
......
2053 2117
#endif
2054 2118

  
2055 2119
  CcTest::InitializeVM();
2056
  if (!i::Isolate::Current()->use_crankshaft()) return;
2120
  if (!CcTest::i_isolate()->use_crankshaft()) return;
2057 2121
  v8::HandleScope outer_scope(CcTest::isolate());
2058 2122

  
2059 2123
  {
......
2071 2135
  Handle<JSFunction> f =
2072 2136
      v8::Utils::OpenHandle(
2073 2137
          *v8::Handle<v8::Function>::Cast(
2074
              v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2138
              CcTest::global()->Get(v8_str("f"))));
2075 2139
  CHECK(f->IsOptimized());
2076 2140

  
2077
  HEAP->incremental_marking()->Abort();
2141
  CcTest::heap()->incremental_marking()->Abort();
2078 2142

  
2079
  // The following two calls will increment HEAP->global_ic_age().
2143
  // The following two calls will increment CcTest::heap()->global_ic_age().
2080 2144
  // Since incremental marking is off, IdleNotification will do full GC.
2081 2145
  const int kLongIdlePauseInMs = 1000;
2082 2146
  v8::V8::ContextDisposedNotification();
2083 2147
  v8::V8::IdleNotification(kLongIdlePauseInMs);
2084 2148

  
2085
  CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
2149
  CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2086 2150
  CHECK_EQ(0, f->shared()->opt_count());
2087 2151
  CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2088 2152
}
......
2092 2156
TEST(OptimizedAllocationAlwaysInNewSpace) {
2093 2157
  i::FLAG_allow_natives_syntax = true;
2094 2158
  CcTest::InitializeVM();
2095
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2159
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2096 2160
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2097 2161
  v8::HandleScope scope(CcTest::isolate());
2098 2162

  
2099
  SimulateFullSpace(HEAP->new_space());
2163
  SimulateFullSpace(CcTest::heap()->new_space());
2100 2164
  AlwaysAllocateScope always_allocate;
2101 2165
  v8::Local<v8::Value> res = CompileRun(
2102 2166
      "function c(x) {"
......
2114 2178
  Handle<JSObject> o =
2115 2179
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2116 2180

  
2117
  CHECK(HEAP->InNewSpace(*o));
2181
  CHECK(CcTest::heap()->InNewSpace(*o));
2118 2182
}
2119 2183

  
2120 2184

  
2121 2185
TEST(OptimizedPretenuringAllocationFolding) {
2122 2186
  i::FLAG_allow_natives_syntax = true;
2123 2187
  CcTest::InitializeVM();
2124
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2188
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2125 2189
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2126 2190
  v8::HandleScope scope(CcTest::isolate());
2127
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2191
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2128 2192

  
2129 2193
  v8::Local<v8::Value> res = CompileRun(
2130 2194
      "function DataObject() {"
......
2145 2209
  Handle<JSObject> o =
2146 2210
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2147 2211

  
2148
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(0)));
2149
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1)));
2150
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2151
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3)));
2152
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4)));
2153
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5)));
2212
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0)));
2213
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
2214
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
2215
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3)));
2216
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4)));
2217
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5)));
2154 2218
}
2155 2219

  
2156 2220

  
2157 2221
TEST(OptimizedPretenuringAllocationFoldingBlocks) {
2158 2222
  i::FLAG_allow_natives_syntax = true;
2159 2223
  CcTest::InitializeVM();
2160
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2224
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2161 2225
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2162 2226
  v8::HandleScope scope(CcTest::isolate());
2163
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2227
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2164 2228

  
2165 2229
  v8::Local<v8::Value> res = CompileRun(
2166 2230
      "function DataObject() {"
......
2181 2245
  Handle<JSObject> o =
2182 2246
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2183 2247

  
2184
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0)));
2185
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1)));
2186
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2187
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3)));
2188
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4)));
2189
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5)));
2248
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
2249
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
2250
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
2251
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3)));
2252
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4)));
2253
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5)));
2190 2254
}
2191 2255

  
2192 2256

  
2193 2257
TEST(OptimizedPretenuringObjectArrayLiterals) {
2194 2258
  i::FLAG_allow_natives_syntax = true;
2195 2259
  CcTest::InitializeVM();
2196
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2260
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2197 2261
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2198 2262
  v8::HandleScope scope(CcTest::isolate());
2199
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2263
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2200 2264

  
2201 2265
  v8::Local<v8::Value> res = CompileRun(
2202 2266
      "function f() {"
......
2210 2274
  Handle<JSObject> o =
2211 2275
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2212 2276

  
2213
  CHECK(HEAP->InOldPointerSpace(o->elements()));
2214
  CHECK(HEAP->InOldPointerSpace(*o));
2277
  CHECK(CcTest::heap()->InOldPointerSpace(o->elements()));
2278
  CHECK(CcTest::heap()->InOldPointerSpace(*o));
2215 2279
}
2216 2280

  
2217 2281

  
2218 2282
TEST(OptimizedPretenuringMixedInObjectProperties) {
2219 2283
  i::FLAG_allow_natives_syntax = true;
2220 2284
  CcTest::InitializeVM();
2221
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2285
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2222 2286
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2223 2287
  v8::HandleScope scope(CcTest::isolate());
2224
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2288
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2225 2289

  
2226 2290
  v8::Local<v8::Value> res = CompileRun(
2227 2291
      "function f() {"
......
2235 2299
  Handle<JSObject> o =
2236 2300
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2237 2301

  
2238
  CHECK(HEAP->InOldPointerSpace(*o));
2239
  CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0)));
2240
  CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(1)));
2302
  CHECK(CcTest::heap()->InOldPointerSpace(*o));
2303
  CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
2304
  CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1)));
2241 2305

  
2242 2306
  JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
2243
  CHECK(HEAP->InOldPointerSpace(inner_object));
2244
  CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
2245
  CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
2307
  CHECK(CcTest::heap()->InOldPointerSpace(inner_object));
2308
  CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
2309
  CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
2246 2310
}
2247 2311

  
2248 2312

  
2249 2313
TEST(OptimizedPretenuringDoubleArrayProperties) {
2250 2314
  i::FLAG_allow_natives_syntax = true;
2251 2315
  CcTest::InitializeVM();
2252
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2316
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2253 2317
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2254 2318
  v8::HandleScope scope(CcTest::isolate());
2255
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2319
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2256 2320

  
2257 2321
  v8::Local<v8::Value> res = CompileRun(
2258 2322
      "function f() {"
......
2266 2330
  Handle<JSObject> o =
2267 2331
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2268 2332

  
2269
  CHECK(HEAP->InOldPointerSpace(*o));
2270
  CHECK(HEAP->InOldDataSpace(o->properties()));
2333
  CHECK(CcTest::heap()->InOldPointerSpace(*o));
2334
  CHECK(CcTest::heap()->InOldDataSpace(o->properties()));
2271 2335
}
2272 2336

  
2273 2337

  
2274 2338
TEST(OptimizedPretenuringdoubleArrayLiterals) {
2275 2339
  i::FLAG_allow_natives_syntax = true;
2276 2340
  CcTest::InitializeVM();
2277
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2341
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2278 2342
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2279 2343
  v8::HandleScope scope(CcTest::isolate());
2280
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2344
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2281 2345

  
2282 2346
  v8::Local<v8::Value> res = CompileRun(
2283 2347
      "function f() {"
......
2291 2355
  Handle<JSObject> o =
2292 2356
      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2293 2357

  
2294
  CHECK(HEAP->InOldDataSpace(o->elements()));
2295
  CHECK(HEAP->InOldPointerSpace(*o));
2358
  CHECK(CcTest::heap()->InOldDataSpace(o->elements()));
2359
  CHECK(CcTest::heap()->InOldPointerSpace(*o));
2296 2360
}
2297 2361

  
2298 2362

  
2299 2363
TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
2300 2364
  i::FLAG_allow_natives_syntax = true;
2301 2365
  CcTest::InitializeVM();
2302
  if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2366
  if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2303 2367
  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2304 2368
  v8::HandleScope scope(CcTest::isolate());
2305
  HEAP->SetNewSpaceHighPromotionModeActive(true);
2369
  CcTest::heap()->SetNewSpaceHighPromotionModeActive(true);
2306 2370

  
2307 2371
  v8::Local<v8::Value> res = CompileRun(
2308 2372
      "function f() {"
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff