| Index: test/cctest/parsing/test-parse-decision.cc | 
| diff --git a/test/cctest/parsing/test-parse-decision.cc b/test/cctest/parsing/test-parse-decision.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..58d734d9770c79f7855faaaec86e049e185a5834 | 
| --- /dev/null | 
| +++ b/test/cctest/parsing/test-parse-decision.cc | 
| @@ -0,0 +1,58 @@ | 
| +// Copyright 2016 the V8 project authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +// Test specific cases of the lazy/eager-parse decision. | 
| +// | 
| +// Note that presently most unit tests for parsing are found in | 
| +// cctest/test-parsing.cc. | 
| + | 
| +#include <unordered_map> | 
| + | 
| +#include "include/v8.h" | 
| +#include "src/api.h" | 
| +#include "src/handles-inl.h" | 
| +#include "src/isolate.h" | 
| +#include "src/utils.h" | 
| + | 
| +#include "test/cctest/cctest.h" | 
| + | 
| +using namespace v8::internal; | 
| + | 
| +TEST(EagerlyCompileImmediateUseFunctions) { | 
| +  if (!FLAG_lazy) return; | 
| +  FLAG_min_preparse_length = 0; | 
| + | 
| +  const char src[] = | 
| +      "function normal() { var a; }\n"             // Normal: Should lazy parse. | 
| +      "(function parenthesized() { var b; })()\n"  // Parenthesized: Pre-parse. | 
| +      "!function exclaimed() { var c; }() \n"      // Exclaimed: Pre-parse. | 
| +      "function normal2() { var d; }\n";           // Normal function again. | 
| + | 
| +  Isolate* isolate = CcTest::i_isolate(); | 
| +  HandleScope scope(isolate); | 
| +  LocalContext env; | 
| + | 
| +  // Compile src & record the 'compiled' state of all top level functions in | 
| +  // is_compiled. | 
| +  std::unordered_map<std::string, bool> is_compiled; | 
| +  { | 
| +    v8::Local<v8::Script> api_script = v8_compile(src); | 
| +    Handle<JSFunction> toplevel_fn = v8::Utils::OpenHandle(*api_script); | 
| +    Handle<Script> script = | 
| +        handle(Script::cast(toplevel_fn->shared()->script())); | 
| + | 
| +    WeakFixedArray::Iterator iter(script->shared_function_infos()); | 
| +    while (SharedFunctionInfo* shared = iter.Next<SharedFunctionInfo>()) { | 
| +      std::unique_ptr<char[]> name = String::cast(shared->name())->ToCString(); | 
| +      is_compiled[name.get()] = shared->is_compiled(); | 
| +    } | 
| +  } | 
| + | 
| +  DCHECK(is_compiled.find("normal") != is_compiled.end()); | 
| + | 
| +  DCHECK(is_compiled["parenthesized"]); | 
| +  DCHECK(is_compiled["exclaimed"]); | 
| +  DCHECK(!is_compiled["normal"]); | 
| +  DCHECK(!is_compiled["normal2"]); | 
| +} | 
|  |