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

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

Issue 151603004: A64: Synchronize with r16587. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CheckMap(HEAP->meta_map(), MAP_TYPE, Map::kSize); 75 CheckMap(HEAP->meta_map(), MAP_TYPE, Map::kSize);
76 CheckMap(HEAP->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); 76 CheckMap(HEAP->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
77 CheckMap(HEAP->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); 77 CheckMap(HEAP->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
78 CheckMap(HEAP->string_map(), STRING_TYPE, kVariableSizeSentinel); 78 CheckMap(HEAP->string_map(), STRING_TYPE, kVariableSizeSentinel);
79 } 79 }
80 80
81 81
82 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { 82 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) {
83 CHECK(obj->IsOddball()); 83 CHECK(obj->IsOddball());
84 bool exc; 84 bool exc;
85 Handle<Object> handle(obj, isolate);
85 Object* print_string = 86 Object* print_string =
86 *Execution::ToString(Handle<Object>(obj, isolate), &exc); 87 *Execution::ToString(isolate, handle, &exc);
87 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string))); 88 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
88 } 89 }
89 90
90 91
91 static void CheckSmi(Isolate* isolate, int value, const char* string) { 92 static void CheckSmi(Isolate* isolate, int value, const char* string) {
92 bool exc; 93 bool exc;
94 Handle<Object> handle(Smi::FromInt(value), isolate);
93 Object* print_string = 95 Object* print_string =
94 *Execution::ToString(Handle<Object>(Smi::FromInt(value), isolate), &exc); 96 *Execution::ToString(isolate, handle, &exc);
95 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string))); 97 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
96 } 98 }
97 99
98 100
99 static void CheckNumber(Isolate* isolate, double value, const char* string) { 101 static void CheckNumber(Isolate* isolate, double value, const char* string) {
100 Object* obj = HEAP->NumberFromDouble(value)->ToObjectChecked(); 102 Object* obj = HEAP->NumberFromDouble(value)->ToObjectChecked();
101 CHECK(obj->IsNumber()); 103 CHECK(obj->IsNumber());
102 bool exc; 104 bool exc;
105 Handle<Object> handle(obj, isolate);
103 Object* print_string = 106 Object* print_string =
104 *Execution::ToString(Handle<Object>(obj, isolate), &exc); 107 *Execution::ToString(isolate, handle, &exc);
105 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string))); 108 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
106 } 109 }
107 110
108 111
109 static void CheckFindCodeObject(Isolate* isolate) { 112 static void CheckFindCodeObject(Isolate* isolate) {
110 // Test FindCodeObject 113 // Test FindCodeObject
111 #define __ assm. 114 #define __ assm.
112 115
113 Assembler assm(isolate, NULL, 0); 116 Assembler assm(isolate, NULL, 0);
114 117
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 global_handles->Destroy(h4.location()); 394 global_handles->Destroy(h4.location());
392 } 395 }
393 396
394 397
395 static bool WeakPointerCleared = false; 398 static bool WeakPointerCleared = false;
396 399
397 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate, 400 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
398 v8::Persistent<v8::Value>* handle, 401 v8::Persistent<v8::Value>* handle,
399 void* id) { 402 void* id) {
400 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; 403 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
401 handle->Dispose(isolate); 404 handle->Dispose();
402 } 405 }
403 406
404 407
405 TEST(WeakGlobalHandlesScavenge) { 408 TEST(WeakGlobalHandlesScavenge) {
406 i::FLAG_stress_compaction = false; 409 i::FLAG_stress_compaction = false;
407 CcTest::InitializeVM(); 410 CcTest::InitializeVM();
408 Isolate* isolate = Isolate::Current(); 411 Isolate* isolate = Isolate::Current();
409 Heap* heap = isolate->heap(); 412 Heap* heap = isolate->heap();
410 Factory* factory = isolate->factory(); 413 Factory* factory = isolate->factory();
411 GlobalHandles* global_handles = isolate->global_handles(); 414 GlobalHandles* global_handles = isolate->global_handles();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 761
759 // Set array length to 0. 762 // Set array length to 0.
760 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); 763 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked();
761 CHECK_EQ(Smi::FromInt(0), array->length()); 764 CHECK_EQ(Smi::FromInt(0), array->length());
762 // Must be in fast mode. 765 // Must be in fast mode.
763 CHECK(array->HasFastSmiOrObjectElements()); 766 CHECK(array->HasFastSmiOrObjectElements());
764 767
765 // array[length] = name. 768 // array[length] = name.
766 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); 769 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked();
767 CHECK_EQ(Smi::FromInt(1), array->length()); 770 CHECK_EQ(Smi::FromInt(1), array->length());
768 CHECK_EQ(array->GetElement(0), *name); 771 CHECK_EQ(array->GetElement(isolate, 0), *name);
769 772
770 // Set array length with larger than smi value. 773 // Set array length with larger than smi value.
771 Handle<Object> length = 774 Handle<Object> length =
772 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 775 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
773 array->SetElementsLength(*length)->ToObjectChecked(); 776 array->SetElementsLength(*length)->ToObjectChecked();
774 777
775 uint32_t int_length = 0; 778 uint32_t int_length = 0;
776 CHECK(length->ToArrayIndex(&int_length)); 779 CHECK(length->ToArrayIndex(&int_length));
777 CHECK_EQ(*length, array->length()); 780 CHECK_EQ(*length, array->length());
778 CHECK(array->HasDictionaryElements()); // Must be in slow mode. 781 CHECK(array->HasDictionaryElements()); // Must be in slow mode.
779 782
780 // array[length] = name. 783 // array[length] = name.
781 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked(); 784 array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked();
782 uint32_t new_int_length = 0; 785 uint32_t new_int_length = 0;
783 CHECK(array->length()->ToArrayIndex(&new_int_length)); 786 CHECK(array->length()->ToArrayIndex(&new_int_length));
784 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 787 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
785 CHECK_EQ(array->GetElement(int_length), *name); 788 CHECK_EQ(array->GetElement(isolate, int_length), *name);
786 CHECK_EQ(array->GetElement(0), *name); 789 CHECK_EQ(array->GetElement(isolate, 0), *name);
787 } 790 }
788 791
789 792
790 TEST(JSObjectCopy) { 793 TEST(JSObjectCopy) {
791 CcTest::InitializeVM(); 794 CcTest::InitializeVM();
792 Isolate* isolate = Isolate::Current(); 795 Isolate* isolate = Isolate::Current();
793 Factory* factory = isolate->factory(); 796 Factory* factory = isolate->factory();
794 797
795 v8::HandleScope sc(CcTest::isolate()); 798 v8::HandleScope sc(CcTest::isolate());
796 String* object_string = String::cast(HEAP->Object_string()); 799 String* object_string = String::cast(HEAP->Object_string());
(...skipping 10 matching lines...) Expand all
807 obj->SetProperty( 810 obj->SetProperty(
808 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 811 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
809 812
810 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); 813 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked();
811 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); 814 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked();
812 815
813 // Make the clone. 816 // Make the clone.
814 Handle<JSObject> clone = Copy(obj); 817 Handle<JSObject> clone = Copy(obj);
815 CHECK(!clone.is_identical_to(obj)); 818 CHECK(!clone.is_identical_to(obj));
816 819
817 CHECK_EQ(obj->GetElement(0), clone->GetElement(0)); 820 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0));
818 CHECK_EQ(obj->GetElement(1), clone->GetElement(1)); 821 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 1));
819 822
820 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); 823 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first));
821 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); 824 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
822 825
823 // Flip the values. 826 // Flip the values.
824 clone->SetProperty( 827 clone->SetProperty(
825 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 828 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
826 clone->SetProperty( 829 clone->SetProperty(
827 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 830 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
828 831
829 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); 832 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked();
830 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); 833 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
831 834
832 CHECK_EQ(obj->GetElement(1), clone->GetElement(0)); 835 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0));
833 CHECK_EQ(obj->GetElement(0), clone->GetElement(1)); 836 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1));
834 837
835 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); 838 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
836 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); 839 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
837 } 840 }
838 841
839 842
840 TEST(StringAllocation) { 843 TEST(StringAllocation) {
841 CcTest::InitializeVM(); 844 CcTest::InitializeVM();
842 Isolate* isolate = Isolate::Current(); 845 Isolate* isolate = Isolate::Current();
843 Factory* factory = isolate->factory(); 846 Factory* factory = isolate->factory();
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1328
1326 // Create a number of global contests which gets linked together. 1329 // Create a number of global contests which gets linked together.
1327 for (int i = 0; i < kNumTestContexts; i++) { 1330 for (int i = 0; i < kNumTestContexts; i++) {
1328 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); 1331 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1329 1332
1330 // Collect garbage that might have been created by one of the 1333 // Collect garbage that might have been created by one of the
1331 // installed extensions. 1334 // installed extensions.
1332 isolate->compilation_cache()->Clear(); 1335 isolate->compilation_cache()->Clear();
1333 heap->CollectAllGarbage(Heap::kNoGCFlags); 1336 heap->CollectAllGarbage(Heap::kNoGCFlags);
1334 1337
1335 bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); 1338 bool opt = (FLAG_always_opt && isolate->use_crankshaft());
1336 1339
1337 CHECK_EQ(i + 1, CountNativeContexts()); 1340 CHECK_EQ(i + 1, CountNativeContexts());
1338 1341
1339 ctx[i]->Enter(); 1342 ctx[i]->Enter();
1340 1343
1341 // Create a handle scope so no function objects get stuch in the outer 1344 // Create a handle scope so no function objects get stuch in the outer
1342 // handle scope 1345 // handle scope
1343 HandleScope scope(isolate); 1346 HandleScope scope(isolate);
1344 const char* source = "function f1() { };" 1347 const char* source = "function f1() { };"
1345 "function f2() { };" 1348 "function f2() { };"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 CHECK_EQ(0, CountNativeContexts()); 1472 CHECK_EQ(0, CountNativeContexts());
1470 1473
1471 // Create an number of contexts and check the length of the weak list both 1474 // Create an number of contexts and check the length of the weak list both
1472 // with and without GCs while iterating the list. 1475 // with and without GCs while iterating the list.
1473 for (int i = 0; i < kNumTestContexts; i++) { 1476 for (int i = 0; i < kNumTestContexts; i++) {
1474 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); 1477 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1475 CHECK_EQ(i + 1, CountNativeContexts()); 1478 CHECK_EQ(i + 1, CountNativeContexts());
1476 CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1)); 1479 CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1));
1477 } 1480 }
1478 1481
1479 bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); 1482 bool opt = (FLAG_always_opt && isolate->use_crankshaft());
1480 1483
1481 // Compile a number of functions the length of the weak list of optimized 1484 // Compile a number of functions the length of the weak list of optimized
1482 // functions both with and without GCs while iterating the list. 1485 // functions both with and without GCs while iterating the list.
1483 ctx[0]->Enter(); 1486 ctx[0]->Enter();
1484 const char* source = "function f1() { };" 1487 const char* source = "function f1() { };"
1485 "function f2() { };" 1488 "function f2() { };"
1486 "function f3() { };" 1489 "function f3() { };"
1487 "function f4() { };" 1490 "function f4() { };"
1488 "function f5() { };"; 1491 "function f5() { };";
1489 CompileRun(source); 1492 CompileRun(source);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 ctx2->Global()->Set(v8_str("o"), v); 1716 ctx2->Global()->Set(v8_str("o"), v);
1714 v8::Local<v8::Value> res = CompileRun( 1717 v8::Local<v8::Value> res = CompileRun(
1715 "function f() { return o.x; }" 1718 "function f() { return o.x; }"
1716 "for (var i = 0; i < 10; ++i) f();" 1719 "for (var i = 0; i < 10; ++i) f();"
1717 "%OptimizeFunctionOnNextCall(f);" 1720 "%OptimizeFunctionOnNextCall(f);"
1718 "f();"); 1721 "f();");
1719 CHECK_EQ(42, res->Int32Value()); 1722 CHECK_EQ(42, res->Int32Value());
1720 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1723 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1721 ctx2->Exit(); 1724 ctx2->Exit();
1722 v8::Local<v8::Context>::New(isolate, ctx1)->Exit(); 1725 v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
1723 ctx1p.Dispose(isolate); 1726 ctx1p.Dispose();
1724 v8::V8::ContextDisposedNotification(); 1727 v8::V8::ContextDisposedNotification();
1725 } 1728 }
1726 HEAP->CollectAllAvailableGarbage(); 1729 HEAP->CollectAllAvailableGarbage();
1727 CHECK_EQ(2, NumberOfGlobalObjects()); 1730 CHECK_EQ(2, NumberOfGlobalObjects());
1728 ctx2p.Dispose(isolate); 1731 ctx2p.Dispose();
1729 HEAP->CollectAllAvailableGarbage(); 1732 HEAP->CollectAllAvailableGarbage();
1730 CHECK_EQ(0, NumberOfGlobalObjects()); 1733 CHECK_EQ(0, NumberOfGlobalObjects());
1731 } 1734 }
1732 1735
1733 1736
1734 // Test that we don't embed functions from foreign contexts into 1737 // Test that we don't embed functions from foreign contexts into
1735 // optimized code. 1738 // optimized code.
1736 TEST(LeakNativeContextViaFunction) { 1739 TEST(LeakNativeContextViaFunction) {
1737 i::FLAG_allow_natives_syntax = true; 1740 i::FLAG_allow_natives_syntax = true;
1738 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 1741 v8::Isolate* isolate = v8::Isolate::GetCurrent();
(...skipping 20 matching lines...) Expand all
1759 ctx2->Global()->Set(v8_str("o"), v); 1762 ctx2->Global()->Set(v8_str("o"), v);
1760 v8::Local<v8::Value> res = CompileRun( 1763 v8::Local<v8::Value> res = CompileRun(
1761 "function f(x) { return x(); }" 1764 "function f(x) { return x(); }"
1762 "for (var i = 0; i < 10; ++i) f(o);" 1765 "for (var i = 0; i < 10; ++i) f(o);"
1763 "%OptimizeFunctionOnNextCall(f);" 1766 "%OptimizeFunctionOnNextCall(f);"
1764 "f(o);"); 1767 "f(o);");
1765 CHECK_EQ(42, res->Int32Value()); 1768 CHECK_EQ(42, res->Int32Value());
1766 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1769 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1767 ctx2->Exit(); 1770 ctx2->Exit();
1768 ctx1->Exit(); 1771 ctx1->Exit();
1769 ctx1p.Dispose(ctx1->GetIsolate()); 1772 ctx1p.Dispose();
1770 v8::V8::ContextDisposedNotification(); 1773 v8::V8::ContextDisposedNotification();
1771 } 1774 }
1772 HEAP->CollectAllAvailableGarbage(); 1775 HEAP->CollectAllAvailableGarbage();
1773 CHECK_EQ(2, NumberOfGlobalObjects()); 1776 CHECK_EQ(2, NumberOfGlobalObjects());
1774 ctx2p.Dispose(isolate); 1777 ctx2p.Dispose();
1775 HEAP->CollectAllAvailableGarbage(); 1778 HEAP->CollectAllAvailableGarbage();
1776 CHECK_EQ(0, NumberOfGlobalObjects()); 1779 CHECK_EQ(0, NumberOfGlobalObjects());
1777 } 1780 }
1778 1781
1779 1782
1780 TEST(LeakNativeContextViaMapKeyed) { 1783 TEST(LeakNativeContextViaMapKeyed) {
1781 i::FLAG_allow_natives_syntax = true; 1784 i::FLAG_allow_natives_syntax = true;
1782 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 1785 v8::Isolate* isolate = v8::Isolate::GetCurrent();
1783 v8::HandleScope outer_scope(isolate); 1786 v8::HandleScope outer_scope(isolate);
1784 v8::Persistent<v8::Context> ctx1p; 1787 v8::Persistent<v8::Context> ctx1p;
(...skipping 18 matching lines...) Expand all
1803 ctx2->Global()->Set(v8_str("o"), v); 1806 ctx2->Global()->Set(v8_str("o"), v);
1804 v8::Local<v8::Value> res = CompileRun( 1807 v8::Local<v8::Value> res = CompileRun(
1805 "function f() { return o[0]; }" 1808 "function f() { return o[0]; }"
1806 "for (var i = 0; i < 10; ++i) f();" 1809 "for (var i = 0; i < 10; ++i) f();"
1807 "%OptimizeFunctionOnNextCall(f);" 1810 "%OptimizeFunctionOnNextCall(f);"
1808 "f();"); 1811 "f();");
1809 CHECK_EQ(42, res->Int32Value()); 1812 CHECK_EQ(42, res->Int32Value());
1810 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1813 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1811 ctx2->Exit(); 1814 ctx2->Exit();
1812 ctx1->Exit(); 1815 ctx1->Exit();
1813 ctx1p.Dispose(ctx1->GetIsolate()); 1816 ctx1p.Dispose();
1814 v8::V8::ContextDisposedNotification(); 1817 v8::V8::ContextDisposedNotification();
1815 } 1818 }
1816 HEAP->CollectAllAvailableGarbage(); 1819 HEAP->CollectAllAvailableGarbage();
1817 CHECK_EQ(2, NumberOfGlobalObjects()); 1820 CHECK_EQ(2, NumberOfGlobalObjects());
1818 ctx2p.Dispose(isolate); 1821 ctx2p.Dispose();
1819 HEAP->CollectAllAvailableGarbage(); 1822 HEAP->CollectAllAvailableGarbage();
1820 CHECK_EQ(0, NumberOfGlobalObjects()); 1823 CHECK_EQ(0, NumberOfGlobalObjects());
1821 } 1824 }
1822 1825
1823 1826
1824 TEST(LeakNativeContextViaMapProto) { 1827 TEST(LeakNativeContextViaMapProto) {
1825 i::FLAG_allow_natives_syntax = true; 1828 i::FLAG_allow_natives_syntax = true;
1826 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 1829 v8::Isolate* isolate = v8::Isolate::GetCurrent();
1827 v8::HandleScope outer_scope(isolate); 1830 v8::HandleScope outer_scope(isolate);
1828 v8::Persistent<v8::Context> ctx1p; 1831 v8::Persistent<v8::Context> ctx1p;
(...skipping 22 matching lines...) Expand all
1851 " p.__proto__ = o;" 1854 " p.__proto__ = o;"
1852 " return p.x;" 1855 " return p.x;"
1853 "}" 1856 "}"
1854 "for (var i = 0; i < 10; ++i) f();" 1857 "for (var i = 0; i < 10; ++i) f();"
1855 "%OptimizeFunctionOnNextCall(f);" 1858 "%OptimizeFunctionOnNextCall(f);"
1856 "f();"); 1859 "f();");
1857 CHECK_EQ(42, res->Int32Value()); 1860 CHECK_EQ(42, res->Int32Value());
1858 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1861 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1859 ctx2->Exit(); 1862 ctx2->Exit();
1860 ctx1->Exit(); 1863 ctx1->Exit();
1861 ctx1p.Dispose(isolate); 1864 ctx1p.Dispose();
1862 v8::V8::ContextDisposedNotification(); 1865 v8::V8::ContextDisposedNotification();
1863 } 1866 }
1864 HEAP->CollectAllAvailableGarbage(); 1867 HEAP->CollectAllAvailableGarbage();
1865 CHECK_EQ(2, NumberOfGlobalObjects()); 1868 CHECK_EQ(2, NumberOfGlobalObjects());
1866 ctx2p.Dispose(isolate); 1869 ctx2p.Dispose();
1867 HEAP->CollectAllAvailableGarbage(); 1870 HEAP->CollectAllAvailableGarbage();
1868 CHECK_EQ(0, NumberOfGlobalObjects()); 1871 CHECK_EQ(0, NumberOfGlobalObjects());
1869 } 1872 }
1870 1873
1871 1874
1872 TEST(InstanceOfStubWriteBarrier) { 1875 TEST(InstanceOfStubWriteBarrier) {
1873 i::FLAG_allow_natives_syntax = true; 1876 i::FLAG_allow_natives_syntax = true;
1874 #ifdef VERIFY_HEAP 1877 #ifdef VERIFY_HEAP
1875 i::FLAG_verify_heap = true; 1878 i::FLAG_verify_heap = true;
1876 #endif 1879 #endif
1877 1880
1878 CcTest::InitializeVM(); 1881 CcTest::InitializeVM();
1879 if (!i::V8::UseCrankshaft()) return; 1882 if (!i::Isolate::Current()->use_crankshaft()) return;
1880 if (i::FLAG_force_marking_deque_overflows) return; 1883 if (i::FLAG_force_marking_deque_overflows) return;
1881 v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); 1884 v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1882 1885
1883 { 1886 {
1884 v8::HandleScope scope(v8::Isolate::GetCurrent()); 1887 v8::HandleScope scope(v8::Isolate::GetCurrent());
1885 CompileRun( 1888 CompileRun(
1886 "function foo () { }" 1889 "function foo () { }"
1887 "function mkbar () { return new (new Function(\"\")) (); }" 1890 "function mkbar () { return new (new Function(\"\")) (); }"
1888 "function f (x) { return (x instanceof foo); }" 1891 "function f (x) { return (x instanceof foo); }"
1889 "function g () { f(mkbar()); }" 1892 "function g () { f(mkbar()); }"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 1989
1987 1990
1988 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { 1991 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1989 i::FLAG_stress_compaction = false; 1992 i::FLAG_stress_compaction = false;
1990 i::FLAG_allow_natives_syntax = true; 1993 i::FLAG_allow_natives_syntax = true;
1991 #ifdef VERIFY_HEAP 1994 #ifdef VERIFY_HEAP
1992 i::FLAG_verify_heap = true; 1995 i::FLAG_verify_heap = true;
1993 #endif 1996 #endif
1994 1997
1995 CcTest::InitializeVM(); 1998 CcTest::InitializeVM();
1996 if (!i::V8::UseCrankshaft()) return; 1999 if (!i::Isolate::Current()->use_crankshaft()) return;
1997 v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); 2000 v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1998 2001
1999 { 2002 {
2000 v8::HandleScope scope(v8::Isolate::GetCurrent()); 2003 v8::HandleScope scope(v8::Isolate::GetCurrent());
2001 CompileRun( 2004 CompileRun(
2002 "function f () {" 2005 "function f () {"
2003 " var s = 0;" 2006 " var s = 0;"
2004 " for (var i = 0; i < 100; i++) s += i;" 2007 " for (var i = 0; i < 100; i++) s += i;"
2005 " return s;" 2008 " return s;"
2006 "}" 2009 "}"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 2046
2044 2047
2045 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { 2048 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
2046 i::FLAG_stress_compaction = false; 2049 i::FLAG_stress_compaction = false;
2047 i::FLAG_allow_natives_syntax = true; 2050 i::FLAG_allow_natives_syntax = true;
2048 #ifdef VERIFY_HEAP 2051 #ifdef VERIFY_HEAP
2049 i::FLAG_verify_heap = true; 2052 i::FLAG_verify_heap = true;
2050 #endif 2053 #endif
2051 2054
2052 CcTest::InitializeVM(); 2055 CcTest::InitializeVM();
2053 if (!i::V8::UseCrankshaft()) return; 2056 if (!i::Isolate::Current()->use_crankshaft()) return;
2054 v8::HandleScope outer_scope(CcTest::isolate()); 2057 v8::HandleScope outer_scope(CcTest::isolate());
2055 2058
2056 { 2059 {
2057 v8::HandleScope scope(CcTest::isolate()); 2060 v8::HandleScope scope(CcTest::isolate());
2058 CompileRun( 2061 CompileRun(
2059 "function f () {" 2062 "function f () {"
2060 " var s = 0;" 2063 " var s = 0;"
2061 " for (var i = 0; i < 100; i++) s += i;" 2064 " for (var i = 0; i < 100; i++) s += i;"
2062 " return s;" 2065 " return s;"
2063 "}" 2066 "}"
(...skipping 18 matching lines...) Expand all
2082 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); 2085 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
2083 CHECK_EQ(0, f->shared()->opt_count()); 2086 CHECK_EQ(0, f->shared()->opt_count());
2084 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2087 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2085 } 2088 }
2086 2089
2087 2090
2088 // Test that HAllocateObject will always return an object in new-space. 2091 // Test that HAllocateObject will always return an object in new-space.
2089 TEST(OptimizedAllocationAlwaysInNewSpace) { 2092 TEST(OptimizedAllocationAlwaysInNewSpace) {
2090 i::FLAG_allow_natives_syntax = true; 2093 i::FLAG_allow_natives_syntax = true;
2091 CcTest::InitializeVM(); 2094 CcTest::InitializeVM();
2092 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2095 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2093 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2096 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2094 v8::HandleScope scope(CcTest::isolate()); 2097 v8::HandleScope scope(CcTest::isolate());
2095 2098
2096 SimulateFullSpace(HEAP->new_space()); 2099 SimulateFullSpace(HEAP->new_space());
2097 AlwaysAllocateScope always_allocate; 2100 AlwaysAllocateScope always_allocate;
2098 v8::Local<v8::Value> res = CompileRun( 2101 v8::Local<v8::Value> res = CompileRun(
2099 "function c(x) {" 2102 "function c(x) {"
2100 " this.x = x;" 2103 " this.x = x;"
2101 " for (var i = 0; i < 32; i++) {" 2104 " for (var i = 0; i < 32; i++) {"
2102 " this['x' + i] = x;" 2105 " this['x' + i] = x;"
2103 " }" 2106 " }"
2104 "}" 2107 "}"
2105 "function f(x) { return new c(x); };" 2108 "function f(x) { return new c(x); };"
2106 "f(1); f(2); f(3);" 2109 "f(1); f(2); f(3);"
2107 "%OptimizeFunctionOnNextCall(f);" 2110 "%OptimizeFunctionOnNextCall(f);"
2108 "f(4);"); 2111 "f(4);");
2109 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); 2112 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value());
2110 2113
2111 Handle<JSObject> o = 2114 Handle<JSObject> o =
2112 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2115 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2113 2116
2114 CHECK(HEAP->InNewSpace(*o)); 2117 CHECK(HEAP->InNewSpace(*o));
2115 } 2118 }
2116 2119
2117 2120
2118 TEST(OptimizedPretenuringAllocationFolding) { 2121 TEST(OptimizedPretenuringAllocationFolding) {
2119 i::FLAG_allow_natives_syntax = true; 2122 i::FLAG_allow_natives_syntax = true;
2120 CcTest::InitializeVM(); 2123 CcTest::InitializeVM();
2121 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2124 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2122 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2125 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2123 v8::HandleScope scope(CcTest::isolate()); 2126 v8::HandleScope scope(CcTest::isolate());
2124 HEAP->SetNewSpaceHighPromotionModeActive(true); 2127 HEAP->SetNewSpaceHighPromotionModeActive(true);
2125 2128
2126 v8::Local<v8::Value> res = CompileRun( 2129 v8::Local<v8::Value> res = CompileRun(
2127 "function DataObject() {" 2130 "function DataObject() {"
2128 " this.a = 1.1;" 2131 " this.a = 1.1;"
2129 " this.b = [{}];" 2132 " this.b = [{}];"
2130 " this.c = 1.2;" 2133 " this.c = 1.2;"
2131 " this.d = [{}];" 2134 " this.d = [{}];"
(...skipping 15 matching lines...) Expand all
2147 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); 2150 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2148 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); 2151 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3)));
2149 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); 2152 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4)));
2150 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); 2153 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5)));
2151 } 2154 }
2152 2155
2153 2156
2154 TEST(OptimizedPretenuringAllocationFoldingBlocks) { 2157 TEST(OptimizedPretenuringAllocationFoldingBlocks) {
2155 i::FLAG_allow_natives_syntax = true; 2158 i::FLAG_allow_natives_syntax = true;
2156 CcTest::InitializeVM(); 2159 CcTest::InitializeVM();
2157 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2160 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2158 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2161 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2159 v8::HandleScope scope(CcTest::isolate()); 2162 v8::HandleScope scope(CcTest::isolate());
2160 HEAP->SetNewSpaceHighPromotionModeActive(true); 2163 HEAP->SetNewSpaceHighPromotionModeActive(true);
2161 2164
2162 v8::Local<v8::Value> res = CompileRun( 2165 v8::Local<v8::Value> res = CompileRun(
2163 "function DataObject() {" 2166 "function DataObject() {"
2164 " this.a = [{}];" 2167 " this.a = [{}];"
2165 " this.b = [{}];" 2168 " this.b = [{}];"
2166 " this.c = 1.1;" 2169 " this.c = 1.1;"
2167 " this.d = 1.2;" 2170 " this.d = 1.2;"
(...skipping 15 matching lines...) Expand all
2183 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); 2186 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2184 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); 2187 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3)));
2185 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); 2188 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4)));
2186 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); 2189 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5)));
2187 } 2190 }
2188 2191
2189 2192
2190 TEST(OptimizedPretenuringObjectArrayLiterals) { 2193 TEST(OptimizedPretenuringObjectArrayLiterals) {
2191 i::FLAG_allow_natives_syntax = true; 2194 i::FLAG_allow_natives_syntax = true;
2192 CcTest::InitializeVM(); 2195 CcTest::InitializeVM();
2193 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2196 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2194 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2197 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2195 v8::HandleScope scope(CcTest::isolate()); 2198 v8::HandleScope scope(CcTest::isolate());
2196 HEAP->SetNewSpaceHighPromotionModeActive(true); 2199 HEAP->SetNewSpaceHighPromotionModeActive(true);
2197 2200
2198 v8::Local<v8::Value> res = CompileRun( 2201 v8::Local<v8::Value> res = CompileRun(
2199 "function f() {" 2202 "function f() {"
2200 " var numbers = [{}, {}, {}];" 2203 " var numbers = [{}, {}, {}];"
2201 " return numbers;" 2204 " return numbers;"
2202 "};" 2205 "};"
2203 "f(); f(); f();" 2206 "f(); f(); f();"
2204 "%OptimizeFunctionOnNextCall(f);" 2207 "%OptimizeFunctionOnNextCall(f);"
2205 "f();"); 2208 "f();");
2206 2209
2207 Handle<JSObject> o = 2210 Handle<JSObject> o =
2208 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2211 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2209 2212
2210 CHECK(HEAP->InOldPointerSpace(o->elements())); 2213 CHECK(HEAP->InOldPointerSpace(o->elements()));
2211 CHECK(HEAP->InOldPointerSpace(*o)); 2214 CHECK(HEAP->InOldPointerSpace(*o));
2212 } 2215 }
2213 2216
2214 2217
2215 TEST(OptimizedPretenuringMixedInObjectProperties) { 2218 TEST(OptimizedPretenuringMixedInObjectProperties) {
2216 i::FLAG_allow_natives_syntax = true; 2219 i::FLAG_allow_natives_syntax = true;
2217 CcTest::InitializeVM(); 2220 CcTest::InitializeVM();
2218 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2221 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2219 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2222 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2220 v8::HandleScope scope(CcTest::isolate()); 2223 v8::HandleScope scope(CcTest::isolate());
2221 HEAP->SetNewSpaceHighPromotionModeActive(true); 2224 HEAP->SetNewSpaceHighPromotionModeActive(true);
2222 2225
2223 v8::Local<v8::Value> res = CompileRun( 2226 v8::Local<v8::Value> res = CompileRun(
2224 "function f() {" 2227 "function f() {"
2225 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" 2228 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};"
2226 " return numbers;" 2229 " return numbers;"
2227 "};" 2230 "};"
2228 "f(); f(); f();" 2231 "f(); f(); f();"
(...skipping 10 matching lines...) Expand all
2239 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); 2242 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
2240 CHECK(HEAP->InOldPointerSpace(inner_object)); 2243 CHECK(HEAP->InOldPointerSpace(inner_object));
2241 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0))); 2244 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
2242 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); 2245 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
2243 } 2246 }
2244 2247
2245 2248
2246 TEST(OptimizedPretenuringDoubleArrayProperties) { 2249 TEST(OptimizedPretenuringDoubleArrayProperties) {
2247 i::FLAG_allow_natives_syntax = true; 2250 i::FLAG_allow_natives_syntax = true;
2248 CcTest::InitializeVM(); 2251 CcTest::InitializeVM();
2249 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2252 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2250 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2253 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2251 v8::HandleScope scope(CcTest::isolate()); 2254 v8::HandleScope scope(CcTest::isolate());
2252 HEAP->SetNewSpaceHighPromotionModeActive(true); 2255 HEAP->SetNewSpaceHighPromotionModeActive(true);
2253 2256
2254 v8::Local<v8::Value> res = CompileRun( 2257 v8::Local<v8::Value> res = CompileRun(
2255 "function f() {" 2258 "function f() {"
2256 " var numbers = {a: 1.1, b: 2.2};" 2259 " var numbers = {a: 1.1, b: 2.2};"
2257 " return numbers;" 2260 " return numbers;"
2258 "};" 2261 "};"
2259 "f(); f(); f();" 2262 "f(); f(); f();"
2260 "%OptimizeFunctionOnNextCall(f);" 2263 "%OptimizeFunctionOnNextCall(f);"
2261 "f();"); 2264 "f();");
2262 2265
2263 Handle<JSObject> o = 2266 Handle<JSObject> o =
2264 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2267 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2265 2268
2266 CHECK(HEAP->InOldPointerSpace(*o)); 2269 CHECK(HEAP->InOldPointerSpace(*o));
2267 CHECK(HEAP->InOldDataSpace(o->properties())); 2270 CHECK(HEAP->InOldDataSpace(o->properties()));
2268 } 2271 }
2269 2272
2270 2273
2271 TEST(OptimizedPretenuringdoubleArrayLiterals) { 2274 TEST(OptimizedPretenuringdoubleArrayLiterals) {
2272 i::FLAG_allow_natives_syntax = true; 2275 i::FLAG_allow_natives_syntax = true;
2273 CcTest::InitializeVM(); 2276 CcTest::InitializeVM();
2274 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2277 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2275 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2278 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2276 v8::HandleScope scope(CcTest::isolate()); 2279 v8::HandleScope scope(CcTest::isolate());
2277 HEAP->SetNewSpaceHighPromotionModeActive(true); 2280 HEAP->SetNewSpaceHighPromotionModeActive(true);
2278 2281
2279 v8::Local<v8::Value> res = CompileRun( 2282 v8::Local<v8::Value> res = CompileRun(
2280 "function f() {" 2283 "function f() {"
2281 " var numbers = [1.1, 2.2, 3.3];" 2284 " var numbers = [1.1, 2.2, 3.3];"
2282 " return numbers;" 2285 " return numbers;"
2283 "};" 2286 "};"
2284 "f(); f(); f();" 2287 "f(); f(); f();"
2285 "%OptimizeFunctionOnNextCall(f);" 2288 "%OptimizeFunctionOnNextCall(f);"
2286 "f();"); 2289 "f();");
2287 2290
2288 Handle<JSObject> o = 2291 Handle<JSObject> o =
2289 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2292 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2290 2293
2291 CHECK(HEAP->InOldDataSpace(o->elements())); 2294 CHECK(HEAP->InOldDataSpace(o->elements()));
2292 CHECK(HEAP->InOldPointerSpace(*o)); 2295 CHECK(HEAP->InOldPointerSpace(*o));
2293 } 2296 }
2294 2297
2295 2298
2296 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { 2299 TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
2297 i::FLAG_allow_natives_syntax = true; 2300 i::FLAG_allow_natives_syntax = true;
2298 CcTest::InitializeVM(); 2301 CcTest::InitializeVM();
2299 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2302 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2300 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2303 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2301 v8::HandleScope scope(CcTest::isolate()); 2304 v8::HandleScope scope(CcTest::isolate());
2302 HEAP->SetNewSpaceHighPromotionModeActive(true); 2305 HEAP->SetNewSpaceHighPromotionModeActive(true);
2303 2306
2304 v8::Local<v8::Value> res = CompileRun( 2307 v8::Local<v8::Value> res = CompileRun(
2305 "function f() {" 2308 "function f() {"
2306 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" 2309 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];"
2307 " return numbers;" 2310 " return numbers;"
2308 "};" 2311 "};"
2309 "f(); f(); f();" 2312 "f(); f(); f();"
(...skipping 13 matching lines...) Expand all
2323 CHECK(HEAP->InOldPointerSpace(*int_array_handle)); 2326 CHECK(HEAP->InOldPointerSpace(*int_array_handle));
2324 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements())); 2327 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements()));
2325 CHECK(HEAP->InOldPointerSpace(*double_array_handle)); 2328 CHECK(HEAP->InOldPointerSpace(*double_array_handle));
2326 CHECK(HEAP->InOldDataSpace(double_array_handle->elements())); 2329 CHECK(HEAP->InOldDataSpace(double_array_handle->elements()));
2327 } 2330 }
2328 2331
2329 2332
2330 TEST(OptimizedPretenuringNestedObjectLiterals) { 2333 TEST(OptimizedPretenuringNestedObjectLiterals) {
2331 i::FLAG_allow_natives_syntax = true; 2334 i::FLAG_allow_natives_syntax = true;
2332 CcTest::InitializeVM(); 2335 CcTest::InitializeVM();
2333 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2336 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2334 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2337 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2335 v8::HandleScope scope(CcTest::isolate()); 2338 v8::HandleScope scope(CcTest::isolate());
2336 HEAP->SetNewSpaceHighPromotionModeActive(true); 2339 HEAP->SetNewSpaceHighPromotionModeActive(true);
2337 2340
2338 v8::Local<v8::Value> res = CompileRun( 2341 v8::Local<v8::Value> res = CompileRun(
2339 "function f() {" 2342 "function f() {"
2340 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" 2343 " var numbers = [[{}, {}, {}],[{}, {}, {}]];"
2341 " return numbers;" 2344 " return numbers;"
2342 "};" 2345 "};"
2343 "f(); f(); f();" 2346 "f(); f(); f();"
(...skipping 13 matching lines...) Expand all
2357 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1)); 2360 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1));
2358 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements())); 2361 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements()));
2359 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2)); 2362 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2));
2360 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements())); 2363 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements()));
2361 } 2364 }
2362 2365
2363 2366
2364 TEST(OptimizedPretenuringNestedDoubleLiterals) { 2367 TEST(OptimizedPretenuringNestedDoubleLiterals) {
2365 i::FLAG_allow_natives_syntax = true; 2368 i::FLAG_allow_natives_syntax = true;
2366 CcTest::InitializeVM(); 2369 CcTest::InitializeVM();
2367 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2370 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2368 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2371 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2369 v8::HandleScope scope(CcTest::isolate()); 2372 v8::HandleScope scope(CcTest::isolate());
2370 HEAP->SetNewSpaceHighPromotionModeActive(true); 2373 HEAP->SetNewSpaceHighPromotionModeActive(true);
2371 2374
2372 v8::Local<v8::Value> res = CompileRun( 2375 v8::Local<v8::Value> res = CompileRun(
2373 "function f() {" 2376 "function f() {"
2374 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" 2377 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];"
2375 " return numbers;" 2378 " return numbers;"
2376 "};" 2379 "};"
2377 "f(); f(); f();" 2380 "f(); f(); f();"
(...skipping 16 matching lines...) Expand all
2394 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements())); 2397 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements()));
2395 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2)); 2398 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2));
2396 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements())); 2399 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements()));
2397 } 2400 }
2398 2401
2399 2402
2400 // Test regular array literals allocation. 2403 // Test regular array literals allocation.
2401 TEST(OptimizedAllocationArrayLiterals) { 2404 TEST(OptimizedAllocationArrayLiterals) {
2402 i::FLAG_allow_natives_syntax = true; 2405 i::FLAG_allow_natives_syntax = true;
2403 CcTest::InitializeVM(); 2406 CcTest::InitializeVM();
2404 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2407 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2405 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2408 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2406 v8::HandleScope scope(CcTest::isolate()); 2409 v8::HandleScope scope(CcTest::isolate());
2407 2410
2408 v8::Local<v8::Value> res = CompileRun( 2411 v8::Local<v8::Value> res = CompileRun(
2409 "function f() {" 2412 "function f() {"
2410 " var numbers = new Array(1, 2, 3);" 2413 " var numbers = new Array(1, 2, 3);"
2411 " numbers[0] = 3.14;" 2414 " numbers[0] = 3.14;"
2412 " return numbers;" 2415 " return numbers;"
2413 "};" 2416 "};"
2414 "f(); f(); f();" 2417 "f(); f(); f();"
2415 "%OptimizeFunctionOnNextCall(f);" 2418 "%OptimizeFunctionOnNextCall(f);"
2416 "f();"); 2419 "f();");
2417 CHECK_EQ(static_cast<int>(3.14), 2420 CHECK_EQ(static_cast<int>(3.14),
2418 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); 2421 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2419 2422
2420 Handle<JSObject> o = 2423 Handle<JSObject> o =
2421 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2424 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2422 2425
2423 CHECK(HEAP->InNewSpace(o->elements())); 2426 CHECK(HEAP->InNewSpace(o->elements()));
2424 } 2427 }
2425 2428
2426 2429
2427 TEST(OptimizedPretenuringCallNew) { 2430 TEST(OptimizedPretenuringCallNew) {
2428 i::FLAG_allow_natives_syntax = true; 2431 i::FLAG_allow_natives_syntax = true;
2429 i::FLAG_pretenuring_call_new = true; 2432 i::FLAG_pretenuring_call_new = true;
2430 CcTest::InitializeVM(); 2433 CcTest::InitializeVM();
2431 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2434 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2432 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2435 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2433 v8::HandleScope scope(CcTest::isolate()); 2436 v8::HandleScope scope(CcTest::isolate());
2434 HEAP->SetNewSpaceHighPromotionModeActive(true); 2437 HEAP->SetNewSpaceHighPromotionModeActive(true);
2435 2438
2436 AlwaysAllocateScope always_allocate; 2439 AlwaysAllocateScope always_allocate;
2437 v8::Local<v8::Value> res = CompileRun( 2440 v8::Local<v8::Value> res = CompileRun(
2438 "function g() { this.a = 0; }" 2441 "function g() { this.a = 0; }"
2439 "function f() {" 2442 "function f() {"
2440 " return new g();" 2443 " return new g();"
2441 "};" 2444 "};"
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 " var a = new Array(n);" 3447 " var a = new Array(n);"
3445 " for (var i = 0; i < n; i += 100) a[i] = i;" 3448 " for (var i = 0; i < n; i += 100) a[i] = i;"
3446 "};" 3449 "};"
3447 "f(10 * 1024 * 1024);"); 3450 "f(10 * 1024 * 1024);");
3448 IncrementalMarking* marking = HEAP->incremental_marking(); 3451 IncrementalMarking* marking = HEAP->incremental_marking();
3449 if (marking->IsStopped()) marking->Start(); 3452 if (marking->IsStopped()) marking->Start();
3450 // This big step should be sufficient to mark the whole array. 3453 // This big step should be sufficient to mark the whole array.
3451 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3454 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3452 ASSERT(marking->IsComplete()); 3455 ASSERT(marking->IsComplete());
3453 } 3456 }
OLDNEW
« no previous file with comments | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698