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

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

Issue 24345003: remove Isolate::GetCurrent from Context api functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-object-observe.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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 "f(new foo()); g();"); 1890 "f(new foo()); g();");
1891 } 1891 }
1892 1892
1893 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 1893 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
1894 marking->Abort(); 1894 marking->Abort();
1895 marking->Start(); 1895 marking->Start();
1896 1896
1897 Handle<JSFunction> f = 1897 Handle<JSFunction> f =
1898 v8::Utils::OpenHandle( 1898 v8::Utils::OpenHandle(
1899 *v8::Handle<v8::Function>::Cast( 1899 *v8::Handle<v8::Function>::Cast(
1900 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 1900 CcTest::global()->Get(v8_str("f"))));
1901 1901
1902 CHECK(f->IsOptimized()); 1902 CHECK(f->IsOptimized());
1903 1903
1904 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && 1904 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) &&
1905 !marking->IsStopped()) { 1905 !marking->IsStopped()) {
1906 // Discard any pending GC requests otherwise we will get GC when we enter 1906 // Discard any pending GC requests otherwise we will get GC when we enter
1907 // code below. 1907 // code below.
1908 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 1908 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1909 } 1909 }
1910 1910
1911 CHECK(marking->IsMarking()); 1911 CHECK(marking->IsMarking());
1912 1912
1913 { 1913 {
1914 v8::HandleScope scope(CcTest::isolate()); 1914 v8::HandleScope scope(CcTest::isolate());
1915 v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); 1915 v8::Handle<v8::Object> global = CcTest::global();
1916 v8::Handle<v8::Function> g = 1916 v8::Handle<v8::Function> g =
1917 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 1917 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
1918 g->Call(global, 0, NULL); 1918 g->Call(global, 0, NULL);
1919 } 1919 }
1920 1920
1921 CcTest::heap()->incremental_marking()->set_should_hurry(true); 1921 CcTest::heap()->incremental_marking()->set_should_hurry(true);
1922 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 1922 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
1923 } 1923 }
1924 1924
1925 1925
1926 TEST(PrototypeTransitionClearing) { 1926 TEST(PrototypeTransitionClearing) {
1927 CcTest::InitializeVM(); 1927 CcTest::InitializeVM();
1928 Isolate* isolate = CcTest::i_isolate(); 1928 Isolate* isolate = CcTest::i_isolate();
1929 Factory* factory = isolate->factory(); 1929 Factory* factory = isolate->factory();
1930 v8::HandleScope scope(CcTest::isolate()); 1930 v8::HandleScope scope(CcTest::isolate());
1931 1931
1932 CompileRun( 1932 CompileRun(
1933 "var base = {};" 1933 "var base = {};"
1934 "var live = [];" 1934 "var live = [];"
1935 "for (var i = 0; i < 10; i++) {" 1935 "for (var i = 0; i < 10; i++) {"
1936 " var object = {};" 1936 " var object = {};"
1937 " var prototype = {};" 1937 " var prototype = {};"
1938 " object.__proto__ = prototype;" 1938 " object.__proto__ = prototype;"
1939 " if (i >= 3) live.push(object, prototype);" 1939 " if (i >= 3) live.push(object, prototype);"
1940 "}"); 1940 "}");
1941 1941
1942 Handle<JSObject> baseObject = 1942 Handle<JSObject> baseObject =
1943 v8::Utils::OpenHandle( 1943 v8::Utils::OpenHandle(
1944 *v8::Handle<v8::Object>::Cast( 1944 *v8::Handle<v8::Object>::Cast(
1945 v8::Context::GetCurrent()->Global()->Get(v8_str("base")))); 1945 CcTest::global()->Get(v8_str("base"))));
1946 1946
1947 // Verify that only dead prototype transitions are cleared. 1947 // Verify that only dead prototype transitions are cleared.
1948 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); 1948 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
1949 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1949 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1950 const int transitions = 10 - 3; 1950 const int transitions = 10 - 3;
1951 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); 1951 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
1952 1952
1953 // Verify that prototype transitions array was compacted. 1953 // Verify that prototype transitions array was compacted.
1954 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); 1954 FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
1955 for (int i = 0; i < transitions; i++) { 1955 for (int i = 0; i < transitions; i++) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 " for (var i = 0; i < 100; i++) s += i;" 2002 " for (var i = 0; i < 100; i++) s += i;"
2003 " return s;" 2003 " return s;"
2004 "}" 2004 "}"
2005 "f(); f();" 2005 "f(); f();"
2006 "%OptimizeFunctionOnNextCall(f);" 2006 "%OptimizeFunctionOnNextCall(f);"
2007 "f();"); 2007 "f();");
2008 } 2008 }
2009 Handle<JSFunction> f = 2009 Handle<JSFunction> f =
2010 v8::Utils::OpenHandle( 2010 v8::Utils::OpenHandle(
2011 *v8::Handle<v8::Function>::Cast( 2011 *v8::Handle<v8::Function>::Cast(
2012 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2012 CcTest::global()->Get(v8_str("f"))));
2013 CHECK(f->IsOptimized()); 2013 CHECK(f->IsOptimized());
2014 2014
2015 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2015 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2016 marking->Abort(); 2016 marking->Abort();
2017 marking->Start(); 2017 marking->Start();
2018 2018
2019 // The following two calls will increment CcTest::heap()->global_ic_age(). 2019 // The following two calls will increment CcTest::heap()->global_ic_age().
2020 const int kLongIdlePauseInMs = 1000; 2020 const int kLongIdlePauseInMs = 1000;
2021 v8::V8::ContextDisposedNotification(); 2021 v8::V8::ContextDisposedNotification();
2022 v8::V8::IdleNotification(kLongIdlePauseInMs); 2022 v8::V8::IdleNotification(kLongIdlePauseInMs);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 " for (var i = 0; i < 100; i++) s += i;" 2059 " for (var i = 0; i < 100; i++) s += i;"
2060 " return s;" 2060 " return s;"
2061 "}" 2061 "}"
2062 "f(); f();" 2062 "f(); f();"
2063 "%OptimizeFunctionOnNextCall(f);" 2063 "%OptimizeFunctionOnNextCall(f);"
2064 "f();"); 2064 "f();");
2065 } 2065 }
2066 Handle<JSFunction> f = 2066 Handle<JSFunction> f =
2067 v8::Utils::OpenHandle( 2067 v8::Utils::OpenHandle(
2068 *v8::Handle<v8::Function>::Cast( 2068 *v8::Handle<v8::Function>::Cast(
2069 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2069 CcTest::global()->Get(v8_str("f"))));
2070 CHECK(f->IsOptimized()); 2070 CHECK(f->IsOptimized());
2071 2071
2072 CcTest::heap()->incremental_marking()->Abort(); 2072 CcTest::heap()->incremental_marking()->Abort();
2073 2073
2074 // The following two calls will increment CcTest::heap()->global_ic_age(). 2074 // The following two calls will increment CcTest::heap()->global_ic_age().
2075 // Since incremental marking is off, IdleNotification will do full GC. 2075 // Since incremental marking is off, IdleNotification will do full GC.
2076 const int kLongIdlePauseInMs = 1000; 2076 const int kLongIdlePauseInMs = 1000;
2077 v8::V8::ContextDisposedNotification(); 2077 v8::V8::ContextDisposedNotification();
2078 v8::V8::IdleNotification(kLongIdlePauseInMs); 2078 v8::V8::IdleNotification(kLongIdlePauseInMs);
2079 2079
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 EmbeddedVector<char, 64> buffer; 2468 EmbeddedVector<char, 64> buffer;
2469 OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i); 2469 OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i);
2470 CompileRun(buffer.start()); 2470 CompileRun(buffer.start());
2471 } 2471 }
2472 CompileRun("var root = new Object;"); 2472 CompileRun("var root = new Object;");
2473 } 2473 }
2474 2474
2475 Handle<JSObject> root = 2475 Handle<JSObject> root =
2476 v8::Utils::OpenHandle( 2476 v8::Utils::OpenHandle(
2477 *v8::Handle<v8::Object>::Cast( 2477 *v8::Handle<v8::Object>::Cast(
2478 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2478 CcTest::global()->Get(v8_str("root"))));
2479 2479
2480 // Count number of live transitions before marking. 2480 // Count number of live transitions before marking.
2481 int transitions_before = CountMapTransitions(root->map()); 2481 int transitions_before = CountMapTransitions(root->map());
2482 CompileRun("%DebugPrint(root);"); 2482 CompileRun("%DebugPrint(root);");
2483 CHECK_EQ(transitions_count, transitions_before); 2483 CHECK_EQ(transitions_count, transitions_before);
2484 2484
2485 SimulateIncrementalMarking(); 2485 SimulateIncrementalMarking();
2486 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2486 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2487 2487
2488 // Count number of live transitions after marking. Note that one transition 2488 // Count number of live transitions after marking. Note that one transition
(...skipping 29 matching lines...) Expand all
2518 2518
2519 // This bug only triggers with aggressive IC clearing. 2519 // This bug only triggers with aggressive IC clearing.
2520 CcTest::heap()->AgeInlineCaches(); 2520 CcTest::heap()->AgeInlineCaches();
2521 2521
2522 // Explicitly request GC to perform final marking step and sweeping. 2522 // Explicitly request GC to perform final marking step and sweeping.
2523 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2523 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2524 2524
2525 Handle<JSObject> root = 2525 Handle<JSObject> root =
2526 v8::Utils::OpenHandle( 2526 v8::Utils::OpenHandle(
2527 *v8::Handle<v8::Object>::Cast( 2527 *v8::Handle<v8::Object>::Cast(
2528 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2528 CcTest::global()->Get(v8_str("root"))));
2529 2529
2530 // The root object should be in a sane state. 2530 // The root object should be in a sane state.
2531 CHECK(root->IsJSObject()); 2531 CHECK(root->IsJSObject());
2532 CHECK(root->map()->IsMap()); 2532 CHECK(root->map()->IsMap());
2533 } 2533 }
2534 2534
2535 2535
2536 TEST(Regress2143b) { 2536 TEST(Regress2143b) {
2537 i::FLAG_collect_maps = true; 2537 i::FLAG_collect_maps = true;
2538 i::FLAG_incremental_marking = true; 2538 i::FLAG_incremental_marking = true;
(...skipping 23 matching lines...) Expand all
2562 2562
2563 // This bug only triggers with aggressive IC clearing. 2563 // This bug only triggers with aggressive IC clearing.
2564 CcTest::heap()->AgeInlineCaches(); 2564 CcTest::heap()->AgeInlineCaches();
2565 2565
2566 // Explicitly request GC to perform final marking step and sweeping. 2566 // Explicitly request GC to perform final marking step and sweeping.
2567 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2567 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2568 2568
2569 Handle<JSObject> root = 2569 Handle<JSObject> root =
2570 v8::Utils::OpenHandle( 2570 v8::Utils::OpenHandle(
2571 *v8::Handle<v8::Object>::Cast( 2571 *v8::Handle<v8::Object>::Cast(
2572 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2572 CcTest::global()->Get(v8_str("root"))));
2573 2573
2574 // The root object should be in a sane state. 2574 // The root object should be in a sane state.
2575 CHECK(root->IsJSObject()); 2575 CHECK(root->IsJSObject());
2576 CHECK(root->map()->IsMap()); 2576 CHECK(root->map()->IsMap());
2577 } 2577 }
2578 2578
2579 2579
2580 TEST(ReleaseOverReservedPages) { 2580 TEST(ReleaseOverReservedPages) {
2581 i::FLAG_trace_gc = true; 2581 i::FLAG_trace_gc = true;
2582 // The optimizer can allocate stuff, messing up the test. 2582 // The optimizer can allocate stuff, messing up the test.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 #ifdef OBJECT_PRINT 2658 #ifdef OBJECT_PRINT
2659 TEST(PrintSharedFunctionInfo) { 2659 TEST(PrintSharedFunctionInfo) {
2660 CcTest::InitializeVM(); 2660 CcTest::InitializeVM();
2661 v8::HandleScope scope(CcTest::isolate()); 2661 v8::HandleScope scope(CcTest::isolate());
2662 const char* source = "f = function() { return 987654321; }\n" 2662 const char* source = "f = function() { return 987654321; }\n"
2663 "g = function() { return 123456789; }\n"; 2663 "g = function() { return 123456789; }\n";
2664 CompileRun(source); 2664 CompileRun(source);
2665 Handle<JSFunction> g = 2665 Handle<JSFunction> g =
2666 v8::Utils::OpenHandle( 2666 v8::Utils::OpenHandle(
2667 *v8::Handle<v8::Function>::Cast( 2667 *v8::Handle<v8::Function>::Cast(
2668 v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); 2668 CcTest::global()->Get(v8_str("g"))));
2669 2669
2670 DisallowHeapAllocation no_allocation; 2670 DisallowHeapAllocation no_allocation;
2671 g->shared()->PrintLn(); 2671 g->shared()->PrintLn();
2672 } 2672 }
2673 #endif // OBJECT_PRINT 2673 #endif // OBJECT_PRINT
2674 2674
2675 2675
2676 TEST(Regress2211) { 2676 TEST(Regress2211) {
2677 CcTest::InitializeVM(); 2677 CcTest::InitializeVM();
2678 v8::HandleScope scope(CcTest::isolate()); 2678 v8::HandleScope scope(CcTest::isolate());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 } 2721 }
2722 2722
2723 { 2723 {
2724 LocalContext env; 2724 LocalContext env;
2725 CompileRun("function fun() {};"); 2725 CompileRun("function fun() {};");
2726 fun2 = env->Global()->Get(v8_str("fun")); 2726 fun2 = env->Global()->Get(v8_str("fun"));
2727 } 2727 }
2728 2728
2729 // Prepare function f that contains type feedback for closures 2729 // Prepare function f that contains type feedback for closures
2730 // originating from two different native contexts. 2730 // originating from two different native contexts.
2731 v8::Context::GetCurrent()->Global()->Set(v8_str("fun1"), fun1); 2731 CcTest::global()->Set(v8_str("fun1"), fun1);
2732 v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2); 2732 CcTest::global()->Set(v8_str("fun2"), fun2);
2733 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); 2733 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
2734 Handle<JSFunction> f = 2734 Handle<JSFunction> f =
2735 v8::Utils::OpenHandle( 2735 v8::Utils::OpenHandle(
2736 *v8::Handle<v8::Function>::Cast( 2736 *v8::Handle<v8::Function>::Cast(
2737 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2737 CcTest::global()->Get(v8_str("f"))));
2738 Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast( 2738 Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast(
2739 f->shared()->code()->type_feedback_info())->type_feedback_cells()); 2739 f->shared()->code()->type_feedback_info())->type_feedback_cells());
2740 2740
2741 CHECK_EQ(2, cells->CellCount()); 2741 CHECK_EQ(2, cells->CellCount());
2742 CHECK(cells->GetCell(0)->value()->IsJSFunction()); 2742 CHECK(cells->GetCell(0)->value()->IsJSFunction());
2743 CHECK(cells->GetCell(1)->value()->IsJSFunction()); 2743 CHECK(cells->GetCell(1)->value()->IsJSFunction());
2744 2744
2745 SimulateIncrementalMarking(); 2745 SimulateIncrementalMarking();
2746 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2746 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2747 2747
(...skipping 24 matching lines...) Expand all
2772 CcTest::InitializeVM(); 2772 CcTest::InitializeVM();
2773 v8::HandleScope scope(CcTest::isolate()); 2773 v8::HandleScope scope(CcTest::isolate());
2774 2774
2775 // Prepare function f that contains a monomorphic IC for object 2775 // Prepare function f that contains a monomorphic IC for object
2776 // originating from the same native context. 2776 // originating from the same native context.
2777 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 2777 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
2778 "function f(o) { return o.x; } f(obj); f(obj);"); 2778 "function f(o) { return o.x; } f(obj); f(obj);");
2779 Handle<JSFunction> f = 2779 Handle<JSFunction> f =
2780 v8::Utils::OpenHandle( 2780 v8::Utils::OpenHandle(
2781 *v8::Handle<v8::Function>::Cast( 2781 *v8::Handle<v8::Function>::Cast(
2782 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2782 CcTest::global()->Get(v8_str("f"))));
2783 2783
2784 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2784 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2785 CHECK(ic_before->ic_state() == MONOMORPHIC); 2785 CHECK(ic_before->ic_state() == MONOMORPHIC);
2786 2786
2787 SimulateIncrementalMarking(); 2787 SimulateIncrementalMarking();
2788 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2788 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2789 2789
2790 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2790 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2791 CHECK(ic_after->ic_state() == MONOMORPHIC); 2791 CHECK(ic_after->ic_state() == MONOMORPHIC);
2792 } 2792 }
2793 2793
2794 2794
2795 TEST(IncrementalMarkingClearsMonomorhpicIC) { 2795 TEST(IncrementalMarkingClearsMonomorhpicIC) {
2796 if (i::FLAG_always_opt) return; 2796 if (i::FLAG_always_opt) return;
2797 CcTest::InitializeVM(); 2797 CcTest::InitializeVM();
2798 v8::HandleScope scope(CcTest::isolate()); 2798 v8::HandleScope scope(CcTest::isolate());
2799 v8::Local<v8::Value> obj1; 2799 v8::Local<v8::Value> obj1;
2800 2800
2801 { 2801 {
2802 LocalContext env; 2802 LocalContext env;
2803 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 2803 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
2804 obj1 = env->Global()->Get(v8_str("obj")); 2804 obj1 = env->Global()->Get(v8_str("obj"));
2805 } 2805 }
2806 2806
2807 // Prepare function f that contains a monomorphic IC for object 2807 // Prepare function f that contains a monomorphic IC for object
2808 // originating from a different native context. 2808 // originating from a different native context.
2809 v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1); 2809 CcTest::global()->Set(v8_str("obj1"), obj1);
2810 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); 2810 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
2811 Handle<JSFunction> f = 2811 Handle<JSFunction> f =
2812 v8::Utils::OpenHandle( 2812 v8::Utils::OpenHandle(
2813 *v8::Handle<v8::Function>::Cast( 2813 *v8::Handle<v8::Function>::Cast(
2814 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2814 CcTest::global()->Get(v8_str("f"))));
2815 2815
2816 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2816 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2817 CHECK(ic_before->ic_state() == MONOMORPHIC); 2817 CHECK(ic_before->ic_state() == MONOMORPHIC);
2818 2818
2819 // Fire context dispose notification. 2819 // Fire context dispose notification.
2820 v8::V8::ContextDisposedNotification(); 2820 v8::V8::ContextDisposedNotification();
2821 SimulateIncrementalMarking(); 2821 SimulateIncrementalMarking();
2822 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2822 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2823 2823
2824 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2824 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
(...skipping 14 matching lines...) Expand all
2839 } 2839 }
2840 2840
2841 { 2841 {
2842 LocalContext env; 2842 LocalContext env;
2843 CompileRun("function fun() { this.x = 2; }; var obj = new fun();"); 2843 CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
2844 obj2 = env->Global()->Get(v8_str("obj")); 2844 obj2 = env->Global()->Get(v8_str("obj"));
2845 } 2845 }
2846 2846
2847 // Prepare function f that contains a polymorphic IC for objects 2847 // Prepare function f that contains a polymorphic IC for objects
2848 // originating from two different native contexts. 2848 // originating from two different native contexts.
2849 v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1); 2849 CcTest::global()->Set(v8_str("obj1"), obj1);
2850 v8::Context::GetCurrent()->Global()->Set(v8_str("obj2"), obj2); 2850 CcTest::global()->Set(v8_str("obj2"), obj2);
2851 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); 2851 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
2852 Handle<JSFunction> f = 2852 Handle<JSFunction> f =
2853 v8::Utils::OpenHandle( 2853 v8::Utils::OpenHandle(
2854 *v8::Handle<v8::Function>::Cast( 2854 *v8::Handle<v8::Function>::Cast(
2855 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2855 CcTest::global()->Get(v8_str("f"))));
2856 2856
2857 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2857 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2858 CHECK(ic_before->ic_state() == POLYMORPHIC); 2858 CHECK(ic_before->ic_state() == POLYMORPHIC);
2859 2859
2860 // Fire context dispose notification. 2860 // Fire context dispose notification.
2861 v8::V8::ContextDisposedNotification(); 2861 v8::V8::ContextDisposedNotification();
2862 SimulateIncrementalMarking(); 2862 SimulateIncrementalMarking();
2863 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2863 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2864 2864
2865 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2865 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 "var g = mkClosure();" 3050 "var g = mkClosure();"
3051 "f(1); f(2);" 3051 "f(1); f(2);"
3052 "g(1); g(2);" 3052 "g(1); g(2);"
3053 "h(1); h(2);" 3053 "h(1); h(2);"
3054 "%OptimizeFunctionOnNextCall(f); f(3);" 3054 "%OptimizeFunctionOnNextCall(f); f(3);"
3055 "%OptimizeFunctionOnNextCall(h); h(3);"); 3055 "%OptimizeFunctionOnNextCall(h); h(3);");
3056 3056
3057 Handle<JSFunction> f = 3057 Handle<JSFunction> f =
3058 v8::Utils::OpenHandle( 3058 v8::Utils::OpenHandle(
3059 *v8::Handle<v8::Function>::Cast( 3059 *v8::Handle<v8::Function>::Cast(
3060 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 3060 CcTest::global()->Get(v8_str("f"))));
3061 CHECK(f->is_compiled()); 3061 CHECK(f->is_compiled());
3062 CompileRun("f = null;"); 3062 CompileRun("f = null;");
3063 3063
3064 Handle<JSFunction> g = 3064 Handle<JSFunction> g =
3065 v8::Utils::OpenHandle( 3065 v8::Utils::OpenHandle(
3066 *v8::Handle<v8::Function>::Cast( 3066 *v8::Handle<v8::Function>::Cast(
3067 v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); 3067 CcTest::global()->Get(v8_str("g"))));
3068 CHECK(g->is_compiled()); 3068 CHECK(g->is_compiled());
3069 const int kAgingThreshold = 6; 3069 const int kAgingThreshold = 6;
3070 for (int i = 0; i < kAgingThreshold; i++) { 3070 for (int i = 0; i < kAgingThreshold; i++) {
3071 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3071 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3072 } 3072 }
3073 3073
3074 code = inner_scope.CloseAndEscape(Handle<Code>(f->code())); 3074 code = inner_scope.CloseAndEscape(Handle<Code>(f->code()));
3075 } 3075 }
3076 3076
3077 // Simulate incremental marking so that the functions are enqueued as 3077 // Simulate incremental marking so that the functions are enqueued as
(...skipping 27 matching lines...) Expand all
3105 CompileRun("function mkClosure() {" 3105 CompileRun("function mkClosure() {"
3106 " return function(x) { return x + 1; };" 3106 " return function(x) { return x + 1; };"
3107 "}" 3107 "}"
3108 "var f = mkClosure();" 3108 "var f = mkClosure();"
3109 "f(1); f(2);" 3109 "f(1); f(2);"
3110 "%OptimizeFunctionOnNextCall(f); f(3);"); 3110 "%OptimizeFunctionOnNextCall(f); f(3);");
3111 3111
3112 Handle<JSFunction> f = 3112 Handle<JSFunction> f =
3113 v8::Utils::OpenHandle( 3113 v8::Utils::OpenHandle(
3114 *v8::Handle<v8::Function>::Cast( 3114 *v8::Handle<v8::Function>::Cast(
3115 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 3115 CcTest::global()->Get(v8_str("f"))));
3116 CHECK(f->is_compiled()); 3116 CHECK(f->is_compiled());
3117 const int kAgingThreshold = 6; 3117 const int kAgingThreshold = 6;
3118 for (int i = 0; i < kAgingThreshold; i++) { 3118 for (int i = 0; i < kAgingThreshold; i++) {
3119 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3119 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3120 } 3120 }
3121 3121
3122 CompileRun("f = null;"); 3122 CompileRun("f = null;");
3123 } 3123 }
3124 3124
3125 // Simulate incremental marking so that unoptimized code is flushed 3125 // Simulate incremental marking so that unoptimized code is flushed
(...skipping 27 matching lines...) Expand all
3153 HandleScope inner_scope(isolate); 3153 HandleScope inner_scope(isolate);
3154 CompileRun("function f() { return 'foobar'; }" 3154 CompileRun("function f() { return 'foobar'; }"
3155 "function g(x) { if (x) f(); }" 3155 "function g(x) { if (x) f(); }"
3156 "f();" 3156 "f();"
3157 "g(false);" 3157 "g(false);"
3158 "g(false);"); 3158 "g(false);");
3159 3159
3160 Handle<JSFunction> f = 3160 Handle<JSFunction> f =
3161 v8::Utils::OpenHandle( 3161 v8::Utils::OpenHandle(
3162 *v8::Handle<v8::Function>::Cast( 3162 *v8::Handle<v8::Function>::Cast(
3163 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 3163 CcTest::global()->Get(v8_str("f"))));
3164 CHECK(f->is_compiled()); 3164 CHECK(f->is_compiled());
3165 const int kAgingThreshold = 6; 3165 const int kAgingThreshold = 6;
3166 for (int i = 0; i < kAgingThreshold; i++) { 3166 for (int i = 0; i < kAgingThreshold; i++) {
3167 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3167 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3168 } 3168 }
3169 3169
3170 shared1 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); 3170 shared1 = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
3171 } 3171 }
3172 3172
3173 // Prepare a shared function info eligible for code flushing that will 3173 // Prepare a shared function info eligible for code flushing that will
3174 // represent the dangling tail of the candidate list. 3174 // represent the dangling tail of the candidate list.
3175 Handle<SharedFunctionInfo> shared2; 3175 Handle<SharedFunctionInfo> shared2;
3176 { 3176 {
3177 HandleScope inner_scope(isolate); 3177 HandleScope inner_scope(isolate);
3178 CompileRun("function flushMe() { return 0; }" 3178 CompileRun("function flushMe() { return 0; }"
3179 "flushMe(1);"); 3179 "flushMe(1);");
3180 3180
3181 Handle<JSFunction> f = 3181 Handle<JSFunction> f =
3182 v8::Utils::OpenHandle( 3182 v8::Utils::OpenHandle(
3183 *v8::Handle<v8::Function>::Cast( 3183 *v8::Handle<v8::Function>::Cast(
3184 v8::Context::GetCurrent()->Global()->Get(v8_str("flushMe")))); 3184 CcTest::global()->Get(v8_str("flushMe"))));
3185 CHECK(f->is_compiled()); 3185 CHECK(f->is_compiled());
3186 const int kAgingThreshold = 6; 3186 const int kAgingThreshold = 6;
3187 for (int i = 0; i < kAgingThreshold; i++) { 3187 for (int i = 0; i < kAgingThreshold; i++) {
3188 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3188 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3189 } 3189 }
3190 3190
3191 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); 3191 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
3192 } 3192 }
3193 3193
3194 // Simulate incremental marking and collect code flushing candidates. 3194 // Simulate incremental marking and collect code flushing candidates.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 "}" 3244 "}"
3245 "obj = fastliteralcase(get_standard_literal(), 1);" 3245 "obj = fastliteralcase(get_standard_literal(), 1);"
3246 "obj = fastliteralcase(get_standard_literal(), 1.5);" 3246 "obj = fastliteralcase(get_standard_literal(), 1.5);"
3247 "obj = fastliteralcase(get_standard_literal(), 2);"); 3247 "obj = fastliteralcase(get_standard_literal(), 2);");
3248 3248
3249 // prepare the heap 3249 // prepare the heap
3250 v8::Local<v8::String> mote_code_string = 3250 v8::Local<v8::String> mote_code_string =
3251 v8_str("fastliteralcase(mote, 2.5);"); 3251 v8_str("fastliteralcase(mote, 2.5);");
3252 3252
3253 v8::Local<v8::String> array_name = v8_str("mote"); 3253 v8::Local<v8::String> array_name = v8_str("mote");
3254 v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0)); 3254 CcTest::global()->Set(array_name, v8::Int32::New(0));
3255 3255
3256 // First make sure we flip spaces 3256 // First make sure we flip spaces
3257 CcTest::heap()->CollectGarbage(NEW_SPACE); 3257 CcTest::heap()->CollectGarbage(NEW_SPACE);
3258 3258
3259 // Allocate the object. 3259 // Allocate the object.
3260 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); 3260 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
3261 array_data->set(0, Smi::FromInt(1)); 3261 array_data->set(0, Smi::FromInt(1));
3262 array_data->set(1, Smi::FromInt(2)); 3262 array_data->set(1, Smi::FromInt(2));
3263 3263
3264 AllocateAllButNBytes(CcTest::heap()->new_space(), 3264 AllocateAllButNBytes(CcTest::heap()->new_space(),
(...skipping 13 matching lines...) Expand all
3278 AllocationMemento::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE); 3278 AllocationMemento::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE);
3279 Object* obj = NULL; 3279 Object* obj = NULL;
3280 CHECK(maybe_object->ToObject(&obj)); 3280 CHECK(maybe_object->ToObject(&obj));
3281 Address addr_obj = reinterpret_cast<Address>( 3281 Address addr_obj = reinterpret_cast<Address>(
3282 reinterpret_cast<byte*>(obj - kHeapObjectTag)); 3282 reinterpret_cast<byte*>(obj - kHeapObjectTag));
3283 CcTest::heap()->CreateFillerObjectAt(addr_obj, 3283 CcTest::heap()->CreateFillerObjectAt(addr_obj,
3284 AllocationMemento::kSize + kPointerSize); 3284 AllocationMemento::kSize + kPointerSize);
3285 3285
3286 // Give the array a name, making sure not to allocate strings. 3286 // Give the array a name, making sure not to allocate strings.
3287 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array); 3287 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
3288 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj); 3288 CcTest::global()->Set(array_name, array_obj);
3289 3289
3290 // This should crash with a protection violation if we are running a build 3290 // This should crash with a protection violation if we are running a build
3291 // with the bug. 3291 // with the bug.
3292 AlwaysAllocateScope aa_scope; 3292 AlwaysAllocateScope aa_scope;
3293 v8::Script::Compile(mote_code_string)->Run(); 3293 v8::Script::Compile(mote_code_string)->Run();
3294 } 3294 }
3295 3295
3296 3296
3297 TEST(Regress168801) { 3297 TEST(Regress168801) {
3298 i::FLAG_always_compact = true; 3298 i::FLAG_always_compact = true;
(...skipping 17 matching lines...) Expand all
3316 HandleScope inner_scope(isolate); 3316 HandleScope inner_scope(isolate);
3317 CompileRun("function mkClosure() {" 3317 CompileRun("function mkClosure() {"
3318 " return function(x) { return x + 1; };" 3318 " return function(x) { return x + 1; };"
3319 "}" 3319 "}"
3320 "var f = mkClosure();" 3320 "var f = mkClosure();"
3321 "f(1); f(2);"); 3321 "f(1); f(2);");
3322 3322
3323 Handle<JSFunction> f = 3323 Handle<JSFunction> f =
3324 v8::Utils::OpenHandle( 3324 v8::Utils::OpenHandle(
3325 *v8::Handle<v8::Function>::Cast( 3325 *v8::Handle<v8::Function>::Cast(
3326 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 3326 CcTest::global()->Get(v8_str("f"))));
3327 CHECK(f->is_compiled()); 3327 CHECK(f->is_compiled());
3328 const int kAgingThreshold = 6; 3328 const int kAgingThreshold = 6;
3329 for (int i = 0; i < kAgingThreshold; i++) { 3329 for (int i = 0; i < kAgingThreshold; i++) {
3330 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3330 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3331 } 3331 }
3332 3332
3333 function = inner_scope.CloseAndEscape(handle(*f, isolate)); 3333 function = inner_scope.CloseAndEscape(handle(*f, isolate));
3334 } 3334 }
3335 3335
3336 // Simulate incremental marking so that unoptimized function is enqueued as a 3336 // Simulate incremental marking so that unoptimized function is enqueued as a
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3372 HandleScope inner_scope(isolate); 3372 HandleScope inner_scope(isolate);
3373 CompileRun("function mkClosure() {" 3373 CompileRun("function mkClosure() {"
3374 " return function(x) { return x + 1; };" 3374 " return function(x) { return x + 1; };"
3375 "}" 3375 "}"
3376 "var f = mkClosure();" 3376 "var f = mkClosure();"
3377 "f(1); f(2);"); 3377 "f(1); f(2);");
3378 3378
3379 Handle<JSFunction> f = 3379 Handle<JSFunction> f =
3380 v8::Utils::OpenHandle( 3380 v8::Utils::OpenHandle(
3381 *v8::Handle<v8::Function>::Cast( 3381 *v8::Handle<v8::Function>::Cast(
3382 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 3382 CcTest::global()->Get(v8_str("f"))));
3383 CHECK(f->is_compiled()); 3383 CHECK(f->is_compiled());
3384 const int kAgingThreshold = 6; 3384 const int kAgingThreshold = 6;
3385 for (int i = 0; i < kAgingThreshold; i++) { 3385 for (int i = 0; i < kAgingThreshold; i++) {
3386 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3386 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3387 } 3387 }
3388 3388
3389 function = inner_scope.CloseAndEscape(handle(*f, isolate)); 3389 function = inner_scope.CloseAndEscape(handle(*f, isolate));
3390 } 3390 }
3391 3391
3392 // Simulate incremental marking so that unoptimized function is enqueued as a 3392 // Simulate incremental marking so that unoptimized function is enqueued as a
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3440 " var a = new Array(n);" 3440 " var a = new Array(n);"
3441 " for (var i = 0; i < n; i += 100) a[i] = i;" 3441 " for (var i = 0; i < n; i += 100) a[i] = i;"
3442 "};" 3442 "};"
3443 "f(10 * 1024 * 1024);"); 3443 "f(10 * 1024 * 1024);");
3444 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 3444 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
3445 if (marking->IsStopped()) marking->Start(); 3445 if (marking->IsStopped()) marking->Start();
3446 // This big step should be sufficient to mark the whole array. 3446 // This big step should be sufficient to mark the whole array.
3447 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3447 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3448 ASSERT(marking->IsComplete()); 3448 ASSERT(marking->IsComplete());
3449 } 3449 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698