| OLD | NEW |
| 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 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 CompileRun("var root = new F;"); | 2892 CompileRun("var root = new F;"); |
| 2893 Handle<JSObject> root = GetByName("root"); | 2893 Handle<JSObject> root = GetByName("root"); |
| 2894 | 2894 |
| 2895 // Count number of live transitions before marking. | 2895 // Count number of live transitions before marking. |
| 2896 int transitions_before = CountMapTransitions(root->map()); | 2896 int transitions_before = CountMapTransitions(root->map()); |
| 2897 CHECK_EQ(transitions_count, transitions_before); | 2897 CHECK_EQ(transitions_count, transitions_before); |
| 2898 | 2898 |
| 2899 CompileRun("o = new F;" | 2899 CompileRun("o = new F;" |
| 2900 "root = new F"); | 2900 "root = new F"); |
| 2901 root = GetByName("root"); | 2901 root = GetByName("root"); |
| 2902 ASSERT(root->map()->transitions()->IsSimpleTransition()); | 2902 DCHECK(root->map()->transitions()->IsSimpleTransition()); |
| 2903 AddPropertyTo(2, root, "happy"); | 2903 AddPropertyTo(2, root, "happy"); |
| 2904 | 2904 |
| 2905 // Count number of live transitions after marking. Note that one transition | 2905 // Count number of live transitions after marking. Note that one transition |
| 2906 // is left, because 'o' still holds an instance of one transition target. | 2906 // is left, because 'o' still holds an instance of one transition target. |
| 2907 int transitions_after = CountMapTransitions( | 2907 int transitions_after = CountMapTransitions( |
| 2908 Map::cast(root->map()->GetBackPointer())); | 2908 Map::cast(root->map()->GetBackPointer())); |
| 2909 CHECK_EQ(1, transitions_after); | 2909 CHECK_EQ(1, transitions_after); |
| 2910 } | 2910 } |
| 2911 #endif // DEBUG | 2911 #endif // DEBUG |
| 2912 | 2912 |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3786 Isolate* isolate = CcTest::i_isolate(); | 3786 Isolate* isolate = CcTest::i_isolate(); |
| 3787 Heap* heap = isolate->heap(); | 3787 Heap* heap = isolate->heap(); |
| 3788 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); | 3788 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); |
| 3789 HandleScopeData* data = isolate->handle_scope_data(); | 3789 HandleScopeData* data = isolate->handle_scope_data(); |
| 3790 Handle<Object> init(heap->empty_string(), isolate); | 3790 Handle<Object> init(heap->empty_string(), isolate); |
| 3791 while (data->next < data->limit) { | 3791 while (data->next < data->limit) { |
| 3792 Handle<Object> obj(heap->empty_string(), isolate); | 3792 Handle<Object> obj(heap->empty_string(), isolate); |
| 3793 } | 3793 } |
| 3794 // An entire block of handles has been filled. | 3794 // An entire block of handles has been filled. |
| 3795 // Next handle would require a new block. | 3795 // Next handle would require a new block. |
| 3796 ASSERT(data->next == data->limit); | 3796 DCHECK(data->next == data->limit); |
| 3797 | 3797 |
| 3798 DeferredHandleScope deferred(isolate); | 3798 DeferredHandleScope deferred(isolate); |
| 3799 DummyVisitor visitor; | 3799 DummyVisitor visitor; |
| 3800 isolate->handle_scope_implementer()->Iterate(&visitor); | 3800 isolate->handle_scope_implementer()->Iterate(&visitor); |
| 3801 delete deferred.Detach(); | 3801 delete deferred.Detach(); |
| 3802 } | 3802 } |
| 3803 | 3803 |
| 3804 | 3804 |
| 3805 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { | 3805 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { |
| 3806 CcTest::InitializeVM(); | 3806 CcTest::InitializeVM(); |
| 3807 v8::HandleScope scope(CcTest::isolate()); | 3807 v8::HandleScope scope(CcTest::isolate()); |
| 3808 CompileRun("function f(n) {" | 3808 CompileRun("function f(n) {" |
| 3809 " var a = new Array(n);" | 3809 " var a = new Array(n);" |
| 3810 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3810 " for (var i = 0; i < n; i += 100) a[i] = i;" |
| 3811 "};" | 3811 "};" |
| 3812 "f(10 * 1024 * 1024);"); | 3812 "f(10 * 1024 * 1024);"); |
| 3813 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 3813 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 3814 if (marking->IsStopped()) marking->Start(); | 3814 if (marking->IsStopped()) marking->Start(); |
| 3815 // This big step should be sufficient to mark the whole array. | 3815 // This big step should be sufficient to mark the whole array. |
| 3816 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3816 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 3817 ASSERT(marking->IsComplete()); | 3817 DCHECK(marking->IsComplete()); |
| 3818 } | 3818 } |
| 3819 | 3819 |
| 3820 | 3820 |
| 3821 TEST(DisableInlineAllocation) { | 3821 TEST(DisableInlineAllocation) { |
| 3822 i::FLAG_allow_natives_syntax = true; | 3822 i::FLAG_allow_natives_syntax = true; |
| 3823 CcTest::InitializeVM(); | 3823 CcTest::InitializeVM(); |
| 3824 v8::HandleScope scope(CcTest::isolate()); | 3824 v8::HandleScope scope(CcTest::isolate()); |
| 3825 CompileRun("function test() {" | 3825 CompileRun("function test() {" |
| 3826 " var x = [];" | 3826 " var x = [];" |
| 3827 " for (var i = 0; i < 10; i++) {" | 3827 " for (var i = 0; i < 10; i++) {" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3947 *v8::Handle<v8::Function>::Cast( | 3947 *v8::Handle<v8::Function>::Cast( |
| 3948 CcTest::global()->Get(v8_str("bar")))); | 3948 CcTest::global()->Get(v8_str("bar")))); |
| 3949 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3949 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 3950 } | 3950 } |
| 3951 | 3951 |
| 3952 // Now make sure that a gc should get rid of the function | 3952 // Now make sure that a gc should get rid of the function |
| 3953 for (int i = 0; i < 4; i++) { | 3953 for (int i = 0; i < 4; i++) { |
| 3954 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3954 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 3955 } | 3955 } |
| 3956 | 3956 |
| 3957 ASSERT(code->marked_for_deoptimization()); | 3957 DCHECK(code->marked_for_deoptimization()); |
| 3958 } | 3958 } |
| 3959 | 3959 |
| 3960 | 3960 |
| 3961 TEST(ObjectsInOptimizedCodeAreWeak) { | 3961 TEST(ObjectsInOptimizedCodeAreWeak) { |
| 3962 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 3962 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
| 3963 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 3963 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
| 3964 i::FLAG_allow_natives_syntax = true; | 3964 i::FLAG_allow_natives_syntax = true; |
| 3965 CcTest::InitializeVM(); | 3965 CcTest::InitializeVM(); |
| 3966 Isolate* isolate = CcTest::i_isolate(); | 3966 Isolate* isolate = CcTest::i_isolate(); |
| 3967 v8::internal::Heap* heap = CcTest::heap(); | 3967 v8::internal::Heap* heap = CcTest::heap(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3988 *v8::Handle<v8::Function>::Cast( | 3988 *v8::Handle<v8::Function>::Cast( |
| 3989 CcTest::global()->Get(v8_str("bar")))); | 3989 CcTest::global()->Get(v8_str("bar")))); |
| 3990 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3990 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 3991 } | 3991 } |
| 3992 | 3992 |
| 3993 // Now make sure that a gc should get rid of the function | 3993 // Now make sure that a gc should get rid of the function |
| 3994 for (int i = 0; i < 4; i++) { | 3994 for (int i = 0; i < 4; i++) { |
| 3995 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3995 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 3996 } | 3996 } |
| 3997 | 3997 |
| 3998 ASSERT(code->marked_for_deoptimization()); | 3998 DCHECK(code->marked_for_deoptimization()); |
| 3999 } | 3999 } |
| 4000 | 4000 |
| 4001 | 4001 |
| 4002 TEST(NoWeakHashTableLeakWithIncrementalMarking) { | 4002 TEST(NoWeakHashTableLeakWithIncrementalMarking) { |
| 4003 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 4003 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
| 4004 if (!i::FLAG_incremental_marking) return; | 4004 if (!i::FLAG_incremental_marking) return; |
| 4005 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 4005 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
| 4006 i::FLAG_allow_natives_syntax = true; | 4006 i::FLAG_allow_natives_syntax = true; |
| 4007 i::FLAG_compilation_cache = false; | 4007 i::FLAG_compilation_cache = false; |
| 4008 CcTest::InitializeVM(); | 4008 CcTest::InitializeVM(); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4320 | 4320 |
| 4321 | 4321 |
| 4322 TEST(Regress357137) { | 4322 TEST(Regress357137) { |
| 4323 CcTest::InitializeVM(); | 4323 CcTest::InitializeVM(); |
| 4324 v8::Isolate* isolate = CcTest::isolate(); | 4324 v8::Isolate* isolate = CcTest::isolate(); |
| 4325 v8::HandleScope hscope(isolate); | 4325 v8::HandleScope hscope(isolate); |
| 4326 v8::Handle<v8::ObjectTemplate> global =v8::ObjectTemplate::New(isolate); | 4326 v8::Handle<v8::ObjectTemplate> global =v8::ObjectTemplate::New(isolate); |
| 4327 global->Set(v8::String::NewFromUtf8(isolate, "interrupt"), | 4327 global->Set(v8::String::NewFromUtf8(isolate, "interrupt"), |
| 4328 v8::FunctionTemplate::New(isolate, RequestInterrupt)); | 4328 v8::FunctionTemplate::New(isolate, RequestInterrupt)); |
| 4329 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); | 4329 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); |
| 4330 ASSERT(!context.IsEmpty()); | 4330 DCHECK(!context.IsEmpty()); |
| 4331 v8::Context::Scope cscope(context); | 4331 v8::Context::Scope cscope(context); |
| 4332 | 4332 |
| 4333 v8::Local<v8::Value> result = CompileRun( | 4333 v8::Local<v8::Value> result = CompileRun( |
| 4334 "var locals = '';" | 4334 "var locals = '';" |
| 4335 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" | 4335 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" |
| 4336 "eval('function f() {' + locals + 'return function() { return v0; }; }');" | 4336 "eval('function f() {' + locals + 'return function() { return v0; }; }');" |
| 4337 "interrupt();" // This triggers a fake stack overflow in f. | 4337 "interrupt();" // This triggers a fake stack overflow in f. |
| 4338 "f()()"); | 4338 "f()()"); |
| 4339 CHECK_EQ(42.0, result->ToNumber()->Value()); | 4339 CHECK_EQ(42.0, result->ToNumber()->Value()); |
| 4340 } | 4340 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4496 #ifdef DEBUG | 4496 #ifdef DEBUG |
| 4497 TEST(PathTracer) { | 4497 TEST(PathTracer) { |
| 4498 CcTest::InitializeVM(); | 4498 CcTest::InitializeVM(); |
| 4499 v8::HandleScope scope(CcTest::isolate()); | 4499 v8::HandleScope scope(CcTest::isolate()); |
| 4500 | 4500 |
| 4501 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4501 v8::Local<v8::Value> result = CompileRun("'abc'"); |
| 4502 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4502 Handle<Object> o = v8::Utils::OpenHandle(*result); |
| 4503 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4503 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
| 4504 } | 4504 } |
| 4505 #endif // DEBUG | 4505 #endif // DEBUG |
| OLD | NEW |