OLD | NEW |
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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 "}\n"; | 40 "}\n"; |
41 String& url = String::Handle(String::New("dart-test:CompileFunction")); | 41 String& url = String::Handle(String::New("dart-test:CompileFunction")); |
42 String& source = String::Handle(String::New(kScriptChars)); | 42 String& source = String::Handle(String::New(kScriptChars)); |
43 Script& script = Script::Handle(Script::New(url, | 43 Script& script = Script::Handle(Script::New(url, |
44 source, | 44 source, |
45 RawScript::kScriptTag)); | 45 RawScript::kScriptTag)); |
46 Library& lib = Library::Handle(Library::CoreLibrary()); | 46 Library& lib = Library::Handle(Library::CoreLibrary()); |
47 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 47 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
48 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 48 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
49 Class& cls = Class::Handle( | 49 Class& cls = Class::Handle( |
50 lib.LookupClass(String::Handle(Symbols::New("A")))); | 50 lib.LookupClass(String::Handle(Symbols::New(thread, "A")))); |
51 EXPECT(!cls.IsNull()); | 51 EXPECT(!cls.IsNull()); |
52 String& function_foo_name = String::Handle(String::New("foo")); | 52 String& function_foo_name = String::Handle(String::New("foo")); |
53 Function& function_foo = | 53 Function& function_foo = |
54 Function::Handle(cls.LookupStaticFunction(function_foo_name)); | 54 Function::Handle(cls.LookupStaticFunction(function_foo_name)); |
55 EXPECT(!function_foo.IsNull()); | 55 EXPECT(!function_foo.IsNull()); |
56 String& function_source = String::Handle(function_foo.GetSource()); | 56 String& function_source = String::Handle(function_foo.GetSource()); |
57 EXPECT_STREQ("static foo() { return 42; }", function_source.ToCString()); | 57 EXPECT_STREQ("static foo() { return 42; }", function_source.ToCString()); |
58 EXPECT(CompilerTest::TestCompileFunction(function_foo)); | 58 EXPECT(CompilerTest::TestCompileFunction(function_foo)); |
59 EXPECT(function_foo.HasCode()); | 59 EXPECT(function_foo.HasCode()); |
60 | 60 |
(...skipping 19 matching lines...) Expand all Loading... |
80 String& url = | 80 String& url = |
81 String::Handle(String::New("dart-test:CompileFunctionOnHelperThread")); | 81 String::Handle(String::New("dart-test:CompileFunctionOnHelperThread")); |
82 String& source = String::Handle(String::New(kScriptChars)); | 82 String& source = String::Handle(String::New(kScriptChars)); |
83 Script& script = Script::Handle(Script::New(url, | 83 Script& script = Script::Handle(Script::New(url, |
84 source, | 84 source, |
85 RawScript::kScriptTag)); | 85 RawScript::kScriptTag)); |
86 Library& lib = Library::Handle(Library::CoreLibrary()); | 86 Library& lib = Library::Handle(Library::CoreLibrary()); |
87 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 87 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
88 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 88 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
89 Class& cls = Class::Handle( | 89 Class& cls = Class::Handle( |
90 lib.LookupClass(String::Handle(Symbols::New("A")))); | 90 lib.LookupClass(String::Handle(Symbols::New(thread, "A")))); |
91 EXPECT(!cls.IsNull()); | 91 EXPECT(!cls.IsNull()); |
92 String& function_foo_name = String::Handle(String::New("foo")); | 92 String& function_foo_name = String::Handle(String::New("foo")); |
93 Function& func = | 93 Function& func = |
94 Function::Handle(cls.LookupStaticFunction(function_foo_name)); | 94 Function::Handle(cls.LookupStaticFunction(function_foo_name)); |
95 EXPECT(!func.HasCode()); | 95 EXPECT(!func.HasCode()); |
96 CompilerTest::TestCompileFunction(func); | 96 CompilerTest::TestCompileFunction(func); |
97 EXPECT(func.HasCode()); | 97 EXPECT(func.HasCode()); |
98 EXPECT(!func.HasOptimizedCode()); | 98 EXPECT(!func.HasOptimizedCode()); |
99 #if !defined(PRODUCT) | 99 #if !defined(PRODUCT) |
100 // Constant in product mode. | 100 // Constant in product mode. |
(...skipping 21 matching lines...) Expand all Loading... |
122 "A main() {\n" | 122 "A main() {\n" |
123 " return unOpt();\n" | 123 " return unOpt();\n" |
124 "}\n"; | 124 "}\n"; |
125 | 125 |
126 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 126 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
127 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 127 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
128 EXPECT_VALID(result); | 128 EXPECT_VALID(result); |
129 RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib)); | 129 RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib)); |
130 Library& lib_handle = Library::ZoneHandle(raw_library); | 130 Library& lib_handle = Library::ZoneHandle(raw_library); |
131 Class& cls = Class::Handle( | 131 Class& cls = Class::Handle( |
132 lib_handle.LookupClass(String::Handle(Symbols::New("A")))); | 132 lib_handle.LookupClass(String::Handle(Symbols::New(thread, "A")))); |
133 EXPECT(!cls.IsNull()); | 133 EXPECT(!cls.IsNull()); |
134 | 134 |
135 Zone* zone = thread->zone(); | 135 Zone* zone = thread->zone(); |
136 const Code& stub = Code::Handle(zone, | 136 const Code& stub = Code::Handle(zone, |
137 StubCode::GetAllocationStubForClass(cls)); | 137 StubCode::GetAllocationStubForClass(cls)); |
138 Class& owner = Class::Handle(); | 138 Class& owner = Class::Handle(); |
139 owner ^= stub.owner(); | 139 owner ^= stub.owner(); |
140 owner.DisableAllocationStub(); | 140 owner.DisableAllocationStub(); |
141 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 141 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
142 EXPECT_VALID(result); | 142 EXPECT_VALID(result); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 EXPECT(val.IsInteger()); | 223 EXPECT(val.IsInteger()); |
224 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); | 224 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
225 | 225 |
226 intptr_t final_class_table_size = | 226 intptr_t final_class_table_size = |
227 Isolate::Current()->class_table()->NumCids(); | 227 Isolate::Current()->class_table()->NumCids(); |
228 // Eval should not eat into this non-renewable resource. | 228 // Eval should not eat into this non-renewable resource. |
229 EXPECT_EQ(initial_class_table_size, final_class_table_size); | 229 EXPECT_EQ(initial_class_table_size, final_class_table_size); |
230 } | 230 } |
231 | 231 |
232 } // namespace dart | 232 } // namespace dart |
OLD | NEW |