Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/cctest/parsing/test-parse-decision.cc

Issue 2547483002: Store SharedFunctionInfos of a Script in a FixedArray indexed by their ID (Closed)
Patch Set: updates Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Test specific cases of the lazy/eager-parse decision. 5 // Test specific cases of the lazy/eager-parse decision.
6 // 6 //
7 // Note that presently most unit tests for parsing are found in 7 // Note that presently most unit tests for parsing are found in
8 // cctest/test-parsing.cc. 8 // cctest/test-parsing.cc.
9 9
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 13 matching lines...) Expand all
24 // Record the 'compiled' state of all top level functions. 24 // Record the 'compiled' state of all top level functions.
25 void GetTopLevelFunctionInfo( 25 void GetTopLevelFunctionInfo(
26 v8::Local<v8::Script> script, 26 v8::Local<v8::Script> script,
27 std::unordered_map<std::string, bool>* is_compiled) { 27 std::unordered_map<std::string, bool>* is_compiled) {
28 // Get the v8::internal::Script object from the API v8::Script. 28 // Get the v8::internal::Script object from the API v8::Script.
29 // The API object 'wraps' the compiled top-level function, not the i::Script. 29 // The API object 'wraps' the compiled top-level function, not the i::Script.
30 Handle<JSFunction> toplevel_fn = v8::Utils::OpenHandle(*script); 30 Handle<JSFunction> toplevel_fn = v8::Utils::OpenHandle(*script);
31 Handle<Script> i_script = 31 Handle<Script> i_script =
32 handle(Script::cast(toplevel_fn->shared()->script())); 32 handle(Script::cast(toplevel_fn->shared()->script()));
33 33
34 WeakFixedArray::Iterator iter(i_script->shared_function_infos()); 34 for (int index = 0; index < i_script->shared_function_infos()->length();
35 while (SharedFunctionInfo* shared = iter.Next<SharedFunctionInfo>()) { 35 ++index) {
36 Object* raw = i_script->shared_function_infos()->get(index);
37 if (raw->IsSmi()) continue;
38 SharedFunctionInfo* shared =
39 SharedFunctionInfo::cast(WeakCell::cast(raw)->value());
36 std::unique_ptr<char[]> name = String::cast(shared->name())->ToCString(); 40 std::unique_ptr<char[]> name = String::cast(shared->name())->ToCString();
37 is_compiled->insert(std::make_pair(name.get(), shared->is_compiled())); 41 is_compiled->insert(std::make_pair(name.get(), shared->is_compiled()));
38 } 42 }
39 } 43 }
40 44
41 } // anonymous namespace 45 } // anonymous namespace
42 46
43 TEST(GetTopLevelFunctionInfo) { 47 TEST(GetTopLevelFunctionInfo) {
44 if (!FLAG_lazy) return; 48 if (!FLAG_lazy) return;
45 49
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 LocalContext env; 101 LocalContext env;
98 102
99 const char src[] = "!function a(){}(),function b(){}(),function c(){}();"; 103 const char src[] = "!function a(){}(),function b(){}(),function c(){}();";
100 std::unordered_map<std::string, bool> is_compiled; 104 std::unordered_map<std::string, bool> is_compiled;
101 GetTopLevelFunctionInfo(v8_compile(src), &is_compiled); 105 GetTopLevelFunctionInfo(v8_compile(src), &is_compiled);
102 106
103 DCHECK(is_compiled["a"]); 107 DCHECK(is_compiled["a"]);
104 DCHECK(is_compiled["b"]); 108 DCHECK(is_compiled["b"]);
105 DCHECK(is_compiled["c"]); 109 DCHECK(is_compiled["c"]);
106 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698