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

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

Issue 1739593002: Revert "Move precompilation-related flags to flags list." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
18 VM_TEST_CASE(CompileScript) { 20 VM_TEST_CASE(CompileScript) {
19 const char* kScriptChars = 21 const char* kScriptChars =
20 "class A {\n" 22 "class A {\n"
21 " static foo() { return 42; }\n" 23 " static foo() { return 42; }\n"
22 "}\n"; 24 "}\n";
23 String& url = String::Handle(String::New("dart-test:CompileScript")); 25 String& url = String::Handle(String::New("dart-test:CompileScript"));
24 String& source = String::Handle(String::New(kScriptChars)); 26 String& source = String::Handle(String::New(kScriptChars));
25 Script& script = Script::Handle(Script::New(url, 27 Script& script = Script::Handle(Script::New(url,
26 source, 28 source,
27 RawScript::kScriptTag)); 29 RawScript::kScriptTag));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 Class& cls = Class::Handle( 91 Class& cls = Class::Handle(
90 lib.LookupClass(String::Handle(Symbols::New("A")))); 92 lib.LookupClass(String::Handle(Symbols::New("A"))));
91 EXPECT(!cls.IsNull()); 93 EXPECT(!cls.IsNull());
92 String& function_foo_name = String::Handle(String::New("foo")); 94 String& function_foo_name = String::Handle(String::New("foo"));
93 Function& func = 95 Function& func =
94 Function::Handle(cls.LookupStaticFunction(function_foo_name)); 96 Function::Handle(cls.LookupStaticFunction(function_foo_name));
95 EXPECT(!func.HasCode()); 97 EXPECT(!func.HasCode());
96 CompilerTest::TestCompileFunction(func); 98 CompilerTest::TestCompileFunction(func);
97 EXPECT(func.HasCode()); 99 EXPECT(func.HasCode());
98 EXPECT(!func.HasOptimizedCode()); 100 EXPECT(!func.HasOptimizedCode());
99 #if !defined(PRODUCT)
100 // Constant in product mode.
101 FLAG_background_compilation = true; 101 FLAG_background_compilation = true;
102 #endif
103 BackgroundCompiler::EnsureInit(thread); 102 BackgroundCompiler::EnsureInit(thread);
104 Isolate* isolate = thread->isolate(); 103 Isolate* isolate = thread->isolate();
105 ASSERT(isolate->background_compiler() != NULL); 104 ASSERT(isolate->background_compiler() != NULL);
106 isolate->background_compiler()->CompileOptimized(func); 105 isolate->background_compiler()->CompileOptimized(func);
107 Monitor* m = new Monitor(); 106 Monitor* m = new Monitor();
108 MonitorLocker ml(m); 107 MonitorLocker ml(m);
109 while (!func.HasOptimizedCode()) { 108 while (!func.HasOptimizedCode()) {
110 ml.WaitWithSafepointCheck(thread, 1); 109 ml.WaitWithSafepointCheck(thread, 1);
111 } 110 }
112 BackgroundCompiler::Stop(isolate->background_compiler()); 111 BackgroundCompiler::Stop(isolate->background_compiler());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXPECT(val.IsInteger()); 221 EXPECT(val.IsInteger());
223 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
224 223
225 intptr_t final_class_table_size = 224 intptr_t final_class_table_size =
226 Isolate::Current()->class_table()->NumCids(); 225 Isolate::Current()->class_table()->NumCids();
227 // Eval should not eat into this non-renewable resource. 226 // Eval should not eat into this non-renewable resource.
228 EXPECT_EQ(initial_class_table_size, final_class_table_size); 227 EXPECT_EQ(initial_class_table_size, final_class_table_size);
229 } 228 }
230 229
231 } // namespace dart 230 } // 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