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

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

Issue 1414933006: Copy ICData descriptors when starting background compilation, so that they do not change while comp… (Closed) Base URL: https://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/coverage.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/symbols.h" 11 #include "vm/symbols.h"
12 #include "vm/thread_pool.h" 12 #include "vm/thread_pool.h"
13 #include "vm/unit_test.h" 13 #include "vm/unit_test.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 DECLARE_FLAG(bool, background_compilation);
18
17 TEST_CASE(CompileScript) { 19 TEST_CASE(CompileScript) {
18 const char* kScriptChars = 20 const char* kScriptChars =
19 "class A {\n" 21 "class A {\n"
20 " static foo() { return 42; }\n" 22 " static foo() { return 42; }\n"
21 "}\n"; 23 "}\n";
22 String& url = String::Handle(String::New("dart-test:CompileScript")); 24 String& url = String::Handle(String::New("dart-test:CompileScript"));
23 String& source = String::Handle(String::New(kScriptChars)); 25 String& source = String::Handle(String::New(kScriptChars));
24 Script& script = Script::Handle(Script::New(url, 26 Script& script = Script::Handle(Script::New(url,
25 source, 27 source,
26 RawScript::kScriptTag)); 28 RawScript::kScriptTag));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 Class& cls = Class::Handle( 90 Class& cls = Class::Handle(
89 lib.LookupClass(String::Handle(Symbols::New("A")))); 91 lib.LookupClass(String::Handle(Symbols::New("A"))));
90 EXPECT(!cls.IsNull()); 92 EXPECT(!cls.IsNull());
91 String& function_foo_name = String::Handle(String::New("foo")); 93 String& function_foo_name = String::Handle(String::New("foo"));
92 Function& func = 94 Function& func =
93 Function::Handle(cls.LookupStaticFunction(function_foo_name)); 95 Function::Handle(cls.LookupStaticFunction(function_foo_name));
94 EXPECT(!func.HasCode()); 96 EXPECT(!func.HasCode());
95 CompilerTest::TestCompileFunction(func); 97 CompilerTest::TestCompileFunction(func);
96 EXPECT(func.HasCode()); 98 EXPECT(func.HasCode());
97 EXPECT(!func.HasOptimizedCode()); 99 EXPECT(!func.HasOptimizedCode());
100 FLAG_background_compilation = true;
98 BackgroundCompiler::EnsureInit(thread); 101 BackgroundCompiler::EnsureInit(thread);
99 Isolate* isolate = thread->isolate(); 102 Isolate* isolate = thread->isolate();
100 ASSERT(isolate->background_compiler() != NULL); 103 ASSERT(isolate->background_compiler() != NULL);
101 isolate->background_compiler()->CompileOptimized(func); 104 isolate->background_compiler()->CompileOptimized(func);
102 Monitor* m = new Monitor(); 105 Monitor* m = new Monitor();
103 MonitorLocker ml(m); 106 MonitorLocker ml(m);
104 while (!func.HasOptimizedCode()) { 107 while (!func.HasOptimizedCode()) {
105 isolate->background_compiler()->InstallGeneratedCode(); 108 isolate->background_compiler()->InstallGeneratedCode();
106 ml.Wait(1); 109 ml.Wait(1);
107 } 110 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 EXPECT(val.IsInteger()); 220 EXPECT(val.IsInteger());
218 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 221 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
219 222
220 intptr_t final_class_table_size = 223 intptr_t final_class_table_size =
221 Isolate::Current()->class_table()->NumCids(); 224 Isolate::Current()->class_table()->NumCids();
222 // Eval should not eat into this non-renewable resource. 225 // Eval should not eat into this non-renewable resource.
223 EXPECT_EQ(initial_class_table_size, final_class_table_size); 226 EXPECT_EQ(initial_class_table_size, final_class_table_size);
224 } 227 }
225 228
226 } // namespace dart 229 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/coverage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698