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 24046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24057 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data); | 24057 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data); |
24058 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); | 24058 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); |
24059 v8::Local<v8::Script> script = | 24059 v8::Local<v8::Script> script = |
24060 v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked(); | 24060 v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked(); |
24061 CHECK(cached_data->rejected); | 24061 CHECK(cached_data->rejected); |
24062 CHECK_EQ( | 24062 CHECK_EQ( |
24063 42, | 24063 42, |
24064 script->Run(context).ToLocalChecked()->Int32Value(context).FromJust()); | 24064 script->Run(context).ToLocalChecked()->Int32Value(context).FromJust()); |
24065 } | 24065 } |
24066 | 24066 |
24067 | 24067 TEST(InvalidParserCacheData) { |
24068 TEST(InvalidCacheData) { | |
24069 v8::V8::Initialize(); | 24068 v8::V8::Initialize(); |
24070 v8::HandleScope scope(CcTest::isolate()); | 24069 v8::HandleScope scope(CcTest::isolate()); |
24071 LocalContext context; | 24070 LocalContext context; |
24072 if (i::FLAG_lazy && !(i::FLAG_ignition && i::FLAG_ignition_eager)) { | 24071 if (i::FLAG_lazy && !(i::FLAG_ignition && i::FLAG_ignition_eager)) { |
24073 // Cached parser data is not consumed while parsing eagerly. | 24072 // Cached parser data is not consumed while parsing eagerly. |
24074 TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache); | 24073 TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache); |
24075 } | 24074 } |
| 24075 } |
| 24076 |
| 24077 TEST(InvalidCodeCacheData) { |
| 24078 v8::V8::Initialize(); |
| 24079 v8::HandleScope scope(CcTest::isolate()); |
| 24080 LocalContext context; |
24076 TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache); | 24081 TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache); |
24077 } | 24082 } |
24078 | 24083 |
24079 | 24084 |
24080 TEST(ParserCacheRejectedGracefully) { | 24085 TEST(ParserCacheRejectedGracefully) { |
24081 // Producing cached parser data while parsing eagerly is not supported. | 24086 // Producing cached parser data while parsing eagerly is not supported. |
24082 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; | 24087 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; |
24083 | 24088 |
24084 i::FLAG_min_preparse_length = 0; | 24089 i::FLAG_min_preparse_length = 0; |
24085 v8::V8::Initialize(); | 24090 v8::V8::Initialize(); |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24978 } | 24983 } |
24979 delete garbage; | 24984 delete garbage; |
24980 // Check that moderate memory pressure notification sets GC into memory | 24985 // Check that moderate memory pressure notification sets GC into memory |
24981 // optimizing mode. | 24986 // optimizing mode. |
24982 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); | 24987 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); |
24983 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24988 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24984 // Check that disabling memory pressure returns GC into normal mode. | 24989 // Check that disabling memory pressure returns GC into normal mode. |
24985 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); | 24990 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); |
24986 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24991 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24987 } | 24992 } |
OLD | NEW |