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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 // test is invalid. | 1380 // test is invalid. |
1381 if (!FLAG_flush_code || !FLAG_flush_code_incrementally || | 1381 if (!FLAG_flush_code || !FLAG_flush_code_incrementally || |
1382 !FLAG_compilation_cache) { | 1382 !FLAG_compilation_cache) { |
1383 return; | 1383 return; |
1384 } | 1384 } |
1385 CcTest::InitializeVM(); | 1385 CcTest::InitializeVM(); |
1386 Isolate* isolate = CcTest::i_isolate(); | 1386 Isolate* isolate = CcTest::i_isolate(); |
1387 Factory* factory = isolate->factory(); | 1387 Factory* factory = isolate->factory(); |
1388 Heap* heap = isolate->heap(); | 1388 Heap* heap = isolate->heap(); |
1389 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1389 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 1390 LanguageMode language_mode = |
| 1391 construct_language_mode(FLAG_use_strict, FLAG_use_strong); |
1390 | 1392 |
1391 v8::HandleScope scope(CcTest::isolate()); | 1393 v8::HandleScope scope(CcTest::isolate()); |
1392 const char* raw_source = | 1394 const char* raw_source = |
1393 "function foo() {" | 1395 "function foo() {" |
1394 " var x = 42;" | 1396 " var x = 42;" |
1395 " var y = 42;" | 1397 " var y = 42;" |
1396 " var z = x + y;" | 1398 " var z = x + y;" |
1397 "};" | 1399 "};" |
1398 "foo()"; | 1400 "foo()"; |
1399 Handle<String> source = factory->InternalizeUtf8String(raw_source); | 1401 Handle<String> source = factory->InternalizeUtf8String(raw_source); |
1400 Handle<Context> native_context = isolate->native_context(); | 1402 Handle<Context> native_context = isolate->native_context(); |
1401 | 1403 |
1402 { | 1404 { |
1403 v8::HandleScope scope(CcTest::isolate()); | 1405 v8::HandleScope scope(CcTest::isolate()); |
1404 CompileRun(raw_source); | 1406 CompileRun(raw_source); |
1405 } | 1407 } |
1406 | 1408 |
1407 // On first compilation, only a hash is inserted in the code cache. We can't | 1409 // On first compilation, only a hash is inserted in the code cache. We can't |
1408 // find that value. | 1410 // find that value. |
1409 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( | 1411 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( |
1410 source, Handle<Object>(), 0, 0, false, true, native_context); | 1412 source, Handle<Object>(), 0, 0, false, true, native_context, |
| 1413 language_mode); |
1411 CHECK(info.is_null()); | 1414 CHECK(info.is_null()); |
1412 | 1415 |
1413 { | 1416 { |
1414 v8::HandleScope scope(CcTest::isolate()); | 1417 v8::HandleScope scope(CcTest::isolate()); |
1415 CompileRun(raw_source); | 1418 CompileRun(raw_source); |
1416 } | 1419 } |
1417 | 1420 |
1418 // On second compilation, the hash is replaced by a real cache entry mapping | 1421 // On second compilation, the hash is replaced by a real cache entry mapping |
1419 // the source to the shared function info containing the code. | 1422 // the source to the shared function info containing the code. |
1420 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, | 1423 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
1421 true, native_context); | 1424 true, native_context, language_mode); |
1422 CHECK(!info.is_null()); | 1425 CHECK(!info.is_null()); |
1423 | 1426 |
1424 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1427 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1425 | 1428 |
1426 // On second compilation, the hash is replaced by a real cache entry mapping | 1429 // On second compilation, the hash is replaced by a real cache entry mapping |
1427 // the source to the shared function info containing the code. | 1430 // the source to the shared function info containing the code. |
1428 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, | 1431 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
1429 true, native_context); | 1432 true, native_context, language_mode); |
1430 CHECK(!info.is_null()); | 1433 CHECK(!info.is_null()); |
1431 | 1434 |
1432 while (!info.ToHandleChecked()->code()->IsOld()) { | 1435 while (!info.ToHandleChecked()->code()->IsOld()) { |
1433 info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY); | 1436 info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY); |
1434 } | 1437 } |
1435 | 1438 |
1436 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1439 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1437 // Ensure code aging cleared the entry from the cache. | 1440 // Ensure code aging cleared the entry from the cache. |
1438 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, | 1441 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
1439 true, native_context); | 1442 true, native_context, language_mode); |
1440 CHECK(info.is_null()); | 1443 CHECK(info.is_null()); |
1441 | 1444 |
1442 { | 1445 { |
1443 v8::HandleScope scope(CcTest::isolate()); | 1446 v8::HandleScope scope(CcTest::isolate()); |
1444 CompileRun(raw_source); | 1447 CompileRun(raw_source); |
1445 } | 1448 } |
1446 | 1449 |
1447 // On first compilation, only a hash is inserted in the code cache. We can't | 1450 // On first compilation, only a hash is inserted in the code cache. We can't |
1448 // find that value. | 1451 // find that value. |
1449 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, | 1452 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
1450 true, native_context); | 1453 true, native_context, language_mode); |
1451 CHECK(info.is_null()); | 1454 CHECK(info.is_null()); |
1452 | 1455 |
1453 for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) { | 1456 for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) { |
1454 compilation_cache->MarkCompactPrologue(); | 1457 compilation_cache->MarkCompactPrologue(); |
1455 } | 1458 } |
1456 | 1459 |
1457 { | 1460 { |
1458 v8::HandleScope scope(CcTest::isolate()); | 1461 v8::HandleScope scope(CcTest::isolate()); |
1459 CompileRun(raw_source); | 1462 CompileRun(raw_source); |
1460 } | 1463 } |
1461 | 1464 |
1462 // If we aged the cache before caching the script, ensure that we didn't cache | 1465 // If we aged the cache before caching the script, ensure that we didn't cache |
1463 // on next compilation. | 1466 // on next compilation. |
1464 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, | 1467 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
1465 true, native_context); | 1468 true, native_context, language_mode); |
1466 CHECK(info.is_null()); | 1469 CHECK(info.is_null()); |
1467 } | 1470 } |
1468 | 1471 |
1469 | 1472 |
1470 // Count the number of native contexts in the weak list of native contexts. | 1473 // Count the number of native contexts in the weak list of native contexts. |
1471 int CountNativeContexts() { | 1474 int CountNativeContexts() { |
1472 int count = 0; | 1475 int count = 0; |
1473 Object* object = CcTest::heap()->native_contexts_list(); | 1476 Object* object = CcTest::heap()->native_contexts_list(); |
1474 while (!object->IsUndefined()) { | 1477 while (!object->IsUndefined()) { |
1475 count++; | 1478 count++; |
(...skipping 3510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4986 #ifdef DEBUG | 4989 #ifdef DEBUG |
4987 TEST(PathTracer) { | 4990 TEST(PathTracer) { |
4988 CcTest::InitializeVM(); | 4991 CcTest::InitializeVM(); |
4989 v8::HandleScope scope(CcTest::isolate()); | 4992 v8::HandleScope scope(CcTest::isolate()); |
4990 | 4993 |
4991 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4994 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4992 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4995 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4993 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4996 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4994 } | 4997 } |
4995 #endif // DEBUG | 4998 #endif // DEBUG |
OLD | NEW |