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

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

Issue 1162033005: Fix http://dartbug.com/23578: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update to ToT. Created 5 years, 6 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
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/unit_test.h" 12 #include "vm/unit_test.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DECLARE_FLAG(bool, enable_type_checks);
17
18 TEST_CASE(CompileScript) { 16 TEST_CASE(CompileScript) {
19 const char* kScriptChars = 17 const char* kScriptChars =
20 "class A {\n" 18 "class A {\n"
21 " static foo() { return 42; }\n" 19 " static foo() { return 42; }\n"
22 "}\n"; 20 "}\n";
23 String& url = String::Handle(String::New("dart-test:CompileScript")); 21 String& url = String::Handle(String::New("dart-test:CompileScript"));
24 String& source = String::Handle(String::New(kScriptChars)); 22 String& source = String::Handle(String::New(kScriptChars));
25 Script& script = Script::Handle(Script::New(url, 23 Script& script = Script::Handle(Script::New(url,
26 source, 24 source,
27 RawScript::kScriptTag)); 25 RawScript::kScriptTag));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 TEST_CASE(RegenerateAllocStubs) { 72 TEST_CASE(RegenerateAllocStubs) {
75 const char* kScriptChars = 73 const char* kScriptChars =
76 "class A {\n" 74 "class A {\n"
77 "}\n" 75 "}\n"
78 "unOpt() => new A(); \n" 76 "unOpt() => new A(); \n"
79 "optIt() => new A(); \n" 77 "optIt() => new A(); \n"
80 "A main() {\n" 78 "A main() {\n"
81 " return unOpt();\n" 79 " return unOpt();\n"
82 "}\n"; 80 "}\n";
83 81
84 bool old_enable_type_checks = FLAG_enable_type_checks; 82 // Isolate::Current()->flags().set_checked(true);
Florian Schneider 2015/06/08 11:25:49 Why is this commmented out?
Ivan Posva 2015/06/08 11:53:57 Because it is being enabled after the isolate has
85 FLAG_enable_type_checks = true;
86 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 83 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
87 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 84 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
88 EXPECT_VALID(result); 85 EXPECT_VALID(result);
89 RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib)); 86 RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib));
90 Library& lib_handle = Library::ZoneHandle(raw_library); 87 Library& lib_handle = Library::ZoneHandle(raw_library);
91 Class& cls = Class::Handle( 88 Class& cls = Class::Handle(
92 lib_handle.LookupClass(String::Handle(Symbols::New("A")))); 89 lib_handle.LookupClass(String::Handle(Symbols::New("A"))));
93 EXPECT(!cls.IsNull()); 90 EXPECT(!cls.IsNull());
94 91
95 Isolate* isolate = Isolate::Current(); 92 Isolate* isolate = Isolate::Current();
96 StubCode* stub_code = isolate->stub_code(); 93 StubCode* stub_code = isolate->stub_code();
97 const Code& stub = Code::Handle(isolate, 94 const Code& stub = Code::Handle(isolate,
98 stub_code->GetAllocationStubForClass(cls)); 95 stub_code->GetAllocationStubForClass(cls));
99 Class& owner = Class::Handle(); 96 Class& owner = Class::Handle();
100 owner ^= stub.owner(); 97 owner ^= stub.owner();
101 owner.DisableAllocationStub(); 98 owner.DisableAllocationStub();
102 result = Dart_Invoke(lib, NewString("main"), 0, NULL); 99 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
103 EXPECT_VALID(result); 100 EXPECT_VALID(result);
104 101
105 owner.DisableAllocationStub(); 102 owner.DisableAllocationStub();
106 result = Dart_Invoke(lib, NewString("main"), 0, NULL); 103 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
107 EXPECT_VALID(result); 104 EXPECT_VALID(result);
108 105
109 owner.DisableAllocationStub(); 106 owner.DisableAllocationStub();
110 result = Dart_Invoke(lib, NewString("main"), 0, NULL); 107 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
111 EXPECT_VALID(result); 108 EXPECT_VALID(result);
112
113 FLAG_enable_type_checks = old_enable_type_checks;
114 } 109 }
115 110
116 111
117 TEST_CASE(EvalExpression) { 112 TEST_CASE(EvalExpression) {
118 const char* kScriptChars = 113 const char* kScriptChars =
119 "int ten = 2 * 5; \n" 114 "int ten = 2 * 5; \n"
120 "get dot => '.'; \n" 115 "get dot => '.'; \n"
121 "class A { \n" 116 "class A { \n"
122 " var apa = 'Herr Nilsson'; \n" 117 " var apa = 'Herr Nilsson'; \n"
123 " calc(x) => '${x*ten}'; \n" 118 " calc(x) => '${x*ten}'; \n"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); 168 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array());
174 } 169 }
175 170
176 EXPECT(!val.IsNull()); 171 EXPECT(!val.IsNull());
177 EXPECT(!val.IsError()); 172 EXPECT(!val.IsError());
178 EXPECT(val.IsInteger()); 173 EXPECT(val.IsInteger());
179 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 174 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
180 } 175 }
181 176
182 } // namespace dart 177 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/dart.h » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698