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

Side by Side Diff: runtime/vm/compiler_test.cc

Issue 1731743003: Move precompilation-related flags to flags list. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: make print_stop_message default false to fix build Created 4 years, 10 months 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
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/constant_propagator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/class_finalizer.h" 6 #include "vm/class_finalizer.h"
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/safepoint.h" 11 #include "vm/safepoint.h"
12 #include "vm/symbols.h" 12 #include "vm/symbols.h"
13 #include "vm/thread_pool.h" 13 #include "vm/thread_pool.h"
14 #include "vm/unit_test.h" 14 #include "vm/unit_test.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 DECLARE_FLAG(bool, background_compilation);
19
20 VM_TEST_CASE(CompileScript) { 18 VM_TEST_CASE(CompileScript) {
21 const char* kScriptChars = 19 const char* kScriptChars =
22 "class A {\n" 20 "class A {\n"
23 " static foo() { return 42; }\n" 21 " static foo() { return 42; }\n"
24 "}\n"; 22 "}\n";
25 String& url = String::Handle(String::New("dart-test:CompileScript")); 23 String& url = String::Handle(String::New("dart-test:CompileScript"));
26 String& source = String::Handle(String::New(kScriptChars)); 24 String& source = String::Handle(String::New(kScriptChars));
27 Script& script = Script::Handle(Script::New(url, 25 Script& script = Script::Handle(Script::New(url,
28 source, 26 source,
29 RawScript::kScriptTag)); 27 RawScript::kScriptTag));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Class& cls = Class::Handle( 89 Class& cls = Class::Handle(
92 lib.LookupClass(String::Handle(Symbols::New("A")))); 90 lib.LookupClass(String::Handle(Symbols::New("A"))));
93 EXPECT(!cls.IsNull()); 91 EXPECT(!cls.IsNull());
94 String& function_foo_name = String::Handle(String::New("foo")); 92 String& function_foo_name = String::Handle(String::New("foo"));
95 Function& func = 93 Function& func =
96 Function::Handle(cls.LookupStaticFunction(function_foo_name)); 94 Function::Handle(cls.LookupStaticFunction(function_foo_name));
97 EXPECT(!func.HasCode()); 95 EXPECT(!func.HasCode());
98 CompilerTest::TestCompileFunction(func); 96 CompilerTest::TestCompileFunction(func);
99 EXPECT(func.HasCode()); 97 EXPECT(func.HasCode());
100 EXPECT(!func.HasOptimizedCode()); 98 EXPECT(!func.HasOptimizedCode());
99 #if !defined(PRODUCT)
100 // Constant in product mode.
101 FLAG_background_compilation = true; 101 FLAG_background_compilation = true;
102 #endif
102 BackgroundCompiler::EnsureInit(thread); 103 BackgroundCompiler::EnsureInit(thread);
103 Isolate* isolate = thread->isolate(); 104 Isolate* isolate = thread->isolate();
104 ASSERT(isolate->background_compiler() != NULL); 105 ASSERT(isolate->background_compiler() != NULL);
105 isolate->background_compiler()->CompileOptimized(func); 106 isolate->background_compiler()->CompileOptimized(func);
106 Monitor* m = new Monitor(); 107 Monitor* m = new Monitor();
107 MonitorLocker ml(m); 108 MonitorLocker ml(m);
108 while (!func.HasOptimizedCode()) { 109 while (!func.HasOptimizedCode()) {
109 ml.WaitWithSafepointCheck(thread, 1); 110 ml.WaitWithSafepointCheck(thread, 1);
110 } 111 }
111 BackgroundCompiler::Stop(isolate->background_compiler()); 112 BackgroundCompiler::Stop(isolate->background_compiler());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT(val.IsInteger()); 222 EXPECT(val.IsInteger());
222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 223 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
223 224
224 intptr_t final_class_table_size = 225 intptr_t final_class_table_size =
225 Isolate::Current()->class_table()->NumCids(); 226 Isolate::Current()->class_table()->NumCids();
226 // Eval should not eat into this non-renewable resource. 227 // Eval should not eat into this non-renewable resource.
227 EXPECT_EQ(initial_class_table_size, final_class_table_size); 228 EXPECT_EQ(initial_class_table_size, final_class_table_size);
228 } 229 }
229 230
230 } // namespace dart 231 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/constant_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698