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

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

Issue 1454553004: Create code and instruction object, and install them in the background compilation thread while br… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 1 month 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/object.h » ('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/symbols.h" 11 #include "vm/symbols.h"
12 #include "vm/thread_pool.h" 12 #include "vm/thread_pool.h"
13 #include "vm/thread_registry.h"
13 #include "vm/unit_test.h" 14 #include "vm/unit_test.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 DECLARE_FLAG(bool, background_compilation); 18 DECLARE_FLAG(bool, background_compilation);
18 19
19 TEST_CASE(CompileScript) { 20 TEST_CASE(CompileScript) {
20 const char* kScriptChars = 21 const char* kScriptChars =
21 "class A {\n" 22 "class A {\n"
22 " static foo() { return 42; }\n" 23 " static foo() { return 42; }\n"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 EXPECT(func.HasCode()); 99 EXPECT(func.HasCode());
99 EXPECT(!func.HasOptimizedCode()); 100 EXPECT(!func.HasOptimizedCode());
100 FLAG_background_compilation = true; 101 FLAG_background_compilation = true;
101 BackgroundCompiler::EnsureInit(thread); 102 BackgroundCompiler::EnsureInit(thread);
102 Isolate* isolate = thread->isolate(); 103 Isolate* isolate = thread->isolate();
103 ASSERT(isolate->background_compiler() != NULL); 104 ASSERT(isolate->background_compiler() != NULL);
104 isolate->background_compiler()->CompileOptimized(func); 105 isolate->background_compiler()->CompileOptimized(func);
105 Monitor* m = new Monitor(); 106 Monitor* m = new Monitor();
106 MonitorLocker ml(m); 107 MonitorLocker ml(m);
107 while (!func.HasOptimizedCode()) { 108 while (!func.HasOptimizedCode()) {
108 isolate->background_compiler()->InstallGeneratedCode(); 109 Isolate::Current()->thread_registry()->CheckSafepoint();
109 ml.Wait(1); 110 ml.Wait(1);
110 } 111 }
111 BackgroundCompiler::Stop(isolate->background_compiler()); 112 BackgroundCompiler::Stop(isolate->background_compiler());
112 } 113 }
113 114
114 115
115 TEST_CASE(RegenerateAllocStubs) { 116 TEST_CASE(RegenerateAllocStubs) {
116 const char* kScriptChars = 117 const char* kScriptChars =
117 "class A {\n" 118 "class A {\n"
118 "}\n" 119 "}\n"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT(val.IsInteger()); 221 EXPECT(val.IsInteger());
221 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
222 223
223 intptr_t final_class_table_size = 224 intptr_t final_class_table_size =
224 Isolate::Current()->class_table()->NumCids(); 225 Isolate::Current()->class_table()->NumCids();
225 // Eval should not eat into this non-renewable resource. 226 // Eval should not eat into this non-renewable resource.
226 EXPECT_EQ(initial_class_table_size, final_class_table_size); 227 EXPECT_EQ(initial_class_table_size, final_class_table_size);
227 } 228 }
228 229
229 } // namespace dart 230 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698