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 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 CompileRun("f1=null"); | 1457 CompileRun("f1=null"); |
1458 | 1458 |
1459 // Scavenge treats these references as strong. | 1459 // Scavenge treats these references as strong. |
1460 for (int j = 0; j < 10; j++) { | 1460 for (int j = 0; j < 10; j++) { |
1461 CcTest::heap()->CollectGarbage(NEW_SPACE); | 1461 CcTest::heap()->CollectGarbage(NEW_SPACE); |
1462 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); | 1462 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); |
1463 } | 1463 } |
1464 | 1464 |
1465 // Mark compact handles the weak references. | 1465 // Mark compact handles the weak references. |
1466 isolate->compilation_cache()->Clear(); | 1466 isolate->compilation_cache()->Clear(); |
| 1467 // We have to collect twice because the type feedback vector |
| 1468 // could be strongly walked before we clear ICs in it. |
| 1469 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1467 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1470 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1468 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1471 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); |
1469 | 1472 |
1470 // Get rid of f3 and f5 in the same way. | 1473 // Get rid of f3 and f5 in the same way. |
1471 CompileRun("f3=null"); | 1474 CompileRun("f3=null"); |
1472 for (int j = 0; j < 10; j++) { | 1475 for (int j = 0; j < 10; j++) { |
1473 CcTest::heap()->CollectGarbage(NEW_SPACE); | 1476 CcTest::heap()->CollectGarbage(NEW_SPACE); |
1474 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1477 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); |
1475 } | 1478 } |
1476 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1479 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3131 { | 3134 { |
3132 LocalContext env; | 3135 LocalContext env; |
3133 CompileRun("function fun() {};"); | 3136 CompileRun("function fun() {};"); |
3134 fun2 = env->Global()->Get(v8_str("fun")); | 3137 fun2 = env->Global()->Get(v8_str("fun")); |
3135 } | 3138 } |
3136 | 3139 |
3137 // Prepare function f that contains type feedback for closures | 3140 // Prepare function f that contains type feedback for closures |
3138 // originating from two different native contexts. | 3141 // originating from two different native contexts. |
3139 CcTest::global()->Set(v8_str("fun1"), fun1); | 3142 CcTest::global()->Set(v8_str("fun1"), fun1); |
3140 CcTest::global()->Set(v8_str("fun2"), fun2); | 3143 CcTest::global()->Set(v8_str("fun2"), fun2); |
3141 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); | 3144 CompileRun("function f(a, b) { new a(); new b(); } f(fun1, fun2);"); |
3142 | 3145 |
3143 Handle<JSFunction> f = | 3146 Handle<JSFunction> f = |
3144 v8::Utils::OpenHandle( | 3147 v8::Utils::OpenHandle( |
3145 *v8::Handle<v8::Function>::Cast( | 3148 *v8::Handle<v8::Function>::Cast( |
3146 CcTest::global()->Get(v8_str("f")))); | 3149 CcTest::global()->Get(v8_str("f")))); |
3147 | 3150 |
3148 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); | 3151 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); |
3149 | 3152 |
3150 int expected_length = FLAG_vector_ics ? 4 : 2; | 3153 int expected_slots = 2; |
3151 CHECK_EQ(expected_length, feedback_vector->length()); | 3154 CHECK_EQ(expected_slots, feedback_vector->Slots()); |
3152 for (int i = 0; i < expected_length; i++) { | 3155 for (int i = 0; i < expected_slots; i++) { |
3153 if ((i % 2) == 1) { | 3156 CHECK(feedback_vector->Get(FeedbackVectorSlot(i))->IsJSFunction()); |
3154 CHECK(feedback_vector->get(i)->IsJSFunction()); | |
3155 } | |
3156 } | 3157 } |
3157 | 3158 |
3158 SimulateIncrementalMarking(CcTest::heap()); | 3159 SimulateIncrementalMarking(CcTest::heap()); |
3159 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 3160 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
3160 | 3161 |
3161 CHECK_EQ(expected_length, feedback_vector->length()); | 3162 CHECK_EQ(expected_slots, feedback_vector->Slots()); |
3162 for (int i = 0; i < expected_length; i++) { | 3163 for (int i = 0; i < expected_slots; i++) { |
3163 CHECK_EQ(feedback_vector->get(i), | 3164 CHECK_EQ(feedback_vector->Get(FeedbackVectorSlot(i)), |
3164 *TypeFeedbackVector::UninitializedSentinel(CcTest::i_isolate())); | 3165 *TypeFeedbackVector::UninitializedSentinel(CcTest::i_isolate())); |
3165 } | 3166 } |
3166 } | 3167 } |
3167 | 3168 |
3168 | 3169 |
3169 static Code* FindFirstIC(Code* code, Code::Kind kind) { | 3170 static Code* FindFirstIC(Code* code, Code::Kind kind) { |
3170 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 3171 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
3171 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 3172 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
3172 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 3173 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
3173 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 3174 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4505 #ifdef DEBUG | 4506 #ifdef DEBUG |
4506 TEST(PathTracer) { | 4507 TEST(PathTracer) { |
4507 CcTest::InitializeVM(); | 4508 CcTest::InitializeVM(); |
4508 v8::HandleScope scope(CcTest::isolate()); | 4509 v8::HandleScope scope(CcTest::isolate()); |
4509 | 4510 |
4510 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4511 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4511 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4512 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4512 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4513 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4513 } | 4514 } |
4514 #endif // DEBUG | 4515 #endif // DEBUG |
OLD | NEW |